Skip to content

Commit 7500d75

Browse files
committed
C++: Fix some easy FPs.
1 parent 1339533 commit 7500d75

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

cpp/ql/src/semmle/code/cpp/security/SensitiveExprs.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ private predicate suspicious(string s) {
1919
s.matches("%trusted%")
2020
) and
2121
not (
22-
s.matches("%hashed%") or
23-
s.matches("%encrypted%") or
24-
s.matches("%crypt%")
22+
s.matches("%hash%") or
23+
s.matches("%crypt%") or
24+
s.matches("%file%") or
25+
s.matches("%conf%")
2526
)
2627
}
2728

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
| test2.cpp:28:2:28:8 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:28:36:28:43 | password | this source. |
22
| test2.cpp:29:2:29:8 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:29:37:29:45 | thepasswd | this source. |
33
| test2.cpp:30:2:30:8 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:30:38:30:47 | accountkey | this source. |
4-
| test2.cpp:31:2:31:8 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:31:41:31:53 | password_hash | this source. |
5-
| test2.cpp:33:2:33:8 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:33:41:33:53 | password_file | this source. |
6-
| test2.cpp:34:2:34:8 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:34:41:34:53 | passwd_config | this source. |
74
| test.cpp:45:3:45:7 | call to fputs | This write into file 'file' may contain unencrypted data from $@ | test.cpp:45:9:45:19 | thePassword | this source. |
85
| test.cpp:70:35:70:35 | call to operator<< | This write into file 'mystream' may contain unencrypted data from $@ | test.cpp:70:38:70:48 | thePassword | this source. |
96
| test.cpp:73:37:73:41 | call to write | This write into file 'mystream' may contain unencrypted data from $@ | test.cpp:73:43:73:53 | thePassword | this source. |

cpp/ql/test/query-tests/Security/CWE/CWE-311/semmle/tests/test2.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,17 @@ void tests(FILE *log, myStruct &s)
3737
char *cpy1 = s.password;
3838
char *cpy2 = crypt(s.password);
3939

40-
fprintf(log, "cpy1 = %s\n", cpy1); // BAD
40+
fprintf(log, "cpy1 = %s\n", cpy1); // BAD [NOT DETECTED]
4141
fprintf(log, "cpy2 = %s\n", cpy2); // GOOD
4242
}
4343

4444
{
4545
char buf[1024];
4646

4747
strcpy(buf, s.password);
48-
fprintf(log, "buf = %s\n", buf); // BAD
48+
fprintf(log, "buf = %s\n", buf); // BAD [NOT DETECTED]
4949

5050
strcpy(buf, s.password_hash);
5151
fprintf(log, "buf = %s\n", buf); // GOOD
5252
}
5353
}
54-

0 commit comments

Comments
 (0)