File tree Expand file tree Collapse file tree 1 file changed +23
-7
lines changed
ruby/ql/lib/codeql/ruby/security/internal Expand file tree Collapse file tree 1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,32 @@ module CleartextSources {
4040 re .getConstantValue ( ) .getStringlikeValue ( ) = [ ".*" , ".+" ]
4141 }
4242
43+ /** Holds if `c` is a sensitive data classification that is relevant to consider for Cleartext Storage queries. */
44+ private predicate isRelevantClassification ( SensitiveDataClassification c ) {
45+ c =
46+ [
47+ SensitiveDataClassification:: password ( ) , SensitiveDataClassification:: certificate ( ) ,
48+ SensitiveDataClassification:: secret ( ) , SensitiveDataClassification:: private ( )
49+ ]
50+ }
51+
52+ pragma [ noinline]
53+ private string getCombinedRelevantSensitiveRegexp ( ) {
54+ // Combine all the maybe-sensitive regexps into one using non-capturing groups and |.
55+ result =
56+ "(?:" +
57+ strictconcat ( string r , SensitiveDataClassification c |
58+ r = maybeSensitiveRegexp ( c ) and isRelevantClassification ( c )
59+ |
60+ r , ")|(?:"
61+ ) + ")"
62+ }
63+
4364 /** Holds if the given name indicates the presence of sensitive data that is relevant to consider for Cleartext Storage queries. */
4465 bindingset [ name]
4566 private predicate nameIndicatesRelevantSensitiveData ( string name ) {
46- exists ( SensitiveDataClassification classification |
47- nameIndicatesSensitiveData ( name , classification ) and
48- classification in [
49- SensitiveDataClassification:: password ( ) , SensitiveDataClassification:: certificate ( ) ,
50- SensitiveDataClassification:: secret ( ) , SensitiveDataClassification:: private ( ) ,
51- ]
52- )
67+ name .regexpMatch ( getCombinedRelevantSensitiveRegexp ( ) ) and
68+ not name .regexpMatch ( notSensitiveRegexp ( ) )
5369 }
5470
5571 /**
You can’t perform that action at this time.
0 commit comments