podster 0.0.1-test.4 → 0.0.1-test.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/repository.js +16 -2
- package/build/core/results.js +107 -48
- package/build/node/github-api.js +2 -3
- package/git/credential-helper +7 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/core/repository.js
CHANGED
|
@@ -57,7 +57,21 @@ export const RENEW_BEFORE_MS = 4 * 60 * 1000;
|
|
|
57
57
|
export const BRANCH_PREFIX = "podster/";
|
|
58
58
|
/** The fixed identity of a commit Runner makes, so no name or address from anywhere else is ever used. */
|
|
59
59
|
export const COMMIT_IDENTITY = { name: "Podster Runner", email: "runner@podster.invalid" };
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The longest installation token Runner takes. GitHub's installation tokens are now `ghs_APPID_JWT`, "~520 characters"
|
|
62
|
+
* that "will vary", with no published maximum, and GitHub says to treat them as opaque (changelog, 2026-04-24 and
|
|
63
|
+
* 2026-10-02). This leaves room for that to grow while keeping a hostile answer bounded. The server holds the same bound
|
|
64
|
+
* (`INSTALLATION_TOKEN_MAX` in `crates/core/src/repo_access.rs`).
|
|
65
|
+
*/
|
|
66
|
+
export const MAX_ACCESS_TOKEN = 4096;
|
|
67
|
+
/**
|
|
68
|
+
* A token's characters: a JWT's base64url segments, their dots, and the `_` of `ghs_APPID_`. Never whitespace, a control
|
|
69
|
+
* character, `:`, `@`, `/`, `=` or anything else that could end or bend an `Authorization` header, a URL or a line of Git's
|
|
70
|
+
* credential protocol.
|
|
71
|
+
*/
|
|
72
|
+
const TOKEN = new RegExp(`^[A-Za-z0-9._-]{20,${MAX_ACCESS_TOKEN}}$`);
|
|
73
|
+
/** Whether a string can be an installation token: its characters and length, nothing about its contents. */
|
|
74
|
+
export const isAccessToken = (v) => TOKEN.test(v);
|
|
61
75
|
const COMMIT = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
62
76
|
const TASK = /^[a-z0-9_-]{1,128}$/;
|
|
63
77
|
/** A branch name Runner will use or accept as a default branch: plain segments, no ref syntax. */
|
|
@@ -100,7 +114,7 @@ export function readAccess(answer, scope, now) {
|
|
|
100
114
|
const { token, expires_at, repository, clone_url, permissions, authority_ends_at } = answer;
|
|
101
115
|
if (typeof token !== "string")
|
|
102
116
|
throw new RepoPathError("access_token_format", false, { type: typeName(token) });
|
|
103
|
-
if (!
|
|
117
|
+
if (!isAccessToken(token))
|
|
104
118
|
throw new RepoPathError("access_token_format", false, { length: token.length, prefix: /^[a-z]{3}_/.test(token) ? "yes" : "no" });
|
|
105
119
|
if (!isCount(expires_at) || expires_at <= now)
|
|
106
120
|
throw new RepoPathError("access_expired");
|
package/build/core/results.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Results (M7 step 11; RUNNER.md lifecycle step 9, "Exfiltration through results" in the threat model). Pure: what Runner
|
|
3
|
+
* makes of a run's structured result before any of it is shown to the owner or submitted to Podster.
|
|
4
|
+
*
|
|
5
|
+
* - **Agent content is data.** The summary and the file paths are the agent's words: they are never logged, never stored
|
|
6
|
+
* in Runner's record, and never read for meaning. They become nothing but text inside a fenced part of the note.
|
|
7
|
+
* - **Hidden characters become visible marks** (owed by step 12's harness). Every format character (general category Cf:
|
|
8
|
+
* bidi embeddings, overrides and isolates, zero widths, the byte order mark, tag characters…), every control character
|
|
9
|
+
* but the line feed, every space but the plain one, line and paragraph separators, combining and enclosing marks, lone
|
|
10
|
+
* surrogates, unassigned and private-use code points, the blank Braille pattern and every other default-ignorable code
|
|
11
|
+
* point is written as `⟨U+XXXX⟩`, so what the reviewer reads is what the agent wrote. This is Runner's one marking set:
|
|
12
|
+
* the terminal's ask and review screens use it too (review 4 on #465).
|
|
13
|
+
* - **Secrets.** Words whose raw text hides characters and in which a secret shows once they're taken out are withheld
|
|
14
|
+
* whole; otherwise every secret of a fixed shape is redacted, before the words are marked. Redaction is a backstop, not
|
|
15
|
+
* a control: the output policy is.
|
|
16
|
+
* - **The note is Runner's, in Markdown.** It states the outcome, the pull request (linked from fixed parts), branch and
|
|
17
|
+
* commit from Runner's own records, and tests as not run by Runner, in fixed words. The agent's words appear only when
|
|
18
|
+
* sharing is allowed, under Runner's own heading, the summary in a fenced code block whose fence no run of backticks in
|
|
19
|
+
* it can close and each file in a code span, so none can pass for Runner's or render as anything but text (review 1 on
|
|
20
|
+
* #465). They're cut once, to `NOTE_WORDS_BYTES` as the note lays them out, never inside a mark, when they're cleaned:
|
|
21
|
+
* the owner reviews exactly the cut words the note carries.
|
|
22
|
+
*/
|
|
23
|
+
import { isFullName } from "./policy.js";
|
|
24
|
+
import { pullRequestUrl } from "./repository.js";
|
|
1
25
|
/** The server's limit on a submission's note (`crates/core` `MAX_NOTE_BYTES`). */
|
|
2
26
|
export const MAX_NOTE_BYTES = 16 * 1024;
|
|
3
27
|
/** The most of the agent's words, marked and redacted, a note carries. **Proposed** figure. */
|
|
@@ -29,8 +53,11 @@ const REDACTED = "[redacted]";
|
|
|
29
53
|
*/
|
|
30
54
|
const SECRETS = [
|
|
31
55
|
{ pattern: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g },
|
|
56
|
+
// GitHub's tokens, old (`ghs_` and 36 characters) and new (`ghs_APPID_JWT`, about 520): `_`, `-` and a dot that joins
|
|
57
|
+
// two segments are all part of one, so the whole token goes, not just up to its first `_` or `.`. It runs before
|
|
58
|
+
// `sk-ant-` and the rest, so another rule can't take a piece from the middle of one and leave its ends.
|
|
59
|
+
{ pattern: /gh[pousr]_(?:[A-Za-z0-9_-]|\.(?=[A-Za-z0-9_-])){20,}/g },
|
|
32
60
|
{ pattern: /sk-ant-[A-Za-z0-9_-]{8,}/g },
|
|
33
|
-
{ pattern: /gh[pousr]_[A-Za-z0-9]{20,}/g },
|
|
34
61
|
{ pattern: /github_pat_[A-Za-z0-9_]{20,}/g },
|
|
35
62
|
{ pattern: /(?<![A-Za-z0-9])sk-[A-Za-z0-9_-]{20,}/g },
|
|
36
63
|
{ pattern: /(?<![A-Za-z0-9])(?:AKIA|ASIA)[0-9A-Z]{16}(?![A-Za-z0-9])/g },
|
|
@@ -79,71 +106,103 @@ const WHY_NOT_SHARED = {
|
|
|
79
106
|
secret_hidden: "The agent's words aren't shared: they held what looked like a secret hidden among characters that don't show.",
|
|
80
107
|
};
|
|
81
108
|
const CUT = "⟨cut by Runner⟩";
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const FILES_DIVIDER = "--- files the agent named ---";
|
|
109
|
+
const WORDS_HEADING = "### Agent's words (unverified)";
|
|
110
|
+
const FILES_HEADING = "### Files the agent named";
|
|
85
111
|
const TOKENS = /⟨U\+[0-9A-F]{4,6}⟩|[\s\S]/gu;
|
|
112
|
+
const longestRun = (text, ch) => Math.max(0, ...[...text.matchAll(ch === "`" ? /`+/g : /~+/g)].map((m) => m[0].length));
|
|
113
|
+
/**
|
|
114
|
+
* Text as a Markdown code span, so nothing in it is read as Markdown: its delimiter is longer than any run of backticks in
|
|
115
|
+
* it, and it's padded with a space on each side when it needs one, which the reader takes off again. A line feed can't be
|
|
116
|
+
* in one, since it could start a block of its own, so it's written as a mark.
|
|
117
|
+
*/
|
|
118
|
+
export function codeSpan(text) {
|
|
119
|
+
const one = text.replace(/\n/g, mark(0x0a));
|
|
120
|
+
const fence = "`".repeat(longestRun(one, "`") + 1);
|
|
121
|
+
const pad = one === "" || one.startsWith("`") || one.endsWith("`") || one.startsWith(" ") || one.endsWith(" ") ? " " : "";
|
|
122
|
+
return `${fence}${pad}${one}${pad}${fence}`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Text as a fenced Markdown code block marked `text`: its fence is backticks, longer than any run of backticks in it and
|
|
126
|
+
* never fewer than three, so no line of the text can close it, and nothing in it is read as Markdown or HTML.
|
|
127
|
+
*/
|
|
128
|
+
export function codeBlock(text) {
|
|
129
|
+
const fence = "`".repeat(Math.max(3, longestRun(text, "`") + 1));
|
|
130
|
+
return `${fence}text\n${text}\n${fence}`;
|
|
131
|
+
}
|
|
86
132
|
/**
|
|
87
|
-
* The agent's words, marked, cut so that their part of the note, as `agentSection` lays it out
|
|
88
|
-
*
|
|
89
|
-
*
|
|
133
|
+
* The agent's words, marked, cut so that their part of the note, as `agentSection` lays it out, is at most
|
|
134
|
+
* `NOTE_WORDS_BYTES`, on a character's edge and never inside a mark, with `CUT` at the end when cut. Words that fit come
|
|
135
|
+
* back as they are, so cutting twice changes nothing.
|
|
90
136
|
*/
|
|
91
137
|
export function cutAgentWords(summary, files) {
|
|
92
138
|
if (byteLength(agentSection(summary, files)) <= NOTE_WORDS_BYTES)
|
|
93
139
|
return { summary, files };
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
size += 1 + byteLength(FILES_DIVIDER);
|
|
107
|
-
for (const file of files) {
|
|
108
|
-
let line = "";
|
|
109
|
-
size += 1 + byteLength(`${FENCE}- `);
|
|
110
|
-
for (const token of file.match(TOKENS) ?? []) {
|
|
111
|
-
const n = byteLength(token);
|
|
112
|
-
if (size + n > room) {
|
|
113
|
-
if (line !== "")
|
|
114
|
-
kept.push(`${line}${CUT}`);
|
|
140
|
+
const said = summary.match(TOKENS) ?? [];
|
|
141
|
+
const named = files.map((f) => f.match(TOKENS) ?? []);
|
|
142
|
+
// The words kept up to a count of characters (marks count as one), read through the summary and then each file.
|
|
143
|
+
const keep = (count) => {
|
|
144
|
+
if (count < said.length || named.length === 0)
|
|
145
|
+
return { summary: `${said.slice(0, count).join("")}${CUT}`, files: [] };
|
|
146
|
+
let left = count - said.length;
|
|
147
|
+
const kept = [];
|
|
148
|
+
for (const file of named) {
|
|
149
|
+
if (left < file.length) {
|
|
150
|
+
if (left > 0)
|
|
151
|
+
kept.push(`${file.slice(0, left).join("")}${CUT}`);
|
|
115
152
|
else if (kept.length > 0)
|
|
116
153
|
kept[kept.length - 1] += CUT;
|
|
117
154
|
else
|
|
118
|
-
return { summary: `${
|
|
119
|
-
return { summary
|
|
155
|
+
return { summary: `${summary}${CUT}`, files: [] };
|
|
156
|
+
return { summary, files: kept };
|
|
120
157
|
}
|
|
121
|
-
|
|
122
|
-
|
|
158
|
+
kept.push(file.join(""));
|
|
159
|
+
left -= file.length;
|
|
123
160
|
}
|
|
124
|
-
kept
|
|
161
|
+
return { summary, files: kept };
|
|
162
|
+
};
|
|
163
|
+
// Each more character kept makes the section no shorter, so the most that fits is found by halving.
|
|
164
|
+
const total = said.length + named.reduce((n, f) => n + f.length, 0);
|
|
165
|
+
let low = 0;
|
|
166
|
+
let high = total - 1;
|
|
167
|
+
while (low < high) {
|
|
168
|
+
const mid = Math.ceil((low + high) / 2);
|
|
169
|
+
if (byteLength(agentSection(keep(mid).summary, keep(mid).files)) <= NOTE_WORDS_BYTES)
|
|
170
|
+
low = mid;
|
|
171
|
+
else
|
|
172
|
+
high = mid - 1;
|
|
125
173
|
}
|
|
126
|
-
return
|
|
174
|
+
return keep(low);
|
|
127
175
|
}
|
|
128
|
-
/** The agent's part of the note:
|
|
176
|
+
/** The agent's part of the note: the summary in a code block, the files named as a list of code spans, under Runner's headings. */
|
|
129
177
|
function agentSection(summary, files) {
|
|
130
|
-
return [
|
|
178
|
+
return [WORDS_HEADING, "", codeBlock(summary), ...(files.length > 0 ? ["", FILES_HEADING, "", ...files.map((f) => `- ${codeSpan(f)}`)] : [])].join("\n");
|
|
131
179
|
}
|
|
132
|
-
/**
|
|
180
|
+
/**
|
|
181
|
+
* The submission's note, as Markdown: Runner's fixed words, and the agent's only when shared, only in a code block and
|
|
182
|
+
* code spans under Runner's headings, so none of theirs can read as Runner's or become anything but text.
|
|
183
|
+
*/
|
|
133
184
|
export function composeNote(input) {
|
|
134
185
|
const pr = input.pull_request;
|
|
135
|
-
const lines = [
|
|
136
|
-
`Result from Podster Runner for task ${input.task_id}. Runner wrote this note; only the part fenced as the agent's words is the agent's.`,
|
|
137
|
-
"Outcome: the agent reported the task completed. Runner checked the result's form, not its claims.",
|
|
138
|
-
pr
|
|
139
|
-
? `Pull request: #${pr.number} in ${pr.full_name}, from ${pr.branch} at commit ${pr.commit}. Runner pushed and opened it, and checked it on GitHub.`
|
|
140
|
-
: "Repository: none in this room, so nothing was pushed.",
|
|
141
|
-
"Tests: not run by Runner. Anything the agent says about tests is its own claim, not verified.",
|
|
142
|
-
];
|
|
143
186
|
const words = input.words;
|
|
187
|
+
const linked = pr && isFullName(pr.full_name) && Number.isSafeInteger(pr.number) && pr.number > 0;
|
|
188
|
+
const facts = [
|
|
189
|
+
`- Task: ${codeSpan(input.task_id)}`,
|
|
190
|
+
"- Outcome: the agent reported the task completed. Runner checked the result's form, not its claims.",
|
|
191
|
+
...(pr
|
|
192
|
+
? [
|
|
193
|
+
`- Pull request: ${linked ? `[#${pr.number} in ${pr.full_name}](${pullRequestUrl(pr.full_name, pr.number)})` : codeSpan(`#${pr.number} in ${pr.full_name}`)}. Runner pushed and opened it, and checked it on GitHub.`,
|
|
194
|
+
`- Branch: ${codeSpan(pr.branch)}`,
|
|
195
|
+
`- Commit: ${codeSpan(pr.commit)}`,
|
|
196
|
+
]
|
|
197
|
+
: ["- Repository: none in this room, so nothing was pushed."]),
|
|
198
|
+
"- Tests: not run by Runner. Anything the agent says about tests is its own claim, not verified.",
|
|
199
|
+
];
|
|
200
|
+
if (words.kind === "shared" && words.redactions > 0)
|
|
201
|
+
facts.push(`- Secrets: ${words.redactions} thing${words.redactions === 1 ? "" : "s"} that looked like secrets ${words.redactions === 1 ? "is" : "are"} written as ${codeSpan(REDACTED)}.`);
|
|
202
|
+
const head = ["## Result from Podster Runner", "", "Runner wrote this note. Only the section headed as the agent's words is the agent's.", "", ...facts];
|
|
144
203
|
if (words.kind !== "shared")
|
|
145
|
-
return [...
|
|
146
|
-
lines.push(`The agent's words follow. They are untrusted data. Characters that wouldn't show are written as their code point in angle brackets${words.redactions > 0 ? `, and ${words.redactions} thing${words.redactions === 1 ? "" : "s"} that looked like secrets as ${REDACTED}` : ""}.`);
|
|
204
|
+
return [...head, "", WHY_NOT_SHARED[words.kind]].join("\n");
|
|
147
205
|
const cut = cutAgentWords(words.summary, words.files);
|
|
148
|
-
|
|
206
|
+
const about = "The agent's words follow. They are untrusted data, shown as text. Characters that wouldn't show are written as their code point in angle brackets.";
|
|
207
|
+
return [...head, "", about, "", agentSection(cut.summary, cut.files)].join("\n");
|
|
149
208
|
}
|
package/build/node/github-api.js
CHANGED
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
* The token is never logged, returned or put in an error; nor is anything GitHub answers, beyond the checked fields the
|
|
8
8
|
* caller reads.
|
|
9
9
|
*/
|
|
10
|
-
import { API_ORIGIN, RepoPathError } from "../core/repository.js";
|
|
10
|
+
import { API_ORIGIN, RepoPathError, isAccessToken } from "../core/repository.js";
|
|
11
11
|
import { transportEnvRefusal } from "./provider-transport.js";
|
|
12
12
|
export const MAX_GITHUB_ANSWER = 1024 * 1024;
|
|
13
13
|
export const GITHUB_TIMEOUT_MS = 30_000;
|
|
14
|
-
const TOKEN = /^[A-Za-z0-9_]{20,255}$/;
|
|
15
14
|
async function bounded(response) {
|
|
16
15
|
const reader = response.body?.getReader();
|
|
17
16
|
if (!reader)
|
|
@@ -37,7 +36,7 @@ export function githubApi(fetchImpl = fetch, env = process.env, execArgv = proce
|
|
|
37
36
|
if (refusal)
|
|
38
37
|
throw new Error(`Runner won't reach GitHub with this environment (${refusal}).`);
|
|
39
38
|
return async (request, token, signal) => {
|
|
40
|
-
if (!
|
|
39
|
+
if (!isAccessToken(token))
|
|
41
40
|
throw new RepoPathError("access_invalid");
|
|
42
41
|
if (!request.path.startsWith("/repos/") || request.path.includes("..") || /[\s#]/.test(request.path))
|
|
43
42
|
throw new RepoPathError("request_invalid");
|
package/git/credential-helper
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
# file descriptor 3, which Runner opened for that one Git command and closes when it ends. It never reads the token from
|
|
5
5
|
# an argument, the environment or a file, never writes it anywhere but Git's own pipe, and answers nothing for anything
|
|
6
6
|
# else. Every other action (store, erase) does nothing.
|
|
7
|
+
# Byte-wise, ASCII-only bracket ranges in the token check below, whatever the caller's locale (macOS bash 3.2 included).
|
|
8
|
+
LC_ALL=C
|
|
9
|
+
export LC_ALL
|
|
7
10
|
[ "$1" = "get" ] || exit 0
|
|
8
11
|
protocol=""
|
|
9
12
|
host=""
|
|
@@ -17,7 +20,10 @@ done
|
|
|
17
20
|
[ "$protocol" = "https" ] || exit 0
|
|
18
21
|
[ "$host" = "github.com" ] || exit 0
|
|
19
22
|
IFS= read -r token <&3 2>/dev/null || exit 0
|
|
23
|
+
# An installation token's characters only (`isAccessToken` in core/repository.ts): letters, digits, `_`, `.` and `-`, so a
|
|
24
|
+
# token can't add a line or a field to Git's credential protocol. At most 4096 of them.
|
|
20
25
|
case "$token" in
|
|
21
|
-
*[!A-Za-z0-
|
|
26
|
+
*[!A-Za-z0-9._-]* | "") exit 0 ;;
|
|
22
27
|
esac
|
|
28
|
+
[ "${#token}" -le 4096 ] || exit 0
|
|
23
29
|
printf 'username=x-access-token\npassword=%s\n' "$token"
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podster",
|
|
3
|
-
"version": "0.0.1-test.
|
|
3
|
+
"version": "0.0.1-test.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "podster",
|
|
9
|
-
"version": "0.0.1-test.
|
|
9
|
+
"version": "0.0.1-test.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/claude-agent-sdk": "0.3.327",
|