Finish coding-agent high-risk boundary coverage
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02669-87ee-7a31-b111-edc95a16e0fa
This commit is contained in:
parent
7a1dcb8a52
commit
429cc912ed
12 changed files with 720 additions and 54 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
|
@ -17,6 +18,14 @@ assert SPEC.loader is not None
|
|||
sys.modules[SPEC.name] = credential_change
|
||||
SPEC.loader.exec_module(credential_change)
|
||||
|
||||
BOUNDARY_SPEC = importlib.util.spec_from_file_location(
|
||||
"agent_high_risk_boundary", REPO_DIR / "scripts/agent_high_risk_boundary.py"
|
||||
)
|
||||
agent_high_risk_boundary = importlib.util.module_from_spec(BOUNDARY_SPEC)
|
||||
assert BOUNDARY_SPEC.loader is not None
|
||||
sys.modules[BOUNDARY_SPEC.name] = agent_high_risk_boundary
|
||||
BOUNDARY_SPEC.loader.exec_module(agent_high_risk_boundary)
|
||||
|
||||
|
||||
class CredentialChangeTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
|
@ -155,29 +164,69 @@ class CredentialChangeTests(unittest.TestCase):
|
|||
self.assertEqual(store["spec"]["conditions"][0]["namespaces"], ["core-hub"])
|
||||
|
||||
def test_agent_boundary_denies_every_current_concrete_high_risk_catalog_path(self) -> None:
|
||||
boundary = (
|
||||
REPO_DIR / "openbao/policies/agent-high-risk-boundary.hcl"
|
||||
).read_text()
|
||||
data_paths = {
|
||||
"platform/data/workloads/activity-core/llm-connect/llm-connect-provider-secrets",
|
||||
"platform/data/workloads/railiance/backup/offsite-lane",
|
||||
"platform/data/workloads/forgejo/forgejo-admin",
|
||||
"tenants/data/binky/company-email/imap",
|
||||
"tenants/data/binky/qonto-api",
|
||||
"platform/data/workloads/coulomb/whynot-design/npm-publish",
|
||||
"platform/data/workloads/rapp-qonto/keycape-client",
|
||||
"platform/data/workloads/agent-harness/forgejo-deploy-key",
|
||||
"platform/data/workloads/audit-core/senders",
|
||||
"platform/data/workloads/email-connect/transactional",
|
||||
"platform/data/workloads/railiance/scaleway/bootstrap",
|
||||
}
|
||||
for path in data_paths:
|
||||
with self.subTest(path=path):
|
||||
self.assertRegex(
|
||||
boundary,
|
||||
rf'path "{path}" \{{\s*capabilities = \["deny"\]',
|
||||
)
|
||||
artifact = agent_high_risk_boundary.load_artifact(
|
||||
REPO_DIR
|
||||
/ "openbao/policies/inputs/ops-warden-high-risk-data-paths.yaml"
|
||||
)
|
||||
boundary = agent_high_risk_boundary.parse_policy(
|
||||
(REPO_DIR / "openbao/policies/agent-high-risk-boundary.hcl").read_text()
|
||||
)
|
||||
report = agent_high_risk_boundary.check_boundary(artifact, boundary)
|
||||
self.assertEqual(report["errors"], [])
|
||||
self.assertEqual(report["high_risk_lanes"], 19)
|
||||
self.assertEqual(report["concrete_entries"], 14)
|
||||
self.assertEqual(report["unique_concrete_paths"], 13)
|
||||
self.assertEqual(report["no_concrete_paths"], 5)
|
||||
self.assertEqual(boundary["auth/token/revoke-self"], {"update"})
|
||||
|
||||
def test_coding_agent_jwt_role_is_exact_bound_and_deny_wins(self) -> None:
|
||||
role = json.loads(
|
||||
(REPO_DIR / "openbao/auth/coding-agent-jwt-role.json").read_text()
|
||||
)
|
||||
self.assertEqual(role["role_type"], "jwt")
|
||||
self.assertEqual(role["bound_audiences"], ["codex-railiance-platform"])
|
||||
self.assertEqual(role["user_claim"], "sub")
|
||||
self.assertEqual(
|
||||
role["bound_claims"],
|
||||
{
|
||||
"sub": "service:codex:railiance-platform",
|
||||
"principal_type": "service",
|
||||
"tenant": "tenant:coulomb",
|
||||
"roles": "coding-agent",
|
||||
},
|
||||
)
|
||||
self.assertEqual(
|
||||
set(role["token_policies"]),
|
||||
{
|
||||
"agent-high-risk-boundary",
|
||||
"workload-kv-read-issue-core-runtime",
|
||||
},
|
||||
)
|
||||
self.assertTrue(role["token_no_default_policy"])
|
||||
self.assertEqual(role["token_ttl"], "15m")
|
||||
self.assertEqual(role["token_max_ttl"], "15m")
|
||||
self.assertEqual(role["token_num_uses"], 8)
|
||||
|
||||
def test_coding_agent_approle_is_bounded_and_deny_wins(self) -> None:
|
||||
role = json.loads(
|
||||
(REPO_DIR / "openbao/auth/coding-agent-approle.json").read_text()
|
||||
)
|
||||
self.assertTrue(role["bind_secret_id"])
|
||||
self.assertEqual(role["secret_id_ttl"], "5m")
|
||||
self.assertEqual(role["secret_id_num_uses"], 1)
|
||||
self.assertEqual(
|
||||
set(role["token_policies"]),
|
||||
{
|
||||
"agent-high-risk-boundary",
|
||||
"workload-kv-read-issue-core-runtime",
|
||||
},
|
||||
)
|
||||
self.assertTrue(role["token_no_default_policy"])
|
||||
self.assertEqual(role["token_ttl"], "15m")
|
||||
self.assertEqual(role["token_max_ttl"], "15m")
|
||||
self.assertEqual(role["token_num_uses"], 8)
|
||||
|
||||
def test_core_hub_database_lanes_are_split_and_exact_scope(self) -> None:
|
||||
database_policy = (
|
||||
REPO_DIR / "openbao/policies/external-secrets-core-hub-database.hcl"
|
||||
).read_text()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue