diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..50143a3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,25 @@ +version: 2 +updates: + # Go modules (go.mod lives in backend/) + - package-ecosystem: "gomod" + directory: "/backend" + schedule: + interval: "weekly" + commit-message: + prefix: "build(deps)" + + # Actions used in .github/workflows + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "ci(deps)" + + # Base images in backend/Dockerfile (golang and distroless) + - package-ecosystem: "docker" + directory: "/backend" + schedule: + interval: "weekly" + commit-message: + prefix: "build(deps)" diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml index a5d090f..e0b20b1 100644 --- a/.github/workflows/ci-backend.yml +++ b/.github/workflows/ci-backend.yml @@ -78,3 +78,22 @@ jobs: # "go run pkg@version" runs the tool without adding it to go.mod - name: govulncheck run: go run golang.org/x/vuln/cmd/govulncheck@latest ./... + + image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # Build the same image the deploy will use. This alone proves the + # Dockerfile still works. + - name: Build the API image + run: docker build -t aktenlens-api:ci backend + + # Fail only on CRITICAL vulnerabilities that already have a fix. + - name: Scan the image with Trivy + uses: aquasecurity/trivy-action@v0.36.0 + with: + image-ref: aktenlens-api:ci + severity: CRITICAL + ignore-unfixed: true + exit-code: "1" diff --git a/Makefile b/Makefile index ab584d5..7d0dd44 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ BACKEND_DIR := backend BUILD_DIR := bin MAIN_PATH := ./cmd/api -.PHONY: all build run dev test test-race fmt vet clean help db db-stop db-logs db-psql db-reset migrate migrate-down migrate-status +.PHONY: all build run dev test test-race fmt vet lint clean help db db-stop db-logs db-psql db-reset migrate migrate-down migrate-status # Default target when running only 'make' all: help @@ -50,6 +50,10 @@ vet: ## Look for suspicious code (go vet) @echo "==> Running vet..." cd $(BACKEND_DIR) && go vet ./... +lint: ## Run golangci-lint (includes gosec) + @echo "==> Running golangci-lint..." + cd $(BACKEND_DIR) && golangci-lint run + clean: ## Remove build artifacts @echo "==> Cleaning artifacts..." rm -rf $(BACKEND_DIR)/$(BUILD_DIR)