generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 7
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
220 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
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,41 @@ | ||
#!/bin/bash | ||
|
||
# Build test images | ||
docker build -f myappDockerfile -t myapptest ../myapp/ | ||
docker build -f configmanagerDockerfile -t configmanagertest ../configmanager/ | ||
docker build -f proxyDockerfile -t proxytest ../proxy/ | ||
|
||
# Delete possible container conflicts | ||
docker rm -f myapp | ||
docker rm -f configmanager | ||
docker rm -f proxy | ||
|
||
# Start the application in demo mode | ||
docker-compose up -d | ||
|
||
# Wait for docker-compose to be ready (checking the logs) | ||
while :; do | ||
status=`docker-compose logs | grep "wasm log: read new config"` | ||
if [ "$status" == "" ]; then | ||
sleep 1 # wait one second before checking again | ||
else | ||
break | ||
fi | ||
done | ||
|
||
# Give some time to Envoy to deploy the config | ||
sleep 4 | ||
|
||
# Run all tests | ||
for test_script in $(find ./stress -type f -name "*.sh") | ||
do | ||
echo "NOW RUNNING TEST: $test_script" | ||
bash "$test_script" | ||
done | ||
|
||
# Done! | ||
echo "ALL TESTS COMPLETED" | ||
|
||
# Cleanup | ||
docker-compose down | ||
|
File renamed without changes.
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,62 @@ | ||
# Time taken for 10000 requests, 1 injected decoy (replace) but 0 trigger (except for last one) | ||
|
||
# Configure decoys | ||
config=' | ||
{ | ||
"filters": [ | ||
{ | ||
"decoy": { | ||
"key": "admin1234" | ||
}, | ||
"inject": { | ||
"store": { | ||
"inResponse": "/robots.txt", | ||
"withVerb": "GET", | ||
"as": "body", | ||
"at": { | ||
"method": "replace", | ||
"property": "((.|\n)*)" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
' | ||
|
||
# connect to configmanager, update /data/cad-default.json | ||
echo "$config" | docker exec -i configmanager sh -c 'cat > /data/cad-default.json' | ||
# wait a few seconds for the proxy to read the new config | ||
sleep 5 | ||
|
||
|
||
# Start timing | ||
start_time=$(date +%s.%N) | ||
|
||
# Temporary file for curl output | ||
tempfile=$(uuidgen -r) | ||
|
||
# Do relevant action(s) | ||
for ((i=1; i<=9999; i++)); do | ||
curl -v http://localhost:8000/ >/dev/null 2>&1 | ||
done | ||
# Check in the 1000th iteration that the decoy is properly injected | ||
curl -v http://localhost:8000/robots.txt >$tempfile 2>&1 | ||
|
||
# Check INJECTION (in $tempfile) | ||
status=$(grep "admin1234" $tempfile) | ||
|
||
# Output result & time | ||
if [ -z "$status" ]; then | ||
echo -e "\033[0;31mFAIL\033[0m" | ||
else | ||
echo -e "\033[0;32mPASS\033[0m" | ||
fi | ||
|
||
check_1_time=$(date +%s.%N) | ||
execution_time=$(echo "$check_1_time - $start_time" | bc) | ||
echo "Execution time: $execution_time seconds" | ||
|
||
# Cleanup | ||
rm $tempfile | ||
|
File renamed without changes.
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,83 @@ | ||
# Time taken for 10000 requests, 100 injected decoy (replace) - each triggered 10 times | ||
|
||
# Configure decoys | ||
element=' | ||
{ | ||
"decoy": { | ||
"key": "somekey" | ||
}, | ||
"inject": { | ||
"store": { | ||
"inResponse": "/1", | ||
"withVerb": "GET", | ||
"as": "body", | ||
"at": { | ||
"method": "replace", | ||
"property": "((.|\n)*)" | ||
} | ||
} | ||
} | ||
} | ||
' | ||
|
||
# Create an array to store the modified elements | ||
declare -a elements | ||
|
||
# Loop through numbers from 1 to 100 and replace /1 with /<number> | ||
for ((i=1; i<=100; i++)); do | ||
modified_element=$(echo "$element" | sed "s/\/1/\/$i/") | ||
elements+=("$modified_element") | ||
done | ||
|
||
# Initialize the decoys variable | ||
config="{ \"filters\": [" | ||
|
||
for ((i=0; i<${#elements[@]}; i++)); do | ||
# Add a comma between elements except for the last one | ||
if [ $i -eq $((${#elements[@]} - 1)) ]; then | ||
config+="$(printf '%s' "${elements[$i]}")" | ||
else | ||
config+="$(printf '%s' "${elements[$i]}")," | ||
fi | ||
done | ||
|
||
config+="]}" | ||
|
||
# connect to configmanager, update /data/cad-default.json | ||
echo "$config" | docker exec -i configmanager sh -c 'cat > /data/cad-default.json' | ||
# wait a few seconds for the proxy to read the new config | ||
sleep 5 | ||
|
||
|
||
# Start timing | ||
start_time=$(date +%s.%N) | ||
|
||
# Temporary file for curl output | ||
tempfile=$(uuidgen -r) | ||
|
||
# Do relevant action(s) | ||
# Query each decoy 100 times | ||
for ((i=1; i<=100; i++)); do | ||
for ((j=1; j<=99; j++)); do | ||
curl -v "http://localhost:8000/$i" >/dev/null 2>&1 | ||
done | ||
# on the 100th time, check that the decoy was properly injected | ||
curl -v "http://localhost:8000/$i" >$tempfile 2>&1 | ||
# Check INJECTION (in $tempfile) | ||
status=$(grep "somekey" $tempfile) | ||
|
||
# Output result & time | ||
if [ -z "$status" ]; then | ||
echo -e "\033[0;31mFAIL\033[0m" | ||
else | ||
echo -e "\033[0;32mPASS\033[0m" | ||
fi | ||
done | ||
|
||
check_1_time=$(date +%s.%N) | ||
execution_time=$(echo "$check_1_time - $start_time" | bc) | ||
echo "Execution time: $execution_time seconds" | ||
|
||
# Cleanup | ||
rm $tempfile | ||
|
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,32 @@ | ||
# Time taken for 10000 requests sent directly to myapp (e.g. not through Envoy) | ||
|
||
# Start timing | ||
start_time=$(date +%s.%N) | ||
|
||
# Temporary file for curl output | ||
tempfile=$(uuidgen -r) | ||
|
||
# Do relevant action(s) | ||
for ((i=1; i<=9999; i++)); do | ||
curl -v http://localhost:3000/ >/dev/null 2>&1 | ||
done | ||
# Check in the 1000th iteration that myapp is properly running | ||
curl -v http://localhost:3000/ >$tempfile 2>&1 | ||
|
||
# Check INJECTION (in $tempfile) | ||
status=$(grep "Welcome" $tempfile) | ||
|
||
# Output result & time | ||
if [ -z "$status" ]; then | ||
echo -e "\033[0;31mFAIL\033[0m" | ||
else | ||
echo -e "\033[0;32mPASS\033[0m" | ||
fi | ||
|
||
check_1_time=$(date +%s.%N) | ||
execution_time=$(echo "$check_1_time - $start_time" | bc) | ||
echo "Execution time: $execution_time seconds" | ||
|
||
# Cleanup | ||
rm $tempfile | ||
|