dexidp / dex

OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
https://dexidp.io
Apache License 2.0
9.41k stars 1.69k forks source link

Gracefully handle no args being passed to entrypoint #3589

Closed rgmz closed 2 months ago

rgmz commented 3 months ago

Overview

This is a minor change to prevent a panic in an admittedly niche edge case.

What this PR does / why we need it

This PR gracefully handles no args being passed to the entrypoint binary.

# before
./docker-entrypoint
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
main.run({0xc000014140?, 0xc00006e740?, 0x0?}, 0x60?, 0x0?)
/usr/local/src/dex/cmd/docker-entrypoint/main.go:56 +0x5c5
main.main()
/usr/local/src/dex/cmd/docker-entrypoint/main.go:21 +0x65

# after
./docker-entrypoint 
error: no args passed to entrypoint

This can occur if someone builds upon the upstream dex image (e.g., adding internal company certificates) and inadvertently breaks the entrypoint/cmd.

Special notes for your reviewer

nabokihms commented 2 months ago

Good catch! Thanks, @rgmz