Skip to content

Commit aabb2fc

Browse files
committed
C++: Tune SensitiveExprs.qll based on real TP and FP results.
1 parent 9896339 commit aabb2fc

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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ private predicate suspicious(string s) {
1414
(
1515
s.matches("%password%") or
1616
s.matches("%passwd%") or
17-
s.matches("%account%") or
18-
s.matches("%accnt%") or
1917
s.matches("%trusted%")
2018
) and
2119
not (
2220
s.matches("%hash%") or
2321
s.matches("%crypt%") or
24-
s.matches("%file%") or
25-
s.matches("%conf%")
22+
s.matches("%file%")
2623
)
2724
}
2825

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +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. |
3-
| 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. |
3+
| 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. |
44
| test2.cpp:40:3:40:9 | call to fprintf | This write into file 'log' may contain unencrypted data from $@ | test2.cpp:37:18:37:25 | password | this source. |
55
| 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. |
66
| 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. |

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ struct myStruct
1919

2020
// not sensitive
2121
char *password_file;
22+
23+
// dubious
2224
char *passwd_config;
23-
2425
};
25-
2626
void tests(FILE *log, myStruct &s)
2727
{
2828
fprintf(log, "password = %s\n", s.password); // BAD
2929
fprintf(log, "thepasswd = %s\n", s.thepasswd); // BAD
30-
fprintf(log, "accountkey = %s\n", s.accountkey); // BAD
30+
fprintf(log, "accountkey = %s\n", s.accountkey); // DUBIOUS [NOT REPORTED]
3131
fprintf(log, "password_hash = %s\n", s.password_hash); // GOOD
3232
fprintf(log, "encrypted_passwd = %s\n", s.encrypted_passwd); // GOOD
3333
fprintf(log, "password_file = %s\n", s.password_file); // GOOD
34-
fprintf(log, "passwd_config = %s\n", s.passwd_config); // GOOD
34+
fprintf(log, "passwd_config = %s\n", s.passwd_config); // DUBIOUS [REPORTED]
3535

3636
{
3737
char *cpy1 = s.password;

0 commit comments

Comments
 (0)