Skip to content

Commit 58e741e

Browse files
authored
Merge pull request #86 from JohanDevl/review/complete-project-review
review: complete project audit with critical fixes
2 parents 9cf7df0 + 23d1469 commit 58e741e

File tree

32 files changed

+6796
-76
lines changed

32 files changed

+6796
-76
lines changed

.github/dependabot.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Dependabot configuration for automated dependency updates
2+
# See: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3+
4+
version: 2
5+
updates:
6+
# Go module dependencies
7+
- package-ecosystem: "gomod"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
day: "monday"
12+
time: "06:00"
13+
timezone: "Europe/Paris"
14+
open-pull-requests-limit: 5
15+
reviewers:
16+
- "JohanDevl"
17+
commit-message:
18+
prefix: "deps"
19+
prefix-development: "deps-dev"
20+
include: "scope"
21+
labels:
22+
- "dependencies"
23+
- "go"
24+
# Group minor and patch updates
25+
groups:
26+
go-dependencies:
27+
patterns:
28+
- "*"
29+
update-types:
30+
- "minor"
31+
- "patch"
32+
# Allow direct dependencies to be updated
33+
allow:
34+
- dependency-type: "direct"
35+
- dependency-type: "indirect"
36+
37+
# Docker base images
38+
- package-ecosystem: "docker"
39+
directory: "/"
40+
schedule:
41+
interval: "weekly"
42+
day: "monday"
43+
time: "06:00"
44+
timezone: "Europe/Paris"
45+
open-pull-requests-limit: 3
46+
reviewers:
47+
- "JohanDevl"
48+
commit-message:
49+
prefix: "docker"
50+
include: "scope"
51+
labels:
52+
- "dependencies"
53+
- "docker"
54+
55+
# GitHub Actions workflows
56+
- package-ecosystem: "github-actions"
57+
directory: "/"
58+
schedule:
59+
interval: "weekly"
60+
day: "monday"
61+
time: "06:00"
62+
timezone: "Europe/Paris"
63+
open-pull-requests-limit: 3
64+
reviewers:
65+
- "JohanDevl"
66+
commit-message:
67+
prefix: "ci"
68+
include: "scope"
69+
labels:
70+
- "dependencies"
71+
- "github-actions"
72+
# Group all GitHub Actions updates
73+
groups:
74+
github-actions:
75+
patterns:
76+
- "*"
77+
update-types:
78+
- "minor"
79+
- "patch"

.github/workflows/auto-tag.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
name: Auto Tag on Merge
22

3+
# ═══════════════════════════════════════════════════════════════════════════════
4+
# IMPORTANT: PAT_TOKEN Requirement
5+
# ═══════════════════════════════════════════════════════════════════════════════
6+
#
7+
# This workflow requires PAT_TOKEN secret to trigger downstream workflows.
8+
#
9+
# Why PAT_TOKEN is needed:
10+
# - GitHub Actions workflows cannot trigger other workflows using GITHUB_TOKEN
11+
# - This workflow creates tags that should trigger the CI/CD pipeline
12+
# - Without PAT_TOKEN, the Docker build workflow will NOT be triggered
13+
#
14+
# Setup instructions:
15+
# 1. Create a Personal Access Token with 'repo' and 'workflow' scopes
16+
# 2. Add it as a repository secret named 'PAT_TOKEN'
17+
# 3. See docs/CI_CD_SETUP.md for detailed instructions
18+
#
19+
# If PAT_TOKEN is not configured, the workflow falls back to GITHUB_TOKEN,
20+
# but this will NOT trigger CI/CD workflows automatically.
21+
# ═══════════════════════════════════════════════════════════════════════════════
22+
323
on:
424
pull_request:
525
types:
@@ -22,6 +42,8 @@ jobs:
2242
uses: actions/checkout@v4
2343
with:
2444
fetch-depth: 0
45+
# IMPORTANT: PAT_TOKEN is required to trigger CI/CD workflows
46+
# Fallback to GITHUB_TOKEN will NOT trigger workflows
2547
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
2648

2749
- name: Set up Git
@@ -68,7 +90,8 @@ jobs:
6890
# Add PR info to tag message
6991
TAG_MESSAGE="Release $NEW_TAG from PR #${{ steps.pr_info.outputs.pr_number }}: ${{ github.event.pull_request.title }}"
7092
71-
# Create and push tag using PAT for workflow triggering
93+
# Create and push tag using PAT_TOKEN for workflow triggering
94+
# PAT_TOKEN is required to trigger ci-cd.yml workflow
7295
git tag -a "$NEW_TAG" -m "$TAG_MESSAGE"
7396
git push https://x-access-token:${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git "$NEW_TAG"
7497
@@ -97,6 +120,8 @@ jobs:
97120
- name: Trigger CI/CD for Docker Build
98121
uses: actions/github-script@v7
99122
with:
123+
# CRITICAL: PAT_TOKEN is required to trigger ci-cd.yml
124+
# GITHUB_TOKEN will NOT work for triggering workflows
100125
github-token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
101126
script: |
102127
const response = await github.rest.actions.createWorkflowDispatch({

.github/workflows/ci-cd.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,60 @@ jobs:
308308

309309
- name: Test Docker image
310310
run: |
311+
echo "🧪 Testing Docker image functionality..."
312+
311313
# Create test directories
312314
mkdir -p ./test_config ./test_logs ./test_exports
313315
314-
# Basic image test - check if it runs properly
316+
IMAGE="${{ env.REGISTRY_IMAGE }}:develop"
317+
318+
# Test 1: Help command
319+
echo "Test 1: --help command"
315320
docker run --rm \
316321
-v $(pwd)/test_config:/app/config \
317322
-v $(pwd)/test_logs:/app/logs \
318323
-v $(pwd)/test_exports:/app/exports \
319-
${{ env.REGISTRY_IMAGE }}:develop --help
324+
$IMAGE --help
325+
echo "✅ Test 1 passed: Help command works"
326+
327+
# Test 2: Version command
328+
echo "Test 2: --version command"
329+
docker run --rm $IMAGE --version
330+
echo "✅ Test 2 passed: Version command works"
320331
321-
echo "✅ Docker image tests passed successfully"
332+
# Test 3: Validate command (check config validation)
333+
echo "Test 3: validate command"
334+
docker run --rm \
335+
-v $(pwd)/config:/app/config:ro \
336+
$IMAGE validate || echo "⚠️ Validation failed (expected without credentials)"
337+
echo "✅ Test 3 completed: Validate command executed"
338+
339+
# Test 4: Check binary permissions and user
340+
echo "Test 4: Binary permissions and non-root user"
341+
docker run --rm $IMAGE sh -c "id; ls -la /app/export-trakt" 2>/dev/null || \
342+
docker run --rm --entrypoint "" $IMAGE /bin/sh -c "id; ls -la /app/export-trakt" 2>/dev/null || \
343+
echo "⚠️ Shell not available (distroless image)"
344+
echo "✅ Test 4 completed: User and permissions check"
345+
346+
# Test 5: Health check (if binary supports --version)
347+
echo "Test 5: Health check verification"
348+
docker run --rm $IMAGE --version > /dev/null && \
349+
echo "✅ Test 5 passed: Health check endpoint works" || \
350+
echo "⚠️ Test 5 failed: Health check not available"
351+
352+
# Test 6: Volume mounts writable
353+
echo "Test 6: Volume mount permissions"
354+
docker run --rm \
355+
-v $(pwd)/test_exports:/app/exports \
356+
--entrypoint "" \
357+
$IMAGE sh -c "touch /app/exports/test.txt && rm /app/exports/test.txt" 2>/dev/null && \
358+
echo "✅ Test 6 passed: Export volume is writable" || \
359+
echo "⚠️ Test 6: Could not test volume permissions (expected for distroless)"
360+
361+
echo ""
362+
echo "═══════════════════════════════════════════════════════"
363+
echo "✅ Docker image tests completed successfully"
364+
echo "═══════════════════════════════════════════════════════"
322365
323366
# Job 4: Notification and Summary
324367
notify:

.github/workflows/docker-cleanup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
types: [closed]
66
branches: ["main", "develop"]
77
schedule:
8-
# Cleanup obsolete images daily at 2:00 AM UTC
9-
- cron: '0 2 * * *'
8+
# Cleanup obsolete images daily at 6:00 AM UTC (after tag monitoring at 2 AM)
9+
- cron: '0 6 * * *'
1010
workflow_dispatch:
1111

1212
env:

.github/workflows/docker-tag-monitor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Docker Tag Monitor
22

33
on:
44
schedule:
5-
# Run once daily at 6 AM UTC to check for missing Docker images
6-
- cron: '0 6 * * *'
5+
# Run once daily at 2 AM UTC to check for missing Docker images (before cleanup at 6 AM)
6+
- cron: '0 2 * * *'
77
workflow_dispatch:
88
inputs:
99
reason:

.github/workflows/go-tests.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v4
2020
with:
21-
go-version: "1.21"
21+
go-version: "1.23"
2222
cache: true
2323

2424
- name: Install dependencies

.github/workflows/security-scan.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,45 @@ jobs:
4949
# Create output directory
5050
mkdir -p security-reports
5151
52-
# Run gosec with error handling
53-
gosec -fmt sarif -out gosec-results.sarif ./... || {
54-
echo "❌ gosec scan failed with exit code $?"
55-
echo "Attempting to run with different format for debugging..."
56-
gosec -fmt text ./... || true
57-
echo "Creating empty SARIF file to prevent upload failure..."
58-
echo '{"version":"2.1.0","$schema":"https://json.schemastore.org/sarif-2.1.0.json","runs":[{"tool":{"driver":{"name":"gosec","version":"0.0.0"}},"results":[]}]}' > gosec-results.sarif
59-
}
52+
# Run gosec and capture exit code
53+
EXIT_CODE=0
54+
gosec -fmt sarif -out gosec-results.sarif ./... || EXIT_CODE=$?
55+
56+
# Check if scan completed successfully
57+
if [ $EXIT_CODE -ne 0 ]; then
58+
echo "❌ gosec scan failed with exit code $EXIT_CODE"
59+
60+
# If SARIF file was created despite exit code (warnings treated as errors)
61+
if [ -f "gosec-results.sarif" ] && [ -s "gosec-results.sarif" ]; then
62+
echo "⚠️ SARIF file exists - scan completed with warnings/issues"
63+
echo "Scan will be marked as failed but results will be uploaded"
64+
# Continue to upload results but mark as failed
65+
else
66+
echo "❌ CRITICAL: gosec scan failed without producing results"
67+
echo "Attempting to run with text format for debugging..."
68+
gosec -fmt text ./... || true
69+
echo ""
70+
echo "🚨 SECURITY SCAN FAILURE - Please fix issues and re-run"
71+
exit 1
72+
fi
73+
fi
6074
6175
# Verify the SARIF file was created
62-
if [ -f "gosec-results.sarif" ]; then
76+
if [ -f "gosec-results.sarif" ] && [ -s "gosec-results.sarif" ]; then
6377
echo "✅ SARIF file created successfully"
6478
echo "File size: $(wc -c < gosec-results.sarif) bytes"
6579
echo "First few lines:"
6680
head -10 gosec-results.sarif || true
6781
else
68-
echo "❌ SARIF file not found, creating empty file..."
69-
echo '{"version":"2.1.0","$schema":"https://json.schemastore.org/sarif-2.1.0.json","runs":[{"tool":{"driver":{"name":"gosec","version":"0.0.0"}},"results":[]}]}' > gosec-results.sarif
82+
echo "❌ CRITICAL: SARIF file not found or empty"
83+
echo "🚨 SECURITY SCAN FAILURE - Cannot proceed without scan results"
84+
exit 1
85+
fi
86+
87+
# If we had issues detected, fail the job
88+
if [ $EXIT_CODE -ne 0 ]; then
89+
echo "🚨 Security scan detected issues - failing job"
90+
exit $EXIT_CODE
7091
fi
7192
7293
- name: Upload gosec results to GitHub Security tab

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,5 @@ coverage.txt
271271
# Go workspace file
272272
go.work
273273

274-
.claude
275-
CLAUDE.md
274+
# Claude Code workspace files (not CLAUDE.md documentation files)
275+
.claude

0 commit comments

Comments
 (0)