Skip to content

Commit 783450f

Browse files
arika0093Copilot
andcommitted
fix(install): shorten transitive HTTP remediation error (review item 12)
Co-authored-by: Copilot <[email protected]>
1 parent 2dd90af commit 783450f

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/apm_cli/install/insecure_policy.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,8 @@ def _guard_transitive_insecure_dependencies(
173173
f"--allow-insecure-host {host}" for host in blocked_hosts
174174
)
175175
message = (
176-
"Transitive HTTP (insecure) dependencies were found on unapproved host(s): "
177-
f"{', '.join(blocked_hosts)}. "
178-
"--allow-insecure only covers direct HTTP dependencies and transitive "
179-
"HTTP dependencies on the same host. "
180-
f"Re-run with {suggested_flags} to allow these transitive hosts."
176+
f"Re-run with {suggested_flags} to allow transitive HTTP dependencies "
177+
f"from unapproved host(s): {', '.join(blocked_hosts)}."
181178
)
182179
logger.error(message)
183180
raise InsecureDependencyPolicyError(message)

tests/unit/test_install_command.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,11 @@ def test_transitive_guard_blocks_unapproved_host(self):
14211421
allow_insecure_hosts=(),
14221422
)
14231423

1424-
assert "mirror.example.com" in str(exc_info.value)
1424+
message = str(exc_info.value)
1425+
assert message.startswith(
1426+
"Re-run with --allow-insecure-host mirror.example.com"
1427+
)
1428+
assert "unapproved host(s): mirror.example.com" in message
14251429

14261430
def test_transitive_guard_allows_same_host_as_direct_insecure_dependency(self):
14271431
"""A direct insecure dependency host also permits transitive deps on that host."""
@@ -1498,4 +1502,8 @@ def test_transitive_guard_blocks_different_host_without_explicit_allowance(self)
14981502
allow_insecure_hosts=(),
14991503
)
15001504

1501-
assert "mirror.example.com" in str(exc_info.value)
1505+
message = str(exc_info.value)
1506+
assert message.startswith(
1507+
"Re-run with --allow-insecure-host mirror.example.com"
1508+
)
1509+
assert "unapproved host(s): mirror.example.com" in message

0 commit comments

Comments
 (0)