-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compliance policy for empty name and version (#3257)
* add policy for empty name and version Signed-off-by: Alex Goodman <[email protected]> * default stub version Signed-off-by: Alex Goodman <[email protected]> * modifying ids requires augmenting relationships Signed-off-by: Alex Goodman <[email protected]> --------- Signed-off-by: Alex Goodman <[email protected]>
- Loading branch information
Showing
9 changed files
with
547 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package options | ||
|
||
import ( | ||
"github.com/anchore/fangs" | ||
"github.com/anchore/syft/syft/cataloging" | ||
) | ||
|
||
var ( | ||
_ fangs.FieldDescriber = (*complianceConfig)(nil) | ||
_ fangs.PostLoader = (*complianceConfig)(nil) | ||
) | ||
|
||
type complianceConfig struct { | ||
MissingName cataloging.ComplianceAction `mapstructure:"missing-name" json:"missing-name" yaml:"missing-name"` | ||
MissingVersion cataloging.ComplianceAction `mapstructure:"missing-version" json:"missing-version" yaml:"missing-version"` | ||
} | ||
|
||
func defaultComplianceConfig() complianceConfig { | ||
def := cataloging.DefaultComplianceConfig() | ||
return complianceConfig{ | ||
MissingName: def.MissingName, | ||
MissingVersion: def.MissingVersion, | ||
} | ||
} | ||
|
||
func (r *complianceConfig) DescribeFields(descriptions fangs.FieldDescriptionSet) { | ||
descriptions.Add(&r.MissingName, "action to take when a package is missing a name") | ||
descriptions.Add(&r.MissingVersion, "action to take when a package is missing a version") | ||
} | ||
|
||
func (r *complianceConfig) PostLoad() error { | ||
r.MissingName = r.MissingName.Parse() | ||
r.MissingVersion = r.MissingVersion.Parse() | ||
return nil | ||
} |
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
Oops, something went wrong.