Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: laurentsimon <[email protected]>
  • Loading branch information
laurentsimon committed Jan 9, 2023
1 parent f052bc9 commit ae53e6e
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
2 changes: 0 additions & 2 deletions checks/evaluation/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func applyScorePolicy(results *checker.TokenPermissionsData, c *checker.CheckReq
remediationMetadata, _ := remediation.New(c)

for _, r := range results.TokenPermissions {

// var rem *remediation.RemediationMetadata
var loc *finding.Location
if r.File != nil {
loc = &finding.Location{
Expand Down
1 change: 0 additions & 1 deletion checks/raw/binary_artifact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/ossf/scorecard/v4/clients"
mockrepo "github.com/ossf/scorecard/v4/clients/mockclients"
"github.com/ossf/scorecard/v4/finding"
)

func strptr(s string) *string {
Expand Down
1 change: 0 additions & 1 deletion checks/raw/dangerous_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"

mockrepo "github.com/ossf/scorecard/v4/clients/mockclients"
"github.com/ossf/scorecard/v4/finding"
)

func errCmp(e1, e2 error) bool {
Expand Down
1 change: 0 additions & 1 deletion checks/raw/dependency_update_tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/ossf/scorecard/v4/checker"
clients "github.com/ossf/scorecard/v4/clients"
mockrepo "github.com/ossf/scorecard/v4/clients/mockclients"
"github.com/ossf/scorecard/v4/finding"
)

func Test_checkDependencyFileExists(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion checks/raw/fuzzing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/ossf/scorecard/v4/checker"
"github.com/ossf/scorecard/v4/clients"
mockrepo "github.com/ossf/scorecard/v4/clients/mockclients"
"github.com/ossf/scorecard/v4/finding"
)

// Test_checkOSSFuzz is a test function for checkOSSFuzz.
Expand Down
2 changes: 1 addition & 1 deletion finding/finding.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OpenSSF Scorecard Authors
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion finding/finding_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 OpenSSF Scorecard Authors
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
33 changes: 18 additions & 15 deletions pkg/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func DetailToString(d *checker.CheckDetail, logLevel log.Level) string {
}

var sb strings.Builder
// Non-structured results.
if d.Msg.Finding == nil {
sb.WriteString(fmt.Sprintf("%s: %s", typeToString(d.Type), d.Msg.Text))

Expand All @@ -50,24 +51,26 @@ func DetailToString(d *checker.CheckDetail, logLevel log.Level) string {
sb.WriteString(fmt.Sprintf(": %s", d.Msg.Remediation.Text))
}

} else {
f := d.Msg.Finding
sb.WriteString(fmt.Sprintf("%s: %s severity: %s", typeToString(d.Type), f.Risk, f.Message))
return sb.String()
}

if f.Location != nil {
sb.WriteString(fmt.Sprintf(": %s", f.Location.Value))
if f.Location.LineStart != nil {
sb.WriteString(fmt.Sprintf(":%d", *f.Location.LineStart))
}
if f.Location.LineEnd != nil && *f.Location.LineStart < *f.Location.LineEnd {
sb.WriteString(fmt.Sprintf("-%d", *f.Location.LineEnd))
}
}
// Stuctured results.
f := d.Msg.Finding
sb.WriteString(fmt.Sprintf("%s: %s severity: %s", typeToString(d.Type), f.Risk, f.Message))

// Effort to remediate.
if f.Remediation != nil {
sb.WriteString(fmt.Sprintf(": %s (%s effort)", f.Remediation.Text, f.Remediation.Effort))
if f.Location != nil {
sb.WriteString(fmt.Sprintf(": %s", f.Location.Value))
if f.Location.LineStart != nil {
sb.WriteString(fmt.Sprintf(":%d", *f.Location.LineStart))
}
if f.Location.LineEnd != nil && *f.Location.LineStart < *f.Location.LineEnd {
sb.WriteString(fmt.Sprintf("-%d", *f.Location.LineEnd))
}
}

// Effort to remediate.
if f.Remediation != nil {
sb.WriteString(fmt.Sprintf(": %s (%s effort)", f.Remediation.Text, f.Remediation.Effort))
}

return sb.String()
Expand Down
4 changes: 2 additions & 2 deletions remediation/remediations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func TestRepeatedSetup(t *testing.T) {
}

want := fmt.Sprintf("ossf/scorecard%d", i)
if rmd.repo != want {
t.Errorf("failed. expected: %v, got: %v", want, rmd.repo)
if rmd.Repo != want {
t.Errorf("failed. expected: %v, got: %v", want, rmd.Repo)
}
}
}
4 changes: 3 additions & 1 deletion rule/rule.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 OpenSSF Scorecard Authors
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,6 +47,7 @@ type Remediation struct {
Effort RemediationEffort `json:"effort"`
}

// nolint: govet
type jsonRemediation struct {
Text []string `yaml:"text"`
Markdown []string `yaml:"markdown"`
Expand Down Expand Up @@ -78,6 +79,7 @@ const (
RiskNone Risk = "None"
)

// nolint: govet
type Rule struct {
Name string
Short string
Expand Down
3 changes: 2 additions & 1 deletion rule/rule_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 OpenSSF Scorecard Authors
// Copyright 2023 OpenSSF Scorecard Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@ var testfs embed.FS

func Test_RuleNew(t *testing.T) {
t.Parallel()
// nolint: govet
tests := []struct {
name string
id string
Expand Down

0 comments on commit ae53e6e

Please sign in to comment.