Skip to content

Commit 8d2cd08

Browse files
committed
fix(benchmark): accept namespaced public case ids
Signed-off-by: huangruiteng <huangrt01@163.com>
1 parent 7174232 commit 8d2cd08

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

‎loopx/capabilities/benchmark_toolkit/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ a loopback socket.
399399
`benchmark_id`, `case_id`, and a custom policy's `policy_id` are public labels, not
400400
paths. Path-like values fail closed and are emitted only as `redacted`, so a runner
401401
cannot move an operator directory into the public receipt through identifier fields.
402+
`case_id` alone may use the canonical two-segment `namespace/name` form used by
403+
public benchmark catalogs. Absolute paths, dot segments, backslashes, whitespace,
404+
and deeper path shapes remain rejected; benchmark and policy ids remain single-token
405+
labels.
402406

403407
### Exact-job container binding
404408

‎loopx/capabilities/benchmark_toolkit/integrity.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@
112112
_PATH_LIKE_LABEL_PATTERN = re.compile(
113113
r"(?i)^(?:[~/\\]|[a-z]:[\\/])|(?:^|[\\/])\.\.(?:[\\/]|$)|[\\/]"
114114
)
115+
_NAMESPACED_PUBLIC_IDENTIFIER_PATTERN = re.compile(
116+
r"^[A-Za-z0-9][A-Za-z0-9_.-]{0,79}/[A-Za-z0-9][A-Za-z0-9_.-]{0,119}$"
117+
)
115118
_NETWORK_COMMAND_PATTERN = re.compile(r"(?is)\b(?:curl|wget)\b|\bgit\s+clone\b")
116119
_HTTP_URL_PATTERN = re.compile(r"(?is)https?://[^\s\"'<>]+")
117120
_GIT_CLONE_COMMAND_PATTERN = re.compile(r"(?is)\bgit\s+clone\b")
@@ -160,11 +163,16 @@ def _public_identifier(
160163
field: str,
161164
structural_failures: list[str],
162165
limit: int,
166+
allow_namespaced: bool = False,
163167
) -> str:
164-
if _path_like_label(value):
168+
text = str(value or "").strip()
169+
namespaced = allow_namespaced and bool(
170+
_NAMESPACED_PUBLIC_IDENTIFIER_PATTERN.fullmatch(text)
171+
)
172+
if _path_like_label(text) and not namespaced:
165173
structural_failures.append(f"{field}_path_like")
166174
return "redacted"
167-
return _safe_label(value, limit=limit)
175+
return _safe_label(text, limit=limit)
168176

169177

170178
def _marker_present(text: str, marker: str) -> bool:
@@ -424,6 +432,7 @@ def build_benchmark_integrity_qualification(
424432
field="runtime_attestation_case_id",
425433
structural_failures=structural_failures,
426434
limit=120,
435+
allow_namespaced=True,
427436
)
428437
schema_version = str(trajectory.get("schema_version") or "")
429438
if not schema_version.startswith("ATIF-v1."):

‎tests/capabilities/test_benchmark_toolkit.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,43 @@ def test_path_like_attestation_labels_fail_closed_without_leaking(
644644
assert private_path not in json.dumps(receipt, sort_keys=True)
645645

646646

647+
def test_namespaced_public_case_id_qualifies_without_weakening_path_gate() -> None:
648+
attestation = _attestation()
649+
attestation["case_id"] = "public-suite/case-1"
650+
651+
receipt = build_benchmark_integrity_qualification(
652+
trajectory=_trajectory(),
653+
runtime_attestation=attestation,
654+
)
655+
656+
assert receipt["integrity_qualified"] is True
657+
assert receipt["case_id"] == "public-suite/case-1"
658+
assert receipt["blockers"] == []
659+
660+
661+
@pytest.mark.parametrize(
662+
"case_id",
663+
[
664+
"public-suite/nested/case-1",
665+
"public-suite/../case-1",
666+
"public suite/case-1",
667+
"public-suite\\case-1",
668+
],
669+
)
670+
def test_noncanonical_namespaced_case_id_still_fails_closed(case_id: str) -> None:
671+
attestation = _attestation()
672+
attestation["case_id"] = case_id
673+
674+
receipt = build_benchmark_integrity_qualification(
675+
trajectory=_trajectory(),
676+
runtime_attestation=attestation,
677+
)
678+
679+
assert receipt["integrity_qualified"] is False
680+
assert receipt["case_id"] == "redacted"
681+
assert "runtime_attestation_case_id_path_like" in receipt["blockers"]
682+
683+
647684
def test_path_like_policy_id_fails_closed_without_leaking() -> None:
648685
private_path = "C:\\Users\\private-user\\policy.json"
649686
receipt = build_benchmark_integrity_qualification(

0 commit comments

Comments
 (0)