Skip to content

Commit

Permalink
🌱 create findings from processing errors
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Korczynski <[email protected]>
  • Loading branch information
AdamKorcz committed Dec 4, 2023
1 parent 0a043e4 commit 3f73d80
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions checks/evaluation/pinned_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,21 @@ func probeRemToRuleRem(rem *probe.Remediation) *rule.Remediation {
}
}

func dependenciesToFindings(deps []checker.Dependency) ([]finding.Finding, error) {
func dependenciesToFindings(r *checker.PinningDependenciesData) ([]finding.Finding, error) {
findings := make([]finding.Finding, 0)
for i := range deps {
rr := deps[i]

for _, e := range r.ProcessingErrors {
e := e
f := finding.Finding{
Message: generateTextIncompleteResults(e),
Location: &e.Location,
Outcome: finding.OutcomeNotAvailable,
}
findings = append(findings, f)
}

for i := range r.Dependencies {
rr := r.Dependencies[i]
if rr.Location == nil {
if rr.Msg == nil {
e := sce.WithMessage(sce.ErrScorecardInternal, "empty File field")
Expand Down Expand Up @@ -199,17 +210,7 @@ func PinningDependencies(name string, c *checker.CheckRequest,
pr := make(map[checker.DependencyUseType]pinnedResult)
dl := c.Dlogger

for _, e := range r.ProcessingErrors {
e := e
dl.Info(&checker.LogMessage{
Finding: &finding.Finding{
Message: generateTextIncompleteResults(e),
Location: &e.Location,
},
})
}

findings, err := dependenciesToFindings(r.Dependencies)
findings, err := dependenciesToFindings(r)
if err != nil {
return checker.CreateRuntimeErrorResult(name, err)
}
Expand Down Expand Up @@ -246,6 +247,11 @@ func PinningDependencies(name string, c *checker.CheckRequest,
lm.Remediation = probeRemToRuleRem(f.Remediation)
}
dl.Warn(lm)
} else if f.Outcome == finding.OutcomeNotAvailable {
dl.Info(&checker.LogMessage{
Finding: &f,
})
continue
}
updatePinningResults(intToDepType[f.Values["dependencyType"]],
f.Outcome, f.Location.Snippet,
Expand Down

0 comments on commit 3f73d80

Please sign in to comment.