From c98fc3b04f5a23bd5165ff2131feb4e61058966b Mon Sep 17 00:00:00 2001 From: ahmed Date: Tue, 29 Aug 2023 16:55:21 -0400 Subject: [PATCH] updating jiratoken detector to use tristate verification --- pkg/detectors/jiratoken/jiratoken.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/detectors/jiratoken/jiratoken.go b/pkg/detectors/jiratoken/jiratoken.go index bfb2fc9eb..965b50d63 100644 --- a/pkg/detectors/jiratoken/jiratoken.go +++ b/pkg/detectors/jiratoken/jiratoken.go @@ -85,8 +85,12 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result // If the request is successful and the login reason is not failed authentication, then the token is valid. // This is because Jira returns a 200 status code even if the token is invalid. // Jira returns a default dashboard page. - if (res.StatusCode >= 200 && res.StatusCode < 300) && res.Header.Get(loginReasonHeaderKey) != failedAuth { - s1.Verified = true + if res.StatusCode >= 200 && res.StatusCode < 300 { + if res.Header.Get(loginReasonHeaderKey) != failedAuth { + s1.Verified = true + } + } else { + s1.VerificationError = fmt.Errorf("unexpected HTTP response status %d", res.StatusCode) } } } @@ -98,7 +102,6 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result } results = append(results, s1) - } }