Created
September 8, 2022 15:17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fuzzed(repo string) (bool, int, error) { | |
//repo = "github.com/sigstore/sigstore" | |
req, err := http.NewRequest("GET", fmt.Sprintf("https://api.securityscorecards.dev/projects/%s", repo), nil) | |
if err != nil { | |
panic(err) | |
} | |
req.Header.Set("Accept", "application/json") | |
resp, err := http.DefaultClient.Do(req) | |
if err != nil { | |
return false, 0, err | |
} | |
defer resp.Body.Close() | |
result, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
return false, 0, err | |
} | |
var scorecard Scorecard | |
err = json.Unmarshal(result, &scorecard) | |
if err != nil { | |
return true, 0, err | |
} | |
for _, check := range scorecard.Checks { | |
if check.Name == "Fuzzing" { | |
if check.Score >= 7 || check.Score < 0 { | |
return true, check.Score, nil | |
} | |
return false, 0, nil | |
} | |
} | |
return false, 0, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment