Skip to content

Commit 48e540f

Browse files
author
dilanbhalla
committed
minor fixes
1 parent db6d5c3 commit 48e540f

File tree

6 files changed

+20
-39
lines changed

6 files changed

+20
-39
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-359/PrivateCleartextWrite.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
* unauthorized persons.
55
* @kind path-problem
66
* @problem.severity error
7-
* @precision high
8-
* @id cpp/exposure-of-sensitive-information
7+
* @id cpp/private-cleartext-write
98
* @tags security
109
* external/cwe/cwe-359
1110
*/
1211

13-
1412
import cpp
1513
import experimental.semmle.code.cpp.security.PrivateCleartextWrite
1614
import experimental.semmle.code.cpp.security.PrivateCleartextWrite::PrivateCleartextWrite

cpp/ql/src/experimental/semmle/code/cpp/security/ExternalLocationSink.qll

Lines changed: 0 additions & 14 deletions
This file was deleted.

cpp/ql/src/experimental/semmle/code/cpp/security/PrivateCleartextWrite.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import cpp
66
import semmle.code.cpp.dataflow.TaintTracking
77
import experimental.semmle.code.cpp.security.PrivateData
88
import semmle.code.cpp.security.FileWrite
9+
import semmle.code.cpp.security.BufferWrite
910
import semmle.code.cpp.dataflow.TaintTracking
10-
import experimental.semmle.code.cpp.security.ExternalLocationSink
1111

1212
module PrivateCleartextWrite {
1313
/**
@@ -60,7 +60,4 @@ module PrivateCleartextWrite {
6060
)
6161
}
6262
}
63-
// class ExternalLocation extends Sink {
64-
// ExternalLocation() { this instanceof ExternalLocationSink }
65-
// }
6663
}

cpp/ql/src/experimental/semmle/code/cpp/security/PrivateData.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private string privateNames() {
1919
// Contact information, such as home addresses and telephone numbers
2020
result = "%postcode%" or
2121
result = "%zipcode%" or
22-
result = "%telephone%" or
22+
// result = "%telephone%" or
2323
// Geographic location - where the user is (or was)
2424
result = "%latitude%" or
2525
result = "%longitude%" or
@@ -28,8 +28,8 @@ private string privateNames() {
2828
result = "%salary%" or
2929
result = "%bankaccount%" or
3030
// Communications - e-mail addresses, private e-mail messages, SMS text messages, chat logs, etc.
31-
result = "%email%" or
32-
result = "%mobile%" or
31+
// result = "%email%" or
32+
// result = "%mobile%" or
3333
result = "%employer%" or
3434
// Health - medical conditions, insurance status, prescription records
3535
result = "%medical%"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| test.cpp:50:9:50:16 | theEmail | This write may contain unencrypted data |
1+
| test.cpp:50:9:50:18 | theZipcode | This write may contain unencrypted data |
22
| test.cpp:66:24:66:30 | medical | This write may contain unencrypted data |
33
| test.cpp:70:24:70:27 | temp | This write may contain unencrypted data |
44
| test.cpp:74:24:74:28 | buff5 | This write may contain unencrypted data |
5-
| test.cpp:87:35:87:42 | theEmail | This write may contain unencrypted data |
6-
| test.cpp:90:40:90:47 | theEmail | This write may contain unencrypted data |
5+
| test.cpp:87:37:87:46 | theZipcode | This write may contain unencrypted data |
6+
| test.cpp:90:42:90:51 | theZipcode | This write may contain unencrypted data |

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-359/semmle/tests/test.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ char *func(char *buffer) {
4343

4444
// test for CleartextFileWrite
4545
void file() {
46-
char *theEmail = "cleartext email!";
46+
char *theZipcode = "cleartext zipcode!";
4747
FILE *file;
4848

49-
// BAD: write email to file in cleartext
50-
fputs(theEmail, file);
49+
// BAD: write zipcode to file in cleartext
50+
fputs(theZipcode, file);
5151

5252
// GOOD: encrypt first
53-
char *encrypted = encrypt(theEmail);
53+
char *encrypted = encrypt(theZipcode);
5454
fwrite(encrypted, sizeof(encrypted), 1, file);
5555
}
5656

@@ -80,17 +80,17 @@ int main(int argc, char** argv) {
8080

8181
// test for CleartextFileWrite
8282
void stream() {
83-
char *theEmail = "cleartext email!";
83+
char *theZipcode = "cleartext zipcode!";
8484
ofstream mystream;
8585

86-
// BAD: write email to file in cleartext
87-
mystream << "the email is: " << theEmail;
86+
// BAD: write zipcode to file in cleartext
87+
mystream << "the zipcode is: " << theZipcode;
8888

89-
// BAD: write email to file in cleartext
90-
(mystream << "the email is: ").write(theEmail, strlen(theEmail));
89+
// BAD: write zipcode to file in cleartext
90+
(mystream << "the zipcode is: ").write(theZipcode, strlen(theZipcode));
9191

9292
// GOOD: encrypt first
93-
char *encrypted = encrypt(theEmail);
94-
mystream << "the email is: " << encrypted;
95-
(mystream << "the email is: ").write(encrypted, strlen(encrypted));
93+
char *encrypted = encrypt(theZipcode);
94+
mystream << "the zipcode is: " << encrypted;
95+
(mystream << "the zipcode is: ").write(encrypted, strlen(encrypted));
9696
}

0 commit comments

Comments
 (0)