10000 bump marvin version by matheusfm · Pull Request #220 · undistro/zora · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bump marvin version #220

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

Merged
merged 2 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/zora/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The following table lists the configurable parameters of the Zora chart and thei
| scan.plugins.marvin.enabled | bool | `true` | Specifies whether the marvin plugin should be created |
| scan.plugins.marvin.resources | object | `{"limits":{"cpu":"500m","memory":"500Mi"},"requests":{"cpu":"250m","memory":"256Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `marvin` container |
| scan.plugins.marvin.image.repository | string | `"ghcr.io/undistro/marvin"` | marvin plugin image repository |
| scan.plugins.marvin.image.tag | string | `"v0. 8000 1.6"` | marvin plugin image tag |
| scan.plugins.marvin.image.tag | string | `"v0.2.0"` | marvin plugin image tag |
| scan.plugins.popeye.enabled | bool | `true` | Specifies whether the popeye plugin should be created |
| scan.plugins.popeye.skipInternalResources | bool | `false` | Specifies whether the following resources should be skipped by `popeye` scans. 1. resources from `kube-system`, `kube-public` and `kube-node-lease` namespaces; 2. kubernetes system reserved RBAC (prefixed with `system:`); 3. `kube-root-ca.crt` configmaps; 4. `default` namespace; 5. `default` serviceaccounts; 6. Helm secrets (prefixed with `sh.helm.release`); 7. Zora components. See `popeye` configuration file that is used for this case: https://github.com/undistro/zora/blob/main/charts/zora/templates/plugins/popeye-config.yaml |
| scan.plugins.popeye.resources | object | `{"limits":{"cpu":"500m","memory":"500Mi"},"requests":{"cpu":"250m","memory":"256Mi"}}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers) to add to `popeye` container |
Expand Down
2 changes: 1 addition & 1 deletion charts/zora/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ scan:
# -- marvin plugin image repository
repository: ghcr.io/undistro/marvin
# -- marvin plugin image tag
tag: v0.1.6
tag: v0.2.0

popeye:
# -- Specifies whether the popeye plugin should be created
Expand Down
2 changes: 1 addition & 1 deletion config/samples/zora_v1alpha1_plugin_marvin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
app.kubernetes.io/created-by: zora
name: marvin
spec:
image: ghcr.io/undistro/marvin:v0.1.6
image: ghcr.io/undistro/marvin:v0.2.0
resources:
limits:
cpu: 500m
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/undistro/marvin v0.1.6
go.uber.org/zap v1.24.0
k8s.io/api v0.26.3
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apimachinery v0.26.3
k8s.io/client-go v0.26.3
k8s.io/metrics v0.26.3
Expand Down Expand Up @@ -69,7 +70,6 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apiserver v0.26.3 // indirect
k8s.io/component-base v0.26.3 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
Expand Down
29 changes: 17 additions & 12 deletions pkg/worker/report/marvin/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,28 @@ func clusterIssueSpec(report *marvin.Report, check *marvin.CheckResult) *v1alpha
resources[gvr] = append(resources[gvr], obj)
}
}
custom := !check.Builtin
category := "Security"
if c, ok := check.Labels["category"]; ok && custom {
category = c
}
url := urls[check.ID]
if u, ok := check.Labels["url"]; ok && custom {
url = u
}
return &v1alpha1.ClusterIssueSpec{
ID: check.ID,
Message: check.Message,
Severity: marvinToZoraSeverity[check.Severity],
Category: category,
Category: getCategory(check),
Resources: resources,
TotalResources: 0,
Url: url,
Custom: custom,
Url: getURL(check),
Custom: !check.Builtin,
}
}

func getCategory(check *marvin.CheckResult) string {
if c, ok := check.Labels["category"]; ok && !check.Builtin {
return c
}
switch check.ID {
case "M-400", "M-401":
return "Best Practices"
case "M-402", "M-403", "M-404", "M-405", "M-406", "M-407":
return "Reliability"
default:
return "Security"
}
}
22 changes: 22 additions & 0 deletions pkg/worker/report/marvin/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ func TestParse(t *testing.T) {
name: "OK",
filename: "httpbin.json",
want: []*v1alpha1.ClusterIssueSpec{
{
ID: "M-400",
Message: "Image tagged latest",
Severity: v1alpha1.SeverityMedium,
Category: "Best Practices",
Resources: map[string][]string{
"apps/v1/deployments": {"httpbin/httpbin"},
"apps/v1/replicasets": {"httpbin/httpbin-5978c9d878"},
},
Url: "https://kubernetes.io/docs/concepts/containers/images/#image-names",
},
{
ID: "M-407",
Message: "CPU not limited",
Severity: v1alpha1.SeverityMedium,
Category: "Reliability",
Resources: map[string][]string{
"apps/v1/deployments": {"httpbin/httpbin"},
"apps/v1/replicasets": {"httpbin/httpbin-5978c9d878"},
},
Url: k8sResourcesURL,
},
{
ID: "M-116",
Message: "Not allowed added/dropped capabilities",
Expand Down
44 changes: 44 additions & 0 deletions pkg/worker/report/marvin/testdata/httpbin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,50 @@
"platform": "linux/amd64"
},
"checks": [
{
"id": "M-400",
"message": "Image tagged latest",
"severity": "Medium",
"builtin": true,
"path": "general/M-400_image_tag_latest.yaml",
"status": "Failed",
"failed": {
"apps/v1/Deployment": [
"httpbin/httpbin"
],
"apps/v1/ReplicaSet": [
"httpbin/httpbin-5978c9d878"
]
},
"passed": {},
"skipped": {},
"errors": [],
"totalFailed": 2,
"totalPassed": 0,
"totalSkipped": 0
},
{
"id": "M-407",
"message": "CPU not limited",
"severity": "Medium",
"builtin": true,
"path": "general/M-407_cpu_limit.yaml",
"status": "Failed",
"failed": {
"apps/v1/Deployment": [
"httpbin/httpbin"
],
"apps/v1/ReplicaSet": [
"httpbin/httpbin-5978c9d878"
]
},
"passed": {},
"skipped": {},
"errors": [],
"totalFailed": 2,
"totalPassed": 0,
"totalSkipped": 0
},
{
"id": "M-116",
"message": "Not allowed added/dropped capabilities",
Expand Down
23 changes: 21 additions & 2 deletions pkg/worker/report/marvin/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@

package marvin

import marvin "github.com/undistro/marvin/pkg/types"

const (
pssBaselineURL = "https://kubernetes.io/docs/concepts/security/pod-security-standards/#baseline"
pssRestrictedURL = "https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted"
k8sResourcesURL = "https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/"
)

var urls = map[string]string{
Expand All @@ -39,9 +42,25 @@ var urls = map[string]string{
"M-115": pssRestrictedURL,
"M-116": pssRestrictedURL,

"M-300": "https://media.defense.gov/2022/Aug/29/2003066362/-1/-1/0/CTR_KUBERNETES_HARDENING_GUIDANCE_1.2_20220829.PDF#page=50",

"M-201": "https://microsoft.github.io/Threat-Matrix-for-Kubernetes/mitigations/MS-M9026%20Avoid%20using%20plain%20text%20credentials%20in%20configuration%20files/",
"M-202": "https://microsoft.github.io/Threat-Matrix-for-Kubernetes/mitigations/MS-M9025%20Disable%20Service%20Account%20Auto%20Mount/",
"M-203": "https://microsoft.github.io/Threat-Matrix-for-Kubernetes/mitigations/MS-M9015%20Avoid%20Running%20Management%20Interface%20on%20Containers/",

"M-300": "https://media.defense.gov/2022/Aug/29/2003066362/-1/-1/0/CTR_KUBERNETES_HARDENING_GUIDANCE_1.2_20220829.PDF#page=50",

"M-400": "https://kubernetes.io/docs/concepts/containers/images/#image-names",
"M-401": "https://kubernetes.io/docs/concepts/configuration/overview/#naked-pods-vs-replicasets-deployments-and-jobs",
"M-402": "https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/",
"M-403": "https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/",
"M-404": k8sResourcesURL,
"M-405": k8sResourcesURL,
"M-406": k8sResourcesURL,
"M-407": k8sResourcesURL,
}

func getURL(check *marvin.CheckResult) string {
if u, ok := check.Labels["url"]; ok && !check.Builtin {
return u
}
return urls[check.ID]
}
0