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

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

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

steps:
- name: Check out code
uses: actions/checkout@v2

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


- name: Run Trivy scan
uses: aquasecurity/trivy-action@0.29.0
with:
image-ref: 'myapp:latest'
vuln-type: 'os,library'
format: 'table'


- name: Install Semgrep
run: |
sudo pip install semgrep --ignore-installed rich

- name: Run Semgrep SAST
run: |
semgrep --config p/security-audit --error --json .
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
33 changes: 33 additions & 0 deletions Lab 4 Patryk Średniawa 303638.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Zad 1: Trivy na lokalnie zbudowanym obrazie Dockera

Po uruchomieniu aplikacji w dockerze otrzymujemy:

![zad1](img/zad1.png)

## Zad2: SAST z wykorzystaniem Semgrep
Po uruchomieniu aplikacji w dockerze otrzymujemy:
![zad2](img/zad2.png)
## Zad 3: Przygotowanie procesu CI/CD z wykorzystaniem Trivy i Semgrep

W ramach zadania stworzono plik security-scan.yml. Sporo prób było nieudanych z różnych powodów. Najpierw Trivy, następnie Semgrep.
![Probyskanowania](img/Probyskanowania.png)

Ostatecznie udało się:
![udanySkan](img/udanySkan.png)
Link do zadania, gdzie są wyniki testów:
https://github.com/PatrykSredniawa/task4/actions/runs/20244296967/job/58120214389

## Zadanie 4: ## Uruchomienie aplikacji lokalnie + DAST z wykorzystaniem ZAP
![zap](img/zap.png)

Wykryto szereg podatności takie jak:
- Absensce of anti-CSRF tokens
- Content Security Policy (CSP) Header Not Set
- Missing Anti-clickjacking header
i wiele wiele innych.

Pokazuje to zalety skanowania dynamicznego. Umożliwia wykrycie podatności, które można ominąc w skanowaniu statycznym bądź je po prostu nie wykryć.
Każde z użytych narzędzi koncentruje się na innym obszarze, przez co wyniki mogą się różnić.
Analiza z użyciem Trivy wykryła podatności związane z bibliotekami Java, wiele z nich miało wysokie ryzyko.
Natomiast analiza dynamiczna z użyciem ZAP umożliwiło wykrycie błędów przede wszystkim konfiguracyjncyh.
Sprawdza przede wszystkim zachowanie aplikacji zamiast samego kodu.
Binary file added img/Probyskanowania.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 img/udanySkan.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 img/zad1.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 img/zad1Java.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 img/zad2.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 img/zap.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,531 changes: 3,531 additions & 0 deletions zap_report.html

Large diffs are not rendered by default.