File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,13 +14,14 @@ predicate isSecretField(Field f) {
1414 f .getName ( ) .regexpMatch ( "(?i).*(apiKey|token|secret|password|auth)" )
1515}
1616
17- predicate isSecretValue ( string_literal s ) {
18- s . getValue ( ) .regexpMatch ( "(?i)^(sk_.*|token_.*|apikey_.*|[a-zA-Z0-9+/=]{32,})" )
17+ predicate isSecretValue ( string value ) {
18+ value .regexpMatch ( "(?i)^(sk_.*|token_.*|apikey_.*|[a-zA-Z0-9+/=]{32,})" )
1919}
2020
21- from Field f , string_literal s
21+ from Field f , Expr :: Literal lit
2222where
2323 isSecretField ( f ) and
24- f .getInitializer ( ) = s and
25- isSecretValue ( s )
26- select s , "Hardcoded secret detected: '" + s .getValue ( ) + "' assigned to field '" + f .getName ( ) + "'"
24+ lit .getType ( ) .hasName ( "string" ) and
25+ f .getInitializer ( ) = lit and
26+ isSecretValue ( lit .getValue ( ) )
27+ select lit , "Hardcoded secret detected: '" + lit .getValue ( ) + "' assigned to field '" + f .getName ( ) + "'"
Original file line number Diff line number Diff line change @@ -501,16 +501,17 @@ predicate isSecretField(Field f) {
501501 f.getName().regexpMatch("(?i).*(apiKey|token|secret|password|auth)")
502502}
503503
504- predicate isSecretValue(string_literal s ) {
505- s.getValue() .regexpMatch("(?i)^(sk_.*|token_.*|apikey_.*|[a-zA-Z0-9+/=]{32,})")
504+ predicate isSecretValue(string value ) {
505+ value .regexpMatch("(?i)^(sk_.*|token_.*|apikey_.*|[a-zA-Z0-9+/=]{32,})")
506506}
507507
508- from Field f, string_literal s
508+ from Field f, Expr::Literal lit
509509where
510510 isSecretField(f) and
511- f.getInitializer() = s and
512- isSecretValue(s)
513- select s, "Hardcoded secret detected: '" + s.getValue() + "' assigned to field '" + f.getName() + "'"
511+ lit.getType().hasName("string") and
512+ f.getInitializer() = lit and
513+ isSecretValue(lit.getValue())
514+ select lit, "Hardcoded secret detected: '" + lit.getValue() + "' assigned to field '" + f.getName() + "'"
514515
515516` ` `
516517
You can’t perform that action at this time.
0 commit comments