Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
feedback - part1
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-santos-code committed Aug 1, 2022
1 parent 2ba56a8 commit c486c0a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func runAudit(auditable ...kubeaudit.Auditable) func(cmd *cobra.Command, args []
sarifReport, err := sarif.Create(report)

if err != nil {
log.WithError(err).Fatal("error generating the SARIF output")
log.WithError(err).Fatal("Error generating the SARIF output")
}

sarifReport.WriteFile(rootConfig.sarifOut)
Expand Down
2 changes: 1 addition & 1 deletion internal/sarif/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var allAuditors = map[string]string{
apparmor.Name: "Finds containers that do not have AppArmor enabled",
asat.Name: "Finds containers where the deprecated SA field is used or with a mounted default SA",
capabilities.Name: "Finds containers that do not drop the recommended capabilities or add new ones",
deprecatedapis.Name: "Finds any resource defined with a deprecated API version.",
deprecatedapis.Name: "Finds any resource defined with a deprecated API version",
hostns.Name: "Finds containers that have HostPID, HostIPC or HostNetwork enabled",
image.Name: "Finds containers which do not use the desired version of an image (via the tag) or use an image without a tag",
limits.Name: "Finds containers which exceed the specified CPU and memory limits or do not specify any",
Expand Down
2 changes: 1 addition & 1 deletion internal/sarif/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestAuditorsLengthAndDescription(t *testing.T) {
// make sure they're added with a matching description
assert.Len(t, allAuditors, len(all.AuditorNames))
for _, description := range allAuditors {
assert.True(t, description != "")
assert.NotEmpty(t, description)
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/sarif/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Create(kubeauditReport *kubeaudit.Report) (*sarif.Report, error) {

// SARIF specifies the following severity levels: warning, error, note and none
// https://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html
// so we're converting info to none here so we get valid SARIF output
// so we're converting info to note here so we get valid SARIF output
if result.Severity.String() == "info" {
severityLevel = "note"
}
Expand All @@ -91,7 +91,7 @@ func Create(kubeauditReport *kubeaudit.Report) (*sarif.Report, error) {

err, errs := validate(&reportBytes)
if err != nil {
return nil, fmt.Errorf("error validating SARIF schema: %s", err)
return nil, fmt.Errorf("error validating SARIF schema: %w", err)
}

if len(errs) > 0 {
Expand Down
4 changes: 4 additions & 0 deletions internal/sarif/sarif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TestCreateWithResults(t *testing.T) {
manifest, openErr := os.Open(fixture)
require.NoError(t, openErr)

defer manifest.Close()

kubeAuditReport, err := auditor.AuditManifest(fixture, manifest)
require.NoError(t, err)

Expand Down Expand Up @@ -155,6 +157,8 @@ func TestCreateWithNoResults(t *testing.T) {
manifest, openErr := os.Open(fixture)
require.NoError(t, openErr)

defer manifest.Close()

kubeAuditReport, err := auditor.AuditManifest(fixture, manifest)
require.NoError(t, err)

Expand Down
1 change: 1 addition & 0 deletions internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func GetReport(t *testing.T, fixtureDir, fixture string, auditables []kubeaudit.
case MANIFEST_MODE:
manifest, openErr := os.Open(fixture)
require.NoError(openErr)
defer manifest.Close()
report, err = auditor.AuditManifest("", manifest)
case LOCAL_MODE:
defer DeleteNamespace(t, namespace)
Expand Down

0 comments on commit c486c0a

Please sign in to comment.