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

🐛 Prevent k8s scan panic #1773

Merged
merged 3 commits into from
Sep 20, 2023
Merged

🐛 Prevent k8s scan panic #1773

merged 3 commits into from
Sep 20, 2023

Conversation

czunker
Copy link
Contributor

@czunker czunker commented Sep 18, 2023

When scanning k8s with container image discovery, it paniced. That happened because asset data was missing.

Fixes #1749

@czunker
Copy link
Contributor Author

czunker commented Sep 18, 2023

This is similar to run and shell:

ad6e646 and #1646

When scanning k8s with container image discovery, it paniced.
That happened because asset data was missing.

Fixes #1749

Signed-off-by: Christian Zunker <[email protected]>
@czunker czunker force-pushed the christian/k8s_scan_panic branch from b6c5985 to cb535f1 Compare September 19, 2023 08:28
@czunker
Copy link
Contributor Author

czunker commented Sep 19, 2023

Working now:

cnquery scan k8s --discover container-images                                                                     ✔ │ 10:24:58 
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
→ using service account credentials
→ discover related assets for 1 asset(s)
→ synchronize assets

 registry.k8s.io/kube-controller-manager@c4765f949306 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
 registry.k8s.io/kube-proxy@ce9abe867450              ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
 registry.k8s.io/kube-scheduler@9c58009453cf          ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
 gcr.io/k8s-minikube/storage-provisioner@c4c05d6ad6c0 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
 registry.k8s.io/coredns/coredns@be7652ce0b43         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
 registry.k8s.io/etcd@8ae03c7bbd43                    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%
 registry.k8s.io/kube-apiserver@dcf39b4579f8          ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%

 7/7 scanned                                          ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100%

Data (7 assets)
===============

Asset: registry.k8s.io/etcd@8ae03c7bbd43
----------------------------------------

asset-overview-assetarch:
asset.arch: "amd64"
...

@czunker czunker marked this pull request as ready for review September 19, 2023 08:30
defaultConnection uint32 = 1
DefaultConnectionType = "aws"
SshConnectionType = "ssh"
RegistryImageConnectionType = "registry-image"
Copy link
Contributor Author

@czunker czunker Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removal is also part of #1707. But I removed even more here.

I had to fix this here otherwise, the AWS provider would take over the provider for some images.

assetCandidates = append(assetCandidates, inventorySpec.Inventory.Spec.Assets...)
} else {
assetCandidates = append(assetCandidates, runtime.Provider.Connection.Asset)
processedAssets, err := providers.ProcessAssetCandidates(runtime, runtime.Provider.Connection, upstream, "")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the actual fix to prevent the panic.

Signed-off-by: Christian Zunker <[email protected]>
@vjeffrey
Copy link
Contributor

this all seems correct, i just wanna spin it up locally before merging - doing that now

@vjeffrey vjeffrey merged commit 1bcabfc into main Sep 20, 2023
10 checks passed
@vjeffrey vjeffrey deleted the christian/k8s_scan_panic branch September 20, 2023 04:10
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2023
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.

V9: segfault scanning k8s
2 participants