fix(security): contain posture evaluation errors

This commit is contained in:
rookiestar28
2026-07-31 06:42:01 +08:00
parent 3fafa42c93
commit c05436944d
2 changed files with 26 additions and 2 deletions
+10 -2
View File
@@ -213,7 +213,12 @@ def resolve_effective_security_posture(
else deployment_profile
)
report = _deployment_report(deployment_profile, env)
try:
report = _deployment_report(deployment_profile, env)
except Exception:
# CRITICAL: delegated evaluators must not expose hostile mapping values or
# exception text across the immutable posture boundary.
raise ValueError("security posture evaluation failed") from None
findings = tuple(_safe_finding(check) for check in report.checks)
pass_codes = tuple(item.code for item in findings if item.severity == "pass")
warn_codes = tuple(item.code for item in findings if item.severity == "warn")
@@ -245,7 +250,10 @@ def resolve_effective_security_posture(
_normalized(env, "OPENCLAW_SPLIT_COMPAT_OVERRIDE") in _CONTROL_PLANE_TRUTHY
)
connector = _connector_posture(env)
try:
connector = _connector_posture(env)
except Exception:
raise ValueError("security posture evaluation failed") from None
active_platforms = tuple(
sorted({str(item) for item in connector["active_platforms"]})
)
+16
View File
@@ -386,6 +386,22 @@ class EffectiveSecurityPostureTestCase(unittest.TestCase):
)
self.assertNotIn("PRIVATE_PROFILE_CANARY", str(profile_error.exception))
class LateExplodingMapping(dict):
def get(self, key, default=None):
if key == "OPENCLAW_CONNECTOR_SLACK_BOT_TOKEN":
raise RuntimeError("PRIVATE_DELEGATED_MAPPING_CANARY")
return super().get(key, default)
with self.assertRaisesRegex(
ValueError, "^security posture evaluation failed$"
) as delegated_error:
resolve_effective_security_posture(
LateExplodingMapping(), network_exposed=False
)
self.assertNotIn(
"PRIVATE_DELEGATED_MAPPING_CANARY", str(delegated_error.exception)
)
def test_request_dynamic_security_state_is_not_in_snapshot_schema(self):
forbidden_names = {
"presented",