Skip to content

Commit 466da5b

Browse files
Pre-filter GitHub v1 findings to prevent large numbers of validation requests (#4468)
1 parent 9adec3c commit 466da5b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/detectors/github/v1/github_old.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
9595
matchPrefix := match[0]
9696
token := match[1]
9797

98+
// It may seem strange to filter out findings prior to verifying them. However, this credential looks like a
99+
// normal sha256 hash, which is an incredibly common string to see. So the filter here prevents an excessive
100+
// number of requests to be sent for findings which will almost certainly not be verified. It must occur before
101+
// verification, because otherwise the number of verification requests can be quite excessive.
102+
if isKnownNonSensitiveCommonPrefix(matchPrefix) {
103+
continue
104+
}
105+
98106
// Note that this false positive check happens **before** verification! I don't know why it's written this way
99107
// but that's why this logic wasn't moved into a CustomFalsePositiveChecker implementation.
100108
if isFp, _ := detectors.IsKnownFalsePositive(token, ghFalsePositives, false); isFp {
@@ -120,13 +128,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
120128

121129
isVerified, userResponse, headers, err := s.VerifyGithub(ctx, client, token)
122130

123-
if !isVerified {
124-
// to avoid false positives for unverified findings
125-
if isKnownNonSensitiveCommonPrefix(matchPrefix) {
126-
continue
127-
}
128-
}
129-
130131
s1.Verified = isVerified
131132
s1.SetVerificationError(err, token)
132133

0 commit comments

Comments
 (0)