Skip to content
Open
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
16 changes: 8 additions & 8 deletions .github/workflows/validate-k8s-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Get Kubeval
- name: Get Kubeconform
env:
KUBEVAL_RELEASES_URL: https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
KUBECONFORM_VERSION: v0.6.4
run: |
mkdir -p .bin
PROJDIR=$(pwd)
cd .bin && wget "${KUBEVAL_RELEASES_URL}" \
&& tar xf $(basename "${KUBEVAL_RELEASES_URL}") \
&& chmod +x kubeval \
&& rm -vf $(basename "${KUBEVAL_RELEASES_URL}") \
cd .bin && wget "https://github.com/yannh/kubeconform/releases/download/${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \
&& tar xf kubeconform-linux-amd64.tar.gz \
&& chmod +x kubeconform \
&& rm -vf kubeconform-linux-amd64.tar.gz \
&& cd "${PROJDIR}"
- name: Validate k8s manifests
run: |
python3 -u .github/scripts/samples-linters/validate-syntax.py \
"assets/queries/k8s/**/test/*.yaml" \
--extra ' --skip-kinds CustomResourceDefinition,KubeletConfiguration,Policy,EncryptionConfiguration,KubeSchedulerConfiguration,SecretProviderClass,Service,Configuration,ContainerSource,Revision' \
--linter .bin/kubeval \
--extra ' -skip CustomResourceDefinition,KubeletConfiguration,Policy,EncryptionConfiguration,KubeSchedulerConfiguration,SecretProviderClass,Service,Configuration,ContainerSource,Revision,PodSecurityPolicy -ignore-missing-schemas' \
--linter .bin/kubeconform \
--skip '.github/scripts/samples-linters/ignore-list/k8s' -v

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "2b1836f1-dcce-416e-8e16-da8c71920633",
"queryName": "Workload Host Port Not Specified",
"id": "cfe96671-84e4-4f25-b349-bea992f590a2",
"queryName": "Workload Host Port Specified",
"severity": "LOW",
"category": "Networking and Firewall",
"descriptionText": "Verifies if Kubernetes workload's host port is specified",
Expand All @@ -10,4 +10,4 @@
"cloudProvider": "common",
"cwe": "665",
"riskScore": "2.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"queryName": "Workload Host Port Specified",
"severity": "LOW",
"line": 9
},
{
"queryName": "Workload Host Port Specified",
"severity": "LOW",
"line": 24
}
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "4e74cf4f-ff65-4c1a-885c-67ab608206ce",
"queryName": "Workload Host Port Not Specified",
"id": "0cfc4fe7-24eb-451f-a1c1-8c2bb82c0fae",
"queryName": "Workload Host Port Specified",
"severity": "LOW",
"category": "Networking and Firewall",
"descriptionText": "Verifies if Kubernetes workload's host port is specified",
Expand All @@ -10,4 +10,4 @@
"cwe": "665",
"cloudProvider": "common",
"riskScore": "2.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ CxPolicy[result] {
resource := input.document[i].resource[x][name]

path := checkPath(resource)
common_lib.valid_key(path.port, "host_port")

not common_lib.valid_key(path.port, "host_port")
result := {
"documentId": input.document[i].id,
"resourceType": x,
"resourceName": tf_lib.get_resource_name(resource, name),
"searchKey": sprintf("%s[%s].%s.port", [x, name, resource_prefix]),
"searchKey": sprintf("%s[%s].%s.port.host_port", [x, name, resource_prefix]),
"issueType": "IncorrectValue",
"keyExpectedValue": "Attribute 'host_port' should be defined and not null",
"keyActualValue": "Attribute 'host_port' is undefined or null",
}
"keyExpectedValue": sprintf("%s[%s].%s.port.host_port should not be defined", [x, name, resource_prefix]),
"keyActualValue": sprintf("%s[%s].%s.port.host_port is defined", [x, name, resource_prefix]),
"searchLine": common_lib.build_search_line(array.concat(["resource", x, name], split(resource_prefix, ".")), ["port", "host_port"]),
}
}

checkPath(resource) = path {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"queryName": "Workload Host Port Specified",
"severity": "LOW",
"line": 18,
"fileName": "positive1.tf"
},
{
"queryName": "Workload Host Port Specified",
"severity": "LOW",
"line": 43,
"fileName": "positive2.tf"
}
]
Loading