Skip to content

Commit

Permalink
Add "recommendation" severity analyzer (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
academo authored Feb 18, 2025
1 parent 8070a79 commit c18a347
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/analysis/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var (
Warning Severity = "warning"
OK Severity = "ok"
SuspectedProblem Severity = "suspected"
Recommendation Severity = "recommendation"
)

type Pass struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/analysis/passes/provenance/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
var (
noProvenanceAttestation = &analysis.Rule{
Name: "no-provenance-attestation",
Severity: analysis.Warning,
Severity: analysis.Recommendation,
}
invalidProvenanceAttestation = &analysis.Rule{
Name: "invalid-provenance-attestation",
Severity: analysis.Warning,
Severity: analysis.Recommendation,
}
)

Expand Down Expand Up @@ -52,7 +52,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
}

matches := githubRe.FindStringSubmatch(pass.CheckParams.SourceCodeReference)
if matches == nil || len(matches) < 3 {
if len(matches) < 3 {
detail := "Cannot verify plugin build. It is recommended to use a pipeline that supports provenance attestation, such as GitHub Actions. https://github.com/grafana/plugin-actions/tree/main/build-plugin"

// add instructions if the source code reference is a github repo
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/plugincheck2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ func main() {
if *strictFlag {
exitCode = 1
}
case analysis.Recommendation:
buf.WriteString(color.CyanString("recommendation: "))
case analysis.OK:
buf.WriteString(color.GreenString("ok: "))
case analysis.SuspectedProblem:
Expand Down

0 comments on commit c18a347

Please sign in to comment.