Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 return v9 portion in provider IDs #3053

Merged
merged 3 commits into from
Jan 18, 2024
Merged

🐛 return v9 portion in provider IDs #3053

merged 3 commits into from
Jan 18, 2024

Conversation

arlimus
Copy link
Member

@arlimus arlimus commented Jan 18, 2024

We have a bug in cnquery/cnspec v9 where differences in the ID can cause a crash:

 panic: shell flag redefined: sudo

goroutine 1 [running]:
github.com/spf13/pflag.(*FlagSet).AddFlag(0xc000516200, 0xc000debb80)
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/flag.go:855 +0x5ec
github.com/spf13/pflag.(*FlagSet).VarPF(0x10?, {0x22dbdc8, 0xc000afe960}, {0xc0006e72c8, 0x4}, {0x0, 0x0}, {0xc00005b2c0, 0x1d})
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/flag.go:838 +0x14f
github.com/spf13/pflag.(*FlagSet).BoolVarP(0xc000afe938?, 0x5?, {0xc0006e72c8?, 0x1946360?}, {0x0?, 0x1dbe006?}, 0x33?, {0xc00005b2c0?, 0x3167bc0?})
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/bool.go:55 +0x3e
github.com/spf13/pflag.(*FlagSet).BoolP(...)
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/bool.go:80
github.com/spf13/pflag.(*FlagSet).Bool(...)
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/bool.go:74
go.mondoo.com/cnquery/v9/cli/providers.attachFlag(0x0?, {{0xc0006e72c8, 0x4}, {0x0, 0x0}, {0xc0006e72d0, 0x5}, {0xc00005b2c0, 0x1d}, 0x1, ...})

This happens when e.g.:

→ /home/zero/.config/mondoo/providers (found 1 providers)

  os 10.0.0 with connectors: local, ssh, winrm, vagrant, container, docker, filesystem

→ /opt/mondoo/providers (found 1 providers)

  os 9.1.17 with connectors: local, ssh, winrm, vagrant, container, docker, filesystem

i.e. when we have an old-style provider ID (in v9.1.17) and a new-style provider ID (which we tried to introduce with this version).

As soon as the ID is restored to be the same, this continue to work with cnquery/cnspec v9.x. We will keep the old version tag in each provider for the duration of v9.x support and remove the version indication from the ID once it is sunset (i.e. when we release v11.0).

This may only be an edge-case with an easy solution/workaround, but it is an annoying experience. We will suffer with a confusing ID for a little bit until we can comfortably clean it up.

@arlimus arlimus requested a review from chris-rock January 18, 2024 09:06
We have a bug in cnquery/cnspec v9 where differences in the ID can cause
a crash:

```
 panic: shell flag redefined: sudo

goroutine 1 [running]:
github.com/spf13/pflag.(*FlagSet).AddFlag(0xc000516200, 0xc000debb80)
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/flag.go:855 +0x5ec
github.com/spf13/pflag.(*FlagSet).VarPF(0x10?, {0x22dbdc8, 0xc000afe960}, {0xc0006e72c8, 0x4}, {0x0, 0x0}, {0xc00005b2c0, 0x1d})
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/flag.go:838 +0x14f
github.com/spf13/pflag.(*FlagSet).BoolVarP(0xc000afe938?, 0x5?, {0xc0006e72c8?, 0x1946360?}, {0x0?, 0x1dbe006?}, 0x33?, {0xc00005b2c0?, 0x3167bc0?})
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/bool.go:55 +0x3e
github.com/spf13/pflag.(*FlagSet).BoolP(...)
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/bool.go:80
github.com/spf13/pflag.(*FlagSet).Bool(...)
    /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.6-0.20201009195203-85dd5c8bc61c/bool.go:74
go.mondoo.com/cnquery/v9/cli/providers.attachFlag(0x0?, {{0xc0006e72c8, 0x4}, {0x0, 0x0}, {0xc0006e72d0, 0x5}, {0xc00005b2c0, 0x1d}, 0x1, ...})
```

This happens when e.g.:

```
→ /home/zero/.config/mondoo/providers (found 1 providers)

  os 10.0.0 with connectors: local, ssh, winrm, vagrant, container, docker, filesystem

→ /opt/mondoo/providers (found 1 providers)

  os 9.1.17 with connectors: local, ssh, winrm, vagrant, container, docker, filesystem
```

i.e. when we have an old-style provider ID (in v9.1.17) and a new-style
provider ID (which we tried to introduce with this version).

As soon as the ID is restored to be the same, this continue to work with
cnquery/cnspec v9.x. We will keep the old version tag in each provider
for the duration of v9.x support and remove the version indication from
the ID once it is sunset (i.e. when we release v11.0).

This may only be an edge-case with an easy solution/workaround, but it
is an annoying experience. We will suffer with a confusing ID for a
little bit until we can comfortably clean it up.

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
@arlimus arlimus merged commit f486104 into main Jan 18, 2024
10 checks passed
@arlimus arlimus deleted the dom/v9-v2 branch January 18, 2024 10:09
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants