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

Commit

Permalink
refactors filepath test
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-santos-code committed Jul 20, 2022
1 parent 44e7e36 commit 6ab787c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 103 deletions.
2 changes: 1 addition & 1 deletion internal/sarif/sarif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestCreate(t *testing.T) {
assert.Contains(t, ruleNames, *sarifResult.RuleID)
assert.Equal(t, tc.expectedErrorLevel, *sarifResult.Level)
assert.Contains(t, *sarifResult.Message.Text, tc.expectedMessage)
assert.Contains(t, *sarifResult.Locations[0].PhysicalLocation.ArtifactLocation.URI, "sarif/fixtures/"+tc.file)
assert.Contains(t, "sarif/fixtures/"+tc.file, *sarifResult.Locations[0].PhysicalLocation.ArtifactLocation.URI)
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions kubeaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import (
"io"
"io/ioutil"
"path/filepath"
"strings"

"github.com/Shopify/kubeaudit/internal/k8sinternal"
"github.com/Shopify/kubeaudit/pkg/k8s"
Expand Down Expand Up @@ -157,13 +158,13 @@ func (a *Kubeaudit) AuditManifest(manifestPath string, manifest io.Reader) (*Rep

for _, result := range results {
auditResults := result.GetAuditResults()
for _, ar := range auditResults {
path, err := filepath.Abs(manifestPath)
if err != nil {
return nil, err
}

ar.FilePath = path
if !filepath.IsAbs(manifestPath) {
manifestPath = strings.TrimPrefix(filepath.Clean("/"+manifestPath), "/")
}

for _, ar := range auditResults {
ar.FilePath = manifestPath
}
}

Expand Down
96 changes: 0 additions & 96 deletions kubeaudit.sarif

This file was deleted.

0 comments on commit 6ab787c

Please sign in to comment.