Skip to content

fix(sandbox): validate required textual fields - #290

Open
altrudev wants to merge 3 commits into
agentrust-io:mainfrom
altrudev:fix/sandbox-required-string-fields-289
Open

fix(sandbox): validate required textual fields#290
altrudev wants to merge 3 commits into
agentrust-io:mainfrom
altrudev:fix/sandbox-required-string-fields-289

Conversation

@altrudev

@altrudev altrudev commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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 TypeError instead of the adapter's field-specific ValueError refusal.

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, integer 1, 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. altrudev reviewed the bounded claim and remains responsible for the contribution.

@altrudev
altrudev requested a review from a team as a code owner September 4, 2026 15:43
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🔴 Contributor Check: HIGH

Check Result
Profile HIGH
Credential LOW
Overall HIGH

Automated check by AgenTrust Contributor Check.

@github-actions github-actions Bot added the needs-review:HIGH Contributor check flagged HIGH risk label Sep 4, 2026

@lywinged lywinged left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-review:HIGH Contributor check flagged HIGH risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sandbox adapter validators leak TypeError on non-string identity fields

2 participants