Skip to content

Commit 0e06cbf

Browse files
committed
Refactor project structure and enhance documentation
- Removed `ai_engine.py` file and migrated its functionalities to a modular `AI/` package. - Added `pyproject.toml` for improved dependency management and build configuration. - Updated `.gitignore` to exclude egg-info files. - Revised `CONTRIBUTING.md` and `README.md` to reflect changes in installation instructions and usage. - Enhanced GitHub Actions workflow to include development dependencies during installation. - Introduced new modules for schema fetching, test execution, and report generation, improving overall organization and maintainability.
1 parent 22f8aa3 commit 0e06cbf

23 files changed

Lines changed: 132 additions & 56 deletions

.github/workflows/secnode-pentest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
python-version: '3.10'
1616

1717
- name: Install dependencies
18-
run: pip install -r requirements.txt
18+
run: pip install -r requirements.txt && pip install -e .[dev]
1919

2020
- name: Run tests
2121
run: pytest
@@ -32,11 +32,11 @@ jobs:
3232
python-version: '3.10'
3333

3434
- name: Install SecNode
35-
run: pip install -r requirements.txt
35+
run: pip install -r requirements.txt && pip install -e .
3636

3737
- name: Run SecNode Scan
3838
env:
3939
SECNODE_LLM: ${{ secrets.SECNODE_LLM }}
4040
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
4141
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
42-
run: python3 secnodeapi.py --target https://staging-api.example.com/swagger.json
42+
run: secnodeapi --target https://staging-api.example.com/swagger.json

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ __pycache__/
1515
.pytest_cache/
1616
.coverage
1717
htmlcov/
18+
*.egg-info/
1819

1920
# macOS
2021
.DS_Store

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Thank you for your interest in contributing to SecNode API! This guide will help
2626
3. **Install dependencies**
2727
```bash
2828
pip install -r requirements.txt
29+
pip install -e .[dev]
2930
```
3031

3132
4. **Configure your LLM provider**
@@ -41,7 +42,7 @@ Thank you for your interest in contributing to SecNode API! This guide will help
4142

4243
5. **Run SecNode in development mode**
4344
```bash
44-
python3 secnodeapi.py --target https://api.example.com/swagger.json
45+
secnodeapi --target https://api.example.com/swagger.json
4546
```
4647

4748
## Enhancing the AI Engine

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ cd secnodeapi
4949
python3 -m venv venv
5050
source venv/bin/activate
5151
pip install -r requirements.txt
52+
pip install -e .
5253

5354
# Configure your AI provider
5455
export SECNODE_LLM="openai/gpt-4o"
5556
export OPENAI_API_KEY="your-api-key"
5657

5758
# Run your first security assessment
58-
python3 secnodeapi.py --target https://api.your-app.com/swagger.yaml
59+
secnodeapi --target https://api.your-app.com/swagger.yaml
5960
```
6061

6162
> [!NOTE]
@@ -89,28 +90,28 @@ SecNode rigorously hunts for:
8990
### Basic Usage
9091
```bash
9192
# Scan an API using a remote Swagger JSON
92-
python3 secnodeapi.py --target http://vulnapi.your-app.com/swagger.json
93+
secnodeapi --target http://vulnapi.your-app.com/swagger.json
9394

9495
# Scan an API using a local OpenAPI YAML file
95-
python3 secnodeapi.py --target ./docs/openapi.yaml
96+
secnodeapi --target ./docs/openapi.yaml
9697
```
9798

9899
### Advanced Testing Scenarios
99100
```bash
100101
# Authenticated Testing (using inline Bearer token)
101-
python3 secnodeapi.py --target https://api.your-app.com/docs \
102+
secnodeapi --target https://api.your-app.com/docs \
102103
--auth-header "Authorization: Bearer my-jwt-token"
103104

104105
# Authenticated Testing (using a JSON auth file)
105-
python3 secnodeapi.py --target https://api.your-app.com/docs \
106+
secnodeapi --target https://api.your-app.com/docs \
106107
--auth-file ./config/auth.json
107108

108109
# Proxy Traffic (e.g. send traffic through Burp Suite/ZAP for manual review)
109-
python3 secnodeapi.py --target https://api.your-app.com/docs \
110+
secnodeapi --target https://api.your-app.com/docs \
110111
--proxy http://127.0.0.1:8080
111112

112113
# Control Concurrency (Scale execution speed)
113-
python3 secnodeapi.py --target https://api.your-app.com/docs \
114+
secnodeapi --target https://api.your-app.com/docs \
114115
--concurrency 10
115116
```
116117

@@ -135,14 +136,14 @@ jobs:
135136
python-version: '3.10'
136137

137138
- name: Install SecNode
138-
run: pip install -r requirements.txt
139+
run: pip install -r requirements.txt && pip install -e .
139140

140141
- name: Run SecNode Scan
141142
env:
142143
SECNODE_LLM: ${{ secrets.SECNODE_LLM }}
143144
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
144145
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
145-
run: python3 secnodeapi.py --target https://staging-api.example.com/swagger.json
146+
run: secnodeapi --target https://staging-api.example.com/swagger.json
146147
```
147148
148149
### Configuration

ai_engine.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

pyproject.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[build-system]
2+
requires = ["setuptools>=69", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "secnodeapi"
7+
version = "0.1.0"
8+
description = "Autonomous, AI-augmented API penetration testing framework."
9+
readme = "README.md"
10+
requires-python = ">=3.9"
11+
dependencies = [
12+
"httpx==0.27.0",
13+
"pydantic==2.6.3",
14+
"structlog==24.1.0",
15+
"litellm==1.34.0",
16+
"PyYAML==6.0.1",
17+
]
18+
19+
[project.optional-dependencies]
20+
dev = [
21+
"pytest==8.3.5",
22+
"pytest-asyncio==0.25.3",
23+
]
24+
25+
[project.scripts]
26+
secnodeapi = "secnodeapi.cli:entrypoint"
27+
28+
[tool.setuptools]
29+
package-dir = {"" = "src"}
30+
31+
[tool.setuptools.packages.find]
32+
where = ["src"]
33+
34+
[tool.pytest.ini_options]
35+
testpaths = ["tests"]
36+
python_files = ["test_*.py"]
37+
asyncio_mode = "strict"
38+
asyncio_default_fixture_loop_scope = "function"

pytest.ini

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/secnodeapi/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
SecNode API package.
3+
"""
4+
5+
__all__ = []

src/secnodeapi/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .cli import entrypoint
2+
3+
4+
if __name__ == "__main__":
5+
entrypoint()

0 commit comments

Comments
 (0)