Skip to content
Merged
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
230 changes: 230 additions & 0 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
name: Combined Security Scanning

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
schedule:
# Run daily at 1 AM UTC
- cron: '0 1 * * *'
workflow_dispatch:

permissions:
contents: read
security-events: write
actions: read
pull-requests: write

jobs:
security-summary:
name: Security Scan Summary
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run npm audit
id: npm-audit
run: |
npm audit --audit-level=moderate --json > npm-audit.json || true
echo "vulnerabilities=$(jq '.metadata.vulnerabilities.total' npm-audit.json)" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Check for secrets
uses: trufflesecurity/trufflehog@main
with:
path: ./
base: ${{ github.event.repository.default_branch }}
head: HEAD
extra_args: --debug --only-verified

eslint-security:
name: ESLint Security Analysis
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run ESLint with security rules
run: |
npm run lint || true
continue-on-error: true

semgrep-scan:
name: Semgrep Security Scan
runs-on: ubuntu-latest

container:
image: returntocorp/semgrep

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Semgrep
run: |
semgrep scan --config auto --sarif --output=semgrep.sarif || true
continue-on-error: true

- name: Upload Semgrep results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: semgrep.sarif
category: semgrep

osv-scanner:
name: OSV Scanner
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run OSV Scanner
uses: google/osv-scanner-action@v1
with:
scan-args: |-
--lockfile=package-lock.json
--format=sarif
--output=osv-results.sarif
continue-on-error: true

- name: Upload OSV results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: osv-results.sarif
category: osv-scanner

docker-security:
name: Docker Security Best Practices
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Hadolint (Dockerfile linter)
uses: hadolint/[email protected]
with:
dockerfile: ./Dockerfile
format: sarif
output-file: hadolint.sarif
ignore: DL3008,DL3009
continue-on-error: true

- name: Upload Hadolint results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: hadolint.sarif
category: hadolint

k8s-security:
name: Kubernetes Security
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Kubescape
uses: kubescape/github-action@main
continue-on-error: true
with:
files: "k8s/*.yaml"
frameworks: |
nsa,mitre

license-check:
name: License Compliance Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Check licenses
run: |
npx license-checker --summary --onlyAllow "MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;0BSD;Unlicense" || true
continue-on-error: true

security-report:
name: Generate Security Report
runs-on: ubuntu-latest
needs: [security-summary, eslint-security, semgrep-scan, osv-scanner, docker-security]
if: always()

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
continue-on-error: true

- name: Generate security summary
run: |
echo "# Security Scan Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Scans Performed" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Dependency vulnerabilities (npm audit)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Secret detection (TruffleHog)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Static code analysis (ESLint, Semgrep)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Dependency vulnerabilities (OSV Scanner)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Docker security (Hadolint)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Kubernetes security (Kubescape)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ License compliance" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "See individual scan results in the Security tab." >> $GITHUB_STEP_SUMMARY

notify-security-team:
name: Notify Security Team
runs-on: ubuntu-latest
needs: [security-summary, eslint-security, semgrep-scan]
if: failure() && github.ref == 'refs/heads/main'

steps:
- name: Send notification
run: |
echo "Security scan failed on main branch!"
echo "Team notification would be sent here (Slack, email, etc.)"
# In production: integrate with notification systems
146 changes: 146 additions & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Snyk Security Scan

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:

permissions:
contents: read
security-events: write
actions: read

jobs:
snyk-scan:
name: Snyk Dependency Scan
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high --all-projects

- name: Upload Snyk results to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: snyk.sarif

snyk-container:
name: Snyk Container Scan
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'schedule'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Docker image
run: docker build -t algo-cloud-ide:${{ github.sha }} .

- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: algo-cloud-ide:${{ github.sha }}
args: --severity-threshold=high

- name: Upload Snyk container results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: snyk.sarif

snyk-code:
name: Snyk Code Analysis
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Snyk Code test
uses: snyk/actions/node@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: code test
args: --severity-threshold=high

- name: Upload Snyk Code results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: snyk.sarif

snyk-monitor:
name: Snyk Monitor (Production)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Monitor with Snyk
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
args: --all-projects --project-name="algo-cloud-ide"

dependency-review:
name: Dependency Review
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Dependency Review
uses: actions/dependency-review-action@v4
with:
fail-on-severity: moderate
deny-licenses: GPL-2.0, GPL-3.0
Loading
Loading