Skip to content

🌱 add support for hadolint SAST #4688

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

AdamKorcz
Copy link
Contributor

What kind of change does this PR introduce?

(Is it a bug fix, feature, docs update, something else?)

feature

What is the current behavior?

Scorecard does not support hadolint SAST.

What is the new behavior (if this is a feature change)?**

Scorecard supports hadolint SAST.

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

Partially fixes #2318 (comment)

Special notes for your reviewer

Does this PR introduce a user-facing change?

Support Hadolint SAST.

@AdamKorcz AdamKorcz requested a review from a team as a code owner June 28, 2025 19:11
@AdamKorcz AdamKorcz requested review from justaugustus and spencerschrock and removed request for a team June 28, 2025 19:11
@AdamKorcz AdamKorcz temporarily deployed to integration-test June 28, 2025 19:11 — with GitHub Actions Inactive
@AdamKorcz AdamKorcz marked this pull request as draft June 28, 2025 19:12
Copy link

codecov bot commented Jun 28, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 68.29%. Comparing base (353ed60) to head (7846164).
Report is 199 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4688      +/-   ##
==========================================
+ Coverage   66.80%   68.29%   +1.48%     
==========================================
  Files         230      249      +19     
  Lines       16602    18904    +2302     
==========================================
+ Hits        11091    12910    +1819     
- Misses       4808     5133     +325     
- Partials      703      861     +158     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AdamKorcz AdamKorcz temporarily deployed to integration-test June 30, 2025 11:25 — with GitHub Actions Inactive
@AdamKorcz AdamKorcz marked this pull request as ready for review June 30, 2025 11:29
Comment on lines 382 to 327
for _, tt := range tests {
searchRequest := clients.SearchRequest{
Query: "github/codeql-action/analyze",
Path: "/.github/workflows",
}
t.Run(tt.name, func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was there a driver behind redefining this in every test instead of once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I added a new test that needs another searchRequest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the duplication caught my eye initially, but I don't think it's not necessary anymore.
When the test was written 4 years ago, the SAST implementation actually used the search interface.

scorecard/checks/sast.go

Lines 170 to 176 in e5a08af

// nolint
func codeQLInCheckDefinitions(c *checker.CheckRequest) (int, error) {
searchRequest := clients.SearchRequest{
Query: "github/codeql-action/analyze",
Path: "/.github/workflows",
}
resp, err := c.RepoClient.Search(searchRequest)

Where as today's implementation uses getSastUsesWorkflows

codeQLWorkflows, err := getSastUsesWorkflows(c, "^github/codeql-action/analyze$", checker.CodeQLWorkflow)
if err != nil {
return data, err
}

which searches the files locally

err := fileparser.OnMatchingFileContentDo(c.RepoClient, fileparser.PathMatcher{
Pattern: ".github/workflows/*",
CaseSensitive: false,
}, searchGitHubActionWorkflowUseRegex, &workflowPaths, usesRegex)

If you uncomment the mock line, nothing panics/breaks, so I say we just get rid of it all the search requests/responses in this test

// mockRepoClient.EXPECT().Search(tt.searchRequest).Return(tt.searchresult, nil).AnyTimes()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to do that, but let me clean up this test in a separate PR to not mix things together? I have reverted my changes in this PR.

Copy link
Member

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm other than the few comments

Copy link

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions bot added the Stale label Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Add more options for SAST tools
2 participants