scorecard icon indicating copy to clipboard operation
scorecard copied to clipboard

Scorecard should provide details on fuzzing coverage in fuzzing check

Open inferno-chromium opened this issue 5 years ago • 18 comments

@htuch's suggestion.

inferno-chromium avatar Nov 24 '20 04:11 inferno-chromium

I think it would be good to understand fuzzer health overall. So, coverage is a big part, but so is performance, whether issues get fixed, other efficacy metrics that OSS-fuzz emits. If there was a way to capture this in simple A/B/C grades or the like it would be very useful. CC @asraa

htuch avatar Nov 24 '20 22:11 htuch

@laurentsimon also mentioned this idea, adding him as fyi

inferno-chromium avatar Apr 02 '21 02:04 inferno-chromium

@inferno-chromium does oss-fuzz provide those details?

naveensrinivasan avatar Apr 02 '21 14:04 naveensrinivasan

They're up on GCS for each project's latest coverage report e.g. https://oss-fuzz.com/coverage-report/job/libfuzzer_asan_abseil-cpp/latest

I'm not sure that's the easiest way to get them

asraa avatar Apr 02 '21 14:04 asraa

They're up on GCS for each project's latest coverage report e.g. https://oss-fuzz.com/coverage-report/job/libfuzzer_asan_abseil-cpp/latest

I'm not sure that's the easiest way to get them

This a good start. Thanks. I will work on updating the fuzzing with that information.

naveensrinivasan avatar Apr 02 '21 15:04 naveensrinivasan

They're up on GCS for each project's latest coverage report e.g. https://oss-fuzz.com/coverage-report/job/libfuzzer_asan_abseil-cpp/latest

I'm not sure that's the easiest way to get them

Is there a json result? I don't have permission to access the dir. We can use the HTTP endpoint to query the results and update the fuzzing results.

naveensrinivasan avatar Apr 02 '21 19:04 naveensrinivasan

@inferno-chromium / @asraa Ping.

naveensrinivasan avatar Apr 26 '21 13:04 naveensrinivasan

@oliverchang can help on providing the json endpoint/gcs info here.

inferno-chromium avatar Apr 28 '21 23:04 inferno-chromium

Sure!

So to get the coverage for a OSS-Fuzz project, you need to read 2 JSON files.

First from e.g. https://oss-fuzz-coverage.storage.googleapis.com/latest_report_info/woff2.json

Then get the "report_summary_path" from that. At time of writing this is "gs://oss-fuzz-coverage/woff2/reports/20210428/linux/summary.json" which can be converted to a HTTP link: https://oss-fuzz-coverage.storage.googleapis.com/woff2/reports/20210428/linux/summary.json

That JSON will have a "totals" field which gives coverage summaries. The best one to use will probably be the most fine grained one ("regions").

oliverchang avatar Apr 29 '21 00:04 oliverchang

The fuzzing results provide all these details.

type ossfuzz struct {
	Data []struct {
		Files []struct {
			Filename string `json:"filename"`
			Summary  struct {
				Branches struct {
					Count      int `json:"count"`
					Covered    int `json:"covered"`
					Notcovered int `json:"notcovered"`
					Percent    int `json:"percent"`
				} `json:"branches"`
				Functions struct {
					Count   int `json:"count"`
					Covered int `json:"covered"`
					Percent int `json:"percent"`
				} `json:"functions"`
				Instantiations struct {
					Count   int `json:"count"`
					Covered int `json:"covered"`
					Percent int `json:"percent"`
				} `json:"instantiations"`
				Lines struct {
					Count   int `json:"count"`
					Covered int `json:"covered"`
					Percent int `json:"percent"`
				} `json:"lines"`
				Regions struct {
					Count      int `json:"count"`
					Covered    int `json:"covered"`
					Notcovered int `json:"notcovered"`
					Percent    int `json:"percent"`
				} `json:"regions"`
			} `json:"summary"`
		} `json:"files"`
		Totals struct {
			Branches struct {
				Count      int     `json:"count"`
				Covered    int     `json:"covered"`
				Notcovered int     `json:"notcovered"`
				Percent    float64 `json:"percent"`
			} `json:"branches"`
			Functions struct {
				Count   int `json:"count"`
				Covered int `json:"covered"`
				Percent int `json:"percent"`
			} `json:"functions"`
			Instantiations struct {
				Count   int     `json:"count"`
				Covered int     `json:"covered"`
				Percent float64 `json:"percent"`
			} `json:"instantiations"`
			Lines struct {
				Count   int     `json:"count"`
				Covered int     `json:"covered"`
				Percent float64 `json:"percent"`
			} `json:"lines"`
			Regions struct {
				Count      int     `json:"count"`
				Covered    int     `json:"covered"`
				Notcovered int     `json:"notcovered"`
				Percent    float64 `json:"percent"`
			} `json:"regions"`
		} `json:"totals"`
	} `json:"data"`
	Type    string `json:"type"`
	Version string `json:"version"`
}

Questions

  1. Should scorecard include all these details on the results? or will some section alone suffice?
  2. The scorecard result does not have an option to include additional details like this by design.

type CheckResult struct {
	Error       error `json:"-"`
	Name        string
	Details     []string
	Confidence  int
	Pass        bool
	ShouldRetry bool `json:"-"`
}

We could extend the results by changing Details []string to Details interface{}. This will maintain backward compatibility on the json but I think it will break the BigQuery. This approach can also be used for the other checks if scorecard would like to extend the additional details.

naveensrinivasan avatar May 12 '21 14:05 naveensrinivasan

cc @azeemshaikh38

naveensrinivasan avatar May 12 '21 14:05 naveensrinivasan

Totals -> Regions -> Percent should be good enough for now (high-level % of code covered). Additional details we can later add once we have some design on the Details string as you said. Right now, too many other things to worry about, but can come back in a month to create maybe some structure on Details field ? @azeemshaikh38 thoughts?

inferno-chromium avatar May 12 '21 15:05 inferno-chromium

+1 to adding this to Details []string for now. I think this is another of those things which will benefit from implementing https://github.com/ossf/scorecard/pull/347#discussion_r616364482.

We should probably consider updating how Details []string looks like after few weeks. But for now, there are too many moving parts and I don't want to add one more.

azeemshaikh38 avatar May 14 '21 20:05 azeemshaikh38

We could wait for the Details results to be finalized. So that when we implement this without []string results.

If we implement with []string results and then move it when we finalize the design for results It will break the functionality.

@inferno-chromium Is this an issue that can wait ? are there teams waiting for this to be addressed?

naveensrinivasan avatar May 14 '21 20:05 naveensrinivasan

+1 to waiting if this is not a blocker.

azeemshaikh38 avatar May 14 '21 21:05 azeemshaikh38

@azeemshaikh38 this would be a good feature to provide more details for package consumers.

Can the result interface accommodate some of these changes?

naveensrinivasan avatar Aug 31 '21 11:08 naveensrinivasan

Possible ideas:

  1. Provide a percentage of code covered and provide a link to a detailed report (similar to Vulnerabilities check w/ OSV)? In this case no need to support the structure above
  2. serialize the structure into a string, and set if to the details's Text or a new field. We can add a different Type check_result.go#L49
  3. add an interface to LogMessage structure (with a new type) to support the structure.

(1) is the simplest to start with, and can be improved later to support a better solution.

laurentsimon avatar Aug 31 '21 15:08 laurentsimon

Discussed in 5/16 meeting: nice to have, but unsure if this functionality could be extended to non-ossfuzz fuzzers

justaugustus avatar May 16 '24 20:05 justaugustus