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

✨ Structured results for Fuzzing check #2658

Closed
wants to merge 4 commits into from

Conversation

laurentsimon
Copy link
Contributor

Structured results for Fuzzing check

Signed-off-by: laurentsimon <[email protected]>
Signed-off-by: laurentsimon <[email protected]>
Signed-off-by: laurentsimon <[email protected]>
Signed-off-by: laurentsimon <[email protected]>
@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Merging #2658 (9b9e042) into main (93900ac) will increase coverage by 8.64%.
The diff coverage is 39.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2658      +/-   ##
==========================================
+ Coverage   41.27%   49.91%   +8.64%     
==========================================
  Files         123      159      +36     
  Lines       10043    12661    +2618     
==========================================
+ Hits         4145     6320    +2175     
- Misses       5602     5966     +364     
- Partials      296      375      +79     

@github-actions
Copy link

Stale pull request message

Comment on lines +15 to +16
short: Check that the project is fuzzed using OSS-Fuzz
desc: This rule checks that whether the project is fuzzed with OSS-Fuzz
Copy link
Member

Choose a reason for hiding this comment

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

copy-paste error with OSS-Fuzz instead of cluster fuzz lite

- If no fuzzing functions are found in the source code, a finding with OutcomeNegative (0) is returned.
risk: Medium
remediation:
effort: High
Copy link
Member

Choose a reason for hiding this comment

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

Would Go native fuzzing be considered lower effort? Assuming it's a go project I'd say probably?

}
return checker.CreateMinScoreResult(name, "project is not fuzzed")
}
fuzzers := []string{}
Copy link
Member

Choose a reason for hiding this comment

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

Since we know the length of r.Fuzzers, we can minimize allocations with:

fuzzers := make([]string, 0, len(r.Fuzzers)

Comment on lines +52 to 53
NumberOfWarn: 4,
NumberOfInfo: 0,
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be 3 warn and 1 info.

The test is broken right now though #2670

@@ -371,3 +371,25 @@ type TokenPermission struct {
Msg *string
Type PermissionLevel
}

// Location generates location from a file.
func (f *File) Location() *finding.Location {
Copy link
Member

Choose a reason for hiding this comment

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

i assume these are identical between this PR and #2634 ?

@@ -199,3 +200,30 @@ func CreateRuntimeErrorResult(name string, e error) CheckResult {
Reason: e.Error(), // Note: message already accessible by caller thru `Error`.
}
}

func LogFinding(rules embed.FS, ruleName, text string, loc *finding.Location,
Copy link
Member

Choose a reason for hiding this comment

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

identical between here and #2634 ?

fuzzer := r.Fuzzers[i]
// NOTE: files are not populated for all fuzzers yet.
// To simplify the code, we currently do not report the locations.
switch fuzzer.Name {
Copy link
Member

Choose a reason for hiding this comment

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

there's a lot of similarity here that could probably be extracted out if we had a map from fuzzer.Name -> rule name.

The switch statement could be replaced with a map. Something like

m := map[string]string{
    "GoNativeFuzzer": fuzzingWithGoNative,
    // and so on
    // ...
}

fuzzRule, ok := m[fuzzer.Name]
if !ok {
 // unsupported rule
}
if err := checker.LogFinding(rules, fuzzRule,
  "project fuzzed with " + fuzzer.Name,
  nil, finding.OutcomePositive, dl); err != nil {
  return checker.CreateRuntimeErrorResult(name, err)
}
reportedRuleResults[fuzzRule] = true

WDUT?


func logDefaultFindings(dl checker.DetailLogger, r map[string]bool) error {
// We always report at least one finding for each rule.
if !r[fuzzingWithGoNative] {
Copy link
Member

Choose a reason for hiding this comment

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

same comment about the map. so the map could be an unexported package level var?

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

Stale pull request message

@github-actions
Copy link

github-actions bot commented Apr 9, 2023

Stale pull request message

@naveensrinivasan
Copy link
Member

@laurentsimon A Friendly ping!

@github-actions
Copy link

github-actions bot commented May 1, 2023

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants