Skip to content

Commit 8bdcc47

Browse files
committed
C++: Add a test.
1 parent 54b8f8e commit 8bdcc47

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
void des_function(); // insecure
3+
void function_using_des(); // insecure
4+
void EncryptWithDES(); // insecure
5+
6+
void aes_function(); // secure
7+
void function_using_aes(); // secure
8+
void EncryptionWithAES(); // secure
9+
10+
void abc_function();
11+
void function_using_abc();
12+
void EncryptionWithABC();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| test.cpp:2:6:2:17 | des_function | getInsecureAlgorithmRegex |
2+
| test.cpp:3:6:3:23 | function_using_des | getInsecureAlgorithmRegex |
3+
| test.cpp:4:6:4:19 | EncryptWithDES | getInsecureAlgorithmRegex |
4+
| test.cpp:6:6:6:17 | aes_function | getSecureAlgorithmRegex |
5+
| test.cpp:7:6:7:23 | function_using_aes | getSecureAlgorithmRegex |
6+
| test.cpp:8:6:8:22 | EncryptionWithAES | getSecureAlgorithmRegex |
7+
| test.cpp:10:6:10:17 | abc_function | |
8+
| test.cpp:11:6:11:23 | function_using_abc | |
9+
| test.cpp:12:6:12:22 | EncryptionWithABC | |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import default
2+
import semmle.code.cpp.security.Encryption
3+
4+
string describe(Function f) {
5+
f.getName().regexpMatch(getSecureAlgorithmRegex()) and
6+
result = "getSecureAlgorithmRegex"
7+
or
8+
f.getName().regexpMatch(getInsecureAlgorithmRegex()) and
9+
result = "getInsecureAlgorithmRegex"
10+
}
11+
12+
from Function f
13+
where exists(f.getLocation().getFile())
14+
select f, concat(describe(f), ", ")

0 commit comments

Comments
 (0)