Repository navigation
test: pin the Slack OAuth redirect origin, the agent dashboard refusal text, and the SSH port probe's bind-only behaviour (abilityai/trinity-enterprise#1117) - #4298
Merged
Conversation
…igin (Abilityai/trinity-enterprise#1117) Drives the real unauthenticated callback route through all of its redirect branches with 18 hostile values in the error parameter, the token-exchange error and the state's agent_name/source. Every Location must keep the configured scheme and host under both Python's and a browser-style parse, carry no CR/LF, add no header, and come from the branch under test.
… sentence (Abilityai/trinity-enterprise#1117) Pins that the loader's refusal codes are a closed set, that each refusal message interpolates only the loader's limits, the offending key and line, and the wrapped PyYAML error, and that the agent server's dashboard handler returns exactly '<code>: <loader message>' with no traceback, frame or path, while a valid file returns its whole parsed content.
…nd closes (Abilityai/trinity-enterprise#1117) Records the real is_port_available's socket calls (exactly settimeout, bind to 0.0.0.0:port, close, on the free and busy paths), checks the socket is closed and nothing accepts a connection afterwards, and shows the wildcard bind sees a bind on another local address that a 127.0.0.1 probe would miss.
…ise (Abilityai/trinity-enterprise#1117) The source scan now also matches refusals built with HardenedYamlError directly, and a new test asserts every raise in the loader is either a bare re-raise or a call to one of its refusal constructors, so a refusal raised any other way can no longer sit outside the code and message checks.
Abilityai/trinity-enterprise#1117) Every state key the test does not set now returns the hostile value and reads as present, so a redirect that starts reading a new state field fails the origin check. The test covers the five redirects that carry caller data, as seven cases (agent and platform where the branch differs); the two redirects that carry only constants are not driven.
…mes no listener (Abilityai/trinity-enterprise#1117) Adds a source check that is_port_available constructs exactly one socket.socket(AF_INET, SOCK_STREAM) as a context manager and names no listen, accept, create_server, create_connection or low-level _socket, which the runtime recorder cannot see.
…117-s15-scanner-claim-pins
obasilakis
approved these changes
Nov 6, 2026
obasilakis
left a comment
Contributor
There was a problem hiding this comment.
Reviewed (code review + /validate-pr, lane A). Approving.
Mutation checks all go red: Slack route taking its base from state, port probe calling listen() or binding 127.0.0.1, refusal text appended. Code under test is already on dev, so merge order versus #4293/#4294 is free.
Non-blocking:
test_ent1117_dashboard_refusal_shape.py:77— the allowlist trusts the namee. A newexcept OSError as e: raise err(code, f"...{e}")arm would pass and put a filesystem path in the refusal. Matching on the caught exception type closes it.- Brittleness, each fails on a harmless edit:
:127requiresnode.cause is None(addingfrom efails it);:136-142require inline f-string literals;:184-188hardcode the 262144/64 caps;test_ent1117_slack_oauth_redirect_origin.py:697-700pins the header set to exactly{content-length, location};test_ent1117_port_probe_bind_only.py:415,427pinsettimeout(1)and:373-394pin the literalsocket.socket(socket.AF_INET, socket.SOCK_STREAM). test_ent1117_port_probe_bind_only.py:453-460fails (does not skip) on an offline macOS laptop.
…117-s15-scanner-claim-pins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of abilityai/trinity-enterprise#1117.
Journey Impact: none: test-only change; no product code changes
Problem
Three behaviours that decide how the platform answers untrusted input had no regression test:
errorparameter, the token-exchange error, or any field of the decoded state.test_3563_slack_oauth_redirect_base.pypins only which base is chosen.GET /api/dashboardanswers a refuseddashboard.yamlwith"<code>: <message>"(bug(security): agent server still parses author-controlled YAML with bare safe_load — outside the ent#314 sweep #1965). Nothing pinned what that string may contain, so a change that appended a file path or a traceback would have passed.is_port_availablechecks an SSH port by binding0.0.0.0:portand closing again. Nothing pinned that it never listens, always closes, or keeps the wildcard address, which is what lets it see a bind on any local address.Fix
Three test files under
tests/unit/. No product code changes.test_ent1117_slack_oauth_redirect_origin.pydrives the real callback route through the five redirects that carry caller data, as seven cases (agent and platform where the branch differs), with 18 hostile values. The decoded state returns the hostile value for every field the test does not set, so a redirect that starts reading a new state field by key is caught. Every Location must:httpsand hosttrinity.example.com, under both Python's parser and a browser-style parse that treats\as/;A companion test checks that the seven cases produce seven distinct, exact Location templates. Two redirects carry only constants (missing parameters, invalid state) and are not driven. The signed state is not required, which makes the test stricter than production.
test_ent1117_dashboard_refusal_shape.pyreads the hardened loader's source and checks three things:raisein it is a bare re-raise or a call to one of its refusal constructors;It then runs the real handler on nine refused documents and requires exactly
"<code>: <loader message>": no traceback, no frame, no file path. Finally, it checks that a valid file returns its whole parsed content.test_ent1117_port_probe_bind_only.pychecks the probe from two sides:socket.socket(AF_INET, SOCK_STREAM)as a context manager and names nolisten,accept,create_server,create_connectionor low-level_socket.settimeout,bind(("0.0.0.0", port))andcloseon both the free and the busy path. It then checks that the socket is closed and nothing accepts a connection afterwards.127.0.0.1probe. A host without a second address fails the test rather than skipping it.Evidence
services.docker_serviceandagent_server.routers(247 passed).lint_sys_modules.py,lint_root_test_placement.pyandruff checkpass./agents/(55 failures); redirecting to theerrorvalue (19), to the exchange error (37), or to an origin built from the agent name at the platform-success (19), agent-success (19) or storage-failure (37) branch; returning caller text that looks like a URL (4); a raw, unquoted Location (20); reading an extra state field into the agent-success (19) or storage-failure (37) redirect.listen()(2); binding127.0.0.1(3); not closing the socket (3); leaking a listening socket (4); settingSO_REUSEADDR(3); briefly listening on a low-level socket (1).backend-unit-test, which collectstests/unit/on every pull request and push todevandmain, with no path filter.Not covered
127.0.0.2, and this PR's CI run is its first Linux run.backend-unit-test's regression diff runs on every pull request but is not a required status check ondev. A red result does not by itself block a merge.