Skip to content

Commit 3a83ff5

Browse files
committed
C++: Add support for class methods.
1 parent 2576075 commit 3a83ff5

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

cpp/ql/src/Security/CWE/CWE-327/BrokenCryptoAlgorithm.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import semmle.code.cpp.security.Encryption
1919
Function getAnInsecureEncryptionFunction() {
2020
(
2121
isInsecureEncryption(result.getName()) or
22-
isInsecureEncryption(result.getAParameter().getName())
22+
isInsecureEncryption(result.getAParameter().getName()) or
23+
isInsecureEncryption(result.getDeclaringType().getName())
2324
) and
2425
exists(result.getACallToThisFunction())
2526
}

cpp/ql/test/query-tests/Security/CWE/CWE-327/BrokenCryptoAlgorithm.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
| test2.cpp:175:28:175:34 | USE_DES | This enum constant access specifies a broken or weak cryptographic algorithm. |
77
| test2.cpp:182:38:182:45 | ALGO_DES | This macro invocation specifies a broken or weak cryptographic algorithm. |
88
| test2.cpp:185:38:185:44 | USE_DES | This enum constant access specifies a broken or weak cryptographic algorithm. |
9+
| test2.cpp:234:2:234:20 | call to encrypt | This function call specifies a broken or weak cryptographic algorithm. |
10+
| test2.cpp:239:5:239:11 | call to encrypt | This function call specifies a broken or weak cryptographic algorithm. |
911
| test.cpp:38:2:38:31 | ENCRYPT_WITH_DES(data,amount) | This macro invocation specifies a broken or weak cryptographic algorithm. |
1012
| test.cpp:39:2:39:31 | ENCRYPT_WITH_RC2(data,amount) | This macro invocation specifies a broken or weak cryptographic algorithm. |
1113
| test.cpp:51:2:51:32 | DES_DO_ENCRYPTION(data,amount) | This macro invocation specifies a broken or weak cryptographic algorithm. |

cpp/ql/test/query-tests/Security/CWE/CWE-327/test2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,12 @@ class aesCipher
231231

232232
void do_classes(const char *data)
233233
{
234-
desEncrypt::encrypt(data); // BAD [NOT DETECTED]
234+
desEncrypt::encrypt(data); // BAD
235235
aes256Encrypt::encrypt(data); // GOOD
236236

237237
desCipher dc;
238238
aesCipher ac;
239-
dc.encrypt(data); // BAD [NOT DETECTED]
239+
dc.encrypt(data); // BAD
240240
ac.encrypt(data); // GOOD
241241
}
242242

0 commit comments

Comments
 (0)