Skip to content

Commit d21eec5

Browse files
authored
Bump syft to v0.41.1 (#3)
1 parent 76a5d79 commit d21eec5

5 files changed

Lines changed: 42 additions & 7 deletions

File tree

cmd/output_writer.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ func parseOptions(outputs []string, defaultFile string) (out []sbom.WriterOption
5656
continue
5757
}
5858

59-
out = append(out, sbom.WriterOption{
60-
Format: format,
61-
Path: file,
62-
})
59+
out = append(out, sbom.NewWriterOption(format, file))
6360
}
6461
return out, errs
6562
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
88
github.com/adrg/xdg v0.2.1
99
github.com/anchore/stereoscope v0.0.0-20220307154759-8a5a70c227d3
10-
github.com/anchore/syft v0.41.0
10+
github.com/anchore/syft v0.41.1
1111
github.com/containerd/containerd v1.5.10 // indirect
1212
github.com/containerd/continuity v0.2.2 // indirect
1313
github.com/docker/cli v20.10.12+incompatible

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ github.com/anchore/packageurl-go v0.0.0-20210922164639-b3fa992ebd29 h1:K9Lfnxwhq
267267
github.com/anchore/packageurl-go v0.0.0-20210922164639-b3fa992ebd29/go.mod h1:Oc1UkGaJwY6ND6vtAqPSlYrptKRJngHwkwB6W7l1uP0=
268268
github.com/anchore/stereoscope v0.0.0-20220307154759-8a5a70c227d3 h1:Kx2jlMdENAf4cVjYGYLI+fiavVhzhtmU89GUYDITJ1w=
269269
github.com/anchore/stereoscope v0.0.0-20220307154759-8a5a70c227d3/go.mod h1:XESZQTgFETDBatmyoet6XZ0zVknoIMDSAhj2INj2a5w=
270-
github.com/anchore/syft v0.41.0 h1:d39UthynwpE88iAWJYRYDFVarfkGOcqCQHt6IPHXWBs=
271-
github.com/anchore/syft v0.41.0/go.mod h1:SQuKJ0oTc1cJGRE1dYbFWN+uPb9R2zltCoqpnWyDJ/M=
270+
github.com/anchore/syft v0.41.1 h1:HzRwGX3Qv6CLA1oveqx+K8tfs/2jo+w6O/VeeL8oiZE=
271+
github.com/anchore/syft v0.41.1/go.mod h1:SQuKJ0oTc1cJGRE1dYbFWN+uPb9R2zltCoqpnWyDJ/M=
272272
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
273273
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
274274
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=

test/cli/sbom_cmd_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package cli
22

33
import (
4+
"fmt"
5+
"path/filepath"
46
"strings"
57
"testing"
68
)
@@ -118,6 +120,26 @@ func TestSBOMCmdFlags(t *testing.T) {
118120
assertSuccessfulReturnCode,
119121
},
120122
},
123+
{
124+
name: "json-file-flag",
125+
args: []string{"sbom", "-o", "json", "--file", filepath.Join(tmp, "output-1.json"), coverageImage},
126+
assertions: []traitAssertion{
127+
assertSuccessfulReturnCode,
128+
assertFileOutput(t, filepath.Join(tmp, "output-1.json"),
129+
assertJsonReport,
130+
),
131+
},
132+
},
133+
{
134+
name: "json-output-flag-to-file",
135+
args: []string{"sbom", "-o", fmt.Sprintf("json=%s", filepath.Join(tmp, "output-2.json")), coverageImage},
136+
assertions: []traitAssertion{
137+
assertSuccessfulReturnCode,
138+
assertFileOutput(t, filepath.Join(tmp, "output-2.json"),
139+
assertJsonReport,
140+
),
141+
},
142+
},
121143
}
122144

123145
for _, tt := range tests {

test/cli/trait_assertions_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,26 @@ import (
1010
"testing"
1111

1212
"github.com/acarl005/stripansi"
13+
"github.com/stretchr/testify/require"
1314
)
1415

1516
type traitAssertion func(tb testing.TB, stdout, stderr string, rc int)
1617

18+
func assertFileOutput(tb testing.TB, path string, assertions ...traitAssertion) traitAssertion {
19+
tb.Helper()
20+
21+
return func(tb testing.TB, _, stderr string, rc int) {
22+
content, err := os.ReadFile(path)
23+
require.NoError(tb, err)
24+
contentStr := string(content)
25+
26+
for _, assertion := range assertions {
27+
// treat the file content as stdout
28+
assertion(tb, contentStr, stderr, rc)
29+
}
30+
}
31+
}
32+
1733
func assertJsonReport(tb testing.TB, stdout, _ string, _ int) {
1834
tb.Helper()
1935
var data interface{}

0 commit comments

Comments
 (0)