mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: Add a test.
This commit is contained in:
12
cpp/ql/test/library-tests/security/encryption/test.cpp
Normal file
12
cpp/ql/test/library-tests/security/encryption/test.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
void des_function(); // insecure
|
||||
void function_using_des(); // insecure
|
||||
void EncryptWithDES(); // insecure
|
||||
|
||||
void aes_function(); // secure
|
||||
void function_using_aes(); // secure
|
||||
void EncryptionWithAES(); // secure
|
||||
|
||||
void abc_function();
|
||||
void function_using_abc();
|
||||
void EncryptionWithABC();
|
||||
@@ -0,0 +1,9 @@
|
||||
| test.cpp:2:6:2:17 | des_function | getInsecureAlgorithmRegex |
|
||||
| test.cpp:3:6:3:23 | function_using_des | getInsecureAlgorithmRegex |
|
||||
| test.cpp:4:6:4:19 | EncryptWithDES | getInsecureAlgorithmRegex |
|
||||
| test.cpp:6:6:6:17 | aes_function | getSecureAlgorithmRegex |
|
||||
| test.cpp:7:6:7:23 | function_using_aes | getSecureAlgorithmRegex |
|
||||
| test.cpp:8:6:8:22 | EncryptionWithAES | getSecureAlgorithmRegex |
|
||||
| test.cpp:10:6:10:17 | abc_function | |
|
||||
| test.cpp:11:6:11:23 | function_using_abc | |
|
||||
| test.cpp:12:6:12:22 | EncryptionWithABC | |
|
||||
14
cpp/ql/test/library-tests/security/encryption/test.ql
Normal file
14
cpp/ql/test/library-tests/security/encryption/test.ql
Normal file
@@ -0,0 +1,14 @@
|
||||
import default
|
||||
import semmle.code.cpp.security.Encryption
|
||||
|
||||
string describe(Function f) {
|
||||
f.getName().regexpMatch(getSecureAlgorithmRegex()) and
|
||||
result = "getSecureAlgorithmRegex"
|
||||
or
|
||||
f.getName().regexpMatch(getInsecureAlgorithmRegex()) and
|
||||
result = "getInsecureAlgorithmRegex"
|
||||
}
|
||||
|
||||
from Function f
|
||||
where exists(f.getLocation().getFile())
|
||||
select f, concat(describe(f), ", ")
|
||||
Reference in New Issue
Block a user