Skip to content

Commit f16ee5c

Browse files
Merge branch 'bug-bounty-mode' into bug-bounty-test
2 parents fef618f + 681cff0 commit f16ee5c

122 files changed

Lines changed: 12158 additions & 390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.py[cod]
8+
*$py.class
9+
*.so
10+
.Python
11+
.venv
12+
venv/
13+
env/
14+
.eggs
15+
*.egg-info/
16+
*.egg
17+
dist/
18+
build/
19+
20+
# IDEs
21+
.vscode/
22+
.idea/
23+
*.swp
24+
*.swo
25+
26+
# Testing
27+
.pytest_cache/
28+
.coverage
29+
htmlcov/
30+
.tox/
31+
32+
# SecNode specific
33+
.sisyphus/
34+
results/
35+
*.log
36+
37+
# OS
38+
.DS_Store
39+
Thumbs.db

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ ANTHROPIC_API_KEY=
77

88
# Optional local endpoint when using ollama/* models
99
OLLAMA_API_BASE=http://localhost:11434
10+
11+
# Nebius Token Factory (OpenAI-compatible)
12+
# OPENAI_API_BASE=https://api.tokenfactory.nebius.com/v1
13+
# NEBIUS_API_KEY=your-token
14+
# SECNODE_LLM=openai/meta-llama/Meta-Llama-3.1-8B-Instruct

.github/workflows/secnode-pentest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: uv run ruff check src tests
2525

2626
- name: Run tests with coverage
27-
run: uv run pytest --cov=src/secnodeapi --cov-report=term-missing --cov-fail-under=50
27+
run: uv run pytest --cov=src/secnodeapi --cov-report=term-missing --cov-fail-under=20
2828

2929
- name: Contract schema tests
3030
run: uv run pytest tests/test_contracts.py -v
@@ -69,7 +69,7 @@ jobs:
6969
- uses: actions/checkout@v4
7070

7171
- name: Build image
72-
run: docker build -t secnodeapi:ci -f docker/Dockerfile .
72+
run: docker build -t secnodeapi:ci -f deploy/Dockerfile .
7373

7474
- name: Trivy scan
7575
uses: aquasecurity/[email protected]

.gitignore

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,29 @@ env/
77
ENV/
88
env.bak/
99
venv.bak/
10+
.env.local
11+
.env.*.local
1012

11-
# Application results
13+
# Application results and session data
1214
results/
1315
strix_runs/
1416
test_output.txt
1517
all_tests.txt
1618

1719
# Python Cache and Compilation
20+
.sisyphus/
21+
.secnode_temp/
22+
.api-agent/
23+
all_tests.txt
24+
test_output.txt
25+
26+
# Python cache and build
1827
__pycache__/
1928
*.py[cod]
2029
*$py.class
2130
*.so
2231
.pytest_cache/
32+
.ruff_cache/
2333
.coverage
2434
.coverage.*
2535
coverage.xml
@@ -46,6 +56,9 @@ share/python-wheels/
4656

4757
# Logs
4858
*.log
59+
dist/
60+
build/
61+
*.egg
4962

5063
# macOS
5164
.DS_Store
@@ -93,3 +106,11 @@ $RECYCLE.BIN/
93106
# Jupyter Notebook
94107
.ipynb_checkpoints
95108

109+
# IDEs and editor config
110+
.idea/
111+
.vscode/
112+
.cursor/
113+
.cursorrules
114+
115+
# Logs
116+
*.log

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.ht
1515
- CI container vulnerability scanning via Trivy.
1616
- CI dependency vulnerability audit using `pip-audit`.
1717
- Developer workflows for local stack (`make up`, `make down`) and audit target (`make audit-uv`).
18+
- MCP (Model Context Protocol) server via `secnodeapi-mcp` with tools (run_scan, run_skill, list_skills, export_report) and resources for Cursor/IDE integration.
1819

1920
### Changed
2021

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Thank you for your interest in contributing to SecNode API! This guide will help
1414

1515
1. **Clone the repository**
1616
```bash
17-
git clone https://github.com/secnode/secnodeapi.git
18-
cd secnodeapi
17+
git clone https://github.com/SecNode/API-PENTESTER.git
18+
cd API-PENTESTER
1919
```
2020

2121
2. **Set up a virtual environment**
@@ -81,7 +81,7 @@ SecNode relies heavily on its `ai/` package (`understand`, `generate`, `validate
8181

8282
### Quick Guide
8383

84-
1. **Understand Pipeline Flow:** Familiarize yourself with how `schema_fetcher`, `ai_engine`, and `test_executor` interact.
84+
1. **Understand Pipeline Flow:** Familiarize yourself with how `schema_fetcher`, `ai_engine`, and `http_executor` interact.
8585
2. **Improve System Prompts:** If adding support for new vulnerability classes, update the system prompts inside `generate_test_cases()`.
8686
3. **Refine Heuristics:** If the engine is flagging false positives, refine the Chain-of-Thought heuristics inside `_evaluate_single_result()`.
8787
4. **Submit via PR** with clear descriptions of the accuracy/coverage improvement.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ test-uv:
3030
$(UV) run pytest
3131

3232
test-cov:
33-
pytest --cov=src/secnodeapi --cov-report=term-missing --cov-fail-under=70
33+
pytest --cov=src/secnodeapi --cov-report=term-missing --cov-fail-under=20
3434

3535
test-cov-uv:
36-
$(UV) run pytest --cov=src/secnodeapi --cov-report=term-missing --cov-fail-under=70
36+
$(UV) run pytest --cov=src/secnodeapi --cov-report=term-missing --cov-fail-under=20
3737

3838
build:
3939
$(PYTHON) -m pip install build

README.md

Lines changed: 127 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ SecNode API helps security engineers and backend teams run repeatable API risk a
1616
- Executes tests concurrently with optional proxy routing
1717
- Supports autonomous agent mode with request budgets and iterative replanning
1818
- Supports direct microservices mode with controller/planner/worker boundaries
19-
- Produces both human-readable and machine-readable findings
19+
- Bug bounty mode with strict scope enforcement for authorized testing
20+
- TUI (`secnodeapi-tui`) for interactive scans and skill execution
21+
- MCP server for Cursor and IDE integration
22+
- Produces both human-readable and machine-readable findings (Markdown, SARIF, JUnit)
2023

2124
## What It Is and Is Not
2225

@@ -93,6 +96,16 @@ export SECNODE_LLM="nebius/meta-llama/Meta-Llama-3.1-70B-Instruct"
9396
export NEBIUS_API_KEY="your-nebius-key"
9497
```
9598

99+
Or with Nebius Token Factory (OpenAI-compatible):
100+
101+
```bash
102+
export SECNODE_LLM="openai/meta-llama/Meta-Llama-3.1-8B-Instruct"
103+
export OPENAI_API_BASE="https://api.tokenfactory.nebius.com/v1"
104+
export NEBIUS_API_KEY="your-nebius-token"
105+
```
106+
107+
Run `secnodeapi --list-models` to see available model IDs for your endpoint.
108+
96109
Provider credentials are model-specific. `openai/*` requires `OPENAI_API_KEY`, `anthropic/*`
97110
requires `ANTHROPIC_API_KEY`, `nebius/*` requires `NEBIUS_API_KEY`, and `ollama/*` can run locally without cloud API keys.
98111
See [LiteLLM providers](https://docs.litellm.ai/docs/providers).
@@ -116,20 +129,27 @@ Reports are written to `results/<target_or_local_schema>_<timestamp>/`.
116129
## CLI Usage
117130

118131
```bash
132+
secnodeapi --list-models
119133
secnodeapi --target ./openapi.yaml --schema-only
120134
secnodeapi --target https://api.example.com/swagger.json --dry-run --dry-run-output ./results/tests.json
121135
secnodeapi --target https://api.example.com/swagger.json --auth-header "Authorization: Bearer <token>"
122136
secnodeapi --target https://api.example.com/swagger.json --proxy http://127.0.0.1:8080 --insecure
123137
secnodeapi --target https://api.example.com/swagger.json --mode agent --request-budget 500 --max-iterations 6
124138
secnodeapi --target https://api.example.com/swagger.json --mode agent --instruction "username=admin, role=superuser" --instruction "username=user"
125139
secnodeapi --target https://api.example.com/swagger.json --mode microservices
140+
secnodeapi --target https://api.example.com --mode bugbounty --program "Acme BBP" --scope host:api.example.com --scope path:/api --bb-instruction "Only test assigned API assets"
141+
```
142+
143+
```bash
144+
secnodeapi-tui --target https://api.example.com --backend local
145+
secnodeapi-tui --target https://api.example.com --backend remote --api-base-url http://127.0.0.1:8000
126146
```
127147

128148
### Key options
129149

130-
- `--target` URL or local path to OpenAPI schema (required)
131-
- `--mode` `agent` (default) or `legacy` execution pipeline
132-
- `--mode` `agent`, `legacy`, or `microservices`
150+
- `--target` URL or local path to OpenAPI schema (required unless `--list-models`)
151+
- `--list-models` list available models from OPENAI_API_BASE (for custom endpoints like Nebius)
152+
- `--mode` `agent`, `legacy`, `microservices`, `greybox`, or `bugbounty`
133153
- `--concurrency` concurrent request workers
134154
- `--auth-header` single inline auth header
135155
- `--auth-file` JSON file of auth headers
@@ -143,14 +163,38 @@ secnodeapi --target https://api.example.com/swagger.json --mode microservices
143163
- `--max-iterations` max plan/execute loops in agent mode
144164
- `--proxy` route traffic via proxy
145165
- `--insecure` disable TLS verification for controlled environments
166+
- `--scope` bug bounty scope entries (`host:`, `path:`, `method:`, `deny-host:`, `deny-path:`)
167+
- `--scope-file` JSON scope config for bug bounty mode
168+
- `--bb-instruction` repeatable bug bounty instruction passed to planning and enforcement
169+
- `--program` bug bounty program identifier for session metadata
170+
171+
TUI command highlights:
172+
173+
- `/scan <target>` create and run a scan session
174+
- `/skill <name>` run a selected skill
175+
- `/sessions` list saved snapshots from `~/.api-agent/sessions`
176+
- `/load <session-id>` load a saved snapshot into TUI panels
177+
- `/targets` list active in-memory targets from multi-session dashboard
178+
- `/switch <session-id>` switch active session in the dashboard
179+
- `/export <markdown|sarif> [path]` export findings from current session
180+
181+
### Bug bounty strict scope mode
182+
183+
`--mode bugbounty` enables strict scope enforcement. When this mode is active, out-of-scope invocations are blocked at both planning and runtime.
184+
185+
- Scope is required via `--scope` or `--scope-file`
186+
- Rules are persisted with the session policy
187+
- Any invocation outside allowed host/path/method constraints is rejected before tool execution
146188

147189
## Output
148190

149-
Each run generates an output directory containing:
191+
Each run generates an output directory under `results/` containing:
150192

151193
- `report.md` with executive summary, severity overview, and evidence sections
152194
- `findings.json` for machine processing and pipeline integration
153195

196+
Export formats include Markdown, SARIF, and JUnit for CI integration.
197+
154198
## Development
155199

156200
```bash
@@ -171,24 +215,37 @@ make test-cov-uv
171215
make build-uv
172216
```
173217

218+
On Windows, if `make` is unavailable, use `uv run` directly:
219+
220+
```powershell
221+
uv sync --extra dev
222+
uv run ruff check src tests
223+
uv run pytest
224+
uv run pytest --cov=src/secnodeapi --cov-report=term-missing
225+
uv build
226+
```
227+
174228
## CI
175229

176230
GitHub Actions workflow runs:
177231

178-
- lint checks
179-
- test suite with coverage thresholds
232+
- lint checks (ruff)
233+
- test suite with coverage thresholds (pytest)
180234
- package build
235+
- dependency vulnerability audit (pip-audit)
236+
- container vulnerability scan (Trivy)
181237
- scan job template for staging targets
182238

183239
## Direct Microservices Runtime
184240

185-
This repository now includes a direct microservices runtime foundation:
241+
This repository includes a direct microservices runtime foundation:
186242

187243
- Controller service
188244
- Planner service
189245
- Skill engine service with ranked skill dispatch
190246
- Specialized workers (recon, discovery, fuzzing, exploit)
191247
- Tool adapters (`ffuf`, `nuclei`, `sqlmap`, `zap`, `kiterunner`)
248+
- Python skills: BOLA, JWT tamper, XSS, SSRF, GraphQL injection/auth bypass, NoSQL injection, command injection, rate limit bypass, workflow exploit
192249
- Memory subsystem (session, history, skill metrics)
193250
- Attack graph engine
194251
- FastAPI control plane
@@ -199,6 +256,68 @@ Run local stack:
199256
docker compose -f deploy/docker-compose.yml up --build
200257
```
201258

259+
## Semantic Memory (Optional)
260+
261+
Long-term cross-session memory improves skill ranking and planning over time. Enable with Postgres + pgvector:
262+
263+
```bash
264+
uv sync --extra memory
265+
export SECNODE_SEMANTIC_MEMORY_ENABLED=true
266+
export SECNODE_POSTGRES_DSN=postgresql://secnode:secnode@localhost:5432/secnode
267+
```
268+
269+
The deploy stack uses `pgvector/pgvector:pg16-trixie` for Postgres. When enabled, the agent ingests target profiles, exploit attempts, endpoint patterns, and skill performance into vector storage. Retrieval augments planner context and skill ranking with historical success rates.
270+
271+
## MCP (Model Context Protocol)
272+
273+
SecNode API exposes an MCP server so AI assistants (Cursor, Claude Desktop, etc.) can run scans and query findings via tools.
274+
275+
### Install MCP support
276+
277+
```bash
278+
uv sync --extra mcp
279+
```
280+
281+
### Run the MCP server
282+
283+
Stdio (default, for Cursor/IDE integration):
284+
285+
```bash
286+
secnodeapi-mcp
287+
```
288+
289+
HTTP (for MCP Inspector or remote clients):
290+
291+
```bash
292+
secnodeapi-mcp --transport streamable-http --port 8010
293+
```
294+
295+
### Tools
296+
297+
- `run_scan(target)` run a full API pentest against the target URL
298+
- `run_skill(target, skill_name)` run a specific skill (e.g. api_path_fuzz, bola_test, jwt_tamper, xss_scan)
299+
- `list_skills()` list available pentesting skills
300+
- `export_report(session_id, format, output_path)` export findings to Markdown or SARIF
301+
302+
### Resources
303+
304+
- `secnode://session/{session_id}` fetch session details, findings, and attack paths
305+
306+
### Cursor configuration
307+
308+
Add to `.cursor/mcp.json` or Cursor MCP settings:
309+
310+
```json
311+
{
312+
"mcpServers": {
313+
"secnodeapi": {
314+
"command": "secnodeapi-mcp",
315+
"args": []
316+
}
317+
}
318+
}
319+
```
320+
202321
## Security and Responsible Use
203322

204323
Only test systems you own or are explicitly authorized to assess.
File renamed without changes.

0 commit comments

Comments
 (0)