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

fix(k8s): skip resources without misconfigs #7797

Merged
merged 7 commits into from
Oct 31, 2024

Conversation

afdesk
Copy link
Contributor

@afdesk afdesk commented Oct 25, 2024

Description

This PR fixes overriding of existed misconfigurations found in image scan.

before

Infra Assessment
┌─────────────┬──────────────────────────────────────────────┬───────────────────┬───────────────────┬───────────────────┐
│  Namespace  │                   Resource                   │  Vulnerabilities  │ Misconfigurations │      Secrets      │
│             │                                              ├───┬───┬───┬───┬───┼───┬───┬───┬───┬───┼───┬───┬───┬───┬───┤
│             │                                              │ C │ H │ M │ L │ U │ C │ H │ M │ L │ U │ C │ H │ M │ L │ U │
├─────────────┼──────────────────────────────────────────────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
│ kube-system │ Service/hubble-peer                          │   │   │   │   │   │   │   │ 1 │   │   │   │   │   │   │   │
│ kube-system │ Service/kube-dns                             │   │   │   │   │   │   │   │ 1 │   │   │   │   │   │   │   │
│ kube-system │ ConfigMap/cilium-config                      │   │   │   │   │   │   │   │ 1 │   │   │   │   │   │   │   │
│ kube-system │ ConfigMap/extension-apiserver-authentication │   │   │   │   │   │   │   │ 1 │   │   │   │   │   │   │   │
└─────────────┴──────────────────────────────────────────────┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN

after:

Infra Assessment
┌─────────────┬──────────────────────────────────────────────┬───────────────────┬──────────────────────┬───────────────────┐
│  Namespace  │                   Resource                   │  Vulnerabilities  │  Misconfigurations   │      Secrets      │
│             │                                              ├───┬───┬───┬───┬───┼───┬────┬────┬────┬───┼───┬───┬───┬───┬───┤
│             │                                              │ C │ H │ M │ L │ U │ C │ H  │ M  │ L  │ U │ C │ H │ M │ L │ U │
├─────────────┼──────────────────────────────────────────────┼───┼───┼───┼───┼───┼───┼────┼────┼────┼───┼───┼───┼───┼───┼───┤
│ kube-system │ Deployment/coredns                           │   │   │   │   │   │   │ 1  │ 4  │ 4  │   │   │   │   │   │   │
│ kube-system │ Service/hubble-peer                          │   │   │   │   │   │   │    │ 1  │    │   │   │   │   │   │   │
│ kube-system │ Service/kube-dns                             │   │   │   │   │   │   │    │ 1  │    │   │   │   │   │   │   │
│ kube-system │ ConfigMap/cilium-config                      │   │   │   │   │   │   │    │ 1  │    │   │   │   │   │   │   │
│ kube-system │ ConfigMap/extension-apiserver-authentication │   │   │   │   │   │   │    │ 1  │    │   │   │   │   │   │   │
│ kube-system │ DaemonSet/cilium                             │   │   │   │   │   │   │ 19 │ 28 │ 57 │   │   │   │   │   │   │
│ kube-system │ DaemonSet/kube-proxy                         │   │   │   │   │   │   │ 3  │ 5  │ 9  │   │   │   │   │   │   │
│ kube-system │ Deployment/cilium-operator                   │   │   │   │   │   │   │ 2  │ 4  │ 9  │   │   │   │   │   │   │
└─────────────┴──────────────────────────────────────────────┴───┴───┴───┴───┴───┴───┴────┴────┴────┴───┴───┴───┴───┴───┴───┘
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@afdesk afdesk marked this pull request as ready for review October 28, 2024 12:23
Comment on lines +94 to +99
if misconfigsResource(m) {
res, ok := index[m.fullname()]
index[m.fullname()] = m
if ok {
index[m.fullname()].Results[0].Misconfigurations = append(index[m.fullname()].Results[0].Misconfigurations, res.Results[0].Misconfigurations...)
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test in report_test.go to cover this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch! thanks!
done 4bc5434

@afdesk afdesk requested a review from simar7 October 29, 2024 05:26
@afdesk
Copy link
Contributor Author

afdesk commented Oct 29, 2024

@simar7 could you take a look again? thanks!

@simar7
Copy link
Member

simar7 commented Oct 30, 2024

lgtm @afdesk we just need to resolve merge conflicts prior to merge. Could you update and push that?

@afdesk
Copy link
Contributor Author

afdesk commented Oct 30, 2024

@simar7 thanks! sure, I'll fix the conflict

@simar7 simar7 added this pull request to the merge queue Oct 31, 2024
Merged via the queue into aquasecurity:main with commit 7882776 Oct 31, 2024
12 checks passed
@afdesk afdesk deleted the fix/k8s/override-misconfigs branch October 31, 2024 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(k8s): inconsistent results for scan with and without images
2 participants