Skip to content

Commit b1ab16e

Browse files
authored
✨ Add raw results to cron scans (#1741)
* draft * updates * updates * updates * updates * updates * comments * comments * comments * comments * comments * comments
1 parent d5893c2 commit b1ab16e

19 files changed

+481
-29
lines changed

checks/binary_artifact.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const CheckBinaryArtifacts string = "Binary-Artifacts"
2626

2727
//nolint
2828
func init() {
29-
var supportedRequestTypes = []checker.RequestType{
29+
supportedRequestTypes := []checker.RequestType{
3030
checker.FileBased,
3131
checker.CommitBased,
3232
}
@@ -47,7 +47,6 @@ func BinaryArtifacts(c *checker.CheckRequest) checker.CheckResult {
4747
// Return raw results.
4848
if c.RawResults != nil {
4949
c.RawResults.BinaryArtifactResults = rawData
50-
return checker.CheckResult{}
5150
}
5251

5352
// Return the score evaluation.

checks/branch_protection.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func BranchProtection(c *checker.CheckRequest) checker.CheckResult {
4343
// Return raw results.
4444
if c.RawResults != nil {
4545
c.RawResults.BranchProtectionResults = rawData
46-
return checker.CheckResult{}
4746
}
4847

4948
// Return the score evaluation.

checks/code_review.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func CodeReview(c *checker.CheckRequest) checker.CheckResult {
4646
// Return raw results.
4747
if c.RawResults != nil {
4848
c.RawResults.CodeReviewResults = rawData
49-
return checker.CheckResult{}
5049
}
5150

5251
// Return the score evaluation.

checks/dependency_update_tool.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const CheckDependencyUpdateTool = "Dependency-Update-Tool"
2626

2727
//nolint
2828
func init() {
29-
var supportedRequestTypes = []checker.RequestType{
29+
supportedRequestTypes := []checker.RequestType{
3030
checker.FileBased,
3131
}
3232
if err := registerCheck(CheckDependencyUpdateTool, DependencyUpdateTool, supportedRequestTypes); err != nil {
@@ -46,7 +46,6 @@ func DependencyUpdateTool(c *checker.CheckRequest) checker.CheckResult {
4646
// Return raw results.
4747
if c.RawResults != nil {
4848
c.RawResults.DependencyUpdateToolResults = rawData
49-
return checker.CheckResult{}
5049
}
5150

5251
// Return the score evaluation.

checks/security_policy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func SecurityPolicy(c *checker.CheckRequest) checker.CheckResult {
4747
// Set the raw results.
4848
if c.RawResults != nil {
4949
c.RawResults.SecurityPolicyResults = rawData
50-
return checker.CheckResult{}
5150
}
5251

5352
return evaluation.SecurityPolicy(CheckSecurityPolicy, c.Dlogger, &rawData)

checks/vulnerabilities.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func Vulnerabilities(c *checker.CheckRequest) checker.CheckResult {
4646
// Set the raw results.
4747
if c.RawResults != nil {
4848
c.RawResults.VulnerabilitiesResults = rawData
49-
return checker.CheckResult{}
5049
}
5150

5251
return evaluation.Vulnerabilities(CheckVulnerabilities, c.Dlogger, &rawData)

cmd/root.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ func rootCmd(o *options.Options) {
128128
ctx,
129129
repoURI,
130130
o.Commit,
131-
o.Format == options.FormatRaw,
132131
enabledChecks,
133132
repoClient,
134133
ossFuzzRepoClient,

cmd/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func serveCmd(o *options.Options) *cobra.Command {
6969
defer ossFuzzRepoClient.Close()
7070
ciiClient := clients.DefaultCIIBestPracticesClient()
7171
repoResult, err := pkg.RunScorecards(
72-
ctx, repo, clients.HeadSHA /*commitSHA*/, false /*raw*/, checks.AllChecks, repoClient,
72+
ctx, repo, clients.HeadSHA /*commitSHA*/, checks.AllChecks, repoClient,
7373
ossFuzzRepoClient, ciiClient, vulnsClient)
7474
if err != nil {
7575
logger.Error(err, "running enabled scorecard checks on repo")

cron/config/config.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ const (
4747
metricExporter string = "SCORECARD_METRIC_EXPORTER"
4848
ciiDataBucketURL string = "SCORECARD_CII_DATA_BUCKET_URL"
4949
blacklistedChecks string = "SCORECARD_BLACKLISTED_CHECKS"
50-
50+
// v2 results.
5151
bigqueryTableV2 string = "SCORECARD_BIGQUERY_TABLEV2"
5252
resultDataBucketURLV2 string = "SCORECARD_DATA_BUCKET_URLV2"
53+
// Raw results.
54+
rawBigqueryTable string = "RAW_SCORECARD_BIGQUERY_TABLE"
55+
rawResultDataBucketURL string = "RAW_SCORECARD_DATA_BUCKET_URL"
5356
)
5457

5558
var (
@@ -78,6 +81,9 @@ type config struct {
7881
// UPGRADEv2: to remove.
7982
ResultDataBucketURLV2 string `yaml:"result-data-bucket-url-v2"`
8083
BigQueryTableV2 string `yaml:"bigquery-table-v2"`
84+
// Raw results.
85+
RawResultDataBucketURL string `yaml:"raw-result-data-bucket-url"`
86+
RawBigQueryTable string `yaml:"raw-bigquery-table"`
8187
}
8288

8389
func getParsedConfigFromFile(byteValue []byte) (config, error) {
@@ -196,6 +202,18 @@ func GetResultDataBucketURLV2() (string, error) {
196202
return getStringConfigValue(resultDataBucketURLV2, configYAML, "ResultDataBucketURLV2", "result-data-bucket-url-v2")
197203
}
198204

205+
// GetRawBigQueryTable returns the table name to transfer cron job results.
206+
func GetRawBigQueryTable() (string, error) {
207+
return getStringConfigValue(rawBigqueryTable, configYAML,
208+
"RawBigQueryTable", "raw-bigquery-table")
209+
}
210+
211+
// GetRawResultDataBucketURL returns the bucketURL for storing cron job's raw results.
212+
func GetRawResultDataBucketURL() (string, error) {
213+
return getStringConfigValue(rawResultDataBucketURL, configYAML,
214+
"RawResultDataBucketURL", "raw-result-data-bucket-url")
215+
}
216+
199217
// GetShardSize returns the shard_size for the cron job.
200218
func GetShardSize() (int, error) {
201219
return getIntConfigValue(shardSize, configYAML, "ShardSize", "shard-size")

cron/config/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ metric-exporter: stackdriver
2929
# UPGRADEv2: to remove.
3030
result-data-bucket-url-v2: gs://ossf-scorecard-data2
3131
bigquery-table-v2: scorecard-v2
32+
# Raw results.
33+
raw-result-data-bucket-url: gs://ossf-scorecard-rawdata
34+
raw-bigquery-table: scorecard-rawdata

0 commit comments

Comments
 (0)