podster 0.0.1-test.4 → 0.0.1-test.5
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
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
|
@@ -29,8 +29,11 @@ const REDACTED = "[redacted]";
|
|
|
29
29
|
*/
|
|
30
30
|
const SECRETS = [
|
|
31
31
|
{ pattern: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g },
|
|
32
|
+
// GitHub's tokens, old (`ghs_` and 36 characters) and new (`ghs_APPID_JWT`, about 520): `_`, `-` and a dot that joins
|
|
33
|
+
// two segments are all part of one, so the whole token goes, not just up to its first `_` or `.`. It runs before
|
|
34
|
+
// `sk-ant-` and the rest, so another rule can't take a piece from the middle of one and leave its ends.
|
|
35
|
+
{ pattern: /gh[pousr]_(?:[A-Za-z0-9_-]|\.(?=[A-Za-z0-9_-])){20,}/g },
|
|
32
36
|
{ pattern: /sk-ant-[A-Za-z0-9_-]{8,}/g },
|
|
33
|
-
{ pattern: /gh[pousr]_[A-Za-z0-9]{20,}/g },
|
|
34
37
|
{ pattern: /github_pat_[A-Za-z0-9_]{20,}/g },
|
|
35
38
|
{ pattern: /(?<![A-Za-z0-9])sk-[A-Za-z0-9_-]{20,}/g },
|
|
36
39
|
{ pattern: /(?<![A-Za-z0-9])(?:AKIA|ASIA)[0-9A-Z]{16}(?![A-Za-z0-9])/g },
|
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.5",
|
|
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.5",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/claude-agent-sdk": "0.3.327",
|