Skip to content

Commit 360795d

Browse files
authored
Merge pull request #2108 from OWASP/update-readme
Update readme and other instructions
2 parents de8c76d + 50abe2e commit 360795d

20 files changed

+1428
-46
lines changed

.github/workflows/pr-preview.yml

Lines changed: 500 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Version Sync Check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'pom.xml'
7+
- 'Dockerfile'
8+
- 'Dockerfile.web'
9+
push:
10+
branches: [master, main]
11+
12+
jobs:
13+
version-check:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 23
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: "23"
23+
distribution: "oracle"
24+
cache: "maven"
25+
26+
- name: Validate version consistency
27+
run: |
28+
chmod +x ./scripts/validate-versions.sh
29+
./scripts/validate-versions.sh
30+
31+
- name: Comment on PR if versions are out of sync
32+
if: failure() && github.event_name == 'pull_request'
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const comment = `🚨 **Version Sync Issue Detected**
37+
38+
The versions in your Dockerfiles don't match the version in \`pom.xml\`.
39+
40+
**🔧 To fix this automatically:**
41+
\`\`\`bash
42+
./scripts/sync-versions.sh
43+
git add Dockerfile Dockerfile.web
44+
git commit -m "Sync versions with pom.xml"
45+
\`\`\`
46+
47+
**📋 Current status:**
48+
- The \`validate-versions.sh\` script found mismatched versions
49+
- Please ensure all Docker build arguments match the Maven project version
50+
- This helps maintain consistency across all deployment methods
51+
52+
---
53+
<sub>Automated version check by GitHub Actions</sub>`;
54+
55+
github.rest.issues.createComment({
56+
issue_number: context.issue.number,
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
body: comment
60+
});

.github/workflows/visual-diff.yml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: Visual Template Diff
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'src/main/resources/templates/**'
7+
- 'src/main/resources/static/**'
8+
9+
jobs:
10+
visual-diff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout PR code
14+
uses: actions/checkout@v4
15+
with:
16+
path: pr-code
17+
18+
- name: Checkout main branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: master
22+
path: main-code
23+
24+
- name: Set up JDK 23 for PR build
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: "23"
28+
distribution: "oracle"
29+
cache: "maven"
30+
31+
- name: Extract PR version
32+
id: extract-pr-version
33+
working-directory: pr-code
34+
run: |
35+
echo "Extracting PR version..."
36+
chmod +x ./mvnw
37+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
38+
DOCKER_VERSION=${VERSION%-SNAPSHOT}
39+
echo "version=$VERSION" >> $GITHUB_OUTPUT
40+
echo "docker_version=$DOCKER_VERSION" >> $GITHUB_OUTPUT
41+
echo "PR version: $VERSION"
42+
43+
- name: Build PR version
44+
working-directory: pr-code
45+
run: |
46+
echo "Building PR version..."
47+
./mvnw --no-transfer-progress clean package -DskipTests
48+
echo "PR JAR built successfully"
49+
docker build --build-arg argBasedVersion="${{ steps.extract-pr-version.outputs.docker_version }}" -t wrongsecrets-pr .
50+
echo "PR Docker image built successfully"
51+
52+
- name: Set up JDK 23 for main build
53+
uses: actions/setup-java@v4
54+
with:
55+
java-version: "23"
56+
distribution: "oracle"
57+
cache: "maven"
58+
59+
- name: Extract main version
60+
id: extract-main-version
61+
working-directory: main-code
62+
run: |
63+
echo "Extracting main version..."
64+
chmod +x ./mvnw
65+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
66+
DOCKER_VERSION=${VERSION%-SNAPSHOT}
67+
echo "version=$VERSION" >> $GITHUB_OUTPUT
68+
echo "docker_version=$DOCKER_VERSION" >> $GITHUB_OUTPUT
69+
echo "Main version: $VERSION"
70+
71+
- name: Build main version
72+
working-directory: main-code
73+
run: |
74+
echo "Building main version..."
75+
./mvnw --no-transfer-progress clean package -DskipTests
76+
echo "Main JAR built successfully"
77+
docker build --build-arg argBasedVersion="${{ steps.extract-main-version.outputs.docker_version }}" -t wrongsecrets-main .
78+
echo "Main Docker image built successfully"
79+
80+
- name: Start both versions
81+
run: |
82+
docker run -d -p 8080:8080 --name pr-version wrongsecrets-pr
83+
docker run -d -p 8081:8080 --name main-version wrongsecrets-main
84+
85+
# Wait for containers to start
86+
echo "Waiting for containers to start..."
87+
sleep 30
88+
89+
# Verify containers are running
90+
if ! docker ps --filter "name=pr-version" --filter "status=running" --quiet | grep -q .; then
91+
echo "PR version container failed to start"
92+
docker logs pr-version
93+
exit 1
94+
fi
95+
96+
if ! docker ps --filter "name=main-version" --filter "status=running" --quiet | grep -q .; then
97+
echo "Main version container failed to start"
98+
docker logs main-version
99+
exit 1
100+
fi
101+
102+
# Wait for services to be ready
103+
echo "Waiting for services to be ready..."
104+
timeout 60 bash -c 'until curl -f http://localhost:8080/actuator/health 2>/dev/null; do sleep 2; done' || echo "PR version health check failed"
105+
timeout 60 bash -c 'until curl -f http://localhost:8081/actuator/health 2>/dev/null; do sleep 2; done' || echo "Main version health check failed"
106+
107+
- name: Setup Node.js
108+
uses: actions/setup-node@v4
109+
with:
110+
node-version: '18'
111+
112+
- name: Install Playwright
113+
run: |
114+
npm install playwright@latest
115+
npx playwright install --with-deps chromium
116+
117+
- name: Take screenshots
118+
run: |
119+
mkdir -p screenshots
120+
121+
# Verify services are running
122+
echo "Verifying services are running..."
123+
docker ps --filter "name=pr-version" --format "table {{.Names}}\t{{.Status}}"
124+
docker ps --filter "name=main-version" --format "table {{.Names}}\t{{.Status}}"
125+
126+
# Screenshot main pages with error handling
127+
node -e "
128+
const { chromium } = require('playwright');
129+
(async () => {
130+
const browser = await chromium.launch({ headless: true });
131+
const page = await browser.newPage();
132+
await page.setViewportSize({ width: 1280, height: 1024 });
133+
134+
try {
135+
// PR version screenshots
136+
console.log('Taking PR screenshots...');
137+
await page.goto('http://localhost:8080', { waitUntil: 'networkidle', timeout: 30000 });
138+
await page.screenshot({ path: 'screenshots/pr-home.png', fullPage: true });
139+
140+
await page.goto('http://localhost:8080/about', { waitUntil: 'networkidle', timeout: 30000 });
141+
await page.screenshot({ path: 'screenshots/pr-about.png', fullPage: true });
142+
143+
// Main version screenshots
144+
console.log('Taking main branch screenshots...');
145+
await page.goto('http://localhost:8081', { waitUntil: 'networkidle', timeout: 30000 });
146+
await page.screenshot({ path: 'screenshots/main-home.png', fullPage: true });
147+
148+
await page.goto('http://localhost:8081/about', { waitUntil: 'networkidle', timeout: 30000 });
149+
await page.screenshot({ path: 'screenshots/main-about.png', fullPage: true });
150+
151+
} catch (error) {
152+
console.error('Screenshot error:', error);
153+
process.exit(1);
154+
} finally {
155+
await browser.close();
156+
}
157+
})();
158+
"
159+
160+
- name: Upload screenshots
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: visual-diff-${{ github.event.number }}
164+
path: screenshots/
165+
166+
- name: Comment with visual diff
167+
uses: actions/github-script@v7
168+
with:
169+
script: |
170+
const comment = `📸 **Visual Diff Available!**
171+
172+
Screenshots have been generated comparing your changes with the main branch.
173+
174+
[Download Visual Diff Artifacts](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
175+
176+
The artifacts contain:
177+
- \`pr-home.png\` - Your version of the home page
178+
- \`main-home.png\` - Current main branch home page
179+
- \`pr-about.png\` - Your version of the about page
180+
- \`main-about.png\` - Current main branch about page
181+
182+
Compare these images to see the visual impact of your changes!
183+
184+
---
185+
<sub>Visual diff generated by GitHub Actions</sub>`;
186+
187+
github.rest.issues.createComment({
188+
issue_number: context.issue.number,
189+
owner: context.repo.owner,
190+
repo: context.repo.repo,
191+
body: comment
192+
});

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM bellsoft/liberica-openjre-debian:23.0.2-9-cds AS builder
22
WORKDIR /builder
33

4-
ARG argBasedVersion="1.12.1"
4+
ARG argBasedVersion="1.12.3B2"
55

66
COPY --chown=wrongsecrets target/wrongsecrets-${argBasedVersion}-SNAPSHOT.jar application.jar
77
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted

Dockerfile.web

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FROM jeroenwillemsen/wrongsecrets:1.12.2A-no-vault
2-
ARG argBasedVersion="1.12.2A-no-vault"
1+
FROM jeroenwillemsen/wrongsecrets:1.12.3B2-no-vault
2+
ARG argBasedVersion="1.12.3B2-no-vault"
33
ARG CANARY_URLS="http://canarytokens.com/terms/about/s7cfbdakys13246ewd8ivuvku/post.jsp,http://canarytokens.com/terms/about/y0all60b627gzp19ahqh7rl6j/post.jsp"
44
ARG CTF_ENABLED=false
55
ARG HINTS_ENABLED=true

0 commit comments

Comments
 (0)