fix(sandbox): validate required textual fields - #290
Conversation
|
🔴 Contributor Check: HIGH
Automated check by AgenTrust Contributor Check. |
lywinged
left a comment
There was a problem hiding this comment.
Approved on 5b4da40 over fc38496. Reproduced on main: SandboxAttestation(measurement=...) with true, 1, [1], {"x": 1} or null escapes as a bare TypeError from the regex, and platform set to [1] or {"x": 1} escapes as an unhashable-type TypeError from the set lookup; hashable non-strings on platform already produced the field's ValueError. On this head all ten inputs produce the field-specific ValueError, the positive control passes, and the PR's test file has 14 of 17 cases failing against main and none here. One step over, outside this PR: the optional fields have no boundary at all. rim_uri=1 constructs, and is refused only by the pydantic RuntimeInfo inside build_trust_record(), which is the later, generic error the comment above _SUBJECT_RE says these dataclass checks exist to pre-empt. Same class, for a follow-up. agt.py has no equivalent pattern. Suite 1,184 passed, 1 skipped; ruff, mypy and the dash check clean.
Tool-assisted: the runs and this write-up.
Closes #289.
What
The sandbox adapter's public dataclasses accepted several runtime-supplied values directly into regex or membership checks before establishing that they were strings. Malformed non-string inputs could therefore escape as bare
TypeErrorinstead of the adapter's field-specificValueErrorrefusal.This change establishes the primitive boundary for:
SandboxAttestation.platform;SandboxAttestation.measurement;SandboxSessionResult.sandbox_id;SandboxSessionResult.image_digest.The existing accepted syntax and semantics are unchanged.
Regression coverage
Focused tests exercise representative non-string values (
True, integer1, array[1], object {"x": 1}) across all four required textual fields, plus valid textual controls.Scope
No schema change, no wire-format change, no URL/digest syntax widening, and no change to optional sandbox fields.
AI-assistance disclosure: ChatGPT assisted with source triage, adversarial-case design, implementation drafting, duplicate/ownership review, and diff review.
altrudevreviewed the bounded claim and remains responsible for the contribution.