Skip to content

Commit b5c2591

Browse files
committed
fix: wrong variable in the psp-seccomp module
Signed-off-by: peefy <[email protected]>
1 parent f5d34c9 commit b5c2591

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

psp-seccomp/kcl.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
22
name = "psp-seccomp"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "`psp-seccomp` is a kcl validation package"
55

psp-seccomp/main.k

+17-17
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ is_exempt = lambda image: str -> bool {
4242
result
4343
}
4444

45+
get_allowed_profiles = lambda -> [str] {
46+
# Plattern the profile list
47+
sum([lambda profile: str -> [str] {
48+
result = [profile]
49+
if not profile.lower().startswith("localhost"):
50+
result = naming_translation[profile]
51+
elif profile == "Localhost":
52+
files = allowedLocalhostFiles or []
53+
result = ["${p}/${file}" for file in files for p in naming_translation[profile]]
54+
elif profile.startswith("localhost"):
55+
result = naming_translation.localhost
56+
result
57+
}(profile) for profile in allowedProfiles], [])
58+
}
59+
4560
allowed_profiles = get_allowed_profiles()
4661

4762
violation = lambda item: {str:}, container: {str:} {
@@ -54,7 +69,7 @@ violation = lambda item: {str:}, container: {str:} {
5469

5570
get_message = lambda profile: str, file: str, name: str, location: str, allowed_profiles: [str] -> str {
5671
message = "Seccomp profile '{}' is not allowed for container '{}'. Found at: {}. Allowed profiles: {}".format(profile, name, location, allowed_profiles) \
57-
if profile == "Localhost" else "Seccomp profile '{}' with file '{}' is not allowed for container '{}'. Found at: {}. Allowed profiles: {}".format(profile, file, name, location, allowed_profile)
72+
if profile == "Localhost" else "Seccomp profile '{}' with file '{}' is not allowed for container '{}'. Found at: {}. Allowed profiles: {}".format(profile, file, name, location, allowed_profiles)
5873
}
5974

6075
allowed_profile = lambda profile: str, file: str, allowed: [str] -> bool {
@@ -92,21 +107,6 @@ get_annotation_localhost_files = lambda -> [str] {
92107
[p.removeprefix("localhost/") for p in allowedProfiles]
93108
}
94109

95-
get_allowed_profiles = lambda -> [str] {
96-
# Plattern the profile list
97-
sum([lambda profile: str -> [str] {
98-
result = [profile]
99-
if not profile.lower().startswith("localhost"):
100-
result = naming_translation[profile]
101-
elif profile == "Localhost":
102-
files = allowedLocalhostFiles or []
103-
result = ["${p}/${file}" for file in files for p in naming_translation[profile]]
104-
elif profile.startswith("localhost"):
105-
result = naming_translation.localhost
106-
result
107-
}(profile) for profile in allowedProfiles], [])
108-
}
109-
110110
# Container profile missing
111111
get_profile = lambda item: {str:}, container: {str:} -> {str:str} {
112112
result: {str:str} = {}
@@ -172,4 +172,4 @@ validate = lambda item: {str:} {
172172
item
173173
}
174174
# Validate All resource
175-
items = [validate(i) for i in option("items")]
175+
items = [validate(i) for i in option("items") or []]

0 commit comments

Comments
 (0)