Crash when running in a container with an empty environment variable
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in pkg/drivers/driver.go at lines 81-82 and trace convertSliceToMap through DockerDriver.GetConfig in pkg/drivers/docker_driver.go. Reproduce the case with a Docker environment entry lacking '=', then verify configuration parsing no longer panics and still handles normal KEY=VALUE entries.
Written by the indexing model from the issue text.
Description
When running in a container started with -e EMPTY and the EMPTY variable is either unset or the empty string, you get a crash like this:
panic: runtime error: index out of range
goroutine 7 [running]:
github.com/GoogleContainerTools/container-structure-test/pkg/drivers.convertSliceToMap(0xc420398270, 0xd, 0xd, 0x0)
/go/src/github.com/GoogleContainerTools/container-structure-test/pkg/drivers/driver.go:82 +0x169
github.com/GoogleContainerTools/container-structure-test/pkg/drivers.(*DockerDriver).GetConfig(0xc42008bba0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/github.com/GoogleContainerTools/container-structure-test/pkg/drivers/docker_driver.go:408 +0x3f5
github.com/GoogleContainerTools/container-structure-test/pkg/types/v2.FileExistenceTest.Run(0xc4202fc4a0, 0x13, 0xc4202fc500, 0x12, 0x1, 0x0, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, ...)
/go/src/github.com/GoogleContainerTools/container-structure-test/pkg/types/v2/file_existence.go:91 +0x242
github.com/GoogleContainerTools/container-structure-test/pkg/types/v2.(*StructureTest).RunFileExistenceTests(0xc420001200, 0xc420216e40)
/go/src/github.com/GoogleContainerTools/container-structure-test/pkg/types/v2/structure.go:117 +0x43f
github.com/GoogleContainerTools/container-structure-test/pkg/types/v2.(*StructureTest).runAll(0xc420001200, 0xc420216e40, 0xc42005e1c0)
/go/src/github.com/GoogleContainerTools/container-structure-test/pkg/types/v2/structure.go:56 +0x69
created by github.com/GoogleContainerTools/container-structure-test/pkg/types/v2.(*StructureTest).RunAll
/go/src/github.com/GoogleContainerTools/container-structure-test/pkg/types/v2/structure.go:49 +0x75
That's because the "Env" part of the "Config" object received from the Docker daemon looks something like
"Env": [
"EMPTY",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
]
isn't prepared for the missing =.
- Dominant language
- Go
- Stars
- 2.5k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GoogleContainerTools/container-structure-test
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
allstar
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
GoogleContainerTools/container-structure-test#393 · 639 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
All issues in GoogleContainerTools/container-structure-test
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100