Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced the easyinsight detector #3384

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
updated statuscode logic
kashifkhan0771 committed Oct 9, 2024
commit 3d1acefb24642422e4db26cf3a42375c783e4aaa
13 changes: 9 additions & 4 deletions pkg/detectors/easyinsight/easyinsight.go
Original file line number Diff line number Diff line change
@@ -111,10 +111,15 @@ func verifyEasyInsight(ctx context.Context, id, key string) (bool, error) {
_ = res.Body.Close()
}()

if res.StatusCode >= 200 && res.StatusCode < 300 {
switch res.StatusCode {
// id, key verified
case http.StatusOK:
return true, nil
// id, key unverified
case http.StatusUnauthorized:
return false, nil
// something invalid
default:
return false, fmt.Errorf("unexpected status code: %d", res.StatusCode)
}

// if status code is not handled, return unexpected code error
return false, fmt.Errorf("unexpected status code: %d", res.StatusCode)
}