Skip to content

Commit 730ec95

Browse files
authored
Merge pull request #134 from invariantlabs-ai/rename-insecure-flag
Rename --insecure flag to --skip-ssl-verify
2 parents a6a793f + 1826878 commit 730ec95

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

src/mcp_scan/MCPScanner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(
7676
verbose: bool = False,
7777
additional_headers: dict | None = None,
7878
control_servers: list | None = None,
79-
insecure: bool = False,
79+
skip_ssl_verify: bool = False,
8080
**kwargs: Any,
8181
):
8282
logger.info("Initializing MCPScanner")
@@ -95,7 +95,7 @@ def __init__(
9595
self.include_built_in = include_built_in
9696
self.control_servers = control_servers
9797
self.verbose = verbose
98-
self.insecure = insecure
98+
self.skip_ssl_verify = skip_ssl_verify
9999
logger.debug(
100100
"MCPScanner initialized with timeout: %d, checks_per_server: %d", server_timeout, checks_per_server
101101
)
@@ -306,7 +306,7 @@ async def scan(self) -> list[ScanPathResult]:
306306
opt_out_of_identity=self.opt_out_of_identity,
307307
skip_pushing=bool(self.control_servers),
308308
verbose=self.verbose,
309-
insecure=self.insecure,
309+
skip_ssl_verify=self.skip_ssl_verify,
310310
)
311311
logger.debug("Result verified: %s", result_verified)
312312
logger.debug("Saving storage file")

src/mcp_scan/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def add_common_arguments(parser):
213213
help="Output results in JSON format instead of rich text",
214214
)
215215
parser.add_argument(
216-
"--insecure",
216+
"--skip-ssl-verify",
217217
default=False,
218218
action="store_true",
219219
help="Disable SSL certificate verification",
@@ -795,7 +795,7 @@ async def run_scan_inspect(mode="scan", args=None):
795795
server_config["opt_out"],
796796
verbose=getattr(args, "verbose", False),
797797
additional_headers=parse_headers(server_config["headers"]),
798-
insecure=getattr(args, "insecure", False),
798+
skip_ssl_verify=getattr(args, "skip_ssl_verify", False),
799799
)
800800
return result
801801

src/mcp_scan/upload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def upload(
6161
verbose: bool = False,
6262
additional_headers: dict | None = None,
6363
max_retries: int = 3,
64-
insecure: bool = False,
64+
skip_ssl_verify: bool = False,
6565
) -> None:
6666
"""
6767
Upload the scan results to the control server with retry logic.
@@ -74,7 +74,7 @@ async def upload(
7474
verbose: Whether to enable verbose logging
7575
additional_headers: Additional HTTP headers to send
7676
max_retries: Maximum number of retry attempts (default: 3)
77-
insecure: Whether to disable SSL certificate verification (default: False)
77+
skip_ssl_verify: Whether to disable SSL certificate verification (default: False)
7878
"""
7979
if not results:
8080
logger.info("No scan results to upload")
@@ -104,7 +104,7 @@ async def upload(
104104
try:
105105
async with aiohttp.ClientSession(
106106
trace_configs=trace_configs,
107-
connector=setup_tcp_connector(insecure=insecure),
107+
connector=setup_tcp_connector(skip_ssl_verify=skip_ssl_verify),
108108
) as session:
109109
headers = {"Content-Type": "application/json"}
110110
headers.update(additional_headers)

src/mcp_scan/verify_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ async def on_request_redirect(session, trace_config_ctx, params):
103103
return [trace_config]
104104

105105

106-
def setup_tcp_connector(insecure: bool = False) -> aiohttp.TCPConnector:
106+
def setup_tcp_connector(skip_ssl_verify: bool = False) -> aiohttp.TCPConnector:
107107
"""
108108
Setup a TCP connector with SSL settings.
109109
110-
When insecure is True, disable SSL verification and hostname checking.
110+
When skip_ssl_verify is True, disable SSL verification and hostname checking.
111111
Otherwise, use a secure default SSL context with certifi CA and TLSv1.2+.
112112
"""
113-
if insecure:
113+
if skip_ssl_verify:
114114
# Disable SSL verification at the connector level
115115
return aiohttp.TCPConnector(ssl=False, enable_cleanup_closed=True)
116116

@@ -152,7 +152,7 @@ async def analyze_machine(
152152
verbose: bool = False,
153153
skip_pushing: bool = False,
154154
max_retries: int = 3,
155-
insecure: bool = False,
155+
skip_ssl_verify: bool = False,
156156
) -> list[ScanPathResult]:
157157
"""
158158
Analyze the scan paths with the analysis server.
@@ -166,7 +166,7 @@ async def analyze_machine(
166166
verbose: Whether to enable verbose logging
167167
skip_pushing: Whether to skip pushing the scan to the platform
168168
max_retries: Maximum number of retry attempts
169-
insecure: Whether to skip SSL verification
169+
skip_ssl_verify: Whether to skip SSL verification
170170
"""
171171
logger.debug(f"Analyzing scan path with URL: {analysis_url}")
172172
user_info = get_user_info(identifier=identifier, opt_out=opt_out_of_identity)
@@ -190,7 +190,7 @@ async def analyze_machine(
190190
try:
191191
async with aiohttp.ClientSession(
192192
trace_configs=trace_configs,
193-
connector=setup_tcp_connector(insecure=insecure),
193+
connector=setup_tcp_connector(skip_ssl_verify=skip_ssl_verify),
194194
) as session:
195195
async with session.post(
196196
analysis_url,

tests/unit/test_cli_parsing.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ async def test_no_upload_when_no_control_servers(self):
409409
mock_upload.assert_not_called()
410410

411411
@pytest.mark.asyncio
412-
async def test_upload_with_insecure(self):
413-
"""Test that upload is called with insecure option."""
412+
async def test_upload_with_skip_ssl_verify(self):
413+
"""Test that upload is called with skip_ssl_verify option."""
414414
from argparse import Namespace
415415

416416
from mcp_scan.cli import run_scan_inspect
@@ -428,30 +428,30 @@ async def test_upload_with_insecure(self):
428428
# Setup upload mock
429429
mock_upload.return_value = None
430430

431-
# Create args with a control server and without the insecure option
432-
args_without_insecure = Namespace(
431+
# Create args with a control server and without the skip_ssl_verify option
432+
args_without_skip_ssl_verify = Namespace(
433433
verification_H=None,
434434
control_servers=[{"url": "https://server1.com", "headers": [], "identifier": None, "opt_out": False}],
435435
)
436436

437437
# Run the scan
438-
await run_scan_inspect(mode="scan", args=args_without_insecure)
438+
await run_scan_inspect(mode="scan", args=args_without_skip_ssl_verify)
439439

440-
# Verify upload was called and insecure was not propagated
440+
# Verify upload was called and skip_ssl_verify was not propagated
441441
_, kwargs = mock_upload.call_args
442-
assert kwargs.get("insecure") is False
442+
assert kwargs.get("skip_ssl_verify") is False
443443

444-
# Create args with a control server and insecure option
445-
args_with_insecure = Namespace(
444+
# Create args with a control server and skip_ssl_verify option
445+
args_with_skip_ssl_verify = Namespace(
446446
verification_H=None,
447447
control_servers=[{"url": "https://server1.com", "headers": [], "identifier": None, "opt_out": False}],
448-
insecure=True,
448+
skip_ssl_verify=True,
449449
)
450450

451451
# Run the scan
452-
await run_scan_inspect(mode="scan", args=args_with_insecure)
452+
await run_scan_inspect(mode="scan", args=args_with_skip_ssl_verify)
453453

454-
# Verify upload was called and insecure was propagated
454+
# Verify upload was called and skip_ssl_verify was propagated
455455
assert mock_upload.call_count == 2
456456
_, kwargs = mock_upload.call_args
457-
assert kwargs.get("insecure") is True
457+
assert kwargs.get("skip_ssl_verify") is True

0 commit comments

Comments
 (0)