Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Comparing metadata for images that don't exist locally causes panic due to SIGSEGV #250

@bobcatfish

Description

@bobcatfish

Observed

When running container-diff using one or more images that do not exist locally and passing --type=metadata, there is a panic :O

container-diff diff cats dogs --type=metadata 
2018/07/25 15:31:31 No matching credentials found for index.docker.io, falling back on anonymous
2018/07/25 15:31:31 No matching credentials found for index.docker.io, falling back on anonymous
WARN[0001] Diff may be inaccurate: open : no such file or directory 
WARN[0001] Diff may be inaccurate: open : no such file or directory 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x81f612]

goroutine 1 [running]:
github.com/GoogleContainerTools/container-diff/differs.getMetadataList(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/GoogleContainerTools/container-diff/differs/metadata_diff.go:77 +0x42
github.com/GoogleContainerTools/container-diff/differs.getMetadataDiff(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/GoogleContainerTools/container-diff/differs/metadata_diff.go:62 +0x8a
github.com/GoogleContainerTools/container-diff/differs.MetadataAnalyzer.Diff(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/GoogleContainerTools/container-diff/differs/metadata_diff.go:40 +0xb2
github.com/GoogleContainerTools/container-diff/differs.(*MetadataAnalyzer).Diff(0xc7ff18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	<autogenerated>:1 +0xab
github.com/GoogleContainerTools/container-diff/differs.DiffRequest.GetDiff(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/GoogleContainerTools/container-diff/differs/differs.go:62 +0x1b8
github.com/GoogleContainerTools/container-diff/cmd.diffImages(0x7ffd24b21fc0, 0x4, 0x7ffd24b21fc5, 0x4, 0xc42028fce0, 0x1, 0x1, 0x0, 0x0)
	/go/src/github.com/GoogleContainerTools/container-diff/cmd/diff.go:110 +0x601
github.com/GoogleContainerTools/container-diff/cmd.glob..func4(0xc57a60, 0xc4202f4330, 0x2, 0x3)
	/go/src/github.com/GoogleContainerTools/container-diff/cmd/diff.go:46 +0x89
github.com/GoogleContainerTools/container-diff/vendor/github.com/spf13/cobra.(*Command).execute(0xc57a60, 0xc4202f42a0, 0x3, 0x3, 0xc57a60, 0xc4202f42a0)
	/go/src/github.com/GoogleContainerTools/container-diff/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/GoogleContainerTools/container-diff/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc57cc0, 0x0, 0x0, 0x0)
	/go/src/github.com/GoogleContainerTools/container-diff/vendor/github.com/spf13/cobra/command.go:852 +0x334
github.com/GoogleContainerTools/container-diff/vendor/github.com/spf13/cobra.(*Command).Execute(0xc57cc0, 0x1f, 0x0)
	/go/src/github.com/GoogleContainerTools/container-diff/vendor/github.com/spf13/cobra/command.go:800 +0x2b
main.main()
	/go/src/github.com/GoogleContainerTools/container-diff/main.go:35 +0x66

Expected

There should be an error message probably, but not a panic/runtime exception, e.g. without --type=metadata the output is:

➜  kaniko git:(local_integration_tests) container-diff diff cats dogs                
2018/07/25 15:33:08 No matching credentials found for index.docker.io, falling back on anonymous
2018/07/25 15:33:08 No matching credentials found for index.docker.io, falling back on anonymous
WARN[0001] Diff may be inaccurate: open : no such file or directory 
WARN[0001] Diff may be inaccurate: open : no such file or directory 
ERRO[0001] Error getting diff with AptAnalyzer: stat : no such file or directory 
ERRO[0001] Could not retrieve diff: Could not perform diff on {<nil>   []} and {<nil>   []} 

Interestingly, the output also doesn't match - but at least doesn't panic! - when using --type=file:

➜  kaniko git:(local_integration_tests) container-diff diff cats dogs --type=file    
2018/07/25 15:33:35 No matching credentials found for index.docker.io, falling back on anonymous
2018/07/25 15:33:35 No matching credentials found for index.docker.io, falling back on anonymous
WARN[0001] Diff may be inaccurate: open : no such file or directory 
WARN[0001] Diff may be inaccurate: open : no such file or directory 

-----File-----

These entries have been added to : None

These entries have been deleted from : None

These entries have been changed between  and : None

Steps to reproduce

Assuming you do not have the images cat and dog locally (or run docker system prune -a so you can use ANY image name XD), run:

container-diff diff cats dogs --type=metadata

This is with version v0.11.0.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions