Skip to content

Commit 15442ab

Browse files
committed
Resolved vunlerabilities (run was under root account; old image had CVEs)
1 parent 9777c3e commit 15442ab

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.sh text eol=lf
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Trivy
2+
3+
permissions:
4+
contents: read
5+
actions: read
6+
security-events: write
7+
8+
on:
9+
pull_request:
10+
workflow_dispatch:
11+
push:
12+
branches:
13+
- master
14+
jobs:
15+
build:
16+
name: Scan
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/[email protected]
21+
22+
- name: Run Trivy vulnerability scanner in repo mode
23+
uses: aquasecurity/[email protected]
24+
with:
25+
scan-type: 'fs'
26+
scanners: 'vuln,misconfig,secret'
27+
ignore-unfixed: true
28+
format: 'sarif'
29+
output: 'trivy-results.sarif'
30+
severity: 'CRITICAL'
31+
32+
- name: Upload Trivy scan results to GitHub Security tab
33+
uses: github/codeql-action/[email protected]
34+
with:
35+
sarif_file: 'trivy-results.sarif'

Dockerfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
1-
FROM n0madic/alpine-gcc:9.2.0
2-
RUN apk add --quiet --no-cache libressl-dev
1+
FROM frolvlad/alpine-gcc:latest
2+
RUN apk add --quiet --no-cache libressl-dev make
3+
4+
# Create non-root user and group
5+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
6+
37
COPY ./*.h /opt/src/
48
COPY ./*.c /opt/src/
59
COPY Makefile /opt/src/
610
COPY entrypoint.sh /
7-
#RUN apt-get install libssl-dev
11+
812
WORKDIR /opt/src
913
RUN make
1014
RUN make OPENSSL=/usr/local/opt/openssl/include OPENSSL_LIB=-L/usr/local/opt/openssl/lib
1115
RUN ["chmod", "+x", "/entrypoint.sh"]
1216
RUN ["chmod", "+x", "/opt/src/jwtcrack"]
17+
18+
# Change ownership to non-root user
19+
RUN chown -R appuser:appgroup /opt/src /entrypoint.sh
20+
21+
USER appuser
22+
23+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["/opt/src/jwtcrack", "--version"] || exit 1
24+
1325
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
/opt/src/jwtcrack $@

main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ void usage(const char *cmd, const char *alphabet, const size_t max_len, const ch
169169

170170
int main(int argc, char **argv) {
171171

172+
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
173+
printf("jwtcrack version 1.0.0\n");
174+
return 0;
175+
}
176+
172177
const EVP_MD *evp_md;
173178
size_t max_len = 6;
174179

0 commit comments

Comments
 (0)