Skip to content
Open
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
37 changes: 37 additions & 0 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Security Scan

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
security-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t myapp:latest .

- name: Install Trivy
run: |
sudo apt-get update
sudo apt-get install -y apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install -y trivy

- name: Run Trivy scan
run: trivy image myapp:latest

- name: Install Semgrep
run: |
python3 -m pip install --upgrade pip
pip install semgrep

- name: Run Semgrep SAST
run: semgrep --config p/security-audit .
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY pom.xml /app
RUN mvn clean install -DskipTests

# ---- Deploy Stage ----
FROM openjdk:11-jdk-slim
FROM eclipse-temurin:11-jre-jammy

# Copy the built JAR from the build stage
COPY --from=build /app/target/thymeleaf-0.0.1-SNAPSHOT.jar /app.jar
Expand Down
62 changes: 62 additions & 0 deletions pull_requst_desc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Zad1
Wynik z konsoli po uruchomieniu przez docer:
![zad1](https://github.com/KarolZebala/kz-tbo-task4/blob/main/zad1_wynik.png?raw=true)
# Zad2
Wynik z konsoli po uruchomieniu przez docer:
![zad1](https://github.com/KarolZebala/kz-tbo-task4/blob/main/zad2_wynik.png?raw=true)
# Zad3
Mój plik `security-scan.yml`:
``` ymlname: Security Scan'

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
security-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t myapp:latest .

- name: Install Trivy
run: |
sudo apt-get update
sudo apt-get install -y apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo "deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install -y trivy

- name: Run Trivy scan
run: trivy image myapp:latest

- name: Install Semgrep
run: |
python3 -m pip install --upgrade pip
pip install semgrep

- name: Run Semgrep SAST
run: semgrep --config p/security-audit .

```
Wynik w Github (link do akcji: https://github.com/KarolZebala/kz-tbo-task4/actions/runs/20188961555/job/57963578095):
![zad1](https://github.com/KarolZebala/kz-tbo-task4/blob/main/zad3_job.png?raw=true)

Wynik Trivy:
![zad3](https://github.com/KarolZebala/kz-tbo-task4/blob/main/zad3_trinity.png?raw=true)

Wynik Secgrep:
![zad3b](https://github.com/KarolZebala/kz-tbo-task4/blob/main/zad3_sec_grep.png?raw=true)
# Zad 4
Wygenrowany plik przez ZAP:
![zad4](https://github.com/KarolZebala/kz-tbo-task4/blob/main/zad4_raport.png?raw=true)

## Wnioski
Przeprowadzone testy bezpieczeństwa pokazały, że mimo braku wykrytych podatności w analizie statycznej kodu (SAST – Semgrep), aplikacja nie jest wolna od ryzyk bezpieczeństwa: analiza zależności (SCA – Trivy) ujawniła liczne podatności, w tym krytyczne i wysokiego ryzyka w bibliotekach Java (m.in. Tomcat, H2, Jackson, Logback), natomiast analiza dynamiczna (DAST – OWASP ZAP) wykazała problemy konfiguracyjne i runtime’owe, takie jak brak ochrony CSRF, CSP oraz nagłówków bezpieczeństwa i nieprawidłowe zarządzanie sesją. Wyniki te potwierdzają, że dopiero połączenie SAST, SCA i DAST daje pełny obraz bezpieczeństwa aplikacji, gdyż każda z metod identyfikuje inny typ zagrożeń.

Binary file added zad1_wynik.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zad2_wynik.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zad3_job.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zad3_sec_grep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zad3_trinity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zad4_raport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions zap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
env:
contexts:
- excludePaths: []
name: baseline
urls:
- http://host.docker.internal:8080
parameters:
failOnError: true
progressToStdout: false
jobs:
- parameters:
enableTags: false
maxAlertsPerRule: 10
type: passiveScan-config
- parameters:
maxDuration: 1
url: http://host.docker.internal:8080
type: spider
- parameters:
maxDuration: 0
type: passiveScan-wait
- parameters:
format: Long
summaryFile: /home/zap/zap_out.json
rules: []
type: outputSummary
- parameters:
reportDescription: ''
reportDir: /zap/wrk/
reportFile: zap_report.html
reportTitle: ZAP Scanning Report
template: traditional-html
type: report
3,308 changes: 3,308 additions & 0 deletions zap_report.html

Large diffs are not rendered by default.