scp-cli 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scp_cli-0.1.7/CLIREADME.md +72 -0
- scp_cli-0.1.7/PKG-INFO +86 -0
- scp_cli-0.1.7/README.md +364 -0
- scp_cli-0.1.7/pyproject.toml +31 -0
- scp_cli-0.1.7/setup.cfg +4 -0
- scp_cli-0.1.7/src/app/__init__.py +1 -0
- scp_cli-0.1.7/src/app/api/__init__.py +0 -0
- scp_cli-0.1.7/src/app/api/admin.py +169 -0
- scp_cli-0.1.7/src/app/api/auth.py +186 -0
- scp_cli-0.1.7/src/app/api/deps.py +146 -0
- scp_cli-0.1.7/src/app/api/routers.py +352 -0
- scp_cli-0.1.7/src/app/cli.py +287 -0
- scp_cli-0.1.7/src/app/core/__init__.py +0 -0
- scp_cli-0.1.7/src/app/core/auth.py +63 -0
- scp_cli-0.1.7/src/app/core/billing_plans.py +38 -0
- scp_cli-0.1.7/src/app/core/config.py +54 -0
- scp_cli-0.1.7/src/app/core/db.py +70 -0
- scp_cli-0.1.7/src/app/core/rate_limiter.py +210 -0
- scp_cli-0.1.7/src/app/main.py +137 -0
- scp_cli-0.1.7/src/app/models.py +103 -0
- scp_cli-0.1.7/src/app/schemas.py +183 -0
- scp_cli-0.1.7/src/app/services/__init__.py +0 -0
- scp_cli-0.1.7/src/app/services/billing.py +126 -0
- scp_cli-0.1.7/src/app/services/email.py +153 -0
- scp_cli-0.1.7/src/app/services/jira_service.py +95 -0
- scp_cli-0.1.7/src/app/services/resolution.py +969 -0
- scp_cli-0.1.7/src/app/services/scanner.py +344 -0
- scp_cli-0.1.7/src/app/services/scanners/__init__.py +11 -0
- scp_cli-0.1.7/src/app/services/scanners/bandit_scanner.py +214 -0
- scp_cli-0.1.7/src/app/services/scanners/base.py +107 -0
- scp_cli-0.1.7/src/app/services/scanners/checkov_scanner.py +219 -0
- scp_cli-0.1.7/src/app/services/scanners/npm_audit_scanner.py +193 -0
- scp_cli-0.1.7/src/app/services/scanners/osv_scanner.py +125 -0
- scp_cli-0.1.7/src/app/services/scanners/pip_audit_scanner.py +241 -0
- scp_cli-0.1.7/src/app/services/scanners/retirejs_scanner.py +168 -0
- scp_cli-0.1.7/src/app/services/scanners/semgrep_scanner.py +293 -0
- scp_cli-0.1.7/src/app/services/slack_service.py +50 -0
- scp_cli-0.1.7/src/app/worker.py +108 -0
- scp_cli-0.1.7/src/scp_cli.egg-info/PKG-INFO +86 -0
- scp_cli-0.1.7/src/scp_cli.egg-info/SOURCES.txt +61 -0
- scp_cli-0.1.7/src/scp_cli.egg-info/dependency_links.txt +1 -0
- scp_cli-0.1.7/src/scp_cli.egg-info/entry_points.txt +2 -0
- scp_cli-0.1.7/src/scp_cli.egg-info/requires.txt +3 -0
- scp_cli-0.1.7/src/scp_cli.egg-info/top_level.txt +1 -0
- scp_cli-0.1.7/tests/test_basic.py +81 -0
- scp_cli-0.1.7/tests/test_billing.py +73 -0
- scp_cli-0.1.7/tests/test_billing_event_alias.py +24 -0
- scp_cli-0.1.7/tests/test_findings_persistence.py +63 -0
- scp_cli-0.1.7/tests/test_health_advanced.py +75 -0
- scp_cli-0.1.7/tests/test_list_scans.py +27 -0
- scp_cli-0.1.7/tests/test_metrics.py +69 -0
- scp_cli-0.1.7/tests/test_multi_tenancy_new.py +198 -0
- scp_cli-0.1.7/tests/test_npm_audit_scanner.py +161 -0
- scp_cli-0.1.7/tests/test_osv_scanner.py +65 -0
- scp_cli-0.1.7/tests/test_password_recovery.py +63 -0
- scp_cli-0.1.7/tests/test_private_repo.py +60 -0
- scp_cli-0.1.7/tests/test_quota_renewal.py +49 -0
- scp_cli-0.1.7/tests/test_rate_limit.py +84 -0
- scp_cli-0.1.7/tests/test_resolution.py +265 -0
- scp_cli-0.1.7/tests/test_retirejs_scanner.py +73 -0
- scp_cli-0.1.7/tests/test_rules_extended.py +74 -0
- scp_cli-0.1.7/tests/test_rules_new.py +50 -0
- scp_cli-0.1.7/tests/test_slack_jira_integration.py +63 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## Security Scanners
|
|
2
|
+
|
|
3
|
+
The platform integrates four industry-standard security scanners:
|
|
4
|
+
|
|
5
|
+
1. **Semgrep** - Multi-language static analysis
|
|
6
|
+
- Supports 18+ languages: Python, JavaScript, TypeScript, Java, Go, Ruby, PHP, C/C++, C#, Rust, Kotlin, Scala, Swift
|
|
7
|
+
- Uses Semgrep Registry community rules
|
|
8
|
+
- OWASP Top 10 and CWE coverage
|
|
9
|
+
|
|
10
|
+
2. **Bandit** - Python static security analysis
|
|
11
|
+
- Detects hard-coded secrets, SQL injection, shell injection, insecure crypto
|
|
12
|
+
- 68+ built-in security checks
|
|
13
|
+
- Severity-based risk scoring
|
|
14
|
+
|
|
15
|
+
2. **Checkov** - Infrastructure as Code security
|
|
16
|
+
- Scans Terraform, Dockerfile, Kubernetes, CloudFormation
|
|
17
|
+
- 1000+ built-in policies (CIS, PCI-DSS, HIPAA compliance)
|
|
18
|
+
- Identifies misconfigurations before deployment
|
|
19
|
+
|
|
20
|
+
3. **pip-audit** - Python dependency vulnerability scanning
|
|
21
|
+
- Checks for known CVEs in dependencies
|
|
22
|
+
- Uses PyPI Advisory Database
|
|
23
|
+
- Provides upgrade recommendations
|
|
24
|
+
|
|
25
|
+
### Scanner Workflow
|
|
26
|
+
|
|
27
|
+
1. Repository is cloned to temporary directory
|
|
28
|
+
2. All applicable scanners run in parallel
|
|
29
|
+
3. Findings are aggregated and stored in database
|
|
30
|
+
4. Risk score calculated based on severity (0-10 scale)
|
|
31
|
+
5. Temporary files cleaned up
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
The platform includes a powerful CLI script to trigger scans and resolutions directly from your terminal.
|
|
36
|
+
|
|
37
|
+
#### 1. Installation
|
|
38
|
+
Ensure you have the dependencies installed:
|
|
39
|
+
```bash
|
|
40
|
+
pip install typer[all] rich requests
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### 2. Usage
|
|
44
|
+
[Get your API key from the dashboard](https://code-security-platform-frontend-lan.vercel.app/login)
|
|
45
|
+
|
|
46
|
+
Running the CLI tool
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Showing the help menu
|
|
50
|
+
scp-cli --help
|
|
51
|
+
|
|
52
|
+
# Authenticate (Set your API key)
|
|
53
|
+
scp-cli auth --key <YOUR_API_KEY>
|
|
54
|
+
|
|
55
|
+
# Start a scan
|
|
56
|
+
scp-cli scan https://github.com/owner/repo
|
|
57
|
+
|
|
58
|
+
# Check scan status
|
|
59
|
+
scp-cli status <scan_id>
|
|
60
|
+
|
|
61
|
+
# Resolve findings (Bulk fix for a scan)
|
|
62
|
+
scp-cli resolve <scan_id>
|
|
63
|
+
|
|
64
|
+
# Check all successfully resolved findings
|
|
65
|
+
scp-cli resolved
|
|
66
|
+
|
|
67
|
+
# Get the PR URL for a specific resolved finding
|
|
68
|
+
scp-cli pr <finding_id>
|
|
69
|
+
|
|
70
|
+
# Check your quota
|
|
71
|
+
scp-cli usage
|
|
72
|
+
```
|
scp_cli-0.1.7/PKG-INFO
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scp-cli
|
|
3
|
+
Version: 0.1.7
|
|
4
|
+
Summary: Security Compliance Platform CLI - Secure your code from the terminal.
|
|
5
|
+
Author-email: Maxwell Sarpong <maxwell@example.com>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: typer>=0.9.0
|
|
12
|
+
Requires-Dist: rich>=13.0.0
|
|
13
|
+
Requires-Dist: requests>=2.31.0
|
|
14
|
+
|
|
15
|
+
## Security Scanners
|
|
16
|
+
|
|
17
|
+
The platform integrates four industry-standard security scanners:
|
|
18
|
+
|
|
19
|
+
1. **Semgrep** - Multi-language static analysis
|
|
20
|
+
- Supports 18+ languages: Python, JavaScript, TypeScript, Java, Go, Ruby, PHP, C/C++, C#, Rust, Kotlin, Scala, Swift
|
|
21
|
+
- Uses Semgrep Registry community rules
|
|
22
|
+
- OWASP Top 10 and CWE coverage
|
|
23
|
+
|
|
24
|
+
2. **Bandit** - Python static security analysis
|
|
25
|
+
- Detects hard-coded secrets, SQL injection, shell injection, insecure crypto
|
|
26
|
+
- 68+ built-in security checks
|
|
27
|
+
- Severity-based risk scoring
|
|
28
|
+
|
|
29
|
+
2. **Checkov** - Infrastructure as Code security
|
|
30
|
+
- Scans Terraform, Dockerfile, Kubernetes, CloudFormation
|
|
31
|
+
- 1000+ built-in policies (CIS, PCI-DSS, HIPAA compliance)
|
|
32
|
+
- Identifies misconfigurations before deployment
|
|
33
|
+
|
|
34
|
+
3. **pip-audit** - Python dependency vulnerability scanning
|
|
35
|
+
- Checks for known CVEs in dependencies
|
|
36
|
+
- Uses PyPI Advisory Database
|
|
37
|
+
- Provides upgrade recommendations
|
|
38
|
+
|
|
39
|
+
### Scanner Workflow
|
|
40
|
+
|
|
41
|
+
1. Repository is cloned to temporary directory
|
|
42
|
+
2. All applicable scanners run in parallel
|
|
43
|
+
3. Findings are aggregated and stored in database
|
|
44
|
+
4. Risk score calculated based on severity (0-10 scale)
|
|
45
|
+
5. Temporary files cleaned up
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
The platform includes a powerful CLI script to trigger scans and resolutions directly from your terminal.
|
|
50
|
+
|
|
51
|
+
#### 1. Installation
|
|
52
|
+
Ensure you have the dependencies installed:
|
|
53
|
+
```bash
|
|
54
|
+
pip install typer[all] rich requests
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### 2. Usage
|
|
58
|
+
[Get your API key from the dashboard](https://code-security-platform-frontend-lan.vercel.app/login)
|
|
59
|
+
|
|
60
|
+
Running the CLI tool
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Showing the help menu
|
|
64
|
+
scp-cli --help
|
|
65
|
+
|
|
66
|
+
# Authenticate (Set your API key)
|
|
67
|
+
scp-cli auth --key <YOUR_API_KEY>
|
|
68
|
+
|
|
69
|
+
# Start a scan
|
|
70
|
+
scp-cli scan https://github.com/owner/repo
|
|
71
|
+
|
|
72
|
+
# Check scan status
|
|
73
|
+
scp-cli status <scan_id>
|
|
74
|
+
|
|
75
|
+
# Resolve findings (Bulk fix for a scan)
|
|
76
|
+
scp-cli resolve <scan_id>
|
|
77
|
+
|
|
78
|
+
# Check all successfully resolved findings
|
|
79
|
+
scp-cli resolved
|
|
80
|
+
|
|
81
|
+
# Get the PR URL for a specific resolved finding
|
|
82
|
+
scp-cli pr <finding_id>
|
|
83
|
+
|
|
84
|
+
# Check your quota
|
|
85
|
+
scp-cli usage
|
|
86
|
+
```
|
scp_cli-0.1.7/README.md
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# Security & Compliance Monitoring — Backend (FastAPI) 🛡
|
|
2
|
+
|
|
3
|
+
Minimal scaffold for the Security & Compliance Monitoring API (FastAPI).
|
|
4
|
+
|
|
5
|
+
What you get
|
|
6
|
+
- Runnable FastAPI app with a simple scan API (POST /api/v1/scans)
|
|
7
|
+
- **Real security scanners**: Bandit (Python static analysis), Checkov (IaC security), pip-audit (dependency vulnerabilities)
|
|
8
|
+
- SQLite default dev DB (configurable via DATABASE_URL)
|
|
9
|
+
- Dockerfile + docker-compose for local dev
|
|
10
|
+
- Unit test + GitHub Actions CI scaffold
|
|
11
|
+
|
|
12
|
+
## Security Scanners
|
|
13
|
+
|
|
14
|
+
The platform integrates four industry-standard security scanners:
|
|
15
|
+
|
|
16
|
+
1. **Semgrep** - Multi-language static analysis
|
|
17
|
+
- Supports 18+ languages: Python, JavaScript, TypeScript, Java, Go, Ruby, PHP, C/C++, C#, Rust, Kotlin, Scala, Swift
|
|
18
|
+
- Uses Semgrep Registry community rules
|
|
19
|
+
- OWASP Top 10 and CWE coverage
|
|
20
|
+
|
|
21
|
+
2. **Bandit** - Python static security analysis
|
|
22
|
+
- Detects hard-coded secrets, SQL injection, shell injection, insecure crypto
|
|
23
|
+
- 68+ built-in security checks
|
|
24
|
+
- Severity-based risk scoring
|
|
25
|
+
|
|
26
|
+
2. **Checkov** - Infrastructure as Code security
|
|
27
|
+
- Scans Terraform, Dockerfile, Kubernetes, CloudFormation
|
|
28
|
+
- 1000+ built-in policies (CIS, PCI-DSS, HIPAA compliance)
|
|
29
|
+
- Identifies misconfigurations before deployment
|
|
30
|
+
|
|
31
|
+
3. **pip-audit** - Python dependency vulnerability scanning
|
|
32
|
+
- Checks for known CVEs in dependencies
|
|
33
|
+
- Uses PyPI Advisory Database
|
|
34
|
+
- Provides upgrade recommendations
|
|
35
|
+
|
|
36
|
+
### Scanner Workflow
|
|
37
|
+
|
|
38
|
+
1. Repository is cloned to temporary directory
|
|
39
|
+
2. All applicable scanners run in parallel
|
|
40
|
+
3. Findings are aggregated and stored in database
|
|
41
|
+
4. Risk score calculated based on severity (0-10 scale)
|
|
42
|
+
5. Temporary files cleaned up
|
|
43
|
+
|
|
44
|
+
<img src="Secure-Code-Platform.drawio.svg" alt="Architecture Diagram" width="800" />
|
|
45
|
+
|
|
46
|
+
Quickstart (macOS):
|
|
47
|
+
|
|
48
|
+
1) Create virtualenv and run locally
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m venv .venv
|
|
52
|
+
source .venv/bin/activate
|
|
53
|
+
pip install -r requirements.txt
|
|
54
|
+
uvicorn app.main:app --reload
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
2) With Docker Compose
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
docker compose up --build
|
|
61
|
+
# API -> https://code-security-platform.onrender.com
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Command Line Interface (CLI) 💻
|
|
65
|
+
|
|
66
|
+
The platform includes a powerful CLI script to trigger scans and resolutions directly from your terminal.
|
|
67
|
+
|
|
68
|
+
#### 1. Installation
|
|
69
|
+
Ensure you have the dependencies installed:
|
|
70
|
+
```bash
|
|
71
|
+
pip install typer[all] rich requests
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### 2. Usage
|
|
75
|
+
Run the CLI as a Python module from the project root:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Authenticate (Set your API key)
|
|
79
|
+
python -m src.app.cli auth --key <YOUR_API_KEY>
|
|
80
|
+
|
|
81
|
+
# Start a scan
|
|
82
|
+
python -m src.app.cli scan https://github.com/owner/repo
|
|
83
|
+
|
|
84
|
+
# Check scan status
|
|
85
|
+
python -m src.app.cli status <scan_id>
|
|
86
|
+
|
|
87
|
+
# Resolve findings (Bulk fix for a scan)
|
|
88
|
+
python -m src.app.cli resolve <scan_id>
|
|
89
|
+
|
|
90
|
+
# Check all successfully resolved findings
|
|
91
|
+
python -m src.app.cli resolved
|
|
92
|
+
|
|
93
|
+
# Get the PR URL for a specific resolved finding
|
|
94
|
+
python -m src.app.cli pr <finding_id>
|
|
95
|
+
|
|
96
|
+
# Check your quota
|
|
97
|
+
python -m src.app.cli usage
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Authentication
|
|
101
|
+
|
|
102
|
+
The platform supports **JWT Authentication** (via login) and **API Key Authentication** (for automated services).
|
|
103
|
+
|
|
104
|
+
#### 1. Register & Login (JWT)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Register
|
|
108
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/register \
|
|
109
|
+
-H "Content-Type: application/json" \
|
|
110
|
+
-d '{ "email": "user@example.com", "password": "yourpassword" }'
|
|
111
|
+
|
|
112
|
+
# Login
|
|
113
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/login \
|
|
114
|
+
-H "Content-Type: application/json" \
|
|
115
|
+
-d '{ "email": "user@example.com", "password": "yourpassword" }'
|
|
116
|
+
# Response: { "access_token": "...", "token_type": "bearer" }
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Use the `access_token` in the `Authorization: Bearer <token>` header for all subsequent requests.
|
|
120
|
+
|
|
121
|
+
#### 2. API Key Authentication
|
|
122
|
+
|
|
123
|
+
Generate an API key after logging in (`POST /api/v1/user/api-key`), then use it via the `x-api-key` header:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
curl https://code-security-platform.onrender.com/api/v1/scans \
|
|
127
|
+
-H "x-api-key: <YOUR_API_KEY>"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### Plans & Quotas
|
|
133
|
+
|
|
134
|
+
Every user is assigned a plan that controls their monthly scan and resolution limits.
|
|
135
|
+
|
|
136
|
+
| Plan | Monthly Scans | Monthly Resolves |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `free` | 2 | 2 |
|
|
139
|
+
| `team` | 500 | 500 |
|
|
140
|
+
| `enterprise` | 2000 | 2000 |
|
|
141
|
+
|
|
142
|
+
- New users are automatically placed on the **Free** plan.
|
|
143
|
+
- Check your current plan and quotas at `GET /api/v1/user/profile`.
|
|
144
|
+
- Check current-month usage at `GET /api/v1/user/usage`.
|
|
145
|
+
- When a quota is exceeded the API returns `403` with a descriptive message indicating which quota was hit and that an upgrade is required.
|
|
146
|
+
- **Upgrade/Transition Plans**:
|
|
147
|
+
- `POST /api/v1/user/subscription/team`: Move to the **Team** tier.
|
|
148
|
+
- `POST /api/v1/user/subscription/enterprise`: Move to the **Enterprise** tier.
|
|
149
|
+
- Renew / reset your current monthly quotas with `POST /api/v1/user/subscription/renew`.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### API Reference
|
|
154
|
+
|
|
155
|
+
All protected endpoints accept either `Authorization: Bearer <JWT_TOKEN>` or `x-api-key: <API_KEY>`.
|
|
156
|
+
|
|
157
|
+
#### Authentication
|
|
158
|
+
|
|
159
|
+
| Method | Endpoint | Description |
|
|
160
|
+
|--------|----------|-------------|
|
|
161
|
+
| `POST` | `/api/v1/auth/register` | Register a new user account (Automatically generates first API key) |
|
|
162
|
+
| `POST` | `/api/v1/auth/init-superuser` | Bootstraps the system by creating the first superuser. Returns `403` if a superuser already exists. |
|
|
163
|
+
| `POST` | `/api/v1/auth/login` | JSON login — returns a JWT. Returns `404` if the email is not found, `401` for a wrong password |
|
|
164
|
+
| `POST` | `/api/v1/auth/token` | OAuth2 form-data login — returns a JWT |
|
|
165
|
+
| `POST` | `/api/v1/auth/request-password-recovery` | Send a password recovery email. Requires `email`. |
|
|
166
|
+
| `POST` | `/api/v1/auth/reset-password` | Reset password. Requires a valid reset `token` and a `new_password`. |
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Register
|
|
170
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/register \
|
|
171
|
+
-H "Content-Type: application/json" \
|
|
172
|
+
-d '{ "email": "user@example.com", "password": "yourpassword" }'
|
|
173
|
+
|
|
174
|
+
# Create Initial Superuser (Run only once to bootstrap)
|
|
175
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/init-superuser \
|
|
176
|
+
-H "Content-Type: application/json" \
|
|
177
|
+
-d '{ "email": "admin@example.com", "password": "secureadminpassword" }'
|
|
178
|
+
|
|
179
|
+
# Login (JSON)
|
|
180
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/login \
|
|
181
|
+
-H "Content-Type: application/json" \
|
|
182
|
+
-d '{ "email": "user@example.com", "password": "yourpassword" }'
|
|
183
|
+
# Response: { "access_token": "...", "token_type": "bearer" }
|
|
184
|
+
|
|
185
|
+
# Request Password Recovery
|
|
186
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/request-password-recovery \
|
|
187
|
+
-H "Content-Type: application/json" \
|
|
188
|
+
-d '{ "email": "user@example.com" }'
|
|
189
|
+
|
|
190
|
+
# Reset Password (using token from email/logs)
|
|
191
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/auth/reset-password \
|
|
192
|
+
-H "Content-Type: application/json" \
|
|
193
|
+
-d '{ "token": "<JWT_TOKEN>", "new_password": "newsecurepassword" }'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
#### User
|
|
199
|
+
|
|
200
|
+
| Method | Endpoint | Auth Required | Description |
|
|
201
|
+
|--------|----------|---------------|-------------|
|
|
202
|
+
| `GET` | `/api/v1/user/profile` | ✅ | Get profile and quota info for the authenticated user |
|
|
203
|
+
| `PUT` | `/api/v1/user/profile` | ✅ | Update optional attributes (like `slack_webhook_url` or `github_token`) |
|
|
204
|
+
| `GET` | `/api/v1/user/usage` | ✅ | Get usage history and current-month credit summary |
|
|
205
|
+
| `GET` | `/api/v1/user/api-keys` | ✅ | List all active API keys for the user (New) |
|
|
206
|
+
| `POST` | `/api/v1/user/api-key` | ✅ | Generate a new random API key (returns the key in the response) |
|
|
207
|
+
| `POST` | `/api/v1/user/subscription/team` | ✅ | Upgrade user to the Team Tier |
|
|
208
|
+
| `POST` | `/api/v1/user/subscription/enterprise` | ✅ | Upgrade user to the Enterprise Tier |
|
|
209
|
+
| `POST` | `/api/v1/user/subscription/renew` | ✅ | Renew current monthly quota (optionally pass `?amount=100.0`) |
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Update user profile
|
|
213
|
+
curl -X PUT https://code-security-platform.onrender.com/api/v1/user/profile \
|
|
214
|
+
-H "Authorization: Bearer <JWT_TOKEN>" \
|
|
215
|
+
-H "Content-Type: application/json" \
|
|
216
|
+
-d '{ "slack_webhook_url": "https://hooks.slack.com/services/...", "github_token": "ghp_..." }'
|
|
217
|
+
|
|
218
|
+
# Get usage
|
|
219
|
+
curl https://code-security-platform.onrender.com/api/v1/user/usage \
|
|
220
|
+
-H "Authorization: Bearer <JWT_TOKEN>"
|
|
221
|
+
|
|
222
|
+
# Renew quota
|
|
223
|
+
curl -X POST "https://code-security-platform.onrender.com/api/v1/user/subscription/renew?amount=100.0" \
|
|
224
|
+
-H "Authorization: Bearer <JWT_TOKEN>"
|
|
225
|
+
|
|
226
|
+
# Upgrade to Team Plan
|
|
227
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/user/subscription/team \
|
|
228
|
+
-H "Authorization: Bearer <JWT_TOKEN>"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
#### Admin
|
|
234
|
+
|
|
235
|
+
| Method | Endpoint | Auth Required | Description |
|
|
236
|
+
|--------|----------|---------------|-------------|
|
|
237
|
+
| `GET` | `/api/v1/admin/users` | ✅ (superuser) | List all registered users |
|
|
238
|
+
| `PUT` | `/api/v1/admin/users/{user_id}` | ✅ (superuser) | Update a user's plan, quota, or `is_superuser` status |
|
|
239
|
+
| `GET` | `/api/v1/admin/scans` | ✅ (superuser) | List all security scans on the platform |
|
|
240
|
+
| `GET` | `/api/v1/admin/findings/fixed` | ✅ (superuser) | List all fixed vulnerabilities across the platform |
|
|
241
|
+
| `GET` | `/api/v1/admin/health/stats` | ✅ (superuser) | Get system-wide health percentage and security stats |
|
|
242
|
+
| `GET` | `/api/v1/admin/events` | ✅ (superuser) | List latest platform-wide events (scans, resolutions, etc.). Supports `offset` and `limit` (default 3). |
|
|
243
|
+
| `POST` | `/api/v1/admin/scans/requeue` | ✅ (superuser) | Re-enqueue all scans stuck in 'queued' status. |
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# List users
|
|
247
|
+
curl https://code-security-platform.onrender.com/api/v1/admin/users \
|
|
248
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>"
|
|
249
|
+
|
|
250
|
+
# Promote user to enterprise
|
|
251
|
+
curl -X PUT https://code-security-platform.onrender.com/api/v1/admin/users/<USER_ID> \
|
|
252
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>" \
|
|
253
|
+
-H "Content-Type: application/json" \
|
|
254
|
+
-d '{ "plan": "enterprise" }'
|
|
255
|
+
|
|
256
|
+
# List all scans on platform
|
|
257
|
+
curl https://code-security-platform.onrender.com/api/v1/admin/scans \
|
|
258
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>"
|
|
259
|
+
|
|
260
|
+
# List all fixed vulnerabilities on platform
|
|
261
|
+
curl https://code-security-platform.onrender.com/api/v1/admin/findings/fixed \
|
|
262
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>"
|
|
263
|
+
|
|
264
|
+
# Get overall system health percentage
|
|
265
|
+
curl https://code-security-platform.onrender.com/api/v1/admin/health/stats \
|
|
266
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>"
|
|
267
|
+
|
|
268
|
+
# Get latest platform events (paginated, shows 3 by default)
|
|
269
|
+
curl https://code-security-platform.onrender.com/api/v1/admin/events \
|
|
270
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>"
|
|
271
|
+
|
|
272
|
+
# Get legacy events with custom offset/limit
|
|
273
|
+
curl "https://code-security-platform.onrender.com/api/v1/admin/events?offset=3&limit=5" \
|
|
274
|
+
-H "Authorization: Bearer <SUPERUSER_JWT>"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
#### Scans
|
|
281
|
+
|
|
282
|
+
| Method | Endpoint | Auth Required | Description |
|
|
283
|
+
|--------|----------|---------------|-------------|
|
|
284
|
+
| `POST` | `/api/v1/scans` | ✅ (quota enforced) | Start a new security scan |
|
|
285
|
+
| `GET` | `/api/v1/scans` | ✅ | List all scans for the authenticated user |
|
|
286
|
+
| `GET` | `/api/v1/scans/{scan_id}` | ✅ | Get details of a specific scan |
|
|
287
|
+
| `DELETE` | `/api/v1/scans/{scan_id}` | ✅ | Remove a scan that is currently in 'queued' state |
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# Start a scan
|
|
291
|
+
curl -X POST https://code-security-platform.onrender.com/api/v1/scans \
|
|
292
|
+
-H "Authorization: Bearer <JWT_TOKEN>" \
|
|
293
|
+
-H "Content-Type: application/json" \
|
|
294
|
+
-d '{ "repo_url": "https://github.com/owner/repo" }'
|
|
295
|
+
|
|
296
|
+
# Remove a queued scan
|
|
297
|
+
curl -X DELETE https://code-security-platform.onrender.com/api/v1/scans/{scan_id} \
|
|
298
|
+
-H "Authorization: Bearer <JWT_TOKEN>"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
#### Findings & Resolution
|
|
304
|
+
|
|
305
|
+
| Method | Endpoint | Auth Required | Description |
|
|
306
|
+
|--------|----------|---------------|-------------|
|
|
307
|
+
| `GET` | `/api/v1/findings/fixed` | ✅ | List all successfully resolved vulnerabilities |
|
|
308
|
+
| `GET` | `/api/v1/findings/{finding_id}` | ✅ | Fetch details of a specific finding (including PR URL) |
|
|
309
|
+
| `POST` | `/api/v1/findings/{target_id}/resolve` | ✅ (quota enforced) | Resolve a finding or all findings in a scan |
|
|
310
|
+
|
|
311
|
+
Pass a **Finding ID** to fix one vulnerability or a **Scan ID** to fix all findings in that scan.
|
|
312
|
+
Add `?force_sync=true` to wait for the result synchronously.
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
curl -X POST "https://code-security-platform.onrender.com/api/v1/findings/<ID>/resolve?force_sync=true" \
|
|
316
|
+
-H "Authorization: Bearer <JWT_TOKEN>" \
|
|
317
|
+
-H "Content-Type: application/json" \
|
|
318
|
+
-d '{ "github_token": "your_personal_access_token" }'
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
#### Observability
|
|
324
|
+
|
|
325
|
+
| Method | Endpoint | Description |
|
|
326
|
+
|--------|----------|-------------|
|
|
327
|
+
| `GET` | `/api/v1/metrics` | Prometheus metrics (CPU, request counts, latencies, etc.) |
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Running the worker (queue mode)
|
|
332
|
+
|
|
333
|
+
- Local (dev):
|
|
334
|
+
```bash
|
|
335
|
+
# start a local redis (homebrew) or use docker-compose (recommended)
|
|
336
|
+
redis-server --port 6379 &
|
|
337
|
+
REDIS_URL=redis://localhost:6379 rq worker scans
|
|
338
|
+
# or use the convenience entrypoint
|
|
339
|
+
REDIS_URL=redis://localhost:6379 python -m app.worker
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
- With Docker Compose (recommended):
|
|
343
|
+
```bash
|
|
344
|
+
docker compose up --build
|
|
345
|
+
# api -> https://code-security-platform.onrender.com
|
|
346
|
+
# worker logs are visible in the `worker` service
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Observability (Prometheus + Sentry) 📈
|
|
350
|
+
|
|
351
|
+
- API metrics: `GET /api/v1/metrics` (Prometheus format)
|
|
352
|
+
- Worker metrics: exposed on `9100` by default when running the worker
|
|
353
|
+
- Sentry: set `SENTRY_DSN` to enable error reporting from API & worker
|
|
354
|
+
|
|
355
|
+
Example (local):
|
|
356
|
+
```bash
|
|
357
|
+
# run everything with docker-compose
|
|
358
|
+
SENTRY_DSN="" docker compose up --build
|
|
359
|
+
# scrape metrics from https://security-compliance-platform.fly.dev/metrics and http://localhost:9100/
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## CI / running without Redis
|
|
363
|
+
|
|
364
|
+
- The scaffold supports a synchronous fallback for local dev and CI. Set `WORKER_SYNC=true` to run scan jobs synchronously (the default in tests/CI).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scp-cli"
|
|
7
|
+
version = "0.1.7"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Maxwell Sarpong", email="maxwell@example.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "Security Compliance Platform CLI - Secure your code from the terminal."
|
|
12
|
+
readme = "CLIREADME.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"typer>=0.9.0",
|
|
21
|
+
"rich>=13.0.0",
|
|
22
|
+
"requests>=2.31.0"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
# This tells pip to create a terminal command called "scp"
|
|
27
|
+
# that points to the "app" Typer instance inside "src/app/cli.py"
|
|
28
|
+
scp-cli = "app.cli:app"
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.packages.find]
|
|
31
|
+
where = ["src"]
|
scp_cli-0.1.7/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.7"
|
|
File without changes
|