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

✨ Allow incomplete local checks #4423

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

Conversation

lharrison13
Copy link

What kind of change does this PR introduce?

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

What is the current behavior?

Certain checks are currently not run when using the local option

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

Now allows incomplete versions of the following checks to be run when using the local option

Fuzzing
License
Packaging
SAST
Security-Policy

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

Which issue(s) this PR fixes

Fixes #3832

Special notes for your reviewer

Does this PR introduce a user-facing change?

For user-facing changes, please add a concise, human-readable release note to
the release-note

(In particular, describe what changes users might need to make in their
application as a result of this pull request.)

Enabled Fuzzing, License, Packaging, SAST, and Security-Policy checks when using --local option
Screenshot 2024-11-26 at 11 59 38 PM

@lharrison13 lharrison13 requested a review from a team as a code owner November 27, 2024 05:01
@lharrison13 lharrison13 requested review from spencerschrock and raghavkaul and removed request for a team November 27, 2024 05:01
@lharrison13 lharrison13 changed the title ✨ Allow incomplete localdir checks ✨ Allow incomplete local checks Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 25.33333% with 56 lines in your changes missing coverage. Please review.

Project coverage is 68.79%. Comparing base (353ed60) to head (f7d0d75).
Report is 60 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4423      +/-   ##
==========================================
+ Coverage   66.80%   68.79%   +1.98%     
==========================================
  Files         230      236       +6     
  Lines       16602    17573     +971     
==========================================
+ Hits        11091    12089     +998     
+ Misses       4808     4691     -117     
- Partials      703      793      +90     

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.

Thanks for sending a PR, overall looks pretty good! Left a few comments

Comment on lines 47 to 48
var err, errG, errGL error

Copy link
Member

Choose a reason for hiding this comment

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

can we be more explicit about which error is which?

errGitHub and errGitLab?

Comment on lines 212 to 215
// ListProgrammingLanguages is unsupported by local client so just return
if errors.Is(err, clients.ErrUnsupportedFeature) {
return checker.FuzzingData{Fuzzers: detectedFuzzers}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

we miss out on most of the file-based detection if we return early here. (only clusterfuzzlite is detected).

I wonder if it makes sense to scan for every language if the client doesn't have the info

Comment on lines 77 to 78
if err != nil {
return data, fmt.Errorf("Client.Actions.ListWorkflowRunsByFileName: %w", err)
// appending empty run for localdir client
Copy link
Member

Choose a reason for hiding this comment

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

lets clarify the purpose of adding the empty run in the comment. maybe something like (but open to suggestions):

// assume the workflow will run for localdir client

Comment on lines 74 to 79
case errors.Is(err, sce.ErrRepoUnreachable), errors.Is(err, clients.ErrUnsupportedFeature):
break
default:
return checker.SecurityPolicyData{}, err
if !errors.Is(err, clients.ErrUnsupportedFeature) {
return checker.SecurityPolicyData{}, err
}
Copy link
Member

Choose a reason for hiding this comment

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

does the case above default not already handle clients.ErrUnsupportedFeature?

Copy link
Author

Choose a reason for hiding this comment

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

I honestly have no clue why i put that there

Comment on lines 41 to 42
//nolint:govet
type localDirClient struct {
type LocalDirClient struct {
Copy link
Member

Choose a reason for hiding this comment

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

nit: now that we're exporting this type, lets make the name match the others:

type Client struct {

so that users will write:

case *localdir.Client:

instead of having the repetition

case *localdir.LocalDirClient:

Comment on lines 335 to +336
requiredRequestTypes: []checker.RequestType{checker.FileBased, checker.CommitBased},
expectedEnabledChecks: 5, // All checks which are FileBased and CommitBased
expectedEnabledChecks: 7, // All checks which are FileBased and CommitBased
Copy link
Member

Choose a reason for hiding this comment

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

hmm, i thought this PR added FileBased to 3 checks that weren't before? Any idea what's going on here?

Copy link
Author

Choose a reason for hiding this comment

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

I think that test is for FileBased and Commit Based. I added 3 checks that were FileBased but two originally had CommitBased.

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.

Feature: Allow "incomplete" checks for --local repos
2 participants