@@ -76,33 +76,8 @@ module HardcodedCredentials {
7676 * where we can be reasonably confident downstream users will not mistake
7777 * that empty string for a usable key.
7878 */
79- private class ReturnedAlongsideErrorSanitizer extends Sanitizer {
80- ReturnedAlongsideErrorSanitizer ( ) {
81- exists ( ReturnStmt r , DataFlow:: CallNode c |
82- c .getTarget ( ) .hasQualifiedName ( "errors" , "New" ) and
83- r .getNumChild ( ) > 1 and
84- r .getAChild ( ) = c .getAResult ( ) .getASuccessor * ( ) .asExpr ( ) and
85- r .getAChild ( ) = this .asExpr ( )
86- )
87- }
88- }
89-
90- /**
91- * A value returned alongside an error-value that is known
92- * to be non-nil by virtue of a guarding check.
93- *
94- * For example, `if err != nil { return "", err }` is unlikely to be
95- * contributing a dangerous hardcoded key.
96- */
97- private class ReturnedAlongsideErrorSanitizerGuard extends Sanitizer {
98- ReturnedAlongsideErrorSanitizerGuard ( ) {
99- exists ( ControlFlow:: ConditionGuardNode guard , SsaWithFields errorVar , ReturnStmt r |
100- guard .ensuresNeq ( errorVar .getAUse ( ) , Builtin:: nil ( ) .getARead ( ) ) and
101- guard .dominates ( this .getBasicBlock ( ) ) and
102- r .getExpr ( 1 ) = errorVar .getAUse ( ) .asExpr ( ) and
103- this .asExpr ( ) = r .getExpr ( 0 )
104- )
105- }
79+ private class ReturnedWithErrorSanitizer extends Sanitizer {
80+ ReturnedWithErrorSanitizer ( ) { DataFlow:: isReturnedWithError ( this ) }
10681 }
10782
10883 /** The result of a formatting string call. */
0 commit comments