-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Weak hash and weak random Java rules need to guard from none (#426)
The algorithm string might have a None value if the parser cannot determine its actual value. For example, in the added testcase, if a value goes through a Properties class, the parser does track this value. Signed-off-by: Eric Brown <eric.brown@securesauce.dev>
- Loading branch information
Showing
4 changed files
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/unit/rules/java/stdlib/java_security/examples/MessageDigestMD5Property.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// level: NONE | ||
// False negative | ||
import java.security.*; | ||
import java.util.*; | ||
|
||
|
||
public class MessageDigestMD5 { | ||
public static void main(String[] args) { | ||
try { | ||
Properties hashProps = new Properties(); | ||
hashProps.setProperty("hashMd5", "MD5") | ||
String algorithm = hashProps.getProperty("hashMd5", "SHA256"); | ||
MessageDigest md = MessageDigest.getInstance(algorithm); | ||
} catch (NoSuchAlgorithmException e) { | ||
System.err.println("MD5 hashing algorithm not available."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters