Skip to content

Commit fbabd2a

Browse files
authored
Remove user configuration (#4)
1 parent 6645bb1 commit fbabd2a

9 files changed

Lines changed: 49 additions & 422 deletions

File tree

README.md

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -13,94 +13,3 @@ curl -sSfL https://raw.githubusercontent.com/anchore/docker-sbom-cli-plugin/main
1313
# use the sbom plugin
1414
docker sbom <my-image>
1515
```
16-
17-
## Configuration
18-
19-
Configuration search paths:
20-
21-
- `.syft.yaml`
22-
- `.syft/config.yaml`
23-
- `~/.syft.yaml`
24-
- `<XDG_CONFIG_HOME>/syft/config.yaml`
25-
26-
Configuration options (example values are the default):
27-
28-
```yaml
29-
# the output format(s) of the SBOM report (options: table, text, json, spdx, ...)
30-
# same as -o, --output, and SYFT_OUTPUT env var
31-
# to specify multiple output files in differing formats, use a list:
32-
# output:
33-
# - "json=<syft-json-output-file>"
34-
# - "spdx-json=<spdx-json-output-file>"
35-
output: "table"
36-
37-
# suppress all output (except for the SBOM report)
38-
# same as -q ; SYFT_QUIET env var
39-
quiet: false
40-
41-
# same as --file; write output report to a file (default is to write to stdout)
42-
file: ""
43-
44-
# a list of globs to exclude from scanning. same as --exclude ; for example:
45-
# exclude:
46-
# - "/etc/**"
47-
# - "./out/**/*.json"
48-
exclude: []
49-
50-
# override the OS or architecture options (e.g. "windows/arm/v7", "linux/arm64", "arm64") similar to "docker --platform"
51-
# same as --platform; SYFT_PLATFORM env var
52-
platform: ""
53-
54-
# catalog packages
55-
package:
56-
57-
# search within archives that do contain a file index to search against (zip)
58-
# note: for now this only applies to the java package cataloger
59-
# SYFT_PACKAGE_SEARCH_INDEXED_ARCHIVES env var
60-
search-indexed-archives: true
61-
62-
# search within archives that do not contain a file index to search against (tar, tar.gz, tar.bz2, etc)
63-
# note: enabling this may result in a performance impact since all discovered compressed tars will be decompressed
64-
# note: for now this only applies to the java package cataloger
65-
# SYFT_PACKAGE_SEARCH_UNINDEXED_ARCHIVES env var
66-
search-unindexed-archives: false
67-
68-
cataloger:
69-
# enable/disable cataloging of packages
70-
# SYFT_PACKAGE_CATALOGER_ENABLED env var
71-
enabled: true
72-
73-
# the search space to look for packages (options: all-layers, squashed)
74-
# same as -s ; SYFT_PACKAGE_CATALOGER_SCOPE env var
75-
scope: "squashed"
76-
77-
# catalog file metadata
78-
file-metadata:
79-
cataloger:
80-
# enable/disable cataloging of file metadata
81-
# SYFT_FILE_METADATA_CATALOGER_ENABLED env var
82-
enabled: true
83-
84-
# the search space to look for file metadata (options: all-layers, squashed)
85-
# SYFT_FILE_METADATA_CATALOGER_SCOPE env var
86-
scope: "squashed"
87-
88-
# the file digest algorithms to use when cataloging files (options: "sha256", "md5", "sha1")
89-
# SYFT_FILE_METADATA_DIGESTS env var
90-
digests: ["sha256"]
91-
92-
log:
93-
# use structured logging
94-
# same as SYFT_LOG_STRUCTURED env var
95-
structured: false
96-
97-
# the log level; note: detailed logging suppress the ETUI
98-
# same as SYFT_LOG_LEVEL env var
99-
level: "error"
100-
101-
# location to write the log file (default is not to have a log file)
102-
# same as SYFT_LOG_FILE env var
103-
file: ""
104-
105-
```
106-

cmd/root.go

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/anchore/stereoscope"
2020
"github.com/anchore/stereoscope/pkg/image"
2121
"github.com/anchore/syft/syft"
22-
"github.com/anchore/syft/syft/artifact"
2322
"github.com/anchore/syft/syft/event"
2423
"github.com/anchore/syft/syft/pkg/cataloger"
2524
"github.com/anchore/syft/syft/sbom"
@@ -33,6 +32,7 @@ Examples:
3332
docker sbom alpine:latest -o syft-json show all possible cataloging details
3433
docker sbom alpine:latest -o syft-json --file sbom.json write report output to a file
3534
docker sbom alpine:latest -o table -o sbom.json=cyclonedx-json report the SBOM in multiple formats
35+
docker sbom alpine:latest --exclude /lib --exclude '**/*.db' ignore one or more paths in the image
3636
docker sbom alpine:latest -v show logging output
3737
docker sbom alpine:latest -vv show verbose debug logs`
3838

@@ -78,7 +78,7 @@ func setPackageFlags(flags *pflag.FlagSet) {
7878
// Formatting & Input options //////////////////////////////////////////////
7979
flags.StringP(
8080
"scope", "s", cataloger.DefaultSearchConfig().Scope.String(),
81-
fmt.Sprintf("selection of layers to catalog, options=%v", source.AllScopes))
81+
fmt.Sprintf("[experimental] selection of layers to catalog, options=%v", source.AllScopes))
8282

8383
flags.StringArrayP(
8484
"output", "o", formatAliases(syft.TableFormatID),
@@ -184,35 +184,26 @@ func isVerbose() (result bool) {
184184
return appConfig.CliOptions.Verbosity > 0 || isPipedInput
185185
}
186186

187-
func generateSBOM(src *source.Source, errs chan error) (*sbom.SBOM, error) {
188-
tasks, err := catalogingTasks()
189-
if err != nil {
190-
return nil, err
191-
}
192-
187+
func generateSBOM(src *source.Source) (*sbom.SBOM, error) {
193188
s := sbom.SBOM{
194189
Source: src.Metadata,
195190
Descriptor: sbom.Descriptor{
196191
Name: internal.SyftName,
197-
Version: version.FromBuild().Version,
192+
Version: version.FromBuild().SyftVersion,
198193
Configuration: appConfig,
199194
},
200195
}
201196

202-
buildRelationships(&s, src, tasks, errs)
203-
204-
return &s, nil
205-
}
206-
207-
func buildRelationships(s *sbom.SBOM, src *source.Source, tasks []task, errs chan error) {
208-
var relationships []<-chan artifact.Relationship
209-
for _, task := range tasks {
210-
c := make(chan artifact.Relationship)
211-
relationships = append(relationships, c)
212-
go runTask(task, &s.Artifacts, src, c, errs)
197+
packageCatalog, relationships, theDistro, err := syft.CatalogPackages(src, appConfig.Package.ToConfig())
198+
if err != nil {
199+
return nil, fmt.Errorf("unable to catalog packages: %w", err)
213200
}
214201

215-
s.Relationships = append(s.Relationships, mergeRelationships(relationships...)...)
202+
s.Artifacts.PackageCatalog = packageCatalog
203+
s.Artifacts.LinuxDistribution = theDistro
204+
s.Relationships = relationships
205+
206+
return &s, nil
216207
}
217208

218209
func sbomExecWorker(si source.Input, writer sbom.Writer) <-chan error {
@@ -229,7 +220,7 @@ func sbomExecWorker(si source.Input, writer sbom.Writer) <-chan error {
229220
return
230221
}
231222

232-
s, err := generateSBOM(src, errs)
223+
s, err := generateSBOM(src)
233224
if err != nil {
234225
errs <- err
235226
return
@@ -247,13 +238,3 @@ func sbomExecWorker(si source.Input, writer sbom.Writer) <-chan error {
247238
}()
248239
return errs
249240
}
250-
251-
func mergeRelationships(cs ...<-chan artifact.Relationship) (relationships []artifact.Relationship) {
252-
for _, c := range cs {
253-
for n := range c {
254-
relationships = append(relationships, n)
255-
}
256-
}
257-
258-
return relationships
259-
}

cmd/tasks.go

Lines changed: 0 additions & 141 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.17
55
require (
66
github.com/Microsoft/hcsshim v0.9.2 // indirect
77
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
8-
github.com/adrg/xdg v0.2.1
98
github.com/anchore/stereoscope v0.0.0-20220307154759-8a5a70c227d3
109
github.com/anchore/syft v0.41.1
1110
github.com/containerd/containerd v1.5.10 // indirect
@@ -16,7 +15,6 @@ require (
1615
github.com/fvbommel/sortorder v1.0.2 // indirect
1716
github.com/gookit/color v1.4.2
1817
github.com/hashicorp/go-multierror v1.1.1
19-
github.com/mitchellh/go-homedir v1.1.0
2018
github.com/moby/sys/mount v0.3.0 // indirect
2119
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
2220
github.com/sirupsen/logrus v1.8.1
@@ -83,6 +81,7 @@ require (
8381
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
8482
github.com/mholt/archiver/v3 v3.5.1 // indirect
8583
github.com/miekg/pkcs11 v1.1.1 // indirect
84+
github.com/mitchellh/go-homedir v1.1.0 // indirect
8685
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
8786
github.com/mitchellh/mapstructure v1.4.3 // indirect
8887
github.com/moby/sys/mountinfo v0.5.0 // indirect

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpH
240240
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
241241
github.com/acobaugh/osrelease v0.1.0 h1:Yb59HQDGGNhCj4suHaFQQfBps5wyoKLSSX/J/+UifRE=
242242
github.com/acobaugh/osrelease v0.1.0/go.mod h1:4bFEs0MtgHNHBrmHCt67gNisnabCRAlzdVasCEGHTWY=
243-
github.com/adrg/xdg v0.2.1 h1:VSVdnH7cQ7V+B33qSJHTCRlNgra1607Q8PzEmnvb2Ic=
244243
github.com/adrg/xdg v0.2.1/go.mod h1:ZuOshBmzV4Ta+s23hdfFZnBsdzmoR3US0d7ErpqSbTQ=
245244
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
246245
github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw=

0 commit comments

Comments
 (0)