Option C Tools
Loading...
Searching...
No Matches
tests_mcp.test_mcp_hardening Namespace Reference

Classes

class  TestGateway
class  TestInputValidation
class  TestPolicyHardening
class  TestSandboxHardening
class  TestRedactionHardening
class  TestAuditHardening
class  TestGeneralHardening

Functions

McpMetrics _isolated_metrics ()
tuple[ServerState, McpAuditLogger_make_state (Path tmp_path, str sandbox_output='{"exit_code":0}', int sandbox_exit_code=0, str profile="default", bool safe_mode=False, int rate_limit=30)
dict _last_audit (McpAuditLogger logger)

Detailed Description

Purpose
-------
Phase 5C programmatic sign-off of blueprint section 12 hardening
checklist.

Responsibilities
----------------
- Verify gateway controls (rate limit, tool manifest).
- Verify input validation (extra="forbid", path traversal, shell
  metacharacters).
- Verify policy enforcement (write-tool confirm, oct_format double-guard,
  strict profile).
- Verify sandbox constraints (no shell=True, cwd pinning, env
  sanitisation, timeout, output cap).
- Verify redaction (secrets, project path, truncation).
- Verify audit records (JSONL per call, session/request IDs).

Diagnostics
-----------
Domain: MCP-TESTS
Levels:
    L2 — test lifecycle
    L3 — assertion details
    L4 — deep tracing

Contracts
---------
- Tests use mock sandbox and ``tmp_path``; no real subprocess is
  spawned.

Function Documentation

◆ _isolated_metrics()

McpMetrics tests_mcp.test_mcp_hardening._isolated_metrics ( )
protected
McpMetrics on a private CollectorRegistry — avoids
``Duplicated timeseries`` collisions across tests.

Definition at line 63 of file test_mcp_hardening.py.

Here is the caller graph for this function:

◆ _last_audit()

dict tests_mcp.test_mcp_hardening._last_audit ( McpAuditLogger logger)
protected

Definition at line 106 of file test_mcp_hardening.py.

Here is the caller graph for this function:

◆ _make_state()

tuple[ServerState, McpAuditLogger] tests_mcp.test_mcp_hardening._make_state ( Path tmp_path,
str sandbox_output = '{"exit_code": 0}',
int sandbox_exit_code = 0,
str profile = "default",
bool safe_mode = False,
int rate_limit = 30 )
protected

Definition at line 72 of file test_mcp_hardening.py.

Here is the call graph for this function:
Here is the caller graph for this function: