Skip to content

Commit 2f7cc15

Browse files
Change arch (#156)
* Improve coverage and clean up tests * Fix formatter protocol contract * Refine reporter structure and adapter naming * improve report component * improve report component * remove backward compatibility shims * fix tests after removing compatibility shims * polish docs and main import * document sandbox provider return types * add auth loader coverage tests
1 parent 9228cf5 commit 2f7cc15

Some content is hidden

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

49 files changed

+2346
-532
lines changed

README.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,105 @@ It does **not** use instrumentation-based fuzzing (no coverage or binary/source
5151

5252
### Basic Fuzzer Flow
5353

54-
![Basic fuzzer flow diagram](images/fuzzer-flow.svg)
54+
```mermaid
55+
flowchart TB
56+
subgraph CLI["CLI + Config"]
57+
A1[parse_arguments]
58+
A2[ValidationManager]
59+
A3[build_cli_config]
60+
A4[ClientSettings]
61+
A1 --> A2 --> A3 --> A4
62+
end
63+
64+
subgraph Runtime["Runtime Orchestration"]
65+
B1[run_with_retry_on_interrupt]
66+
B2[unified_client_main]
67+
B3[RunPlan + Commands]
68+
B4[ClientExecutionPipeline]
69+
B1 --> B2 --> B3 --> B4
70+
end
71+
72+
subgraph Transport["Transport Layer"]
73+
C1[DriverCatalog + build_driver]
74+
C2[TransportDriver]
75+
C3[HttpDriver / SseDriver / StdioDriver / StreamHttpDriver]
76+
C4[JsonRpcAdapter]
77+
C5[RetryingTransport (optional)]
78+
C1 --> C2 --> C3
79+
C3 --> C4
80+
C3 --> C5
81+
end
82+
83+
subgraph Clients["Client Layer"]
84+
D1[MCPFuzzerClient]
85+
D2[ToolClient]
86+
D3[ProtocolClient]
87+
D1 --> D2
88+
D1 --> D3
89+
end
90+
91+
subgraph Mutators["Mutators + Strategies"]
92+
E1[ToolMutator]
93+
E2[ProtocolMutator]
94+
E3[ToolStrategies / ProtocolStrategies]
95+
E4[SeedPool + mutate_seed_payload]
96+
E1 --> E3
97+
E2 --> E3
98+
E1 --> E4
99+
E2 --> E4
100+
end
101+
102+
subgraph Execution["Execution + Concurrency"]
103+
F1[AsyncFuzzExecutor]
104+
F2[ToolExecutor]
105+
F3[ProtocolExecutor]
106+
F4[ResultBuilder]
107+
F1 --> F2
108+
F1 --> F3
109+
F2 --> F4
110+
F3 --> F4
111+
end
112+
113+
subgraph Safety["Safety System"]
114+
G1[SafetyFilter + DangerDetector]
115+
G2[Filesystem Sandbox]
116+
G3[System Command Blocker]
117+
G4[Network Policy]
118+
G1 --> G2
119+
G1 --> G3
120+
G1 --> G4
121+
end
122+
123+
subgraph RuntimeMgr["Process Runtime"]
124+
H1[ProcessManager]
125+
H2[ProcessWatchdog]
126+
H3[SignalDispatcher]
127+
H4[ProcessSupervisor]
128+
H1 --> H2
129+
H1 --> H3
130+
H4 --> H1
131+
end
132+
133+
subgraph Reporting["Reporting + Output"]
134+
I1[FuzzerReporter]
135+
I2[FormatterRegistry]
136+
I3[OutputProtocol + OutputManager]
137+
I4[Console/JSON/CSV/XML/HTML/MD Formatters]
138+
I1 --> I2 --> I4
139+
I1 --> I3
140+
end
141+
142+
A4 --> B1
143+
B4 --> D1
144+
C1 --> D1
145+
D2 --> E1
146+
D3 --> E2
147+
E1 --> F2
148+
E2 --> F3
149+
D1 --> G1
150+
C3 --> H4
151+
D1 --> I1
152+
```
55153

56154
### Extensibility for Contributors
57155
MCP Server Fuzzer is designed for easy extension while keeping CLI usage simple:

docs/architecture/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ flowchart TB
2525
end
2626
2727
subgraph Client
28-
B1[UnifiedMCPFuzzerClient (client/main.py)]
28+
B1[MCPFuzzerClient (client/main.py)]
2929
B2[Safety Integration]
3030
B3[Reporting Integration]
3131
end

docs/components/process-management.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ The executor's concurrency can be configured in several ways:
3636
executor = AsyncFuzzExecutor(max_concurrency=10)
3737
```
3838

39-
2. **Via UnifiedMCPFuzzerClient**:
39+
2. **Via MCPFuzzerClient**:
4040

4141
```python
42-
client = UnifiedMCPFuzzerClient(
42+
client = MCPFuzzerClient(
4343
transport,
4444
max_concurrency=10 # Controls concurrency for both tool and protocol fuzzers
4545
)
@@ -174,6 +174,20 @@ async def main():
174174
asyncio.run(main())
175175
```
176176

177+
### ProcessManager Lifecycle States
178+
179+
| Stage | Trigger | Notes |
180+
| --- | --- | --- |
181+
| Unregistered | Initial state | Process not tracked by registry. |
182+
| Registered | `register_existing_process` | Process added to registry and watchdog. |
183+
| Running | `start_process` | Process launched and `started` event emitted. |
184+
| Stopping | `stop_process` | Graceful/forced stop requested. |
185+
| Stopped | `stop_process` / exit | Process stopped, `stopped` event emitted. |
186+
| Shutdown | `shutdown` | All processes stopped, watchdog stopped, registry cleared. |
187+
188+
Events emitted by the manager (`started`, `stopped`, `stopped_all`, `shutdown`,
189+
`shutdown_failed`, `signal`, `signal_all`) allow observers to track transitions.
190+
177191
## Configuration
178192

179193
### WatchdogConfig

docs/components/safety.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,51 @@ it to a bug report or CI artifact. Standardized output artifacts (`output.types`
160160
containing `safety_summary`) convey the same information in a machine-readable
161161
format.
162162

163+
## Extending Detection and Sandbox Providers
164+
165+
You can customize detection patterns by passing explicit lists when constructing
166+
`SafetyFilter`:
167+
168+
```python
169+
from mcp_fuzzer.safety_system.safety import SafetyFilter
170+
171+
custom_filter = SafetyFilter(
172+
dangerous_url_patterns=[r"https?://", r"example\\.com"],
173+
dangerous_script_patterns=[r"<script", r"onload="],
174+
dangerous_command_patterns=[r"rm\\s+-rf", r"shutdown"],
175+
dangerous_argument_names=["path", "command"],
176+
)
177+
```
178+
179+
To swap the filesystem sandbox implementation, implement the `SandboxProvider`
180+
protocol and pass it to `SafetyFilter`:
181+
182+
```python
183+
from mcp_fuzzer.safety_system.safety import SandboxProvider, SafetyFilter
184+
from mcp_fuzzer.safety_system.filesystem.sandbox import FilesystemSandbox
185+
186+
class CustomSandbox(SandboxProvider):
187+
def initialize(self, root: str) -> None:
188+
...
189+
190+
def get_sandbox(self) -> FilesystemSandbox:
191+
...
192+
193+
custom_filter = SafetyFilter(sandbox_provider=CustomSandbox())
194+
```
195+
196+
## Minimal Policy Configuration Example
197+
198+
```yaml
199+
safety_enabled: true
200+
enable_safety_system: true
201+
fs_root: "~/.mcp_fuzzer"
202+
no_network: true
203+
allow_hosts:
204+
- "localhost"
205+
- "127.0.0.1"
206+
```
207+
163208
## Best Practices
164209
165210
- Always combine `--enable-safety-system` with a sandboxed `--fs-root` when

docs/configuration/configuration.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ timeout: 30.0
5252
tool_timeout: 10.0
5353
log_level: "INFO"
5454

55+
# Transport retry policy (optional)
56+
# transport_retries: Total attempts for transport requests (1 disables retries)
57+
# transport_retry_delay: Base delay between retries (seconds)
58+
# transport_retry_backoff: Backoff multiplier
59+
# transport_retry_max_delay: Maximum delay between retries (seconds)
60+
# transport_retry_jitter: Jitter factor for retry delay
61+
transport_retries: 1
62+
transport_retry_delay: 0.5
63+
transport_retry_backoff: 2.0
64+
transport_retry_max_delay: 5.0
65+
transport_retry_jitter: 0.1
66+
5567
# Safety and filesystem constraints
5668
safety_enabled: true
5769
enable_safety_system: false
@@ -198,8 +210,8 @@ export_csv: "reports/results.csv"
198210
export_html: "reports/results.html"
199211
```
200212

201-
Standardized output files are currently emitted as JSON; `output.format` is
202-
accepted for compatibility with legacy tooling.
213+
Standardized output files are currently emitted as JSON regardless of
214+
`output.format`; other values are reserved for future formats.
203215

204216
## Authentication Configuration
205217

@@ -244,5 +256,3 @@ custom_transports:
244256
Use the transport by setting `protocol: mytransport` in the same config file.
245257

246258
## Notes
247-
248-
- Standardized output files are currently emitted as JSON; `output.format` is accepted for compatibility.

0 commit comments

Comments
 (0)