mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
refactor: replace ioutil=>io; update linter (#1211)
This commit is contained in:
parent
0a1cd25ba5
commit
b48316742f
@ -10,7 +10,6 @@ linters:
|
||||
enable:
|
||||
- asciicheck
|
||||
- bodyclose
|
||||
- deadcode
|
||||
- depguard
|
||||
- dogsled
|
||||
- dupl
|
||||
@ -31,20 +30,18 @@ linters:
|
||||
- nakedret
|
||||
- nolintlint
|
||||
- revive
|
||||
- rowserrcheck
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
||||
|
||||
# do not enable...
|
||||
# - gochecknoglobals
|
||||
# - gochecknoinits # this is too aggressive
|
||||
# - rowserrcheck disabled per generics https://github.com/golangci/golangci-lint/issues/2649
|
||||
# - godot
|
||||
# - godox
|
||||
# - goerr113
|
||||
|
||||
@ -3,7 +3,7 @@ package packages
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/wagoodman/go-partybus"
|
||||
@ -162,7 +162,7 @@ func runPackageSbomUpload(src *source.Source, s sbom.SBOM, app *config.Applicati
|
||||
return fmt.Errorf("unable to open dockerfile=%q: %w", app.Anchore.Dockerfile, err)
|
||||
}
|
||||
|
||||
dockerfileContents, err = ioutil.ReadAll(fh)
|
||||
dockerfileContents, err = io.ReadAll(fh)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read dockerfile=%q: %w", app.Anchore.Dockerfile, err)
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package file
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"regexp"
|
||||
"text/template"
|
||||
|
||||
@ -84,7 +84,7 @@ func (c Classifier) Classify(resolver source.FileResolver, location source.Locat
|
||||
defer internal.CloseAndLogError(contentReader, location.VirtualPath)
|
||||
|
||||
// TODO: there is room for improvement here, as this may use an excessive amount of memory. Alternate approach is to leverage a RuneReader.
|
||||
contents, err := ioutil.ReadAll(contentReader)
|
||||
contents, err := io.ReadAll(contentReader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
"sort"
|
||||
|
||||
@ -111,7 +110,7 @@ func extractValue(resolver source.FileResolver, location source.Location, start,
|
||||
}
|
||||
defer internal.CloseAndLogError(readCloser, location.VirtualPath)
|
||||
|
||||
n, err := io.CopyN(ioutil.Discard, readCloser, start)
|
||||
n, err := io.CopyN(io.Discard, readCloser, start)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to read contents for location=%q : %w", location, err)
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
@ -79,7 +78,7 @@ func readerAtPosition(resolver source.FileResolver, location source.Location, se
|
||||
return nil, fmt.Errorf("unable to fetch reader for location=%q : %w", location, err)
|
||||
}
|
||||
if seekPosition > 0 {
|
||||
n, err := io.CopyN(ioutil.Discard, readCloser, seekPosition)
|
||||
n, err := io.CopyN(io.Discard, readCloser, seekPosition)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read contents for location=%q while searching for secrets: %w", location, err)
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
// Package xcoff implements access to XCOFF (Extended Common Object File Format) files.
|
||||
|
||||
//nolint //this is an internal golang lib
|
||||
//nolint:all
|
||||
package xcoff
|
||||
|
||||
import (
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//nolint // this is an internal golang lib
|
||||
//nolint:all
|
||||
package xcoff
|
||||
|
||||
// File Header.
|
||||
|
||||
@ -3,7 +3,6 @@ package java
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -12,7 +11,7 @@ import (
|
||||
|
||||
func saveArchiveToTmp(archiveVirtualPath string, reader io.Reader) (string, string, func(), error) {
|
||||
name := filepath.Base(archiveVirtualPath)
|
||||
tempDir, err := ioutil.TempDir("", "syft-archive-contents-")
|
||||
tempDir, err := os.MkdirTemp("", "syft-archive-contents-")
|
||||
if err != nil {
|
||||
return "", "", func() {}, fmt.Errorf("unable to create tempdir for archive processing: %w", err)
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
@ -169,7 +169,7 @@ func (c *PackageCataloger) fetchDirectURLData(resolver source.FileResolver, meta
|
||||
}
|
||||
defer internal.CloseAndLogError(directURLContents, directURLLocation.VirtualPath)
|
||||
|
||||
buffer, err := ioutil.ReadAll(directURLContents)
|
||||
buffer, err := io.ReadAll(directURLContents)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package rpm
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
rpmdb "github.com/knqyf263/go-rpmdb/pkg"
|
||||
@ -17,7 +16,7 @@ import (
|
||||
|
||||
// parseRpmDb parses an "Packages" RPM DB and returns the Packages listed within it.
|
||||
func parseRpmDB(resolver source.FilePathResolver, dbLocation source.Location, reader io.Reader) ([]pkg.Package, error) {
|
||||
f, err := ioutil.TempFile("", internal.ApplicationName+"-rpmdb")
|
||||
f, err := os.CreateTemp("", internal.ApplicationName+"-rpmdb")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create temp rpmdb file: %w", err)
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package swift
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
@ -18,7 +17,7 @@ var _ common.ParserFn = parsePodfileLock
|
||||
|
||||
// parsePodfileLock is a parser function for Podfile.lock contents, returning all cocoapods pods discovered.
|
||||
func parsePodfileLock(_ string, reader io.Reader) ([]*pkg.Package, []artifact.Relationship, error) {
|
||||
bytes, err := ioutil.ReadAll(reader)
|
||||
bytes, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("unable to read file: %w", err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user