common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
956 stars 90 forks source link

Panic error when granted_sso_start_url or granted_sso_region aren't defined #605

Open ericofusco opened 4 months ago

ericofusco commented 4 months ago

Version: 0.20.7

Profile config example:

[profile example]
granted_sso_account_id = 0123456789012
granted_sso_role_name  = role-name
credential_process  = granted credential-process --profile example
common_fate_generated_from = aws-sso

# When any of the following parameters aren't defined it throws a panic error
# granted_sso_start_url = https://example.awsapps.com/start
# granted_sso_region = us-east-2

Generates the panic error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x20 pc=0x1010a0278]

goroutine 1 [running]:
github.com/common-fate/granted/pkg/cfaws.ParseGrantedSSOProfile({0x1014324f0, 0x140001a6010}, 0x1400050d340)
    /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/cfaws/granted_config.go:49 +0x278
github.com/common-fate/granted/pkg/cfaws.(*Profiles).LoadInitialisedProfile(0x14000481f40, {0x1014324f0, 0x140001a6010}, {0x1400048d1e8?, 0x14000296f08?})
    /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/cfaws/profiles.go:317 +0x12c
github.com/common-fate/granted/pkg/assume.AssumeCommand(0x1400042c040)
    /Users/runner/work/granted-cli-build/granted-cli-build/granted/pkg/assume/assume.go:302 +0x388c
github.com/urfave/cli/v2.(*Command).Run(0x14000430140, 0x1400042c040, {0x140001aa000, 0x2, 0x2})
    /Users/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.24.1/command.go:271 +0x78c
github.com/urfave/cli/v2.(*App).RunContext(0x1400041e1e0, {0x1014324f0?, 0x140001a6010}, {0x140001aa000, 0x2, 0x2})
    /Users/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.24.1/app.go:333 +0x5dc
github.com/urfave/cli/v2.(*App).Run(...)
    /Users/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.24.1/app.go:310
main.main()
    /Users/runner/work/granted-cli-build/granted-cli-build/granted/cmd/granted/main.go:50 +0x2d4

Expected behavior

Throws an error just like when other granted parameters aren't defined. Example:

[✘] invalid aws config for granted login. 'granted_sso_account_id' field must be provided