cai/tests
Mike German bb79146c68 fix(fetch_url): block cloud-metadata via IPv4-mapped IPv6 in SSRF guard
The fetch_url SSRF guard guarantees cloud-metadata endpoints (e.g.
169.254.169.254) are ALWAYS blocked, even when CAI_FETCH_ALLOW_INTERNAL
is set for an authorised internal pentest. That guarantee could be
bypassed with the IPv4-mapped IPv6 form of the IMDS address, e.g.
http://[::ffff:169.254.169.254]/ (or its hex form ::ffff:a9fe:a9fe),
because the metadata block is a plain string comparison against the bare
IPv4 literal. With allow_internal=True the private/reserved check is
skipped, so nothing caught the mapped form and the request reached IMDS.

Unwrap IPv4-mapped IPv6 addresses to their embedded IPv4 before the
metadata and private-range checks in both the literal-IP and DNS-resolved
paths. This also hardens the private-range check on Python versions that
do not classify mapped addresses as private/link-local.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Mike German <mike@stepsventures.com>
2026-07-06 21:31:06 -04:00
..
agents CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
api CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
cli CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
commands CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
continuous_ops CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
core CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
ctfs CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
fixtures CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
integration CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
mcp CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
others CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
prompts CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
refusals CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
repl CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
sdk CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
tools fix(fetch_url): block cloud-metadata via IPv4-mapped IPv6 in SSRF guard 2026-07-06 21:31:06 -04:00
tracing CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
util CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
voice CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
README.md Pretty print result classes 2025-03-17 11:11:39 -04:00
__init__.py Initial commit 2025-03-11 09:42:28 -07:00
conftest.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
fake_model.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
helpers.py fix mcp test 2025-04-11 08:24:26 +02:00
test_cli_print_deduplication.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_compact_command.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_config_loader_agents.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_unified_pattern.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
testing_processor.py CLI responding, but only to proprietary models 2025-03-28 09:48:16 +01:00

README.md

Tests

Before running any tests, make sure you have uv installed (and ideally run make sync after).

Running tests

make tests

Snapshots

We use inline-snapshots for some tests. If your code adds new snapshot tests or breaks existing ones, you can fix/create them. After fixing/creating snapshots, run make tests again to verify the tests pass.

Fixing snapshots

make snapshots-fix

Creating snapshots

make snapshots-update