Skip to content

Commit

Permalink
fix: wrong variable in the psp-seccomp module
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Dec 15, 2023
1 parent f5d34c9 commit b5c2591
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion psp-seccomp/kcl.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "psp-seccomp"
version = "0.1.1"
version = "0.1.2"
description = "`psp-seccomp` is a kcl validation package"

34 changes: 17 additions & 17 deletions psp-seccomp/main.k
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ is_exempt = lambda image: str -> bool {
result
}

get_allowed_profiles = lambda -> [str] {
# Plattern the profile list
sum([lambda profile: str -> [str] {
result = [profile]
if not profile.lower().startswith("localhost"):
result = naming_translation[profile]
elif profile == "Localhost":
files = allowedLocalhostFiles or []
result = ["${p}/${file}" for file in files for p in naming_translation[profile]]
elif profile.startswith("localhost"):
result = naming_translation.localhost
result
}(profile) for profile in allowedProfiles], [])
}

allowed_profiles = get_allowed_profiles()

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

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

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

get_allowed_profiles = lambda -> [str] {
# Plattern the profile list
sum([lambda profile: str -> [str] {
result = [profile]
if not profile.lower().startswith("localhost"):
result = naming_translation[profile]
elif profile == "Localhost":
files = allowedLocalhostFiles or []
result = ["${p}/${file}" for file in files for p in naming_translation[profile]]
elif profile.startswith("localhost"):
result = naming_translation.localhost
result
}(profile) for profile in allowedProfiles], [])
}

# Container profile missing
get_profile = lambda item: {str:}, container: {str:} -> {str:str} {
result: {str:str} = {}
Expand Down Expand Up @@ -172,4 +172,4 @@ validate = lambda item: {str:} {
item
}
# Validate All resource
items = [validate(i) for i in option("items")]
items = [validate(i) for i in option("items") or []]

0 comments on commit b5c2591

Please sign in to comment.