-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
80 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
timeout=300 | ||
start_time=$SECONDS | ||
while [[ -z $(kubectl -n kubescape get openvulnerabilityexchangecontainers.spdx.softwarecomposition.kubescape.io) ]]; do | ||
echo "Waiting for VEX generation..." | ||
sleep 10 | ||
if [[ $((SECONDS - start_time)) -gt $timeout ]]; then | ||
echo "Timeout reached. Exiting..." | ||
|
||
# Loop through all pods in the kubescape namespace and print the logs | ||
for pod in $(kubectl -n kubescape get pods -o jsonpath='{.items[*].metadata.name}'); do | ||
echo "Logs for $pod:" | ||
kubectl -n kubescape logs "$pod" | ||
done | ||
|
||
break | ||
fi | ||
done | ||
|
||
echo "Saving VEX results..." | ||
kubectl -n kubescape get openvulnerabilityexchangecontainer \ | ||
"$(kubectl -n kubescape get openvulnerabilityexchangecontainer -o jsonpath='{.items[0].metadata.name}')" \ | ||
-o jsonpath='{.spec}' > vex.json | ||
|
||
echo "Affected:" | ||
jq "." vex.json | grep -c "\"affected\"" | ||
|
||
echo "Not affected:" | ||
jq "." vex.json | grep -c "\"not_affected\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
kubectl apply -f "$DEPLOYMENT_FILE" | ||
$READY_CONDITION | ||
helm install "$HELM_CHART_PATH" --wait --timeout 300s --generate-name | ||
|
||
if [[ -n "$READY_CONDITION" ]]; then | ||
$READY_CONDITION | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
# Get the pod name and container port of the test application | ||
POD_NAME=$(kubectl get pods -l "app.kubernetes.io/name=hello-world" -o jsonpath="{.items[0].metadata.name}") | ||
CONTAINER_PORT=$(kubectl get pod "$POD_NAME" -o jsonpath="{.spec.containers[0].ports[0].containerPort}") | ||
# Expose the test app on localhost | ||
kubectl port-forward "$POD_NAME" 8080:"$CONTAINER_PORT" & | ||
sleep 5 | ||
# Test the application by sending a request to it a number of times | ||
for _ in {1..10}; do | ||
# Prints just the status code | ||
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8080 | ||
echo | ||
done | ||
# Stop the port-forwarding | ||
kill %1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
if [[ -n "$TEST_COMMAND" ]]; then | ||
$TEST_COMMAND | ||
fi |