Guardrails CLI for scanning repositories
Project description
Topcoder Guardrails
Enterprise-grade guardrails for GitHub Copilot workflows: a FastAPI backend, GitHub App integration, and CLI that enforce security, policy, and licensing standards with explainable AI + static analysis.
Deployed URL
https://topcoder-production.up.railway.app
Quick start (hosted)
- Open the deployed URL.
- Go to /settings/ui.
- Paste your OpenAI API key and save.
- Create or update a PR in a repo where the GitHub App is installed. Guardrails posts comments/checks automatically.
That is all most users need.
What this delivers
- Hybrid analysis engine: rule-based static checks + AI review with explanations.
- Copilot awareness: stricter handling for AI-generated code paths.
- Policy-based enforcement: advisory, warning, blocking, with override label support.
- License/IP compliance: SPDX/license detection and duplication heuristics.
- GitHub PR + commit integration: check runs, inline comments, and summaries.
- Auditability: audit log export, resolution events, and dashboards.
- Extensible rulepacks: sector-specific YAML rulepacks and repo overrides.
Challenge requirement coverage
- Secure coding guardrails with OWASP/CWE mappings.
- Copilot-aware flagging and stricter enforcement for AI-generated code.
- Configurable coding standards via YAML/JSON repo config.
- AI-assisted PR review with explanations and suggested fixes (security, performance, maintainability).
- License/IP checks (restricted licenses + duplication heuristics).
- Policy-based enforcement modes (advisory, warning, blocking) with override support.
- PR and commit scanning via GitHub App (check runs + inline comments + summaries).
- Traceability with audit IDs, export, and resolution events.
- Async scan flow for large PRs.
- Pluggable rulepacks per industry (finance, healthcare, public sector, telecom, government) and custom uploads.
Architecture
- backend/ — FastAPI service, rule engine, AI review, audit logging
- github-app/ — GitHub App integration (PR + commit scanning)
- src/guardrails_cli/ — CLI package for local repo scans
- docs/ — Architecture notes
Security & data handling
- No source code retention beyond analysis. Audit logs store sanitized output only.
- Settings storage is encrypted when a key is configured.
- Data residency can be enforced via repo config + environment variable.
Requirements
CLI
- Python 3.9+
Configuration (backend)
Core settings:
- OPENAI_API_KEY (optional) — used when no per-user key exists
- GUARDRAILS_API_TOKEN (optional) — bearer token required for analysis/scan endpoints when set
- GUARDRAILS_ADMIN_TOKEN (optional) — bearer token required for admin endpoints (audit export, rulepack upload)
- SETTINGS_SCOPE (default: global) — global | user | ip
- SETTINGS_TOKEN (optional) — protects settings endpoints
- REQUIRE_AI_REVIEW_DEFAULT (default: false)
GitHub App integration
The GitHub App scans PRs and pushes, posts comments/checks, and reads repo overrides from .guardrails/config.yml|yaml|json.
Environment variables:
- BACKEND_URL (required)
- BACKEND_TOKEN (optional) — bearer token for secured backend endpoints
- OVERRIDE_LABEL (optional, default: guardrails-override)
- MAX_FILES (optional, default: 100)
- MAX_FILE_BYTES (optional, default: 200000)
- USE_ASYNC_SCAN (optional, default: false)
CLI usage
Install:
pip install guardrails-cli
Scan:
guardrails scan <repo-path> --user <token>
# Or, from inside your repo:
guardrails scan --user <token>
Before scanning, save your OpenAI API key in the hosted settings UI (/settings/ui). The CLI uses the hosted backend by default.
If the backend enforces API tokens:
guardrails scan <repo-path> --user <token> --api-token <backend-token>
Fix modes:
- Full fix (AI rewrite + safe fixes):
guardrails scan --full-fix --user <token> - Safe fix only:
guardrails scan --safe-fix --user <token> - No fixes:
guardrails scan --no-fix --user <token>
Notes:
- Hosted URL: https://topcoder-production.up.railway.app
- Override with GUARDRAILS_API_URL or --api
- Use --autofix to apply safe local fixes
- Use --no-ai to disable AI review for a run
What users must do
- Provide their own OpenAI API key via /settings/ui (hosted).
- Install the CLI only if they want local scans.
CLI settings (optional)
guardrails settings --issue-user-token
API endpoints
- GET /health
- GET /
- GET /dashboard
- GET /settings
- POST /settings/token
- GET /settings/token/current
- POST /settings/token/assign
- GET /settings/ui
- POST /settings/api-key
- POST /settings/ai-mode
- POST /settings/autofix-mode
- POST /settings/override-allowed
- POST /analyze
- POST /analyze-batch
- POST /scan/async
- GET /scan/status/{job_id}
- GET /report/summary
- GET /report/trends
- GET /rulepacks
- POST /rulepacks
- GET /audit/export
- POST /audit/resolve
- GET /docs
Testing
pytest
- GET /report/summary — Audit summary counts
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guardrails_cli-0.1.23.tar.gz.
File metadata
- Download URL: guardrails_cli-0.1.23.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5b2f6049e1797be24ea6eff0881d9d03b9f0959c5abe8ae716c485fd7365238
|
|
| MD5 |
e5ad7ddca1b2d032e3c726bd2f864001
|
|
| BLAKE2b-256 |
3bdaf2efcaa43aabc301535a863a9e72c2457767789f1ac78aa736ed9422058d
|
File details
Details for the file guardrails_cli-0.1.23-py3-none-any.whl.
File metadata
- Download URL: guardrails_cli-0.1.23-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81b9aa617ef0cc9af11516b2c3bd49ab5dbbc36a48457bed698af280b7c8da2a
|
|
| MD5 |
b914193378594d0b1cde380643761225
|
|
| BLAKE2b-256 |
05f879f976f55edd2e677e0630d253b8a1f4454000114070ab96be692608119d
|