Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7fab2e7
fix(tier3): mask credentials after JSON-escaped line breaks in judge …
rng1995 Nov 12, 2026
cfa306f
fix(tier3): keep tool-call arguments and empty-reply bodies in RAGAS …
rng1995 Nov 12, 2026
53a09fa
docs(changelog): note judge evidence masking at JSON-escaped line starts
rng1995 Nov 12, 2026
9455fc3
docs(changelog): place the judge evidence masking entry with the judg…
rng1995 Nov 12, 2026
e3b545a
fix(tier3): mask quoted credentials escaped twice in judge evidence
rng1995 Nov 13, 2026
86776ef
fix(tier3): mask judge evidence credentials after escaped tabs and no…
rng1995 Nov 13, 2026
76b5a4c
docs(changelog): cover escaped tabs, non-ASCII escapes and twice-esca…
rng1995 Nov 13, 2026
42b964b
fix(tier3): mask judge evidence after an escaped tab at a JSON-escape…
rng1995 Nov 13, 2026
ea146fe
docs(tier3): name the JSON-escaped Cookie shapes judge evidence still…
rng1995 Nov 13, 2026
f867027
Merge main into naren/fix-tier3-ragas-evidence-masking
rng1995 Nov 13, 2026
960d86c
fix(tier3): keep RAGAS reply evidence to the text RAGAS parses
rng1995 Nov 13, 2026
f223507
fix(tier3): mask judge evidence credentials after JSON escapes
rng1995 Nov 13, 2026
862a355
fix(tier3): mask whole judge evidence text before its escaped lines
rng1995 Nov 13, 2026
a66f119
Merge main into naren/fix-tier3-ragas-evidence-masking
rng1995 Nov 13, 2026
6661151
fix(tier3): mask credential values in JSON-escaped quotes
rng1995 Nov 14, 2026
f81cb6a
ci(gitleaks): allow the JSON-escaped-quote judge evidence test placeh…
rng1995 Nov 14, 2026
aac2a96
fix(tier3): mask the line after a credential value that reads through…
rng1995 Nov 14, 2026
2ef8839
fix(tier3): mask a line's value only where the whole pass took its name
rng1995 Nov 14, 2026
19d5c98
fix(tier3): keep a bare -p argv element in JSON-escaped text
rng1995 Nov 14, 2026
19e4f08
fix(tier3): mask a twice-escaped attached -pVALUE argv element again
rng1995 Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ All notable changes to SkillEvaluator are documented in this file.
user-request section when it is set below 2,000, and that a check budget too
small to hold the final response beside some tool history is logged as a
warning rather than quietly raised — lower the final-response limit with it.
- `judge_attempts.json` now masks `Cookie` header values, credential flag values
(`--token`, `--password`, `-u user:password`, `--cookie`) and keys such as
`sk-proj-...` that start a line in JSON-escaped text, as in RAGAS prompts and
replies. A line break there is the two characters `\n`, and these values were
saved in clear after it or after an escaped tab (`\t`). A RAGAS `replied` entry
for a reply with no text and no tool call, such as a refusal or a
content-filter stop, now saves the whole reply body instead of an empty reply.
- Code Risk Analysis reports Semgrep file-level parse errors as one partial-scan
error that names up to 20 unparsed files, relative to the skill and with the
line of the first error, instead of the first three truncated messages. The
Expand Down
33 changes: 18 additions & 15 deletions docs/tier3-live-evaluation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1379,21 +1379,24 @@ the case is judged and scored normally.
truncated reply, the LLM attempts keep their own status (`rejected`, or
`error` if the retry failed in transport), and an `accepted` `salvage`
entry, numbered like the truncated attempt, holds the rebuilt results.
When the RAGAS goal scorer runs, each request it sends is saved as a
`ragas` entry with its messages as the prompt and the model named in the
request: `replied` with the judge's reply, which is the text or the
tool-call arguments RAGAS parses, or `error` with the HTTP status and body,
or with the reason the reply was not received. A request that fails before
any response arrives, such as a refused connection, saves no entry of its
own. A last `ragas` entry is `accepted` with the score RAGAS computed, or
`error` with the reason the prompt judge ran instead. Only that last entry
counts toward `--max-judge-calls`; the request entries do not.
Configured credentials, common key shapes, URL userinfo, `Authorization`,
API-key, token and `Cookie` header values, and credential flag values
(`--token`, `--password`, `curl -u user:password`) are masked, and long
prompts and replies are shortened. The prompts contain the task question,
expected answer, and agent evidence. Pass `--harbor-keep-jobs` to keep the
Harbor trial directories that hold this file.
When the RAGAS goal scorer runs, each request it sends is saved as a `ragas`
entry with its messages as the prompt and the model named in the request. A
`replied` entry holds the judge's reply: the text or the tool-call arguments
RAGAS parses, or the whole reply body when it has neither, such as a refusal
or a content-filter stop. An `error` entry holds the HTTP status and body,
or the reason the reply was not received. A request that fails before any
response arrives, such as a refused connection, saves no entry of its own. A
last `ragas` entry is `accepted` with the score RAGAS computed, or `error`
with the reason the prompt judge ran instead. Only that last entry counts
toward `--max-judge-calls`; the request entries do not. Configured
credentials, common key shapes, URL userinfo, `Authorization`, API-key,
token and `Cookie` header values, and credential flag values (`--token`,
`--password`, `curl -u user:password`) are masked, also at the start of a
Comment thread
rng1995 marked this conversation as resolved.
Resolved
line in JSON-escaped text such as RAGAS prompts, where a line break is the
two characters `\n`. Long prompts and replies are shortened. The prompts
contain the task question, expected answer, and agent evidence. Pass
`--harbor-keep-jobs` to keep the Harbor trial directories that hold this
file.
- **Reasoning models.** GPT-5 and GPT-6 judges get no `temperature` and at
least 32,768 output tokens, because reasoning tokens count against the
limit; other judges get 16,384. GPT-6 judges and Claude 5.5 or later judges
Expand Down
54 changes: 46 additions & 8 deletions src/skillevaluator/tier3/harbor/templates/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -2843,17 +2843,49 @@ def _judge_retry_feedback(problem):
)


def _redact_judge_evidence(text):
"""Mask credentials in a judge prompt, reply, or problem before it is saved."""
# RAGAS writes its input into the prompt as JSON, and tool-call arguments are
# JSON, so a line break or tab in that text arrives as the two characters "\n",
# "\r" or "\t". A header, flag or key that starts a line there follows the
# letter of the escape, where patterns that need a line start, a space or a
# word boundary before it do not match. So once the whole text is masked, the
# text between these escapes is masked again as lines of their own.
_JUDGE_EVIDENCE_ESCAPE_RE = re.compile(r"(\\[nrt])")


def _mask_judge_evidence_text(text):
"""Mask credentials in *text* read as one piece."""
# Share finding credential semantics without imposing the finding scanner's
# 2,000-character input budget on the longer judge prompt and reply budgets.
redacted = _shared_checks._mask_finding_evidence_credentials(str(text), preserve_header_format=True)
redacted = _shared_checks._mask_finding_evidence_credentials(text, preserve_header_format=True)
redacted = _redact_configured_credentials(_redact_evidence_text(redacted))
for pattern in _SECRET_PATTERNS:
redacted = pattern.sub("<redacted>", redacted)
return redacted


def _mask_judge_evidence_line(text):
"""Mask credentials in the text between two escapes, which is not trimmed."""
redacted = _shared_checks._mask_finding_evidence_credentials(text, preserve_header_format=True)
redacted = redact_secrets_in_log_line(redacted)
for pattern in _SECRET_PATTERNS:
redacted = pattern.sub("<redacted>", redacted)
return redacted


def _redact_judge_evidence(text):
"""Mask credentials in a judge prompt, reply, or problem before it is saved."""
# The whole text is masked first, so a form that runs over an escape (a
# private key block, a continued or quoted value, a value that holds "\n"
# or "\u00e4") is masked whole before the text is split at the escapes.
redacted = _mask_judge_evidence_text(str(text))
Comment thread
rng1995 marked this conversation as resolved.
Resolved
parts = _JUDGE_EVIDENCE_ESCAPE_RE.split(redacted)
if len(parts) == 1:
return redacted
# Text and escapes alternate.
parts[::2] = [_mask_judge_evidence_line(part) if part else part for part in parts[::2]]
return "".join(parts)


def _verifier_output_dir():
"""Directory that receives skill_evaluator_reward.json (see write_reward_outputs)."""
if (
Expand Down Expand Up @@ -3270,14 +3302,20 @@ def _ragas_request_text(body):


def _ragas_reply_text(body):
"""Return the judge's answer in one chat-completions reply: its text, or the tool-call arguments RAGAS parses."""
"""Return the judge's answer in one chat-completions reply: its text, or the tool-call arguments RAGAS parses.

A reply with neither, such as a refusal or a content-filter stop, is
returned whole, so the refusal or the finish reason is kept.
"""
try:
message = json.loads(body)["choices"][0]["message"]
if message.get("content") or not message.get("tool_calls"):
return str(message.get("content") or "")
return "\n".join(str(call["function"]["arguments"]) for call in message["tool_calls"])
if message.get("content"):
return str(message["content"])
if message.get("tool_calls"):
return "\n".join(str(call["function"]["arguments"]) for call in message["tool_calls"])
except (ValueError, LookupError, TypeError, AttributeError):
return body.decode("utf-8", "replace")
pass
return body.decode("utf-8", "replace")


def _record_ragas_exchange(response, problem=None):
Expand Down
174 changes: 174 additions & 0 deletions tests/tier3/test_judge_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,175 @@ def test_judge_evidence_masks_json_escaped_tool_call_headers(command: str, secre
assert "<redacted>" in redacted


# RAGAS writes the agent's messages into its prompt as JSON, and tool-call
# arguments are JSON, so a line that starts with a credential follows an
# escaped "\n" (or "\r\n", or "\n\t") there, once or twice escaped.
@pytest.mark.parametrize(
("line", "secret", "kept"),
[
pytest.param(
"Authorization: Bearer bbbbbbbbbbbb", "bbbbbbbbbbbb", "Authorization: Bearer <redacted>", id="authorization"
),
pytest.param(
'Authorization: Digest username="u", response="dddddddddddd"',
"dddddddddddd",
"Authorization: Digest <redacted>",
id="authorization-digest",
),
pytest.param("Cookie: session=cccccccccccc", "cccccccccccc", "Cookie: <redacted>", id="cookie"),
pytest.param("Api-Key: kkkkkkkkkkkk", "kkkkkkkkkkkk", "Api-Key: <redacted>", id="api-key"),
pytest.param("--token tttttttttttt", "tttttttttttt", "--token <redacted>", id="token-flag"),
pytest.param("--password pppppppppppp", "pppppppppppp", "--password <redacted>", id="password-flag"),
pytest.param("-token tttttttttttt", "tttttttttttt", "-token <redacted>", id="short-token-flag"),
pytest.param("-u uuuu:pppppppppppp", "pppppppppppp", "-u <redacted>", id="user-flag"),
pytest.param("--cookie session=cccccccccccc", "cccccccccccc", "--cookie <redacted>", id="cookie-flag"),
pytest.param("sk-proj-" + "a" * 24, "a" * 24, "sk-<redacted>", id="openai-key"),
pytest.param("ghp_" + "g" * 36, "g" * 36, "ghp_<redacted>", id="github-token"),
],
)
@pytest.mark.parametrize("line_break", ["\n", "\r\n", "\n\t"], ids=["lf", "crlf", "lf-tab"])
def test_judge_evidence_masks_credentials_after_json_escaped_line_breaks(
line: str, secret: str, kept: str, line_break: str
) -> None:
text = f"HTTP/1.1 200 OK{line_break}{line}{line_break}done"
assert secret not in eval_template._redact_judge_evidence(text)

for escaped in (json.dumps({"reply": text}), json.dumps(json.dumps({"reply": text}))):
redacted = eval_template._redact_judge_evidence(escaped)

assert secret not in redacted
assert kept in redacted


# json.dumps writes a tab as "\t", so in JSON a credential can follow the letter t.
@pytest.mark.parametrize(
("text", "secret"),
[
pytest.param("ok\tCookie: session=cccccccccccc", "cccccccccccc", id="tab-cookie"),
pytest.param("ok\t--token tttttttttttt", "tttttttttttt", id="tab-token-flag"),
pytest.param("ok\t-u uuuu:pppppppppppp", "pppppppppppp", id="tab-user-flag"),
],
)
def test_judge_evidence_masks_credentials_after_json_escaped_tabs(text: str, secret: str) -> None:
assert secret not in eval_template._redact_judge_evidence(text)

for escaped in (json.dumps({"reply": text}), json.dumps(json.dumps({"reply": text}))):
assert "\\t" in escaped
redacted = eval_template._redact_judge_evidence(escaped)

assert secret not in redacted
assert "<redacted>" in redacted


# Split so that no private key header appears in this file as one literal.
_PRIVATE_KEY = "PRIVATE " + "KEY"
_KEY_BODY_LINES = ("MIIEbodyLineOne", "MIIEbodyLineTwo")


# A private key block spans lines, which JSON writes as "\n" escapes. The block
# is masked whole, never only its BEGIN line.
@pytest.mark.parametrize(
"label",
[
pytest.param(f"RSA {_PRIVATE_KEY}", id="rsa"),
pytest.param(f"EC {_PRIVATE_KEY}", id="ec"),
pytest.param(f"OPENSSH {_PRIVATE_KEY}", id="openssh"),
pytest.param(f"PGP {_PRIVATE_KEY} BLOCK", id="pgp"),
pytest.param(f"ENCRYPTED {_PRIVATE_KEY}", id="encrypted"),
pytest.param(_PRIVATE_KEY, id="pkcs8"),
],
)
def test_judge_evidence_masks_private_key_blocks_in_json_escaped_text(label: str) -> None:
block = "\n".join((f"-----BEGIN {label}-----", *_KEY_BODY_LINES, f"-----END {label}-----"))
prompt = json.dumps({"user_input": [{"content": f"see\n{block}\nok", "type": "ai"}]}, indent=4)

for escaped in (json.dumps({"content": block}), json.dumps(json.dumps({"content": block})), prompt):
redacted = eval_template._redact_judge_evidence(escaped)

assert "<redacted private key>" in redacted
assert "-----END" not in redacted
for line in _KEY_BODY_LINES:
assert line not in redacted


# A value may hold an escape: a quoted value a line break or tab, a password a
# non-ASCII character (written "\u00e4" by json.dumps), or a path a backslash.
# The whole value is masked in JSON escaped once or twice, and in plain text
# too, where only a real line break ends a quoted value.
@pytest.mark.parametrize(
"text",
[
pytest.param('tool --password "a\n' + "Tail" * 3 + '" -x', id="quoted-line-break"),
pytest.param('tool --password "a\t' + "Tail" * 3 + '" -x', id="quoted-tab"),
pytest.param("mysql --password p\u00e4ss" + "Tail" * 3 + " -x", id="non-ascii-password"),
pytest.param("tool --token tok\u00e9n" + "Tail" * 3 + " -x", id="non-ascii-token"),
pytest.param("tool -u admin:p\u00e4ss" + "Tail" * 3 + " -x", id="non-ascii-user"),
pytest.param('tool --token "t\u00f6ken' + "Tail" * 3 + '" -x', id="non-ascii-quoted-token"),
pytest.param("tool --password ab\\n" + "Tail" * 3 + " -x", id="backslash-n-password"),
pytest.param("tool --token C:\\new\\" + "Tail" * 3 + " -x", id="windows-path-token"),
],
)
def test_judge_evidence_masks_values_that_hold_escapes(text: str) -> None:
forms = [json.dumps({"command": text}), json.dumps(json.dumps({"command": text}))]
if "\n" not in text:
forms.append(text)
for form in forms:
redacted = eval_template._redact_judge_evidence(form)

assert "Tail" not in redacted
assert "<redacted> -x" in redacted


# A credential flag that starts a JSON-escaped line keeps its whole value
# masked, also when the value holds a non-ASCII character.
@pytest.mark.parametrize(
"text",
[
pytest.param("--password p\u00e4ss" + "Tail" * 3 + " -h db", id="password"),
pytest.param("--token tok\u00e9n" + "Tail" * 3 + " -x", id="token"),
pytest.param("-u admin:p\u00e4ss" + "Tail" * 3 + " -x", id="user"),
pytest.param('--token "t\u00f6ken' + "Tail" * 3 + '" -x', id="quoted-token"),
],
)
def test_judge_evidence_masks_non_ascii_values_at_json_escaped_line_starts(text: str) -> None:
for escaped in (json.dumps({"reply": f"ok\n{text}"}), json.dumps(json.dumps({"reply": f"ok\n{text}"}))):
redacted = eval_template._redact_judge_evidence(escaped)

assert "Tail" not in redacted
assert "<redacted>" in redacted


# Tool-call arguments reach the behavior and goal prompts as json.dumps text,
# where the line breaks of a written key file and of a continued command are
# "\n" escapes.
def test_judge_evidence_masks_multi_line_tool_call_arguments() -> None:
block = "\n".join(
(f"-----BEGIN OPENSSH {_PRIVATE_KEY}-----", *_KEY_BODY_LINES, f"-----END OPENSSH {_PRIVATE_KEY}-----")
)
trajectory = {
"steps": [
{
"source": "agent",
"tool_calls": [
{"function_name": "Write", "arguments": {"file_path": "id_ed25519", "content": block}},
{"function_name": "Bash", "arguments": {"command": "sshpass -p \\\n" + "Tail" * 3 + " ssh host"}},
],
},
]
}
summary = eval_template.build_conversation_summary(trajectory, "Set up the deploy key.")
assert _KEY_BODY_LINES[0] in summary
assert "Tail" in summary

redacted = eval_template._redact_judge_evidence(summary)

assert "<redacted private key>" in redacted
assert "sshpass -p <redacted> ssh host" in redacted
assert "Tail" not in redacted
for line in _KEY_BODY_LINES:
assert line not in redacted


@pytest.mark.parametrize(
"text",
[
Expand All @@ -1115,6 +1284,11 @@ def test_judge_evidence_masks_json_escaped_tool_call_headers(command: str, secre
"see https://example.com/docs?a=b@c and mailto:user@example.com",
"Authorization is required for this endpoint.",
"curl --cookie-jar cookies.txt https://x; see the api-key rotation docs",
# JSON-escaped lines, as in RAGAS prompts and tool-call arguments.
json.dumps(
"Authorization is required.\npython -u script.py\n--token-limit 5\n\tcookie-jar ready\r\nC:\\new\\temp"
),
json.dumps("caf\u00e9 --token-limit 5\t\u201cAuthorization is required\u201d\tpython -u script.py"),
],
)
def test_judge_evidence_keeps_ordinary_text(text: str) -> None:
Expand Down
Loading
Loading