Skip to content

Commit 6151d40

Browse files
authored
Merge pull request #2227 from OWASP/copilot/fix-2226
Fix dotnet installation failure and add GHCR support for wrongsecrets-desktop containers
2 parents 4d894d1 + 328bddb commit 6151d40

File tree

3 files changed

+153
-11
lines changed

3 files changed

+153
-11
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Build and Publish Desktop Containers
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
build-and-publish-desktop:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
container:
19+
- name: "webdesktop"
20+
dockerfile: "Dockerfile_webdesktop"
21+
image_name: "wrongsecrets-desktop"
22+
- name: "webdesktop-k8s"
23+
dockerfile: "Dockerfile_webdesktopk8s"
24+
image_name: "wrongsecrets-desktop-k8s"
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v5
28+
29+
- name: Set up JDK 23
30+
uses: actions/setup-java@v5
31+
with:
32+
java-version: "23"
33+
distribution: "temurin"
34+
cache: "maven"
35+
36+
- name: Extract version from pom.xml
37+
id: extract-version
38+
run: |
39+
echo "Extracting version from pom.xml..."
40+
chmod +x ./mvnw
41+
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
42+
DOCKER_VERSION=${VERSION%-SNAPSHOT}
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
echo "docker_version=$DOCKER_VERSION" >> $GITHUB_OUTPUT
45+
echo "Detected version: $VERSION"
46+
echo "Docker version: $DOCKER_VERSION"
47+
48+
- name: Build application
49+
run: ./mvnw --no-transfer-progress clean package -DskipTests
50+
51+
- name: Verify JAR file was created
52+
run: |
53+
echo "Checking target directory..."
54+
ls -la target/
55+
echo "Looking for JAR files..."
56+
find target/ -name "*.jar" -type f
57+
echo "Verifying specific JAR exists..."
58+
JAR_FILE="target/wrongsecrets-${{ steps.extract-version.outputs.version }}.jar"
59+
if [ -f "$JAR_FILE" ]; then
60+
echo "✅ JAR file found: $JAR_FILE"
61+
ls -la "$JAR_FILE"
62+
else
63+
echo "❌ Expected JAR file not found: $JAR_FILE"
64+
echo "Available JAR files:"
65+
find target/ -name "*.jar" -type f || echo "No JAR files found"
66+
exit 1
67+
fi
68+
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
72+
- name: Log in to GitHub Container Registry
73+
uses: docker/login-action@v3
74+
with:
75+
registry: ghcr.io
76+
username: ${{ github.actor }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Extract metadata
80+
id: meta
81+
uses: docker/metadata-action@v5
82+
with:
83+
images: ghcr.io/${{ github.repository }}/${{ matrix.image_name }}
84+
tags: |
85+
type=ref,event=branch
86+
type=raw,value=latest-master
87+
type=sha,prefix={{branch}}-
88+
89+
- name: Create secret file for build
90+
run: |
91+
echo "wrongsecret-3" > /tmp/mysecret.txt
92+
93+
- name: Build and push Docker image
94+
id: build
95+
uses: docker/build-push-action@v6
96+
with:
97+
platforms: linux/amd64,linux/arm64
98+
context: .
99+
file: ${{ matrix.dockerfile }}
100+
push: true
101+
tags: ${{ steps.meta.outputs.tags }}
102+
labels: ${{ steps.meta.outputs.labels }}
103+
build-args: |
104+
argBasedVersion=${{ steps.extract-version.outputs.docker_version }}
105+
secrets: |
106+
mysecret=/tmp/mysecret.txt
107+
cache-from: type=gha,scope=${{ matrix.name }}
108+
cache-to: type=gha,mode=max,scope=${{ matrix.name }}
109+
110+
- name: Verify Docker image was built
111+
run: |
112+
echo "Verifying Docker image was built successfully..."
113+
echo "Container: ${{ matrix.name }}"
114+
echo "Dockerfile: ${{ matrix.dockerfile }}"
115+
echo "Image tags: ${{ steps.meta.outputs.tags }}"
116+
echo "Image digest: ${{ steps.build.outputs.digest }}"
117+
118+
create-summary:
119+
runs-on: ubuntu-latest
120+
needs: build-and-publish-desktop
121+
steps:
122+
- name: Create Release Summary
123+
run: |
124+
echo "## 🖥️ Desktop Containers Published" >> $GITHUB_STEP_SUMMARY
125+
echo "" >> $GITHUB_STEP_SUMMARY
126+
echo "**📦 Container Images Published:**" >> $GITHUB_STEP_SUMMARY
127+
echo "" >> $GITHUB_STEP_SUMMARY
128+
echo "- \`ghcr.io/${{ github.repository }}/wrongsecrets-desktop:latest-master\`" >> $GITHUB_STEP_SUMMARY
129+
echo "- \`ghcr.io/${{ github.repository }}/wrongsecrets-desktop-k8s:latest-master\`" >> $GITHUB_STEP_SUMMARY
130+
echo "" >> $GITHUB_STEP_SUMMARY
131+
echo "**🐳 Try the desktop environments:**" >> $GITHUB_STEP_SUMMARY
132+
echo "" >> $GITHUB_STEP_SUMMARY
133+
echo "**Standard Desktop:**" >> $GITHUB_STEP_SUMMARY
134+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
135+
echo "docker pull ghcr.io/${{ github.repository }}/wrongsecrets-desktop:latest-master" >> $GITHUB_STEP_SUMMARY
136+
echo "docker run -d -p 3000:3000 ghcr.io/${{ github.repository }}/wrongsecrets-desktop:latest-master" >> $GITHUB_STEP_SUMMARY
137+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
138+
echo "" >> $GITHUB_STEP_SUMMARY
139+
echo "**Kubernetes Desktop:**" >> $GITHUB_STEP_SUMMARY
140+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
141+
echo "docker pull ghcr.io/${{ github.repository }}/wrongsecrets-desktop-k8s:latest-master" >> $GITHUB_STEP_SUMMARY
142+
echo "docker run -d -p 3000:3000 ghcr.io/${{ github.repository }}/wrongsecrets-desktop-k8s:latest-master" >> $GITHUB_STEP_SUMMARY
143+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
144+
echo "" >> $GITHUB_STEP_SUMMARY
145+
echo "Then visit: http://localhost:3000" >> $GITHUB_STEP_SUMMARY

Dockerfile_webdesktop

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN \
99

1010
RUN \
1111
echo "**** install packages ****" && \
12-
apk add --no-cache shadow keepassxc radare2 aws-cli geany git gdb build-base icu-libs icu-data-full&& \
12+
apk add --no-cache shadow keepassxc radare2 aws-cli geany git gdb build-base icu-libs icu-data-full ca-certificates libgcc libstdc++ zlib && \
1313
echo "**** adding abc user to root for Docker ****" && \
1414
usermod -aG root abc && \
1515
touch /var/run/docker.sock && \
@@ -18,14 +18,13 @@ RUN \
1818
rm -rf /tmp/*
1919

2020
RUN \
21-
export DOTNET_INSTALL_DIR="/etc/dotnet" && \
2221
echo "installing dotnet" && \
2322
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
2423
chmod +x dotnet-install.sh && \
25-
./dotnet-install.sh --version latest && \
24+
./dotnet-install.sh --install-dir /etc/dotnet --version latest && \
2625
export DOTNET_ROOT=/etc/dotnet && \
27-
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools && \
28-
export PATH="$PATH:/config/.dotnet/tools" &&\
26+
export PATH="/etc/dotnet:/etc/dotnet/tools:$PATH" && \
27+
dotnet --info && \
2928
dotnet tool install ilspycmd --version 9.0.0.7889 --tool-path /etc/dotnet/tools
3029

3130
# Add secret handling for Kubernetes-specific Docker builds
@@ -47,5 +46,4 @@ COPY src/main/resources/executables/secrchallenge.json /var/tmp/wrongsecrets/
4746
COPY src/test/resources/alibabacreds.kdbx /var/tmp/wrongsecrets/
4847
COPY wrongsecret-desktop-resources/welcome.md /var/tmp/wrongsecrets/
4948

50-
5149
COPY wrongsecret-desktop-resources/startwm.sh /defaults/startwm.sh

Dockerfile_webdesktopk8s

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN \
99

1010
RUN \
1111
echo "**** install packages ****" && \
12-
apk add --no-cache shadow keepassxc radare2 aws-cli geany git gdb build-base icu-libs icu-data-full && \
12+
apk add --no-cache shadow keepassxc radare2 aws-cli geany git gdb build-base icu-libs icu-data-full ca-certificates libgcc libstdc++ zlib && \
1313
echo "**** adding abc user to root for Docker ****" && \
1414
usermod -aG root abc && \
1515
touch /var/run/docker.sock && \
@@ -23,14 +23,13 @@ RUN echo "**** clone wrongsecrets.git for webtop in k8s ****" && \
2323
git clone https://github.com/OWASP/wrongsecrets.git
2424

2525
RUN \
26-
export DOTNET_INSTALL_DIR="/etc/dotnet" && \
2726
echo "installing dotnet" && \
2827
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && \
2928
chmod +x dotnet-install.sh && \
30-
./dotnet-install.sh --version latest && \
29+
./dotnet-install.sh --install-dir /etc/dotnet --version latest && \
3130
export DOTNET_ROOT=/etc/dotnet && \
32-
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools && \
33-
export PATH="$PATH:/config/.dotnet/tools" &&\
31+
export PATH="/etc/dotnet:/etc/dotnet/tools:$PATH" && \
32+
dotnet --info && \
3433
dotnet tool install ilspycmd --version 9.0.0.7889 --tool-path /etc/dotnet/tools
3534

3635
# Add a secret using --mount and write it to a specific file path for the challenge

0 commit comments

Comments
 (0)