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

🐛 Fix SAST no longer working for CodeQL #3591

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion checks/sast.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const CheckSAST = "SAST"

var errInvalid = errors.New("invalid")

var sastTools = map[string]bool{"github-code-scanning": true, "lgtm-com": true, "sonarcloud": true}
var sastTools = map[string]bool{
"github-advanced-security": true,
"github-code-scanning": true,
"lgtm-com": true,
"sonarcloud": true,
}

var allowedConclusions = map[string]bool{"success": true, "neutral": true}

Expand Down
71 changes: 70 additions & 1 deletion checks/sast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,53 @@ func Test_SAST(t *testing.T) {
expected: checker.CheckResult{Score: -1},
},
{
name: "Successful SAST checker should return success status",
name: "Successful SAST checker should return success status for github-advanced-security",
commits: []clients.Commit{
{
AssociatedMergeRequest: clients.PullRequest{
MergedAt: time.Now().Add(time.Hour - 1),
},
},
},
searchresult: clients.SearchResponse{},
checkRuns: []clients.CheckRun{
{
Status: "completed",
Conclusion: "success",
App: clients.CheckRunApp{
Slug: "github-advanced-security",
},
},
},
expected: checker.CheckResult{
Score: 10,
},
},
{
name: "Successful SAST checker should return success status for github-code-scanning",
commits: []clients.Commit{
{
AssociatedMergeRequest: clients.PullRequest{
MergedAt: time.Now().Add(time.Hour - 1),
},
},
},
searchresult: clients.SearchResponse{},
checkRuns: []clients.CheckRun{
{
Status: "completed",
Conclusion: "success",
App: clients.CheckRunApp{
Slug: "github-code-scanning",
},
},
},
expected: checker.CheckResult{
Score: 10,
},
},
{
name: "Successful SAST checker should return success status for lgtm",
commits: []clients.Commit{
{
AssociatedMergeRequest: clients.PullRequest{
Expand All @@ -82,6 +128,29 @@ func Test_SAST(t *testing.T) {
Score: 10,
},
},
{
name: "Successful SAST checker should return success status for sonarcloud",
commits: []clients.Commit{
{
AssociatedMergeRequest: clients.PullRequest{
MergedAt: time.Now().Add(time.Hour - 1),
},
},
},
searchresult: clients.SearchResponse{},
checkRuns: []clients.CheckRun{
{
Status: "completed",
Conclusion: "success",
App: clients.CheckRunApp{
Slug: "sonarcloud",
},
},
},
expected: checker.CheckResult{
Score: 10,
},
},
{
name: "Failed SAST checker should return success status",
commits: []clients.Commit{
Expand Down
Loading