|
| 1 | +# Snyk Security Scanning Setup Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | +This repository uses Snyk for comprehensive security scanning of dependencies, container images, and source code. The Snyk workflow has been configured but requires a secret token to function properly. |
| 5 | + |
| 6 | +## Required Configuration |
| 7 | + |
| 8 | +### Step 1: Obtain Your Snyk API Token |
| 9 | +1. Go to [Snyk Account Settings](https://app.snyk.io/account) |
| 10 | +2. Log in to your Snyk account (create one if you don't have it) |
| 11 | +3. Navigate to **Settings** → **General** → **API Token** |
| 12 | +4. Click **Show** to reveal your API token |
| 13 | +5. Copy the token (it should start with a UUID format) |
| 14 | + |
| 15 | +### Step 2: Add SNYK_TOKEN to GitHub Repository Secrets |
| 16 | +1. Go to your GitHub repository: https://github.com/Algodons/algo |
| 17 | +2. Navigate to **Settings** → **Secrets and variables** → **Actions** |
| 18 | +3. Click **New repository secret** |
| 19 | +4. Set the following: |
| 20 | + - **Name**: `SNYK_TOKEN` |
| 21 | + - **Secret**: Paste your Snyk API token from Step 1 |
| 22 | +5. Click **Add secret** |
| 23 | + |
| 24 | +### Step 3: Verify the Configuration |
| 25 | +After adding the secret, the Snyk workflow will be able to authenticate properly. You can verify by: |
| 26 | + |
| 27 | +1. Pushing a commit to `main` or `develop` branch, or |
| 28 | +2. Manually triggering the workflow from the Actions tab |
| 29 | +3. Checking that the workflow runs successfully without authentication errors |
| 30 | + |
| 31 | +## What This Enables |
| 32 | + |
| 33 | +With the SNYK_TOKEN configured, the repository will have: |
| 34 | + |
| 35 | +### 1. **Dependency Scanning** |
| 36 | +- Automatically scans `package.json` and `package-lock.json` for vulnerable dependencies |
| 37 | +- Runs on every push and pull request |
| 38 | +- Results uploaded to GitHub Security tab |
| 39 | + |
| 40 | +### 2. **Container Scanning** |
| 41 | +- Scans Docker images for vulnerabilities |
| 42 | +- Checks base images and installed packages |
| 43 | +- Runs on pushes to main/develop branches |
| 44 | + |
| 45 | +### 3. **Code Analysis** |
| 46 | +- Static analysis of source code for security issues |
| 47 | +- Identifies common vulnerabilities (XSS, SQL injection, etc.) |
| 48 | +- Provides remediation advice |
| 49 | + |
| 50 | +### 4. **Production Monitoring** |
| 51 | +- Monitors production dependencies on main branch |
| 52 | +- Tracks vulnerabilities over time in Snyk dashboard |
| 53 | +- Sends alerts for newly discovered issues |
| 54 | + |
| 55 | +## Workflow Schedule |
| 56 | + |
| 57 | +The Snyk security scan runs: |
| 58 | +- On every push to `main` and `develop` branches |
| 59 | +- On every pull request to `main` and `develop` branches |
| 60 | +- Daily at 2:00 AM UTC (scheduled scan) |
| 61 | +- On manual workflow dispatch |
| 62 | + |
| 63 | +## Viewing Results |
| 64 | + |
| 65 | +### In GitHub |
| 66 | +1. Go to the **Security** tab in your repository |
| 67 | +2. Click **Code scanning alerts** |
| 68 | +3. Filter by tool: "Snyk" |
| 69 | + |
| 70 | +### In Snyk Dashboard |
| 71 | +1. Log in to [Snyk Dashboard](https://app.snyk.io) |
| 72 | +2. Select your organization |
| 73 | +3. View "algo-cloud-ide" project |
| 74 | +4. See detailed vulnerability reports and remediation advice |
| 75 | + |
| 76 | +## Troubleshooting |
| 77 | + |
| 78 | +### Authentication Errors (SNYK-0005) |
| 79 | +**Error**: `Authentication credentials not recognized, or user access is not provisioned` |
| 80 | + |
| 81 | +**Solutions**: |
| 82 | +- Verify SNYK_TOKEN secret is correctly set in GitHub |
| 83 | +- Ensure the token is valid and not expired |
| 84 | +- Regenerate a new token from Snyk if needed |
| 85 | +- Check that the token has proper permissions in Snyk |
| 86 | + |
| 87 | +### Missing SARIF File |
| 88 | +**Error**: `Path does not exist: snyk.sarif` |
| 89 | + |
| 90 | +**Solutions**: |
| 91 | +- This usually occurs when authentication fails |
| 92 | +- Fix the SNYK_TOKEN first |
| 93 | +- The SARIF file is now automatically generated with `--sarif-file-output=snyk.sarif` |
| 94 | + |
| 95 | +### Incompatible CLI Flags |
| 96 | +**Error**: `Invalid flag option (SNYK-CLI-0004)` |
| 97 | + |
| 98 | +**Solutions**: |
| 99 | +- This has been fixed in the workflow |
| 100 | +- The monitor job now only uses `--all-projects` flag |
| 101 | +- No action needed |
| 102 | + |
| 103 | +## Support |
| 104 | + |
| 105 | +For questions or issues: |
| 106 | +1. Check the [Snyk Documentation](https://docs.snyk.io/) |
| 107 | +2. Review workflow logs in GitHub Actions tab |
| 108 | +3. Contact the DevOps team |
| 109 | +4. Open an issue in the repository |
| 110 | + |
| 111 | +## Security Note |
| 112 | + |
| 113 | +⚠️ **Never commit the SNYK_TOKEN to version control!** |
| 114 | +Always use GitHub Secrets for storing sensitive tokens and credentials. |
0 commit comments