From 338cf578ed74becc66906b5e9b950f9b700cbc37 Mon Sep 17 00:00:00 2001 From: Shlomo Heigh Date: Mon, 10 Jun 2024 15:53:05 -0400 Subject: [PATCH 1/3] Add sleep command to ensure latest usage data --- generate.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/generate.sh b/generate.sh index 042a97c..6652bae 100755 --- a/generate.sh +++ b/generate.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -x +# Wait the nodeAgent.config.updatePeriod used when installing the Kubescape helm chart. +# This ensures that the VEX documents are updated with the latest usage data. +sleep 60 + +# Now attempt to retrieve the VEX documents timeout=300 start_time=$SECONDS while [[ -z $(kubectl -n kubescape get openvulnerabilityexchangecontainers.spdx.softwarecomposition.kubescape.io) ]]; do From c89ecd55d1b07b9e1b033c63f8cedc13793af953 Mon Sep 17 00:00:00 2001 From: Shlomo Heigh Date: Mon, 10 Jun 2024 16:12:23 -0400 Subject: [PATCH 2/3] Remove 'set -x' to stop excessive logging --- generate.sh | 1 - install.sh | 1 - self-test/test.sh | 1 - setup.sh | 1 - test.sh | 1 - 5 files changed, 5 deletions(-) diff --git a/generate.sh b/generate.sh index 6652bae..3ecd7a7 100755 --- a/generate.sh +++ b/generate.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x # Wait the nodeAgent.config.updatePeriod used when installing the Kubescape helm chart. # This ensures that the VEX documents are updated with the latest usage data. diff --git a/install.sh b/install.sh index 2e8eff8..e07a5f2 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x helm install "$HELM_CHART_PATH" --wait --timeout "$INSTALL_TIMEOUT" --generate-name -n "$TESTS_NAMESPACE" --create-namespace diff --git a/self-test/test.sh b/self-test/test.sh index dfef241..68f15b8 100755 --- a/self-test/test.sh +++ b/self-test/test.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x # Get the pod name and container port of the test application POD_NAME=$(kubectl -n self-test get pods -l "app.kubernetes.io/name=hello-world" -o jsonpath="{.items[0].metadata.name}") diff --git a/setup.sh b/setup.sh index 51593a0..497735f 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x # Install Kubescape helm repo add kubescape https://kubescape.github.io/helm-charts/ diff --git a/test.sh b/test.sh index 49fa45c..d060db4 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -set -x if [[ -n "$TEST_COMMAND" ]]; then $TEST_COMMAND From 0fa2e3dd3102352544d5a753aa349e8ff5a50b31 Mon Sep 17 00:00:00 2001 From: Shlomo Heigh Date: Mon, 10 Jun 2024 16:19:10 -0400 Subject: [PATCH 3/3] Simplify summary log statements --- generate.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generate.sh b/generate.sh index 3ecd7a7..8af813d 100755 --- a/generate.sh +++ b/generate.sh @@ -2,6 +2,7 @@ # Wait the nodeAgent.config.updatePeriod used when installing the Kubescape helm chart. # This ensures that the VEX documents are updated with the latest usage data. +echo "Waiting for VEX generation..." sleep 60 # Now attempt to retrieve the VEX documents @@ -48,11 +49,10 @@ for doc in $vex_docs; do # # Save the VEX document (the .spec portion) to a file jq ".spec" <<< "$vex_object" > out/"$image".json - echo "Affected:" - jq "." out/"$image".json | grep -c "\"affected\"" + count_affected=$(jq "." out/"$image".json | grep -c "\"affected\"") + count_not_affected=$(jq "." out/"$image".json | grep -c "\"not_affected\"") - echo "Not affected:" - jq "." out/"$image".json | grep -c "\"not_affected\"" + echo "Saved VEX document for $image. $count_affected issues affected, $count_not_affected not affected." done # Check if there are any VEX documents saved