Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
faaa47c
feat: add Dockerfile for Trivy version tracking
hassaansaleem28 Jan 30, 2026
9f4a200
build: add dynamic Trivy versioning and caching to root Makefile
hassaansaleem28 Jan 30, 2026
14d9ca2
build(backend): implement standardized security scan target
hassaansaleem28 Jan 30, 2026
9750683
build(frontend): implement standardized security scan target
hassaansaleem28 Jan 30, 2026
e58c7b5
ci: refactor workflow to use Makefile targets for security scans
hassaansaleem28 Jan 30, 2026
23a0a53
style: apply pre-commit auto-fixes
hassaansaleem28 Jan 30, 2026
e29eea7
Merge branch 'main' into refactor/ci-use-makefile-security-scans
hassaansaleem28 Jan 30, 2026
4ed573a
fix: add missing line continuation in security-scan-code target
hassaansaleem28 Jan 30, 2026
cf1a11a
Merge remote changes from GitHub
hassaansaleem28 Jan 30, 2026
50098ad
Merge branch 'refactor/ci-use-makefile-security-scans' of https://git…
hassaansaleem28 Jan 30, 2026
645764f
fix: restore executable permission to manage.py
hassaansaleem28 Jan 30, 2026
f494533
Update code
arkid15r Jan 30, 2026
73afcec
Merge branch 'main' into refactor/ci-use-makefile-security-scans
arkid15r Jan 30, 2026
72018c1
fix(ci): align ci workflows with makefiles
hassaansaleem28 Feb 1, 2026
34a6b66
Add dependabot tracking
hassaansaleem28 Feb 1, 2026
fe1b5f6
Merge branch 'main' into refactor/ci-use-makefile-security-scans
hassaansaleem28 Feb 1, 2026
2075f0c
fix(docker): pin npm version and preserve build cache
hassaansaleem28 Feb 1, 2026
1836bef
Merge branch 'refactor/ci-use-makefile-security-scans' of https://git…
hassaansaleem28 Feb 1, 2026
307ad4d
Merge branch 'main' into refactor/ci-use-makefile-security-scans
hassaansaleem28 Feb 1, 2026
7be1e25
Update .github/workflows/run-ci-cd.yaml
hassaansaleem28 Feb 3, 2026
5a4a940
ci: remove redundant trivy setup step
hassaansaleem28 Feb 3, 2026
0457d82
Merge branch 'refactor/ci-use-makefile-security-scans' of https://git…
hassaansaleem28 Feb 3, 2026
28fcf37
Merge branch 'main' into refactor/ci-use-makefile-security-scans
hassaansaleem28 Feb 3, 2026
a32c533
Merge branch 'main' into refactor/ci-use-makefile-security-scans
arkid15r Feb 3, 2026
dea9aae
fix(ci): optimize trivy scans and resolve build vulnerabilities
hassaansaleem28 Feb 4, 2026
3305cd3
Merge branch 'main' into refactor/ci-use-makefile-security-scans
hassaansaleem28 Feb 4, 2026
96aab6e
Update trivy.yaml to not use depracted syntax
hassaansaleem28 Feb 4, 2026
bade9ef
Merge branch 'main' into pr/hassaansaleem28/3678
arkid15r Feb 5, 2026
8c0cf8b
Update code
arkid15r Feb 5, 2026
3569a01
Merge branch 'main' into refactor/ci-use-makefile-security-scans
arkid15r Feb 5, 2026
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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ updates:
schedule:
interval: daily

- package-ecosystem: docker
directory: /docker/trivy
schedule:
interval: daily

- package-ecosystem: github-actions
directory: /
schedule:
Expand Down
80 changes: 24 additions & 56 deletions .github/workflows/run-ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,15 @@ jobs:
- name: Run Semgrep security scan
run: make security-scan-code-semgrep

- name: Upload Semgrep report
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
with:
name: semgrep-results-run-${{ github.run_number }}
path: semgrep-security-report.txt
retention-days: 14

- name: Setup Trivy
uses: aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514
- name: Cache Trivy DB
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
with:
cache: true
path: .trivy-cache
key: trivy-${{ runner.os }}-${{ hashFiles('docker/trivy/Dockerfile') }}
restore-keys: trivy-${{ runner.os }}-

- name: Run Trivy security scan
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8
with:
scan-type: fs
skip-setup-trivy: true
trivy-config: trivy.yaml
run: make security-scan-code-trivy SCANNERS=misconfig,secret,vuln
timeout-minutes: 5

run-backend-tests:
Expand Down Expand Up @@ -551,28 +541,17 @@ jobs:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Setup Trivy
uses: aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514
- name: Cache Trivy DB
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
with:
cache: true
path: .trivy-cache
key: trivy-${{ runner.os }}-${{ hashFiles('docker/trivy/Dockerfile') }}
restore-keys: trivy-${{ runner.os }}-

- name: Scan backend image
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8
with:
exit-code: 1
image-ref: owasp/nest:backend-staging
scan-type: image
skip-setup-trivy: true
trivy-config: trivy.yaml

- name: Scan frontend image
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8
with:
exit-code: 1
image-ref: owasp/nest:frontend-staging
scan-type: image
skip-setup-trivy: true
trivy-config: trivy.yaml
- name: Run Trivy security scan via Makefile
run: |
make security-scan-backend-image BACKEND_IMAGE_NAME=owasp/nest:backend-staging
make security-scan-frontend-image FRONTEND_IMAGE_NAME=owasp/nest:frontend-staging
timeout-minutes: 5

deploy-staging-nest:
Expand Down Expand Up @@ -921,28 +900,17 @@ jobs:
- name: Check out repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd

- name: Setup Trivy
uses: aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514
- name: Cache Trivy DB
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306
with:
cache: true
path: .trivy-cache
key: trivy-${{ runner.os }}-${{ hashFiles('docker/trivy/Dockerfile') }}
restore-keys: trivy-${{ runner.os }}-

- name: Scan backend image
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8
with:
exit-code: 1
image-ref: owasp/nest:backend-production
scan-type: image
skip-setup-trivy: true
trivy-config: trivy.yaml

- name: Scan frontend image
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8
with:
exit-code: 1
image-ref: owasp/nest:frontend-production
scan-type: image
skip-setup-trivy: true
trivy-config: trivy.yaml
- name: Run Trivy security scan via Makefile
run: |
make security-scan-backend-image BACKEND_IMAGE_NAME=owasp/nest:backend-production
make security-scan-frontend-image FRONTEND_IMAGE_NAME=owasp/nest:frontend-production
timeout-minutes: 5

deploy-production-nest:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ backend/fuzzing_results/
.python_history
.python-version
.ruff_cache
.trivy-cache
.venv/
.vscode
*.bak
Expand Down
30 changes: 21 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ include cspell/Makefile
include docs/Makefile
include frontend/Makefile

.PHONY: build clean check pre-commit prune run scan-images security-scan test update
.PHONY: build clean check pre-commit prune run scan-images security-scan security-scan-code \
security-scan-code-semgrep security-scan-code-trivy security-scan-images \
security-scan-backend-image security-scan-frontend-image test update \
clean-trivy-cache

MAKEFLAGS += --no-print-directory

Expand All @@ -12,7 +15,8 @@ build:

clean: \
clean-dependencies \
clean-docker
clean-docker \
clean-trivy-cache

clean-dependencies: \
clean-backend-dependencies \
Expand All @@ -23,6 +27,9 @@ clean-docker: \
clean-docs-docker \
clean-frontend-docker

clean-trivy-cache:
@rm -rf $(CURDIR)/.trivy-cache

check: \
check-spelling \
check-backend \
Expand Down Expand Up @@ -70,7 +77,8 @@ security-scan-images: \

security-scan-code-semgrep:
@echo "Running Semgrep security scan..."
@docker run --rm \
@docker run \
--rm \
-v "$(PWD):/src" \
-w /src \
$$(grep -E '^FROM semgrep/semgrep:' docker/semgrep/Dockerfile | sed 's/^FROM //') \
Expand Down Expand Up @@ -104,17 +112,21 @@ security-scan-code-semgrep:
--timeout-threshold 3 \
--text \
--text-output=semgrep-security-report.txt \
.
.

SCANNERS ?= misconfig,vuln

security-scan-code-trivy:
@echo "Running Trivy security scan..."
@docker run \
--rm \
-v "$(PWD):/src" \
-w /src \
aquasec/trivy fs \
--config trivy.yaml \
.
-e TRIVY_SCANNERS="$(SCANNERS)" \
-v $(CURDIR):/src \
-v $(CURDIR)/trivyignore.yaml:/trivyignore.yaml:ro \
-v $(CURDIR)/trivy.yaml:/trivy.yaml:ro \
-v $(CURDIR)/.trivy-cache:/root/.cache/trivy \
$$(grep -E '^FROM aquasec/trivy:' docker/trivy/Dockerfile | sed 's/^FROM //') \
fs --config /trivy.yaml /src

test: \
test-nest-app
Expand Down
25 changes: 18 additions & 7 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,24 @@ save-backup:
@CMD="python manage.py dumpdata --natural-primary --natural-foreign --indent=2" $(MAKE) exec-backend-command > backend/data/backup.json
@gzip backend/data/backup.json

security-scan-backend-image: build-backend-local-image
@trivy image \
--config trivy.yaml \
--docker-host $$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null) \
--exit-code 1 \
--severity CRITICAL,HIGH \
nest-backend-local
# vars (defaults for local dev)
BACKEND_IMAGE_NAME ?= nest-backend-local
IMAGE_SCANNERS ?= misconfig,secret,vuln

security-scan-backend-image:
@if [ "$(BACKEND_IMAGE_NAME)" = "nest-backend-local" ]; then \
$(MAKE) build-backend-local-image; \
fi
@echo "Scanning image: $(BACKEND_IMAGE_NAME)..."
@docker run \
--rm \
-e TRIVY_SCANNERS="$(IMAGE_SCANNERS)" \
-v $(CURDIR)/trivyignore.yaml:/trivyignore.yaml:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(CURDIR)/trivy.yaml:/trivy.yaml:ro \
-v $(CURDIR)/.trivy-cache:/root/.cache/trivy \
$$(grep -E '^FROM aquasec/trivy:' docker/trivy/Dockerfile | sed 's/^FROM //') \
image --config /trivy.yaml $(BACKEND_IMAGE_NAME)

shell-backend:
@CMD="/bin/sh" $(MAKE) exec-backend-command-it
Expand Down
2 changes: 1 addition & 1 deletion backend/apps/owasp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ owasp-generate-community-snapshot-video:
@mkdir -p backend/generated_videos
@docker run \
--env-file backend/.env \
--mount type=bind,src="$(PWD)/backend/generated_videos",dst=/home/owasp/generated_videos \
--mount type=bind,src="$(CURDIR)/backend/generated_videos",dst=/home/owasp/generated_videos \
--network nest-local_nest-network \
--rm \
nest-snapshot-video \
Expand Down
9 changes: 5 additions & 4 deletions cspell/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ cspell-check: cspell-install cspell-run

cspell-run:
@docker run \
--mount type=bind,src="$(PWD)",dst=/nest \
--mount type=bind,src="$(CURDIR)",dst=/nest \
--rm \
cspell -c cspell/cspell.json "$(CMD)"

update-cspell-dependencies: cspell-install
@-docker run \
-it \
--mount type=bind,src="$(PWD)",dst=/nest \
--entrypoint=/bin/sh \
--workdir=/nest/cspell \
--interactive \
--mount type=bind,src="$(CURDIR)",dst=/nest \
--rm \
--tty \
--workdir=/nest/cspell \
cspell -c "pnpm install && pnpm upgrade && rm -rf ./node_modules"
2 changes: 2 additions & 0 deletions cspell/custom-dict.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AVD
Agentic
Agsoc
Aichi
Expand Down Expand Up @@ -127,6 +128,7 @@ menteemodule_set
mentees
mern
millify
misconfig
mkv
mpim
navlink
Expand Down
3 changes: 3 additions & 0 deletions docker/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ COPY --chmod=444 .env .pnpmrc next.config.ts postcss.config.js tailwind.config.m
COPY --chmod=555 public public
COPY --chmod=555 src src

ARG FORCE_STANDALONE
ENV FORCE_STANDALONE=$FORCE_STANDALONE

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
ENV NEXT_TELEMETRY_DISABLED=1
Expand Down
1 change: 1 addition & 0 deletions docker/trivy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM aquasec/trivy:0.58.0
25 changes: 18 additions & 7 deletions frontend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ SHELL := /bin/bash

build-frontend-local-image:
@DOCKER_BUILDKIT=1 NEXT_PUBLIC_ENVIRONMENT=local docker build \
--build-arg FORCE_STANDALONE=yes \
--no-cache \
-f docker/frontend/Dockerfile \
-t nest-frontend-local \
Expand Down Expand Up @@ -56,13 +57,23 @@ generate-graphql-types:
|| (printf "pnpm run graphql-codegen"; for i in $$(seq 1 49); do printf "."; done; printf "\033[37;41mFailed\033[0m\n" \
&& pnpm run graphql-codegen))

security-scan-frontend-image: build-frontend-local-image
@trivy image \
--config trivy.yaml \
--docker-host $$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null) \
--exit-code 1 \
--severity CRITICAL,HIGH \
nest-frontend-local
FRONTEND_IMAGE_NAME ?= nest-frontend-local
IMAGE_SCANNERS ?= misconfig,secret,vuln

security-scan-frontend-image:
@if [ "$(FRONTEND_IMAGE_NAME)" = "nest-frontend-local" ]; then \
$(MAKE) build-frontend-local-image; \
fi
@echo "Scanning image: $(FRONTEND_IMAGE_NAME)..."
@docker run \
--rm \
-e TRIVY_SCANNERS="$(IMAGE_SCANNERS)" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(CURDIR)/trivy.yaml:/trivy.yaml:ro \
-v $(CURDIR)/trivyignore.yaml:/trivyignore.yaml:ro \
-v $(CURDIR)/.trivy-cache:/root/.cache/trivy \
$$(grep -E '^FROM aquasec/trivy:' docker/trivy/Dockerfile | sed 's/^FROM //') \
image --config /trivy.yaml $(FRONTEND_IMAGE_NAME)

shell-frontend:
@CMD="/bin/sh" $(MAKE) exec-frontend-command-it
Expand Down
3 changes: 2 additions & 1 deletion frontend/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { withSentryConfig } from '@sentry/nextjs'
import type { NextConfig } from 'next'

const forceStandalone = process.env.FORCE_STANDALONE === 'yes'
const isLocal = process.env.NEXT_PUBLIC_ENVIRONMENT === 'local'

const nextConfig: NextConfig = {
Expand Down Expand Up @@ -33,7 +34,7 @@ const nextConfig: NextConfig = {
productionBrowserSourceMaps: true,
serverExternalPackages: ['import-in-the-middle', 'require-in-the-middle'],
transpilePackages: ['@react-leaflet/core', 'leaflet', 'react-leaflet', 'react-leaflet-cluster'],
...(isLocal ? {} : { output: 'standalone' }),
...(isLocal && !forceStandalone ? {} : { output: 'standalone' }),
}

export default withSentryConfig(nextConfig, {
Expand Down
11 changes: 6 additions & 5 deletions trivy.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
exit-code: 1

filesystem:
skip-files:

ignorefile: trivyignore.yaml
ignorefile: /trivyignore.yaml

report: all

scan:
show-suppressed: true
skip-files:

severity:
Expand All @@ -15,7 +20,3 @@ timeout: 10m

vulnerability:
ignore-unfixed: true
security-checks:
- config
- secret
- vuln
6 changes: 6 additions & 0 deletions trivyignore.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
misconfigurations:
- id: AVD-DS-0002 # Require non-root USER in Dockerfile.
paths:
- docker/semgrep/Dockerfile
- docker/trivy/Dockerfile

vulnerabilities:
# TODO(arkid15r): Remove when v5.9.3 is no longer current.
- id: CVE-2025-64756 # glob: Command Injection Vulnerability via Malicious Filenames.