This guide covers setting up Global SAST Scanner for local development and testing.
- Python 3.9+
- Docker (for Redis)
- Git
- API Tokens: GitHub and GitLab tokens (see Installation Guide)
The fastest way to get started:
./scripts/quick-start.sh --pythonThis automatically:
- Creates a Python virtual environment at the repo root
- Installs all modules in editable mode
- Starts Redis container
- Configures environment
- Starts API server and worker
git clone <repository-url>
cd GSAST/
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateAll four modules are managed as a uv workspace via the root pyproject.toml. Install them all in editable mode:
# Using pip (standard)
pip install -e gsast-core/ -e gsast-api/ -e gsast-worker/ -e gsast-cli/
# Or using uv (faster)
uv syncEach module can also be installed independently if you only need a subset — see the per-module docs in docs/modules/.
The worker requires Semgrep and TruffleHog:
pip install semgrep==1.99.0
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/binRedis is required for job queues and result storage:
# Using Docker (recommended)
docker run -d --name gsast-redis -p 6379:6379 redis:7-alpine
# Or install locally (macOS)
brew install redis && redis-servercp env.example .envEdit .env:
# Required
GITHUB_API_TOKEN=ghp_your_github_token_here
GITLAB_API_TOKEN=glpat_your_gitlab_token_here
GITLAB_URL=https://gitlab.com
API_SECRET_KEY=your_secure_random_secret
REDIS_URL=redis://localhost:6379
# Optional for development
FLASK_ENV=development
LOG_LEVEL=DEBUGGenerate a secure API secret:
openssl rand -base64 32# Load environment
set -a && source .env && set +a
# Terminal 1 — API server
gsast-api
# Terminal 2 — Worker
gsast-worker
# Terminal 3 — Use the CLI
gsast --helpGSAST/
├── gsast-core/ # Shared library (models, configs, repolib, sastlib)
│ └── gsast_core/
│ ├── configs/ # Environment variable resolution
│ ├── models/ # Pydantic data models (GSASTConfig, …)
│ ├── repolib/ # GitHub/GitLab repo discovery + download
│ ├── sastlib/ # Plugin interface, manager, SARIF utilities
│ └── utils/ # Logging
│
├── gsast-api/ # Flask API server
│ └── gsast_api/
│ ├── routes/ # Blueprint route handlers
│ ├── services/ # Scan and scanner service logic
│ ├── docs/ # Flasgger YAML spec fragments
│ ├── app.py # App factory + main()
│ ├── auth.py # Request authentication
│ └── infra.py # CLI arg parsing + Redis setup
│
├── gsast-worker/ # RQ worker + scanner plugins
│ └── gsast_worker/
│ ├── plugins/ # semgrep, trufflehog, dependency-confusion
│ ├── tasks.py # RQ task: clone → scan → store
│ └── worker.py # RQ Worker setup + main()
│
├── gsast-cli/ # CLI client
│ └── gsast_cli/
│ └── cli_client.py # Click commands
│
├── helm/ # Kubernetes Helm chart
├── scripts/ # Deployment and utility scripts
└── docs/ # Documentation
└── modules/ # Per-module reference docs
# Run tests for all modules
pytest gsast-core/tests/ gsast-api/tests/ gsast-worker/tests/
# Run with coverage
pytest gsast-core/tests/ --cov=gsast_core --cov-report=html
# Run a specific module's tests
cd gsast-core/ && pytest tests/ -v
cd gsast-api/ && pytest tests/ -vpip install black flake8 isort mypy
black gsast-core/ gsast-api/ gsast-worker/ gsast-cli/
isort gsast-core/ gsast-api/ gsast-worker/ gsast-cli/
flake8 gsast-core/ gsast-api/ gsast-worker/ gsast-cli/gsast-apiThen visit:
- API Documentation: http://localhost:5000/apidocs/
Example API calls:
# Start a scan
curl -X POST http://localhost:5000/scan \
-H "Content-Type: application/json" \
-H "API-SECRET-KEY: your-api-secret-key" \
-d '{
"config": {
"target": {
"provider": "github",
"organizations": ["your-org"]
},
"scanners": ["semgrep", "trufflehog"]
},
"rule_files": []
}'
# Check scan status
curl http://localhost:5000/scan/SCAN-2024-01-01-12-00-00/status \
-H "API-SECRET-KEY: your-api-secret-key"cat > ~/.gsast.json << EOF
{
"api_secret_key": "your-api-secret-key",
"base_url": "http://localhost:5000",
"target": {
"provider": "github",
"organizations": ["your-org"]
},
"scanners": ["semgrep", "trufflehog", "dependency-confusion"]
}
EOF
gsast scan rules/sg_custom/
gsast info SCAN-2024-01-01-12-00-00
gsast results SCAN-2024-01-01-12-00-00See the CLI reference for all commands and options.
Scanners are discovered via Python entry points under the gsast.scanners group. See the worker module docs for a step-by-step guide.
export LOG_LEVEL=DEBUG
export FLASK_ENV=development
gsast-apiexport LOG_LEVEL=DEBUG
gsast-workerredis-cli ping
redis-cli monitor
redis-cli keys "*"
redis-cli llen "default"export FLASK_DEBUG=1
gsast-apiCreate .vscode/settings.json:
{
"python.defaultInterpreterPath": "./venv/bin/python",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black",
"python.sortImports.args": ["--profile", "black"]
}Create .vscode/launch.json for debugging:
{
"version": "0.2.0",
"configurations": [
{
"name": "API Server",
"type": "python",
"request": "launch",
"module": "gsast_api.app",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env"
},
{
"name": "Worker",
"type": "python",
"request": "launch",
"module": "gsast_worker.worker",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env"
}
]
}- Set interpreter:
Settings > Project > Python Interpreter > Add > Existing environment > ./venv/bin/python - Set environment file:
Run/Debug Configurations > Environment variables > Load from file > .env
-
Import errors after adding a new module:
pip install -e gsast-core/ -e gsast-api/ -e gsast-worker/ -e gsast-cli/
-
Redis connection errors:
redis-cli ping docker restart gsast-redis
-
Port already in use:
lsof -i :5000 kill -9 <PID> # Or use a different port export FLASK_RUN_PORT=5001
-
SSL certificate errors (corporate networks):
export GITHUB_DISABLE_SSL_VERIFY=true export PYTHONHTTPSVERIFY=0
- Create a feature branch:
git checkout -b feature/your-feature - Write tests: Add tests for new functionality in the affected module's
tests/directory - Run tests:
pytest gsast-core/tests/ gsast-api/tests/ - Check style:
black . && flake8 . - Update docs: Document new features (update the relevant
docs/modules/*.mdfile) - Submit PR: Create pull request with clear description