Skip to content

Commit 7b753fd

Browse files
committed
Fix: artifact commands failing due to incorrect userAgent formatting
Signed-off-by: Santosh <[email protected]>
1 parent 175d746 commit 7b753fd

File tree

6 files changed

+134
-1
lines changed

6 files changed

+134
-1
lines changed

pkg/utils/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,5 +425,6 @@ func GetVersion() (string, error) {
425425
if err != nil {
426426
return "", fmt.Errorf("error running git describe: %v", err)
427427
}
428-
return string(version), nil
428+
userAgent := fmt.Sprintf("intelops/genval: %s", string(version))
429+
return strings.ReplaceAll(userAgent, "\n", ""), nil
429430
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
deny[msg] {
4+
input.kind == "Deployment"
5+
not input.spec.template.spec.securityContext.runAsNonRoot
6+
7+
msg := "Containers must not run as root"
8+
}
9+
10+
deny[msg] {
11+
input.kind == "Deployment"
12+
not input.spec.selector.matchLabels.app
13+
14+
msg := "Containers must provide app label for pod selectors"
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "DenyLatest",
3+
"policy_file": "k8s.rego",
4+
"policy_name": "deny_latest",
5+
"severity": "High",
6+
"Description": "Ensure Image does not use 'latest' tag",
7+
"Benchmark": "CIS-4.9",
8+
"Category": "Infrastructure security"
9+
}
10+
11+
12+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package validate_k8s
2+
3+
import rego.v1
4+
5+
6+
deny_latest contains msg if {
7+
input.kind == "Deployment"
8+
c:= input.spec.template.spec.containers[i].image
9+
not endswith(c, "latest")
10+
msg:= "Image does not use 'latest' tag"
11+
}
12+
13+
# deny_secret contains msg if {
14+
# input.kind == "Deployment"
15+
# container := input.spec.template.spec.containers[_]
16+
# not container.envFrom
17+
# msg:= "Deployment does not use 'envFrom'"
18+
# }
19+
20+
# deny_secret contains msg if {
21+
# input.kind == "Deployment"
22+
# container := input.spec.template.spec.containers[_]
23+
# env := container.envFrom[_]
24+
# not env.secretRef
25+
# msg:= "Deployment does not use 'secretRef' in ENV"
26+
# }
27+
28+
# deny_secret contains msg if {
29+
# input.kind == "Deployment"
30+
# container := input.spec.template.spec.containers[_]
31+
# env := container.env[_]
32+
# env.valueFrom != []
33+
# msg:= "Deployment does not use 'valueFrom' in ENV"
34+
# }
35+
36+
# deny_priviliged_pod contains msg if {
37+
# input.kind == "Deployment"
38+
# not input.spec.template.spec.securityContext
39+
# msg:= "Deployment does not use priviliged pod"
40+
# }
41+
42+
# deny_priviliged_pod contains msg if {
43+
# input.kind == "Deployment"
44+
# podSpec := input.spec.template.spec.securityContext
45+
46+
# not podSpec.priviliged
47+
# msg:= "Deployment does not use priviliged pod"
48+
# }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "DenySecret",
3+
"policy_file": "k8s.rego",
4+
"policy_name": "deny_priviliged_pod",
5+
"severity": "High",
6+
"Description": "Ensure Deployment does not use 'secretRef' in ENV",
7+
"Benchmark": "CIS-4.9",
8+
"Category": "Infrastructure security"
9+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package validate_k8s
2+
3+
import rego.v1
4+
5+
6+
# deny_latest contains msg if {
7+
# input.kind == "Deployment"
8+
# c:= input.spec.template.spec.containers[i].image
9+
# not endswith(c, "latest")
10+
# msg:= "Image does not use 'latest' tag"
11+
# }
12+
13+
# deny_secret contains msg if {
14+
# input.kind == "Deployment"
15+
# container := input.spec.template.spec.containers[_]
16+
# not container.envFrom
17+
# msg:= "Deployment does not use 'envFrom'"
18+
# }
19+
20+
# deny_secret contains msg if {
21+
# input.kind == "Deployment"
22+
# container := input.spec.template.spec.containers[_]
23+
# env := container.envFrom[_]
24+
# not env.secretRef
25+
# msg:= "Deployment does not use 'secretRef' in ENV"
26+
# }
27+
28+
# deny_secret contains msg if {
29+
# input.kind == "Deployment"
30+
# container := input.spec.template.spec.containers[_]
31+
# env := container.env[_]
32+
# env.valueFrom != []
33+
# msg:= "Deployment does not use 'valueFrom' in ENV"
34+
# }
35+
36+
deny_priviliged_pod contains msg if {
37+
input.kind == "Deployment"
38+
not input.spec.template.spec.securityContext
39+
msg:= "Deployment does not use priviliged pod"
40+
}
41+
42+
# deny_priviliged_pod contains msg if {
43+
# input.kind == "Deployment"
44+
# podSpec := input.spec.template.spec.securityContext
45+
46+
# not podSpec.priviliged
47+
# msg:= "Deployment does not use priviliged pod"
48+
# }

0 commit comments

Comments
 (0)