File tree Expand file tree Collapse file tree
java/ql/lib/semmle/code/java/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import java
44private import semmle.code.java.dataflow.TaintTracking
5+ private import semmle.code.java.security.Sanitizers
56private import semmle.code.java.security.SensitiveActions
67
78/** A sink representing persistent storage that saves data in clear text. */
@@ -76,17 +77,6 @@ private class DefaultCleartextStorageSanitizer extends CleartextStorageSanitizer
7677 }
7778}
7879
79- /**
80- * Method call for encrypting sensitive information. As there are various implementations of
81- * encryption (reversible and non-reversible) from both JDK and third parties, this class simply
82- * checks method name to take a best guess to reduce false positives.
83- */
84- private class EncryptedSensitiveMethodCall extends MethodCall {
85- EncryptedSensitiveMethodCall ( ) {
86- this .getMethod ( ) .getName ( ) .toLowerCase ( ) .matches ( [ "%encrypt%" , "%hash%" , "%digest%" ] )
87- }
88- }
89-
9080/** Flow configuration for encryption methods flowing to inputs of persistent storage. */
9181private module EncryptedValueFlowConfig implements DataFlow:: ConfigSig {
9282 predicate isSource ( DataFlow:: Node src ) { src .asExpr ( ) instanceof EncryptedSensitiveMethodCall }
Original file line number Diff line number Diff line change @@ -63,3 +63,14 @@ class RegexpCheckBarrier extends DataFlow::Node {
6363 exists ( RegexMatch rm | rm instanceof Annotation | this .asExpr ( ) = rm .getString ( ) )
6464 }
6565}
66+
67+ /**
68+ * A method call for encrypting, hashing, or digesting sensitive information. As there are various
69+ * implementations of encryption (reversible and non-reversible) from both JDK and third parties,
70+ * this class simply checks the method name to take a best guess to reduce false positives.
71+ */
72+ class EncryptedSensitiveMethodCall extends MethodCall {
73+ EncryptedSensitiveMethodCall ( ) {
74+ this .getMethod ( ) .getName ( ) .toLowerCase ( ) .matches ( [ "%encrypt%" , "%hash%" , "%digest%" ] )
75+ }
76+ }
Original file line number Diff line number Diff line change @@ -125,12 +125,7 @@ private class DefaultSensitiveLoggerBarrier extends SensitiveLoggerBarrier {
125125 * This is consistent with the treatment of encryption in `CleartextStorageQuery.qll` (CWE-312).
126126 */
127127private class EncryptionBarrier extends SensitiveLoggerBarrier {
128- EncryptionBarrier ( ) {
129- exists ( MethodCall mc |
130- this .asExpr ( ) = mc and
131- mc .getMethod ( ) .getName ( ) .toLowerCase ( ) .matches ( [ "%encrypt%" , "%hash%" , "%digest%" ] )
132- )
133- }
128+ EncryptionBarrier ( ) { this .asExpr ( ) instanceof EncryptedSensitiveMethodCall }
134129}
135130
136131/** A data-flow configuration for identifying potentially-sensitive data flowing to a log output. */
You can’t perform that action at this time.
0 commit comments