From aa1ecbfdefc5386c63bdac21d78655c951fe973a Mon Sep 17 00:00:00 2001 From: airp0wer Date: Tue, 21 Jul 2026 10:42:06 +0300 Subject: [PATCH] =?UTF-8?q?ci(security):=20dependabot=20+=20CodeQL=20+=20n?= =?UTF-8?q?pm=20audit=20+=20Trivy-=D1=81=D0=BA=D0=B0=D0=BD=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - .github/dependabot.yml: еженедельные обновления npm/github-actions/docker со сгруппированными PR - codeql.yml: SAST (javascript-typescript, security-and-quality) на push/PR в main/dev + еженедельный проход - security-audit.yml: npm audit --audit-level=high (пока non-blocking) - docker.yml: Trivy-скан запушенного образа с выгрузкой SARIF в Security tab (non-blocking), least-privilege permissions на workflow --- .github/dependabot.yml | 35 ++++++++++++++++++++++++++ .github/workflows/codeql.yml | 37 ++++++++++++++++++++++++++++ .github/workflows/docker.yml | 25 +++++++++++++++++++ .github/workflows/security-audit.yml | 35 ++++++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/security-audit.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a835e5c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,35 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 + groups: + # Схлопываем шумные обновления в один PR, чтобы не плодить десятки веток. + dev-dependencies: + dependency-type: "development" + production-minor-patch: + dependency-type: "production" + update-types: + - "minor" + - "patch" + labels: + - "dependencies" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 5 + labels: + - "dependencies" + - "ci" + + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" + - "docker" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..e891448 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,37 @@ +name: CodeQL + +on: + push: + branches: [main, dev] + pull_request: + branches: [main, dev] + schedule: + # Еженедельный полный проход, чтобы ловить новые правила даже без коммитов. + - cron: "27 3 * * 1" + +permissions: + contents: read + +jobs: + analyze: + name: Analyze (javascript-typescript) + runs-on: ubuntu-latest + permissions: + security-events: write + actions: read + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: javascript-typescript + queries: security-and-quality + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:javascript-typescript" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 10df084..1a79754 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,6 +12,9 @@ env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} +permissions: + contents: read + jobs: lint: uses: ./.github/workflows/lint.yml @@ -22,6 +25,7 @@ jobs: permissions: contents: read packages: write + security-events: write steps: - name: Checkout code @@ -53,6 +57,7 @@ jobs: type=raw,value=latest,enable={{is_default_branch}} - name: Build and push Docker image + id: build uses: docker/build-push-action@v5 with: context: . @@ -66,3 +71,23 @@ jobs: VITE_TELEGRAM_BOT_USERNAME= VITE_APP_NAME=Cabinet VITE_APP_LOGO=V + + # Сканируем запушенный образ на CVE. Пока non-blocking (exit-code: 0): + # находки уезжают в Security → Code scanning, но сборку не роняют. + # Для ужесточения — поставить severity-фильтр в exit-code и убрать PR-гейт. + - name: Scan image with Trivy + if: github.event_name != 'pull_request' + uses: aquasecurity/trivy-action@0.24.0 + with: + image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }} + format: sarif + output: trivy-results.sarif + severity: HIGH,CRITICAL + exit-code: "0" + + - name: Upload Trivy results to Security tab + if: github.event_name != 'pull_request' + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: trivy-results.sarif + category: trivy diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml new file mode 100644 index 0000000..82d0bda --- /dev/null +++ b/.github/workflows/security-audit.yml @@ -0,0 +1,35 @@ +name: Security Audit + +on: + push: + branches: [main, dev] + pull_request: + branches: [main, dev] + schedule: + - cron: "27 4 * * 1" + +permissions: + contents: read + +jobs: + npm-audit: + name: npm audit + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + + - name: Install dependencies + run: npm ci + + # Пока non-blocking: сообщаем о HIGH/CRITICAL, но не валим пайплайн. + # Когда долги по зависимостям разгребём — убрать continue-on-error. + - name: Run npm audit (high+) + continue-on-error: true + run: npm audit --audit-level=high