Skip to content

Commit

Permalink
Merge pull request google#315 from ackama:linting/enable-whitespace
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702332969
  • Loading branch information
copybara-github committed Dec 3, 2024
2 parents 6284554 + 300cb82 commit 3c34c67
Show file tree
Hide file tree
Showing 16 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ linters:
# - unused
# - usestdlibvars
# - wastedassign
# - whitespace
- whitespace
- zerologlint
disable-all: true
1 change: 0 additions & 1 deletion artifact/image/layerscanning/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ func TestLoadFrom(t *testing.T) {

compareChainLayerEntries(t, chainLayer, wantChainLayerEntries)
}

})
}
}
Expand Down
2 changes: 0 additions & 2 deletions artifact/image/layerscanning/layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (fakeV1Layer *fakeV1Layer) MediaType() (types.MediaType, error) {
}

func TestConvertV1Layer(t *testing.T) {

reader := io.NopCloser(nil)
tests := []struct {
name string
Expand Down Expand Up @@ -306,7 +305,6 @@ func TestChainFSOpen(t *testing.T) {
if diff := cmp.Diff(gotFile, tc.wantNode, cmp.AllowUnexported(fileNode{})); tc.wantNode != nil && diff != "" {
t.Errorf("Open(%v) returned file: %v, want file: %v", tc.path, gotFile, tc.wantNode)
}

})
}
}
Expand Down
1 change: 0 additions & 1 deletion artifact/image/symlink/symlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ func removeLayerPathPrefix(path, layerPath string) string {
// For example, if a symlink with path `a/symlink.txt“ points to “../../file.text“, then
// this function would return true because the target file is outside of the root directory.
func TargetOutsideRoot(path, target string) bool {

// Create a marker directory as root to check if the target path is outside of the root directory.
markerDir := uuid.New().String()
if filepath.IsAbs(target) {
Expand Down
2 changes: 0 additions & 2 deletions artifact/image/symlink/symlink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
)

func TestTargetOutsideRoot(t *testing.T) {

tests := []struct {
name string
path string
Expand Down Expand Up @@ -78,5 +77,4 @@ func TestTargetOutsideRoot(t *testing.T) {
}
})
}

}
1 change: 0 additions & 1 deletion artifact/image/tar/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (

// SaveToTarball saves a container image to a tarball.
func SaveToTarball(path string, image v1.Image) error {

f, err := os.Create(path)
if err != nil {
return fmt.Errorf("failed to create tar file %q: %w", path, err)
Expand Down
1 change: 0 additions & 1 deletion artifact/image/tar/tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func filesMatch(t *testing.T, path1, path2 string) bool {
}

func mustHashFile(t *testing.T, path string) string {

f, err := os.Open(path)
if err != nil {
t.Fatalf("os.Open(%q) error: %v", path, err)
Expand Down
3 changes: 0 additions & 3 deletions artifact/image/unpack/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ func (cfg *UnpackerConfig) WithRequirer(requirer require.FileRequirer) *Unpacker

// NewUnpacker creates a new Unpacker.
func NewUnpacker(cfg *UnpackerConfig) (*Unpacker, error) {

if cfg.SymlinkResolution == "" {
return nil, errors.New("cfg.SymlinkResolution was not specified")
}
Expand Down Expand Up @@ -226,7 +225,6 @@ func (u *Unpacker) UnpackSquashedFromTarball(dir string, tarPath string) error {
// Each layer is unpacked into a subdirectory of dir where the sub-directory name is the layer digest.
// The returned list contains the digests of the image layers from in order oldest/base layer first, and most-recent/top layer last.
func (u *Unpacker) UnpackLayers(dir string, image v1.Image) ([]string, error) {

if u.SymlinkResolution == SymlinkIgnore {
return nil, fmt.Errorf("symlink resolution strategy %q is not supported", u.SymlinkResolution)
}
Expand Down Expand Up @@ -292,7 +290,6 @@ func (u *Unpacker) UnpackLayers(dir string, image v1.Image) ([]string, error) {
}

func unpack(dir string, reader io.Reader, symlinkResolution SymlinkResolution, symlinkErrStrategy SymlinkErrStrategy, requirer require.FileRequirer, requiredTargets map[string]bool, finalPass bool, maxSizeBytes int64) (map[string]bool, error) {

tarReader := tar.NewReader(reader)

// Defensive copy of requiredTargets to avoid modifying the original.
Expand Down
3 changes: 0 additions & 3 deletions artifact/image/unpack/unpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ func TestUnpackSquashed(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {

defer os.RemoveAll(tc.dir)
u := mustNewUnpacker(t, tc.cfg)
gotErr := u.UnpackSquashed(tc.dir, tc.image)
Expand Down Expand Up @@ -438,7 +437,6 @@ func TestUnpackLayers(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {

u := mustNewUnpacker(t, test.cfg)

defer os.RemoveAll(test.dir)
Expand Down Expand Up @@ -586,7 +584,6 @@ func mustReadSubDirs(t *testing.T, dir string) []digestAndContent {
// This image may not contain parent directories because it is constructed from an intermediate tarball.
// This is useful for testing the parent directory creation logic of unpack.
func mustNewSquashedImage(t *testing.T, pathsToContent map[string]contentAndMode) v1.Image {

// Squash layers into a single layer.
files := make(map[string]contentAndMode)
for path, contentAndMode := range pathsToContent {
Expand Down
2 changes: 0 additions & 2 deletions detector/weakcredentials/filebrowser/filebrowser.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func (d Detector) Scan(ctx context.Context, scanRoot *scalibrfs.ScanRoot, ix *in
}

return nil, nil

}

func isVulnerable(ctx context.Context, fileBrowserIP string, fileBrowserPort int) bool {
Expand Down Expand Up @@ -164,7 +163,6 @@ func checkAccessibility(ctx context.Context, fileBrowserIP string, fileBrowserPo

// checkLogin checks if the login with default credentials is successful.
func checkLogin(ctx context.Context, fileBrowserIP string, fileBrowserPort int) bool {

client := &http.Client{Timeout: requestTimeout}
targetURL := fmt.Sprintf("http://%s:%d/api/login", fileBrowserIP, fileBrowserPort)

Expand Down
1 change: 0 additions & 1 deletion extractor/filesystem/language/java/groupid/groupid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
)

func TestFromArtifactID(t *testing.T) {

tests := []struct {
name string
artifactID string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ func TestExtract(t *testing.T) {
for _, tt := range tests {
// Note the subtest here
t.Run(tt.name, func(t *testing.T) {

r, err := os.Open(tt.path)
defer func() {
if err = r.Close(); err != nil {
Expand Down
2 changes: 0 additions & 2 deletions extractor/filesystem/os/macapps/macapps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
)

func TestFileRequired(t *testing.T) {

tests := []struct {
name string
path string
Expand Down Expand Up @@ -129,7 +128,6 @@ func TestFileRequired(t *testing.T) {
}

func TestExtract(t *testing.T) {

tests := []struct {
name string
path string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func taskMetadata(ctx context.Context, client CtrdClient, task *task.Process, na
if err != nil {
log.Errorf("Failed to obtain container info for container %v, error: %v", task.ID, err)
return md, err

}

image, err := container.Image(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func (c *Container) Info(ctx context.Context, opts ...containerd.InfoOpts) (cont

func (c *Container) Task(context.Context, cio.Attach) (containerd.Task, error) {
return NewFakeTask(c.rootfs), nil

}

// Image returns the underlying container Image object with a given digest.
Expand Down
1 change: 0 additions & 1 deletion testing/fakeextractor/fake_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ var AllowUnexported = cmp.AllowUnexported(fakeExtractor{})
// The fakeExtractor returns FileRequired(path) = true for any path in requiredFiles.
// The fakeExtractor returns the inventory and error from pathToNamesErr given the same path to Extract(...).
func New(name string, version int, requiredFiles []string, pathToNamesErr map[string]NamesErr) filesystem.Extractor {

rfs := map[string]bool{}
for _, path := range requiredFiles {
rfs[path] = true
Expand Down

0 comments on commit 3c34c67

Please sign in to comment.