mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
chore: clean up linting configuration (#1343)
This commit is contained in:
parent
f8be64d312
commit
0774ad15e2
@ -11,9 +11,9 @@ linters:
|
|||||||
- asciicheck
|
- asciicheck
|
||||||
- bodyclose
|
- bodyclose
|
||||||
- depguard
|
- depguard
|
||||||
- dogsled
|
|
||||||
- dupl
|
- dupl
|
||||||
- errcheck
|
- errcheck
|
||||||
|
- errorlint
|
||||||
- exportloopref
|
- exportloopref
|
||||||
- funlen
|
- funlen
|
||||||
- gocognit
|
- gocognit
|
||||||
@ -21,13 +21,13 @@ linters:
|
|||||||
- gocritic
|
- gocritic
|
||||||
- gocyclo
|
- gocyclo
|
||||||
- gofmt
|
- gofmt
|
||||||
- goprintffuncname
|
- tparallel
|
||||||
|
- importas
|
||||||
- gosec
|
- gosec
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
@ -37,8 +37,25 @@ linters:
|
|||||||
- unparam
|
- unparam
|
||||||
- unused
|
- unused
|
||||||
- whitespace
|
- whitespace
|
||||||
|
linters-settings:
|
||||||
|
funlen:
|
||||||
|
# Checks the number of lines in a function.
|
||||||
|
# If lower than 0, disable the check.
|
||||||
|
# Default: 60
|
||||||
|
lines: 70
|
||||||
|
# Checks the number of statements in a function.
|
||||||
|
# If lower than 0, disable the check.
|
||||||
|
# Default: 40
|
||||||
|
statements: 50
|
||||||
|
output:
|
||||||
|
uniq-by-line: false
|
||||||
|
run:
|
||||||
|
timeout: 10m
|
||||||
|
|
||||||
# do not enable...
|
# do not enable...
|
||||||
|
# - dogsled # found to be to niche and ineffective
|
||||||
|
# - goprintffuncname # does not catch all cases and there are exceptions
|
||||||
|
# - nakedret # does not catch all cases and should not fail a build
|
||||||
# - gochecknoglobals
|
# - gochecknoglobals
|
||||||
# - gochecknoinits # this is too aggressive
|
# - gochecknoinits # this is too aggressive
|
||||||
# - rowserrcheck disabled per generics https://github.com/golangci/golangci-lint/issues/2649
|
# - rowserrcheck disabled per generics https://github.com/golangci/golangci-lint/issues/2649
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ VERSION=$(shell git describe --dirty --always --tags)
|
|||||||
TEMPDIR = ./.tmp
|
TEMPDIR = ./.tmp
|
||||||
|
|
||||||
# commands and versions
|
# commands and versions
|
||||||
LINTCMD = $(TEMPDIR)/golangci-lint run --tests=false --timeout=5m --config .golangci.yaml
|
LINTCMD = $(TEMPDIR)/golangci-lint run --tests=false
|
||||||
GOIMPORTS_CMD = $(TEMPDIR)/gosimports -local github.com/anchore
|
GOIMPORTS_CMD = $(TEMPDIR)/gosimports -local github.com/anchore
|
||||||
RELEASE_CMD=$(TEMPDIR)/goreleaser release --rm-dist
|
RELEASE_CMD=$(TEMPDIR)/goreleaser release --rm-dist
|
||||||
SNAPSHOT_CMD=$(RELEASE_CMD) --skip-publish --snapshot
|
SNAPSHOT_CMD=$(RELEASE_CMD) --skip-publish --snapshot
|
||||||
|
|||||||
@ -39,7 +39,7 @@ func Attest(v *viper.Viper, app *config.Application, ro *options.RootOptions) *c
|
|||||||
// run to unmarshal viper object onto app config
|
// run to unmarshal viper object onto app config
|
||||||
// the viper object correctly
|
// the viper object correctly
|
||||||
if err := app.LoadAllValues(v, ro.Config); err != nil {
|
if err := app.LoadAllValues(v, ro.Config); err != nil {
|
||||||
return fmt.Errorf("invalid application config: %v", err)
|
return fmt.Errorf("invalid application config: %w", err)
|
||||||
}
|
}
|
||||||
// configure logging for command
|
// configure logging for command
|
||||||
newLogWrapper(app)
|
newLogWrapper(app)
|
||||||
|
|||||||
@ -32,8 +32,6 @@ const indent = " "
|
|||||||
// at this level. Values from the config should only be used after `app.LoadAllValues` has been called.
|
// at this level. Values from the config should only be used after `app.LoadAllValues` has been called.
|
||||||
// Cobra does not have knowledge of the user provided flags until the `RunE` block of each command.
|
// Cobra does not have knowledge of the user provided flags until the `RunE` block of each command.
|
||||||
// `RunE` is the earliest that the complete application configuration can be loaded.
|
// `RunE` is the earliest that the complete application configuration can be loaded.
|
||||||
//
|
|
||||||
//nolint:funlen
|
|
||||||
func New() (*cobra.Command, error) {
|
func New() (*cobra.Command, error) {
|
||||||
app := &config.Application{}
|
app := &config.Application{}
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,6 @@ import (
|
|||||||
// eventLoop listens to worker errors (from execution path), worker events (from a partybus subscription), and
|
// eventLoop listens to worker errors (from execution path), worker events (from a partybus subscription), and
|
||||||
// signal interrupts. Is responsible for handling each event relative to a given UI an to coordinate eventing until
|
// signal interrupts. Is responsible for handling each event relative to a given UI an to coordinate eventing until
|
||||||
// an eventual graceful exit.
|
// an eventual graceful exit.
|
||||||
//
|
|
||||||
//nolint:funlen
|
|
||||||
func EventLoop(workerErrs <-chan error, signals <-chan os.Signal, subscription *partybus.Subscription, cleanupFn func(), uxs ...ui.UI) error {
|
func EventLoop(workerErrs <-chan error, signals <-chan os.Signal, subscription *partybus.Subscription, cleanupFn func(), uxs ...ui.UI) error {
|
||||||
defer cleanupFn()
|
defer cleanupFn()
|
||||||
events := subscription.Events()
|
events := subscription.Events()
|
||||||
|
|||||||
@ -57,7 +57,7 @@ func Packages(v *viper.Viper, app *config.Application, ro *options.RootOptions,
|
|||||||
}),
|
}),
|
||||||
Args: func(cmd *cobra.Command, args []string) error {
|
Args: func(cmd *cobra.Command, args []string) error {
|
||||||
if err := app.LoadAllValues(v, ro.Config); err != nil {
|
if err := app.LoadAllValues(v, ro.Config); err != nil {
|
||||||
return fmt.Errorf("invalid application config: %v", err)
|
return fmt.Errorf("invalid application config: %w", err)
|
||||||
}
|
}
|
||||||
// configure logging for command
|
// configure logging for command
|
||||||
newLogWrapper(app)
|
newLogWrapper(app)
|
||||||
|
|||||||
@ -28,7 +28,7 @@ func PowerUser(v *viper.Viper, app *config.Application, ro *options.RootOptions)
|
|||||||
}),
|
}),
|
||||||
Args: func(cmd *cobra.Command, args []string) error {
|
Args: func(cmd *cobra.Command, args []string) error {
|
||||||
if err := app.LoadAllValues(v, ro.Config); err != nil {
|
if err := app.LoadAllValues(v, ro.Config); err != nil {
|
||||||
return fmt.Errorf("invalid application config: %v", err)
|
return fmt.Errorf("invalid application config: %w", err)
|
||||||
}
|
}
|
||||||
// configure logging for command
|
// configure logging for command
|
||||||
newLogWrapper(app)
|
newLogWrapper(app)
|
||||||
|
|||||||
@ -75,9 +75,11 @@ func (cfg *Application) LoadAllValues(v *viper.Viper, configPath string) error {
|
|||||||
|
|
||||||
// check if user specified config; otherwise read all possible paths
|
// check if user specified config; otherwise read all possible paths
|
||||||
if err := loadConfig(v, configPath); err != nil {
|
if err := loadConfig(v, configPath); err != nil {
|
||||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
var notFound *viper.ConfigFileNotFoundError
|
||||||
// Not Found; ignore this error
|
if errors.As(err, ¬Found) {
|
||||||
log.Debug("no config file found; proceeding with defaults")
|
log.Debugf("no config file found, using defaults")
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("unable to load config: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -26,14 +27,14 @@ func (e ErrPath) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsErrPath(err error) bool {
|
func IsErrPath(err error) bool {
|
||||||
_, ok := err.(ErrPath)
|
var pathErr ErrPath
|
||||||
return ok
|
return errors.As(err, &pathErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsErrPathPermission(err error) bool {
|
func IsErrPathPermission(err error) bool {
|
||||||
pathErr, ok := err.(ErrPath)
|
var pathErr ErrPath
|
||||||
if ok {
|
if errors.As(err, &pathErr) {
|
||||||
return os.IsPermission(pathErr.Err)
|
return os.IsPermission(pathErr.Err)
|
||||||
}
|
}
|
||||||
return ok
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,7 +106,7 @@ func findArchiveStartOffset(r io.ReaderAt, size int64) (startOfArchive uint64, e
|
|||||||
bLen = size
|
bLen = size
|
||||||
}
|
}
|
||||||
buf = make([]byte, int(bLen))
|
buf = make([]byte, int(bLen))
|
||||||
if _, err := r.ReadAt(buf, size-bLen); err != nil && err != io.EOF {
|
if _, err := r.ReadAt(buf, size-bLen); err != nil && !errors.Is(err, io.EOF) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if p := findSignatureInBlock(buf); p >= 0 {
|
if p := findSignatureInBlock(buf); p >= 0 {
|
||||||
|
|||||||
@ -47,12 +47,12 @@ func main() {
|
|||||||
func run() error {
|
func run() error {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to get licenses list: %+v", err)
|
return fmt.Errorf("unable to get licenses list: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var result LicenseList
|
var result LicenseList
|
||||||
if err = json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
if err = json.NewDecoder(resp.Body).Decode(&result); err != nil {
|
||||||
return fmt.Errorf("unable to decode license list: %+v", err)
|
return fmt.Errorf("unable to decode license list: %w", err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := resp.Body.Close(); err != nil {
|
if err := resp.Body.Close(); err != nil {
|
||||||
@ -62,7 +62,7 @@ func run() error {
|
|||||||
|
|
||||||
f, err := os.Create(source)
|
f, err := os.Create(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to create %q: %+v", source, err)
|
return fmt.Errorf("unable to create %q: %w", source, err)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
@ -85,7 +85,7 @@ func run() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to generate template: %+v", err)
|
return fmt.Errorf("unable to generate template: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ func handleExit(event partybus.Event) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := fn(); err != nil {
|
if err := fn(); err != nil {
|
||||||
return fmt.Errorf("unable to show package catalog report: %v", err)
|
return fmt.Errorf("unable to show package catalog report: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ func IDByHash(obj interface{}) (ID, error) {
|
|||||||
SlicesAsSets: true,
|
SlicesAsSets: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("could not build ID for object=%+v: %+v", obj, err)
|
return "", fmt.Errorf("could not build ID for object=%+v: %w", obj, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ID(fmt.Sprintf("%x", f)), nil
|
return ID(fmt.Sprintf("%x", f)), nil
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/anchore/syft/syft/pkg"
|
"github.com/anchore/syft/syft/pkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:funlen, gocognit
|
//nolint:gocognit
|
||||||
func encodeExternalReferences(p pkg.Package) *[]cyclonedx.ExternalReference {
|
func encodeExternalReferences(p pkg.Package) *[]cyclonedx.ExternalReference {
|
||||||
var refs []cyclonedx.ExternalReference
|
var refs []cyclonedx.ExternalReference
|
||||||
if hasMetadata(p) {
|
if hasMetadata(p) {
|
||||||
|
|||||||
@ -85,7 +85,6 @@ func Sorted(values map[string]string) (out []NameValue) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:funlen
|
|
||||||
func encode(out map[string]string, value reflect.Value, prefix string, fn FieldName) {
|
func encode(out map[string]string, value reflect.Value, prefix string, fn FieldName) {
|
||||||
if !value.IsValid() || value.Type() == nil {
|
if !value.IsValid() || value.Type() == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/anchore/syft/syft/pkg"
|
"github.com/anchore/syft/syft/pkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:funlen
|
|
||||||
func SourceInfo(p pkg.Package) string {
|
func SourceInfo(p pkg.Package) string {
|
||||||
answer := ""
|
answer := ""
|
||||||
switch p.Type {
|
switch p.Type {
|
||||||
|
|||||||
@ -17,8 +17,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// toFormatModel creates and populates a new JSON document struct that follows the SPDX 2.2 spec from the given cataloging results.
|
// toFormatModel creates and populates a new JSON document struct that follows the SPDX 2.2 spec from the given cataloging results.
|
||||||
//
|
|
||||||
//nolint:funlen
|
|
||||||
func toFormatModel(s sbom.SBOM) *spdx.Document2_2 {
|
func toFormatModel(s sbom.SBOM) *spdx.Document2_2 {
|
||||||
name, namespace := spdxhelpers.DocumentNameAndNamespace(s.Source)
|
name, namespace := spdxhelpers.DocumentNameAndNamespace(s.Source)
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,6 @@ func getFileReader(path string, resolver source.FileResolver) (io.Reader, error)
|
|||||||
return dbContentReader, nil
|
return dbContentReader, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:funlen
|
|
||||||
func parseDatabase(b *bufio.Scanner) (*pkg.AlpmMetadata, error) {
|
func parseDatabase(b *bufio.Scanner) (*pkg.AlpmMetadata, error) {
|
||||||
var entry pkg.AlpmMetadata
|
var entry pkg.AlpmMetadata
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@ -115,7 +115,7 @@ func extractAllFields(reader *bufio.Reader) (map[string]interface{}, error) {
|
|||||||
for {
|
for {
|
||||||
line, err := reader.ReadString('\n')
|
line, err := reader.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
return dpkgFields, errEndOfPackages
|
return dpkgFields, errEndOfPackages
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@ -42,7 +42,7 @@ func (c Classifier) Examine(reader source.LocationReadCloser) (p *pkg.Package, r
|
|||||||
|
|
||||||
contents, err := getContents(reader)
|
contents, err := getContents(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("unable to get read contents for file: %+v", err)
|
return nil, nil, fmt.Errorf("unable to get read contents for file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var classifiedPackage *pkg.Package
|
var classifiedPackage *pkg.Package
|
||||||
@ -88,12 +88,12 @@ func (c Classifier) Examine(reader source.LocationReadCloser) (p *pkg.Package, r
|
|||||||
func getContents(reader source.LocationReadCloser) ([]byte, error) {
|
func getContents(reader source.LocationReadCloser) ([]byte, error) {
|
||||||
unionReader, err := unionreader.GetUnionReader(reader.ReadCloser)
|
unionReader, err := unionreader.GetUnionReader(reader.ReadCloser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to get union reader for file: %+v", err)
|
return nil, fmt.Errorf("unable to get union reader for file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
contents, err := io.ReadAll(unionReader)
|
contents, err := io.ReadAll(unionReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to get contents for file: %+v", err)
|
return nil, fmt.Errorf("unable to get contents for file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return contents, nil
|
return contents, nil
|
||||||
|
|||||||
@ -57,7 +57,7 @@ func parsePackageJSON(_ source.FileResolver, _ *generic.Environment, reader sour
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
var p packageJSON
|
var p packageJSON
|
||||||
if err := dec.Decode(&p); err == io.EOF {
|
if err := dec.Decode(&p); errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to parse package.json file: %w", err)
|
return nil, nil, fmt.Errorf("failed to parse package.json file: %w", err)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package javascript
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
@ -50,7 +51,7 @@ func parsePackageLock(resolver source.FileResolver, _ *generic.Environment, read
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
var lock packageLock
|
var lock packageLock
|
||||||
if err := dec.Decode(&lock); err == io.EOF {
|
if err := dec.Decode(&lock); errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to parse package-lock.json file: %w", err)
|
return nil, nil, fmt.Errorf("failed to parse package-lock.json file: %w", err)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package php
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ func parseComposerLock(_ source.FileResolver, _ *generic.Environment, reader sou
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
var lock composerLock
|
var lock composerLock
|
||||||
if err := dec.Decode(&lock); err == io.EOF {
|
if err := dec.Decode(&lock); errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to parse composer.lock file: %w", err)
|
return nil, nil, fmt.Errorf("failed to parse composer.lock file: %w", err)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package php
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ func parseInstalledJSON(_ source.FileResolver, _ *generic.Environment, reader so
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
var lock installedJSONComposerV2
|
var lock installedJSONComposerV2
|
||||||
if err := dec.Decode(&lock); err == io.EOF {
|
if err := dec.Decode(&lock); errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to parse installed.json file: %w", err)
|
return nil, nil, fmt.Errorf("failed to parse installed.json file: %w", err)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package python
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
@ -44,7 +45,7 @@ func parsePipfileLock(_ source.FileResolver, _ *generic.Environment, reader sour
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
var lock pipfileLock
|
var lock pipfileLock
|
||||||
if err := dec.Decode(&lock); err == io.EOF {
|
if err := dec.Decode(&lock); errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, nil, fmt.Errorf("failed to parse Pipfile.lock file: %w", err)
|
return nil, nil, fmt.Errorf("failed to parse Pipfile.lock file: %w", err)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package python
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -20,7 +21,7 @@ func parseWheelOrEggRecord(reader io.Reader) []pkg.PythonFileRecord {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
recordList, err := r.Read()
|
recordList, err := r.Read()
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,7 +71,7 @@ func parseInstalledFiles(reader io.Reader, location, sitePackagesRootPath string
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
line, err := r.ReadString('\n')
|
line, err := r.ReadString('\n')
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import (
|
|||||||
func parseRpm(_ source.FileResolver, _ *generic.Environment, reader source.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
func parseRpm(_ source.FileResolver, _ *generic.Environment, reader source.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||||
rpm, err := rpmutils.ReadRpm(reader)
|
rpm, err := rpmutils.ReadRpm(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("RPM file found but unable to read: %s (%v)", reader.Location.RealPath, err)
|
return nil, nil, fmt.Errorf("RPM file found but unable to read: %s (%w)", reader.Location.RealPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nevra, err := rpm.Header.GetNEVRA()
|
nevra, err := rpm.Header.GetNEVRA()
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package rpm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ func parseRpmManifest(_ source.FileResolver, _ *generic.Environment, reader sour
|
|||||||
for {
|
for {
|
||||||
line, err := r.ReadString('\n')
|
line, err := r.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package rust
|
package rust
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
rustaudit "github.com/microsoft/go-rustaudit"
|
rustaudit "github.com/microsoft/go-rustaudit"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/log"
|
"github.com/anchore/syft/internal/log"
|
||||||
@ -42,7 +44,7 @@ func parseAuditBinaryEntry(reader unionreader.UnionReader, filename string) []ru
|
|||||||
versionInfo, err := rustaudit.GetDependencyInfo(r)
|
versionInfo, err := rustaudit.GetDependencyInfo(r)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == rustaudit.ErrNoRustDepInfo {
|
if errors.Is(err, rustaudit.ErrNoRustDepInfo) {
|
||||||
// since the cataloger can only select executables and not distinguish if they are a Rust-compiled
|
// since the cataloger can only select executables and not distinguish if they are a Rust-compiled
|
||||||
// binary, we should not show warnings/logs in this case.
|
// binary, we should not show warnings/logs in this case.
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -21,13 +21,13 @@ type cargoLockFile struct {
|
|||||||
func parseCargoLock(_ source.FileResolver, _ *generic.Environment, reader source.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
func parseCargoLock(_ source.FileResolver, _ *generic.Environment, reader source.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) {
|
||||||
tree, err := toml.LoadReader(reader)
|
tree, err := toml.LoadReader(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("unable to load Cargo.lock for parsing: %v", err)
|
return nil, nil, fmt.Errorf("unable to load Cargo.lock for parsing: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m := cargoLockFile{}
|
m := cargoLockFile{}
|
||||||
err = tree.Unmarshal(&m)
|
err = tree.Unmarshal(&m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("unable to parse Cargo.lock: %v", err)
|
return nil, nil, fmt.Errorf("unable to parse Cargo.lock: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var pkgs []pkg.Package
|
var pkgs []pkg.Package
|
||||||
|
|||||||
@ -76,8 +76,6 @@ func formatDockerPullPhase(phase docker.PullPhase, inputStr string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// formatDockerImagePullStatus writes the docker image pull status summarized into a single line for the given state.
|
// formatDockerImagePullStatus writes the docker image pull status summarized into a single line for the given state.
|
||||||
//
|
|
||||||
//nolint:funlen
|
|
||||||
func formatDockerImagePullStatus(pullStatus *docker.PullStatus, spinner *components.Spinner, line *frame.Line) {
|
func formatDockerImagePullStatus(pullStatus *docker.PullStatus, spinner *components.Spinner, line *frame.Line) {
|
||||||
var size, current uint64
|
var size, current uint64
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user