Skip to content

Commit 7f84cf6

Browse files
committed
Add test case
1 parent 7baaa23 commit 7f84cf6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

java/ql/test/query-tests/security/CWE-327/semmle/tests/MaybeBrokenCryptoAlgorithm.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ nodes
44
| WeakHashing.java:15:55:15:83 | getProperty(...) | semmle.label | getProperty(...) |
55
| WeakHashing.java:18:56:18:95 | getProperty(...) | semmle.label | getProperty(...) |
66
| WeakHashing.java:21:56:21:91 | getProperty(...) | semmle.label | getProperty(...) |
7+
| WeakHashing.java:30:55:30:64 | "SHA3-512" | semmle.label | "SHA3-512" |
78
subpaths
89
#select
910
| Test.java:34:21:34:53 | new SecretKeySpec(...) | Test.java:34:48:34:52 | "foo" | Test.java:34:48:34:52 | "foo" | Cryptographic algorithm $@ may not be secure, consider using a different algorithm. | Test.java:34:48:34:52 | "foo" | foo |
1011
| WeakHashing.java:15:29:15:84 | getInstance(...) | WeakHashing.java:15:55:15:83 | getProperty(...) | WeakHashing.java:15:55:15:83 | getProperty(...) | Cryptographic algorithm $@ may not be secure, consider using a different algorithm. | WeakHashing.java:15:55:15:83 | getProperty(...) | MD5 |
1112
| WeakHashing.java:18:30:18:96 | getInstance(...) | WeakHashing.java:18:56:18:95 | getProperty(...) | WeakHashing.java:18:56:18:95 | getProperty(...) | Cryptographic algorithm $@ may not be secure, consider using a different algorithm. | WeakHashing.java:18:56:18:95 | getProperty(...) | MD5 |
1213
| WeakHashing.java:21:30:21:92 | getInstance(...) | WeakHashing.java:21:56:21:91 | getProperty(...) | WeakHashing.java:21:56:21:91 | getProperty(...) | Cryptographic algorithm $@ may not be secure, consider using a different algorithm. | WeakHashing.java:21:56:21:91 | getProperty(...) | MD5 |
14+
| WeakHashing.java:30:29:30:65 | getInstance(...) | WeakHashing.java:30:55:30:64 | "SHA3-512" | WeakHashing.java:30:55:30:64 | "SHA3-512" | Cryptographic algorithm $@ may not be secure, consider using a different algorithm. | WeakHashing.java:30:55:30:64 | "SHA3-512" | SHA3-512 |

java/ql/test/query-tests/security/CWE-327/semmle/tests/WeakHashing.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ void hashing() throws NoSuchAlgorithmException, IOException {
2525

2626
// OK: Property does not exist and default is secure
2727
MessageDigest ok2 = MessageDigest.getInstance(props.getProperty("hashAlg3", "SHA-256"));
28+
29+
// GOOD: Using a strong hashing algorithm
30+
MessageDigest ok3 = MessageDigest.getInstance("SHA3-512");
2831
}
29-
}
32+
}

0 commit comments

Comments
 (0)