Skip to content
Merged
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
26 changes: 26 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Victim Project Profiles

on:
pull_request:
push:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v4

- name: 🧰 Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Benign Test
run: ./tests/benign.sh

- name: Malicious Test
run: ./tests/malicious.sh
47 changes: 47 additions & 0 deletions tests/benign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

set -e

cd java/maven/abstract-project/install-me-first
mvn clean install -q
cd ../victim

declare -A profiles=(
[shade]="target/victim-1.0.jar"
[assembly]="target/victim-1.0-jar-with-dependencies.jar"
[spring]="target/victim-1.0-spring-boot.jar"
[jar]="target/victim-1.0.jar"
[quarkus]="target/victim-1.0-quarkus.jar"
[bundle]="target/victim-1.0.jar"
)

any_failed=0

for profile in "${!profiles[@]}"; do
echo "=============================="
echo "Building with profile: $profile"
mvn clean package -P"$profile" -q

jar_file="${profiles[$profile]}"
echo "Running: java -jar $jar_file"

output=$(java -jar "$jar_file")

if ! echo "$output" | grep -q "88.*88.*88"; then
echo "[PASS] Profile '$profile' passed the output check."
else
echo "[FAIL] Profile '$profile' failed the output check."
echo "-------- Output Start --------"
echo "$output"
echo "--------- Output End ---------"
any_failed=1
fi
done

if [ "$any_failed" -eq 1 ]; then
echo "❌ One or more profiles failed. Exiting with code 1."
exit 1
else
echo "✅ All profiles passed."
exit 0
fi
47 changes: 47 additions & 0 deletions tests/malicious.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

set -e

cd java/maven/abstract-project/install-me-first
mvn clean install -Pinject -q
cd ../victim

declare -A profiles=(
[shade]="target/victim-1.0.jar"
[assembly]="target/victim-1.0-jar-with-dependencies.jar"
[spring]="target/victim-1.0-spring-boot.jar"
[jar]="target/victim-1.0.jar"
[quarkus]="target/victim-1.0-quarkus.jar"
[bundle]="target/victim-1.0.jar"
)

any_failed=0

for profile in "${!profiles[@]}"; do
echo "=============================="
echo "Building with profile: $profile"
mvn clean package -P"$profile" -q

jar_file="${profiles[$profile]}"
echo "Running: java -jar $jar_file"

output=$(java -jar "$jar_file")

if echo "$output" | grep -q "88.*88.*88"; then
echo "[PASS] Profile '$profile' passed the output check."
else
echo "[FAIL] Profile '$profile' failed the output check."
echo "-------- Output Start --------"
echo "$output"
echo "--------- Output End ---------"
any_failed=1
fi
done

if [ "$any_failed" -eq 1 ]; then
echo "❌ One or more profiles failed. Exiting with code 1."
exit 1
else
echo "✅ All profiles passed."
exit 0
fi
Loading