-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43462de
commit db98d20
Showing
5 changed files
with
85 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors | ||
|
||
// Package lint contains functions for verifying zarf yaml files are valid | ||
package lint | ||
|
||
import ( | ||
"github.com/defenseunicorns/pkg/helpers/v2" | ||
"github.com/defenseunicorns/zarf/src/types" | ||
) | ||
|
||
// GroupFindingsByPath groups findings by their package path | ||
func GroupFindingsByPath(findings []types.PackageFinding, severity types.Severity, packageName string) map[string][]types.PackageFinding { | ||
findings = helpers.RemoveMatches(findings, func(finding types.PackageFinding) bool { | ||
return finding.Severity > severity | ||
}) | ||
for i := range findings { | ||
if findings[i].PackageNameOverride == "" { | ||
findings[i].PackageNameOverride = packageName | ||
} | ||
if findings[i].PackagePathOverride == "" { | ||
findings[i].PackagePathOverride = "." | ||
} | ||
} | ||
|
||
mapOfFindingsByPath := make(map[string][]types.PackageFinding) | ||
for _, finding := range findings { | ||
mapOfFindingsByPath[finding.PackagePathOverride] = append(mapOfFindingsByPath[finding.PackagePathOverride], finding) | ||
} | ||
return mapOfFindingsByPath | ||
} | ||
|
||
// HasSeverity returns true if the findings contain a severity equal to or greater than the given severity | ||
func HasSeverity(findings []types.PackageFinding, severity types.Severity) bool { | ||
for _, finding := range findings { | ||
if finding.Severity <= severity { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.