dcert 3.0.75__tar.gz → 3.0.76__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dcert-3.0.75 → dcert-3.0.76}/PKG-INFO +4 -1
- {dcert-3.0.75 → dcert-3.0.76}/README.md +3 -0
- {dcert-3.0.75 → dcert-3.0.76}/pyproject.toml +1 -1
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/__init__.py +7 -1
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/tools.py +97 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_tools.py +42 -1
- {dcert-3.0.75 → dcert-3.0.76}/.gitignore +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/auth.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/binary.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/checksums.json +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/cli.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/client.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/config.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/config.yaml +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/download.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/middleware.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/py.typed +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/resilience.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/src/dcert/server.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/__init__.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/conftest.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_auth.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_binary.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_cli.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_config.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_download.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_integration.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_middleware.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_resilience.py +0 -0
- {dcert-3.0.75 → dcert-3.0.76}/tests/test_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dcert
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.76
|
|
4
4
|
Summary: MCP server for TLS certificate analysis via the Model Context Protocol
|
|
5
5
|
Project-URL: Homepage, https://github.com/SCGIS-Wales/dcert
|
|
6
6
|
Project-URL: Repository, https://github.com/SCGIS-Wales/dcert
|
|
@@ -123,6 +123,9 @@ Leaving out `session` uses a shared default session that is created on first use
|
|
|
123
123
|
| `create_truststore()` | Create a PKCS12 truststore from CA certs |
|
|
124
124
|
| `tls_scan()` | Enumerate the TLS versions, cipher suites and groups a server accepts |
|
|
125
125
|
| `list_cipher_suites()` | List TLS cipher suites from the IANA registry (offline) |
|
|
126
|
+
| `list_tls_policies()` | List the catalogued TLS security policies (offline) |
|
|
127
|
+
| `show_tls_policy()` | Show one catalogued TLS security policy (offline) |
|
|
128
|
+
| `tls_policy_test()` | Test an endpoint against a TLS security policy, or identify the closest one |
|
|
126
129
|
| `explain_cipher_suite()` | Explain one cipher suite in any notation (offline) |
|
|
127
130
|
|
|
128
131
|
The network facing functions accept the shared mTLS and connection options (`client_cert`, `client_key`, `pkcs12`, `cert_password`, `ca_cert`, `connect_to`, `resolve`, `proxy`, `noproxy`) as keyword arguments.
|
|
@@ -81,6 +81,9 @@ Leaving out `session` uses a shared default session that is created on first use
|
|
|
81
81
|
| `create_truststore()` | Create a PKCS12 truststore from CA certs |
|
|
82
82
|
| `tls_scan()` | Enumerate the TLS versions, cipher suites and groups a server accepts |
|
|
83
83
|
| `list_cipher_suites()` | List TLS cipher suites from the IANA registry (offline) |
|
|
84
|
+
| `list_tls_policies()` | List the catalogued TLS security policies (offline) |
|
|
85
|
+
| `show_tls_policy()` | Show one catalogued TLS security policy (offline) |
|
|
86
|
+
| `tls_policy_test()` | Test an endpoint against a TLS security policy, or identify the closest one |
|
|
84
87
|
| `explain_cipher_suite()` | Explain one cipher suite in any notation (offline) |
|
|
85
88
|
|
|
86
89
|
The network facing functions accept the shared mTLS and connection options (`client_cert`, `client_key`, `pkcs12`, `cert_password`, `ca_cert`, `connect_to`, `resolve`, `proxy`, `noproxy`) as keyword arguments.
|
|
@@ -23,7 +23,7 @@ Usage with the typed async wrappers::
|
|
|
23
23
|
result = await analyze_certificate(target="example.com", session=session)
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
__version__ = "3.0.
|
|
26
|
+
__version__ = "3.0.76"
|
|
27
27
|
|
|
28
28
|
from dcert.client import create_client
|
|
29
29
|
from dcert.config import Config, load_config
|
|
@@ -64,7 +64,10 @@ from dcert.tools import (
|
|
|
64
64
|
explain_cipher_suite,
|
|
65
65
|
export_pem,
|
|
66
66
|
list_cipher_suites,
|
|
67
|
+
list_tls_policies,
|
|
68
|
+
show_tls_policy,
|
|
67
69
|
tls_connection_info,
|
|
70
|
+
tls_policy_test,
|
|
68
71
|
tls_scan,
|
|
69
72
|
verify_key_match,
|
|
70
73
|
)
|
|
@@ -117,4 +120,7 @@ __all__ = [
|
|
|
117
120
|
"list_cipher_suites",
|
|
118
121
|
"explain_cipher_suite",
|
|
119
122
|
"tls_scan",
|
|
123
|
+
"list_tls_policies",
|
|
124
|
+
"show_tls_policy",
|
|
125
|
+
"tls_policy_test",
|
|
120
126
|
]
|
|
@@ -773,6 +773,100 @@ async def tls_scan(
|
|
|
773
773
|
return await call_tool("tls_scan", arguments, session=session, timeout=timeout)
|
|
774
774
|
|
|
775
775
|
|
|
776
|
+
async def list_tls_policies(
|
|
777
|
+
*,
|
|
778
|
+
provider: str | None = None,
|
|
779
|
+
session: Session | None = None,
|
|
780
|
+
timeout: float | None = None,
|
|
781
|
+
) -> ToolResponse:
|
|
782
|
+
"""List the catalogued TLS security policies (no network access).
|
|
783
|
+
|
|
784
|
+
Args:
|
|
785
|
+
provider: ``"aws_alb"``, ``"aws_nlb"``, ``"aws_cloudfront"``,
|
|
786
|
+
``"aws_api_gateway"`` or ``"mozilla"``.
|
|
787
|
+
session: Session to use; the shared default when ``None``.
|
|
788
|
+
timeout: Per call timeout in seconds.
|
|
789
|
+
"""
|
|
790
|
+
arguments = build_arguments("list_tls_policies", {}, {"provider": provider})
|
|
791
|
+
return await call_tool("list_tls_policies", arguments, session=session, timeout=timeout)
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
async def show_tls_policy(
|
|
795
|
+
*,
|
|
796
|
+
policy_id: str,
|
|
797
|
+
provider: str | None = None,
|
|
798
|
+
session: Session | None = None,
|
|
799
|
+
timeout: float | None = None,
|
|
800
|
+
) -> ToolResponse:
|
|
801
|
+
"""Show one catalogued TLS security policy (no network access).
|
|
802
|
+
|
|
803
|
+
Args:
|
|
804
|
+
policy_id: Policy id, e.g. ``"ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09"``.
|
|
805
|
+
provider: The provider, when several publish the same id.
|
|
806
|
+
session: Session to use; the shared default when ``None``.
|
|
807
|
+
timeout: Per call timeout in seconds.
|
|
808
|
+
"""
|
|
809
|
+
arguments = build_arguments("show_tls_policy", {"id": policy_id}, {"provider": provider})
|
|
810
|
+
return await call_tool("show_tls_policy", arguments, session=session, timeout=timeout)
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
async def tls_policy_test(
|
|
814
|
+
*,
|
|
815
|
+
target: str,
|
|
816
|
+
policy: str | None = None,
|
|
817
|
+
provider: str | None = None,
|
|
818
|
+
versions: Sequence[str] | None = None,
|
|
819
|
+
identify: bool = False,
|
|
820
|
+
strict: bool = False,
|
|
821
|
+
allow_legacy_tls: bool = False,
|
|
822
|
+
sni: str | None = None,
|
|
823
|
+
starttls: str | None = None,
|
|
824
|
+
session: Session | None = None,
|
|
825
|
+
timeout: float | None = None,
|
|
826
|
+
**options: Unpack[ConnectionOptions],
|
|
827
|
+
) -> ToolResponse:
|
|
828
|
+
"""Test whether *target* behaves exactly like a named TLS security policy.
|
|
829
|
+
|
|
830
|
+
Args:
|
|
831
|
+
target: HTTPS URL or hostname (``host[:port]`` with *starttls*).
|
|
832
|
+
policy: Policy id, e.g. ``"ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09"``;
|
|
833
|
+
required unless *identify* is set.
|
|
834
|
+
provider: The provider, when several publish the policy id.
|
|
835
|
+
versions: Only these protocol versions, e.g. ``["1.2", "1.3"]``.
|
|
836
|
+
identify: Rank every catalogued policy instead of testing one.
|
|
837
|
+
strict: Report an inconclusive verdict as a failure (exit code 10).
|
|
838
|
+
allow_legacy_tls: Also test TLS 1.0 and 1.1.
|
|
839
|
+
sni: Override the SNI hostname.
|
|
840
|
+
starttls: ``"smtp"``, ``"imap"``, ``"pop3"`` or ``"ftp"``.
|
|
841
|
+
session: Session to use; the shared default when ``None``.
|
|
842
|
+
timeout: Per call timeout in seconds.
|
|
843
|
+
**options: See :class:`ConnectionOptions`.
|
|
844
|
+
|
|
845
|
+
Raises:
|
|
846
|
+
ValueError: If neither or both of *policy* and *identify* are given.
|
|
847
|
+
"""
|
|
848
|
+
if (policy is None) != identify:
|
|
849
|
+
raise ValueError("tls_policy_test() needs exactly one of policy or identify=True")
|
|
850
|
+
arguments = build_arguments(
|
|
851
|
+
"tls_policy_test",
|
|
852
|
+
{"target": target},
|
|
853
|
+
{
|
|
854
|
+
"policy": policy,
|
|
855
|
+
"provider": provider,
|
|
856
|
+
"versions": list(versions) if versions else None,
|
|
857
|
+
"sni": sni,
|
|
858
|
+
"starttls": starttls,
|
|
859
|
+
**options,
|
|
860
|
+
},
|
|
861
|
+
defaulted={
|
|
862
|
+
"identify": (identify, False),
|
|
863
|
+
"strict": (strict, False),
|
|
864
|
+
"allow_legacy_tls": (allow_legacy_tls, False),
|
|
865
|
+
},
|
|
866
|
+
)
|
|
867
|
+
return await call_tool("tls_policy_test", arguments, session=session, timeout=timeout)
|
|
868
|
+
|
|
869
|
+
|
|
776
870
|
async def list_cipher_suites(
|
|
777
871
|
*,
|
|
778
872
|
protocol: str | None = None,
|
|
@@ -830,4 +924,7 @@ TOOL_FUNCTIONS: tuple[Callable[..., Awaitable[ToolResponse]], ...] = (
|
|
|
830
924
|
list_cipher_suites,
|
|
831
925
|
explain_cipher_suite,
|
|
832
926
|
tls_scan,
|
|
927
|
+
list_tls_policies,
|
|
928
|
+
show_tls_policy,
|
|
929
|
+
tls_policy_test,
|
|
833
930
|
)
|
|
@@ -40,7 +40,10 @@ from dcert.tools import (
|
|
|
40
40
|
export_pem,
|
|
41
41
|
extract_text,
|
|
42
42
|
list_cipher_suites,
|
|
43
|
+
list_tls_policies,
|
|
44
|
+
show_tls_policy,
|
|
43
45
|
tls_connection_info,
|
|
46
|
+
tls_policy_test,
|
|
44
47
|
tls_scan,
|
|
45
48
|
verify_key_match,
|
|
46
49
|
)
|
|
@@ -308,6 +311,38 @@ CASES = [
|
|
|
308
311
|
),
|
|
309
312
|
(explain_cipher_suite, {"suite": "C02F"}, "explain_cipher_suite", {"suite": "C02F"}),
|
|
310
313
|
(tls_scan, {"target": "e"}, "tls_scan", {"target": "e"}),
|
|
314
|
+
(list_tls_policies, {}, "list_tls_policies", {}),
|
|
315
|
+
(
|
|
316
|
+
tls_policy_test,
|
|
317
|
+
{
|
|
318
|
+
"target": "e",
|
|
319
|
+
"policy": "P",
|
|
320
|
+
"versions": ("1.2", "1.3"),
|
|
321
|
+
"strict": True,
|
|
322
|
+
"resolve": "e:443:10.0.0.1",
|
|
323
|
+
},
|
|
324
|
+
"tls_policy_test",
|
|
325
|
+
{
|
|
326
|
+
"target": "e",
|
|
327
|
+
"policy": "P",
|
|
328
|
+
"versions": ["1.2", "1.3"],
|
|
329
|
+
"strict": True,
|
|
330
|
+
"resolve": "e:443:10.0.0.1",
|
|
331
|
+
},
|
|
332
|
+
),
|
|
333
|
+
(
|
|
334
|
+
tls_policy_test,
|
|
335
|
+
{"target": "e", "identify": True},
|
|
336
|
+
"tls_policy_test",
|
|
337
|
+
{"target": "e", "identify": True},
|
|
338
|
+
),
|
|
339
|
+
(list_tls_policies, {"provider": "aws_alb"}, "list_tls_policies", {"provider": "aws_alb"}),
|
|
340
|
+
(
|
|
341
|
+
show_tls_policy,
|
|
342
|
+
{"policy_id": "P", "provider": "aws_nlb"},
|
|
343
|
+
"show_tls_policy",
|
|
344
|
+
{"id": "P", "provider": "aws_nlb"},
|
|
345
|
+
),
|
|
311
346
|
(
|
|
312
347
|
tls_scan,
|
|
313
348
|
{
|
|
@@ -403,7 +438,7 @@ async def test_input_validation(open_session):
|
|
|
403
438
|
|
|
404
439
|
|
|
405
440
|
def test_all_tool_functions_present():
|
|
406
|
-
assert len(TOOL_FUNCTIONS) ==
|
|
441
|
+
assert len(TOOL_FUNCTIONS) == 17
|
|
407
442
|
# inspect, not asyncio: asyncio.iscoroutinefunction is deprecated from 3.14.
|
|
408
443
|
assert all(inspect.iscoroutinefunction(f) for f in TOOL_FUNCTIONS)
|
|
409
444
|
|
|
@@ -781,3 +816,9 @@ def test_default_session_is_rebuilt_for_a_new_event_loop(monkeypatch, caplog):
|
|
|
781
816
|
assert len(created) == 2
|
|
782
817
|
assert "Dropping the default session of a previous event loop" in caplog.text
|
|
783
818
|
asyncio.run(close_default_session())
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
@pytest.mark.parametrize("kwargs", [{}, {"policy": "P", "identify": True}])
|
|
822
|
+
async def test_tls_policy_test_needs_exactly_one_of_policy_or_identify(kwargs):
|
|
823
|
+
with pytest.raises(ValueError, match="exactly one"):
|
|
824
|
+
await tls_policy_test(target="e", **kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|