podster 0.0.1-test.3 → 0.0.1-test.4
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 +18 -8
- package/build/core/runtime.js +10 -1
- package/build/node/claude-engine.js +27 -1
- package/build/node/repo-path.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/build/core/repository.js
CHANGED
|
@@ -24,13 +24,18 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { isFullName } from "./policy.js";
|
|
26
26
|
export { isFullName };
|
|
27
|
-
|
|
27
|
+
const KEY_NAME = /^[a-z_]{1,40}$/;
|
|
28
|
+
/** The JSON type name of a value, as a fixed word. */
|
|
29
|
+
const typeName = (v) => (v === null ? "null" : Array.isArray(v) ? "array" : typeof v);
|
|
28
30
|
export class RepoPathError extends Error {
|
|
29
31
|
code;
|
|
30
32
|
/** Worth trying again later: the network, a rate limit, a branch that moved while read. */
|
|
31
33
|
transient;
|
|
32
|
-
|
|
34
|
+
/** Fixed-shape facts about a refused answer, for the log: key names, a length, a type. Never a value. */
|
|
35
|
+
detail;
|
|
36
|
+
constructor(code, transient = false, detail = {}) {
|
|
33
37
|
super(`repository path: ${code}`);
|
|
38
|
+
this.detail = detail;
|
|
34
39
|
this.code = /^[a-z][a-z0-9_]{0,63}$/.test(code) ? code : "unknown";
|
|
35
40
|
this.transient = transient;
|
|
36
41
|
}
|
|
@@ -85,17 +90,22 @@ export const pullRequestUrl = (full_name, number) => `https://${GIT_HOST}/${full
|
|
|
85
90
|
*/
|
|
86
91
|
export function readAccess(answer, scope, now) {
|
|
87
92
|
if (!isObj(answer))
|
|
88
|
-
throw new RepoPathError("
|
|
93
|
+
throw new RepoPathError("access_not_object", false, { type: typeName(answer) });
|
|
89
94
|
const keys = ["token", "expires_at", "repository", "clone_url", "permissions", "authority_ends_at"];
|
|
90
|
-
if (Object.keys(answer).length !== keys.length || !keys.every((k) => Object.hasOwn(answer, k)))
|
|
91
|
-
|
|
95
|
+
if (Object.keys(answer).length !== keys.length || !keys.every((k) => Object.hasOwn(answer, k))) {
|
|
96
|
+
// Only key names that look like names, at most 10, so a hostile answer can't put text in a log.
|
|
97
|
+
const names = Object.keys(answer).sort().slice(0, 10).map((k) => (KEY_NAME.test(k) ? k : "?")).join(",");
|
|
98
|
+
throw new RepoPathError("access_fields", false, { count: Object.keys(answer).length, ...(names ? { names } : {}) });
|
|
99
|
+
}
|
|
92
100
|
const { token, expires_at, repository, clone_url, permissions, authority_ends_at } = answer;
|
|
93
|
-
if (typeof token !== "string"
|
|
94
|
-
throw new RepoPathError("
|
|
101
|
+
if (typeof token !== "string")
|
|
102
|
+
throw new RepoPathError("access_token_format", false, { type: typeName(token) });
|
|
103
|
+
if (!TOKEN.test(token))
|
|
104
|
+
throw new RepoPathError("access_token_format", false, { length: token.length, prefix: /^[a-z]{3}_/.test(token) ? "yes" : "no" });
|
|
95
105
|
if (!isCount(expires_at) || expires_at <= now)
|
|
96
106
|
throw new RepoPathError("access_expired");
|
|
97
107
|
if (!(authority_ends_at === null || isCount(authority_ends_at)))
|
|
98
|
-
throw new RepoPathError("
|
|
108
|
+
throw new RepoPathError("access_authority_invalid");
|
|
99
109
|
if (!isObj(permissions) || Object.keys(permissions).length !== 3 || permissions.contents !== "write" || permissions.pull_requests !== "write" || permissions.metadata !== "read")
|
|
100
110
|
throw new RepoPathError("access_permissions");
|
|
101
111
|
if (!isFullName(repository) || !sameName(repository, scope.full_name))
|
package/build/core/runtime.js
CHANGED
|
@@ -18,7 +18,10 @@ export const systemClock = {
|
|
|
18
18
|
const NAME = /^[a-z][a-z0-9_.]{0,63}$/;
|
|
19
19
|
const ID_VALUE = /^[A-Za-z0-9_-]{1,128}$/;
|
|
20
20
|
const CODE_VALUE = /^[a-z][a-z0-9_]{0,63}$/;
|
|
21
|
-
const
|
|
21
|
+
const NAMES_VALUE = /^[a-z_?]{1,40}(,[a-z_?]{1,40}){0,9}$/;
|
|
22
|
+
const PREFIX_VALUE = /^(yes|no)$/;
|
|
23
|
+
const TYPE_VALUE = /^(null|array|object|string|number|boolean|undefined|bigint|symbol|function)$/;
|
|
24
|
+
const NUMBER_FIELDS = new Set(["seq", "count", "status", "length"]);
|
|
22
25
|
const ID_FIELDS = new Set(["agent", "plugin_agent", "workspace", "task", "attempt_id"]);
|
|
23
26
|
/** The line a logger writes, with everything that isn't allowed dropped. */
|
|
24
27
|
export function logLine(at, outcome, fields = {}) {
|
|
@@ -28,6 +31,12 @@ export function logLine(at, outcome, fields = {}) {
|
|
|
28
31
|
line[name] = value;
|
|
29
32
|
else if (ID_FIELDS.has(name) && typeof value === "string" && ID_VALUE.test(value))
|
|
30
33
|
line[name] = value;
|
|
34
|
+
else if (name === "names" && typeof value === "string" && NAMES_VALUE.test(value))
|
|
35
|
+
line[name] = value;
|
|
36
|
+
else if (name === "prefix" && typeof value === "string" && PREFIX_VALUE.test(value))
|
|
37
|
+
line[name] = value;
|
|
38
|
+
else if (name === "type" && typeof value === "string" && TYPE_VALUE.test(value))
|
|
39
|
+
line[name] = value;
|
|
31
40
|
else if (name === "code" && typeof value === "string" && CODE_VALUE.test(value))
|
|
32
41
|
line[name] = value;
|
|
33
42
|
}
|
|
@@ -106,6 +106,32 @@ export const INSPECT_FAILED = {
|
|
|
106
106
|
};
|
|
107
107
|
/** Docker's own answer for an image it doesn't have, from `docker image inspect`. */
|
|
108
108
|
const NO_SUCH_IMAGE = /^(Error: |Error response from daemon: )?No such image: /m;
|
|
109
|
+
const JSON_NO_SUCH_IMAGE_PREFIX = "Error response from daemon: ";
|
|
110
|
+
/**
|
|
111
|
+
* Docker 28.5.1 answers a missing image as `Error response from daemon: {"message":"No such image: <id>"}`. Accepted
|
|
112
|
+
* only as one JSON object whose single key is `message` and whose value is "No such image: " plus the pinned ID or its
|
|
113
|
+
* short form; anything else is not Docker's answer for this image.
|
|
114
|
+
*/
|
|
115
|
+
function isJsonNoSuchImage(stderr, pinnedId) {
|
|
116
|
+
const text = stderr.trim();
|
|
117
|
+
if (!text.startsWith(JSON_NO_SUCH_IMAGE_PREFIX))
|
|
118
|
+
return false;
|
|
119
|
+
let parsed;
|
|
120
|
+
try {
|
|
121
|
+
parsed = JSON.parse(text.slice(JSON_NO_SUCH_IMAGE_PREFIX.length));
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
127
|
+
return false;
|
|
128
|
+
const keys = Object.keys(parsed);
|
|
129
|
+
if (keys.length !== 1 || keys[0] !== "message")
|
|
130
|
+
return false;
|
|
131
|
+
const message = parsed.message;
|
|
132
|
+
const hex = pinnedId.replace(/^sha256:/, "");
|
|
133
|
+
return typeof message === "string" && [pinnedId, hex, hex.slice(0, 12)].some((id) => message === `No such image: ${id}`);
|
|
134
|
+
}
|
|
109
135
|
/** A build's bound: Claude Code's image fetches its packages, so it can take minutes. */
|
|
110
136
|
const BUILD_TIMEOUT_MS = 30 * 60_000;
|
|
111
137
|
/**
|
|
@@ -124,7 +150,7 @@ export async function ensureImage(name, opts) {
|
|
|
124
150
|
if (present.code === 0)
|
|
125
151
|
return pinnedId;
|
|
126
152
|
// Rebuilt only when Docker says it hasn't the image (security review L4 on #470). Any other failure stops.
|
|
127
|
-
if (present.code !== 1 || present.cut || !NO_SUCH_IMAGE.test(present.stderr))
|
|
153
|
+
if (present.code !== 1 || present.cut || !(NO_SUCH_IMAGE.test(present.stderr) || isJsonNoSuchImage(present.stderr, pinnedId)))
|
|
128
154
|
throw new Error(INSPECT_FAILED[name]);
|
|
129
155
|
}
|
|
130
156
|
opts.notify(BUILDING[name]);
|
package/build/node/repo-path.js
CHANGED
|
@@ -70,7 +70,7 @@ export class RepoBroker {
|
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
72
72
|
this.held.delete(k);
|
|
73
|
-
this.log("repo.access", "refused", { ...ids, code: error
|
|
73
|
+
this.log("repo.access", "refused", error instanceof RepoPathError ? { ...ids, code: error.code, ...error.detail } : { ...ids, code: "access_invalid" });
|
|
74
74
|
throw error;
|
|
75
75
|
}
|
|
76
76
|
this.held.set(k, access);
|
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.4",
|
|
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.4",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/claude-agent-sdk": "0.3.327",
|