Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ linters:
- tenv # Deprecated
- testpackage
- tparallel # Parallel tests mixes up log lines of multiple tests in the internal test runner
- unparam # TODO(#274): work on enabling this
- usetesting # TODO(#274): work on enabling this
- varnamelen
- wrapcheck
Expand Down
11 changes: 4 additions & 7 deletions artifact/image/layerscanning/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,7 @@ func FromV1Image(v1Image v1.Image, config *Config) (*Image, error) {
}

// Remove any unnecessary file nodes from the chain layers based on the configured requirer.
bytesRemoved, err := removeUnnecessaryFileNodes(chainLayers, config.Requirer, config.MaxSymlinkDepth)
if err != nil {
return outputImage, fmt.Errorf("failed to remove unnecessary file nodes: %w", err)
}
bytesRemoved := removeUnnecessaryFileNodes(chainLayers, config.Requirer, config.MaxSymlinkDepth)
outputImage.size -= bytesRemoved

return outputImage, nil
Expand Down Expand Up @@ -300,10 +297,10 @@ func isNodeRequired(node *fileNode, requirer require.FileRequirer) bool {
// removeUnnecessaryFileNodes removes any file nodes from the chain layers that are not required by
// the requirer. Symlink nodes are accounted for by preserving target nodes if the symlink node is
// required.
func removeUnnecessaryFileNodes(chainLayers []*chainLayer, requirer require.FileRequirer, symlinkDepth int) (int64, error) {
func removeUnnecessaryFileNodes(chainLayers []*chainLayer, requirer require.FileRequirer, symlinkDepth int) int64 {
// If there are no chain layers, then there are no nodes to remove.
if len(chainLayers) == 0 {
return 0, nil
return 0
}

// Prune only the final chain layer since SCALIBR scans the last layer.
Expand Down Expand Up @@ -358,7 +355,7 @@ func removeUnnecessaryFileNodes(chainLayers []*chainLayer, requirer require.File
bytesRemoved += node.Size()
}
}
return bytesRemoved, nil
return bytesRemoved
}

// addRootDirectoryToChainLayers adds the root ("\"") directory to each chain layer.
Expand Down
6 changes: 2 additions & 4 deletions artifact/image/layerscanning/image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package image

import (
"bytes"
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -636,8 +635,7 @@ func TestFromTarball(t *testing.T) {
// 4. Devise a pathtree that will return an error when inserting a path. Make sure that Load()
// returns an error.
func TestFromV1Image(t *testing.T) {
ctx := context.Background()
fakeImage, err := constructImage(ctx, "1.0", "fake-package-name")
fakeImage, err := constructImage("1.0", "fake-package-name")
if err != nil {
t.Fatalf("Failed to construct image: %v", err)
}
Expand Down Expand Up @@ -1062,7 +1060,7 @@ func TestInitializeChainLayers(t *testing.T) {
//
// Put them in a single tarball to make a single layer and put that layer in an empty image to
// make the minimal image that will work.
func constructImage(ctx context.Context, version, fakePackageName string) (*v1.Image, error) {
func constructImage(version, fakePackageName string) (*v1.Image, error) {
// The file containing the fake package version.
statusContents := fmt.Sprintf("Package: %s\nVersion: %s\nStatus: install ok installed", fakePackageName, version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ func TestExtract(t *testing.T) {
}
}

//nolint:unparam
func createFileFromTestData(t *testing.T, root string, subPath string, fileName string, testDataFilePath string) {
t.Helper()
_ = os.MkdirAll(filepath.Join(root, subPath), 0755)
Expand Down
1 change: 1 addition & 0 deletions guidedremediation/guidedremediation.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func readWriterForManifest(manifestPath string, registry string) (manifest.ReadW
return nil, fmt.Errorf("unsupported manifest: %q", baseName)
}

//nolint:unparam // TODO(#454): implement pending
func readWriterForLockfile(lockfilePath string) (lockfile.ReadWriter, error) {
baseName := filepath.Base(lockfilePath)
// TODO(#454): package-lock.json when in-place strategy is migrated.
Expand Down