gcb-host 0.0.3 → 0.1.0

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.
@@ -1,44 +1,49 @@
1
1
  /**
2
- * `host-opener` — fulfil the container's requests to open pull requests, as the person running it.
2
+ * `host-opener` — fulfil the container's requests to open pull requests or issues with the gh account
3
+ * each request names.
3
4
  *
4
5
  * This runs on the host, beside the checkout the container also sees, and it does exactly one thing:
5
- * it turns a request file into a pull request, using the credentials of whoever started it. That is
6
- * the whole point — a pull request authored by a person is one that automated reviewers will actually
7
- * review, and the app cannot be that person.
6
+ * it turns a request file into a pull request or issue, using the gh account the request names. That
7
+ * is the whole point — content authored by a person is what automated reviewers will actually review,
8
+ * and the app cannot be that person.
8
9
  *
9
10
  * It has no other power. It cannot push, merge, close or read anything, and it never runs a shell: the
10
11
  * program it calls is configuration, and it is called with an argument list built here.
11
12
  */
12
13
  import { execFile } from 'node:child_process';
13
- import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
14
+ import { existsSync, mkdtempSync, rmSync, statSync, writeFileSync } from 'node:fs';
14
15
  import { homedir, tmpdir } from 'node:os';
15
16
  import { join, resolve } from 'node:path';
16
17
  import { promisify } from 'node:util';
17
- import { channelDir, clearOpener, discoverCheckouts, findGitDir, listRequests, readOpener, claimRequest, removeRequest, requestProblems, writeOpener, writeResult, } from 'gcb-core';
18
+ import { channelDir, clearOpener, discoverCheckouts, findGitDir, listRequests, readOpener, claimRequest, removeRequest, requestProblems, writeOpener, writeResult, HOST, } from 'gcb-core';
18
19
  import { fail, listFlag, parseArgs, say, warn } from 'gcb-core';
19
20
  import { applyProxyChoice, parseProxy } from '../http.js';
21
+ import { loadConfig, resolveConfigPath } from '../config.js';
22
+ import { hostConfig, repoAllowed } from '../policy.js';
20
23
  const run = promisify(execFile);
21
- /** How long one `pr create` may take. */
24
+ /** How long one `pr create` or `issue create` may take. */
22
25
  const CREATE_TIMEOUT_MS = 120_000;
23
26
  /** Usage text for `host-opener`. */
24
27
  export const HOST_OPENER_USAGE = `Usage: gcb host-opener [options]
25
28
 
26
29
  Run on the host, once, beside the trees the container also sees. It finds the checkouts under the
27
- roots it is given — ones created later included — and fulfils their requests to open a pull request
28
- with the credentials of whoever runs it, so the pull request is authored by a person rather than by
30
+ roots it is given — ones created later included — and fulfils their requests to create a pull request, issue
31
+ or fork with the gh account each request names, so the result is authored by a person rather than by
29
32
  the app's bot. It does nothing else: it cannot push, merge or close anything.
30
33
 
31
34
  --root <dir> A tree to serve, repeatable (default: $HOME)
32
35
  --depth <n> How far below a root to look for checkouts (default: 4)
33
36
  --repo <path> Serve this one checkout instead of discovering any
34
- --command <path> The program that creates a pull request
37
+ --config <path> Broker config whose allowlist fork requests are checked against
38
+ (default: $GIT_BROKER_CONFIG, else ./broker.config.yml)
39
+ --command <path> The program that creates a pull request, issue or fork
35
40
  (default: $GIT_BROKER_PR_COMMAND, else gh)
36
41
  --arg <token> An extra argument for that program, before the subcommand (repeatable)
37
42
  --interval <seconds> How often to look for requests (default: 5)
38
43
  --once Fulfil what is waiting, then exit
39
44
  -h, --help Show this help
40
45
 
41
- The container asks for this by passing --via-host to \`pr\`. Requests are files under
46
+ The container asks for this by passing --as-user to \`pr\`. Requests are files under
42
47
  <git dir>/gcb/pr-requests, which is shared with the container and untracked by git
43
48
  — so the paths on the two sides never have to match: each writes and reads its own view of the same
44
49
  directory, and only the roots this process scans are host-side paths.
@@ -59,6 +64,19 @@ export function pullRequestUrl(output) {
59
64
  return undefined;
60
65
  return { number: Number(digits), url: match[0] };
61
66
  }
67
+ /**
68
+ * Pull the issue number and URL out of the program's output.
69
+ *
70
+ * @param output - the program's standard output.
71
+ * @returns the number and URL, or `undefined`.
72
+ */
73
+ export function issueUrl(output) {
74
+ const match = /https:\/\/[^\s]+\/issues\/(\d+)/.exec(output);
75
+ const digits = match?.[1];
76
+ if (!match || digits === undefined)
77
+ return undefined;
78
+ return { number: Number(digits), url: match[0] };
79
+ }
62
80
  /**
63
81
  * Run the `host-opener` command.
64
82
  *
@@ -77,6 +95,21 @@ export async function runHostOpener(argv) {
77
95
  const scanned = roots.length > 0 ? roots.map((root) => resolve(root)) : [homedir()];
78
96
  const depth = Number(args.value('depth') ?? '4');
79
97
  const command = args.value('command') ?? process.env['GIT_BROKER_PR_COMMAND'] ?? 'gh';
98
+ const configPath = args.value('config');
99
+ let config;
100
+ /** Whether the broker's allowlist permits this host/repository, loaded only for fork requests. */
101
+ const allowed = (host, repo) => {
102
+ if (config === undefined) {
103
+ try {
104
+ config = loadConfig(resolveConfigPath(configPath));
105
+ }
106
+ catch (error) {
107
+ throw new Error(`a fork needs the broker config allowlist: ${error.message}; pass --config or set GIT_BROKER_CONFIG`);
108
+ }
109
+ }
110
+ const block = hostConfig(config, host);
111
+ return block !== null && repoAllowed(block.allow, repo);
112
+ };
80
113
  const extra = listFlag(args, 'arg');
81
114
  const interval = Number(args.value('interval') ?? '5');
82
115
  if (!Number.isFinite(interval) || interval < 1) {
@@ -99,7 +132,12 @@ export async function runHostOpener(argv) {
99
132
  const advertise = (dir) => {
100
133
  advertised.add(dir);
101
134
  if (readOpener(dir)?.pid !== process.pid) {
102
- writeOpener(dir, { pid: process.pid, command, startedAt: new Date().toISOString() });
135
+ writeOpener(dir, {
136
+ pid: process.pid,
137
+ command,
138
+ startedAt: new Date().toISOString(),
139
+ kinds: ['pull-request', 'issue', 'fork'],
140
+ });
103
141
  }
104
142
  };
105
143
  // However this process ends — a signal, --once, an exception — its markers go with it. A stale
@@ -120,14 +158,14 @@ export async function runHostOpener(argv) {
120
158
  process.on('SIGINT', stop);
121
159
  process.on('SIGTERM', stop);
122
160
  say(single === undefined ? `serving the checkouts under ${scanned.join(', ')}` : `serving ${single}`);
123
- say(`creating pull requests with ${command}${extra.length > 0 ? ` ${extra.join(' ')}` : ''}, as ${process.env['USER'] ?? 'this user'}`);
161
+ say(`creating pull requests, issues and forks with ${command}${extra.length > 0 ? ` ${extra.join(' ')}` : ''}, as the request's account or this user`);
124
162
  for (;;) {
125
163
  for (const { repo, dir } of targets()) {
126
164
  // One checkout the container has made hostile — its channel directory replaced by a file, say —
127
165
  // must not stop the opener serving every other root, under Restart=always least of all.
128
166
  try {
129
167
  advertise(dir);
130
- await sweep(dir, repo, command, extra);
168
+ await sweep(dir, repo, command, extra, allowed);
131
169
  }
132
170
  catch (error) {
133
171
  warn(`could not serve ${repo}: ${error.message}`);
@@ -142,16 +180,16 @@ export async function runHostOpener(argv) {
142
180
  * Answer everything waiting in the channel.
143
181
  *
144
182
  * @param dir - the channel directory.
145
- * @param repo - the checkout to create pull requests in.
183
+ * @param repo - the checkout to create pull requests or issues in.
146
184
  * @param command - the program to call.
147
185
  * @param extra - arguments to pass before the subcommand.
148
186
  * @returns how many requests were answered.
149
187
  */
150
- async function sweep(dir, repo, command, extra) {
188
+ async function sweep(dir, repo, command, extra, allowed) {
151
189
  let answered = 0;
152
190
  for (const id of listRequests(dir)) {
153
191
  // Claimed, not read: two openers — a service and a hand-run --once — would otherwise both act on the
154
- // same request and each create the pull request, under the person's name.
192
+ // same request and each create it, under the person's name.
155
193
  const request = claimRequest(dir, id);
156
194
  if (!request) {
157
195
  // Either unreadable or already claimed, and the two are not worth telling apart here: removing
@@ -175,21 +213,49 @@ async function sweep(dir, repo, command, extra) {
175
213
  answered += 1;
176
214
  continue;
177
215
  }
178
- const result = await openOne(repo, command, extra, { ...request, proxy });
216
+ const result = await openOne(repo, command, extra, { ...request, proxy }, allowed);
179
217
  writeResult(dir, id, result);
180
218
  removeRequest(dir, id);
181
219
  if (result.error !== undefined) {
182
- warn(`failed to open ${request.head}: ${result.error}`);
220
+ warn(`failed to open ${request.kind === 'fork' ? 'fork' : request.kind === 'issue' ? 'issue' : request.head}: ${result.error}`);
183
221
  }
184
222
  else {
185
- say(`opened #${result.number}: ${result.url}`);
223
+ say(request.kind === 'fork'
224
+ ? `forked ${request.repo} as ${request.account ?? 'this user'}: ${result.url}`
225
+ : `opened #${result.number} as ${request.account ?? 'this user'}: ${result.url}`);
186
226
  }
187
227
  answered += 1;
188
228
  }
189
229
  return answered;
190
230
  }
231
+ /** Environment for one gh call: the selected account or inherited config, plus the proxy choice. */
232
+ function forkEnv(proxy, account, host) {
233
+ const env = openerEnv(proxy, account);
234
+ // gh chooses between GH_TOKEN and GH_ENTERPRISE_TOKEN by host; forcing GH_HOST is what keeps an
235
+ // inherited token from selecting another instance. Named accounts already had their tokens removed.
236
+ env['GH_HOST'] = host;
237
+ return env;
238
+ }
239
+ function openerEnv(proxy, account) {
240
+ const env = { ...process.env };
241
+ if (account !== undefined) {
242
+ const dir = join(homedir(), '.config', `gh-${account}`);
243
+ if (!existsSync(dir) || !statSync(dir).isDirectory()) {
244
+ throw new Error(`no gh config for account ${JSON.stringify(account)} at ${dir}`);
245
+ }
246
+ // Tokens in the opener's own environment would override the selected account's config.
247
+ delete env['GH_TOKEN'];
248
+ delete env['GITHUB_TOKEN'];
249
+ delete env['GH_ENTERPRISE_TOKEN'];
250
+ delete env['GITHUB_ENTERPRISE_TOKEN'];
251
+ delete env['GH_HOST'];
252
+ env['GH_CONFIG_DIR'] = dir;
253
+ }
254
+ applyProxyChoice(env, proxy);
255
+ return env;
256
+ }
191
257
  /**
192
- * Create one pull request.
258
+ * Create one pull request, issue or fork.
193
259
  *
194
260
  * @param repo - the checkout to create it in.
195
261
  * @param command - the program to call.
@@ -197,38 +263,71 @@ async function sweep(dir, repo, command, extra) {
197
263
  * @param request - what to create.
198
264
  * @returns the number and URL, or the reason it did not work.
199
265
  */
200
- function openerEnv(proxy) {
201
- const env = { ...process.env };
202
- applyProxyChoice(env, proxy);
203
- return env;
204
- }
205
- async function openOne(repo, command, extra, request) {
266
+ async function openOne(repo, command, extra, request, allowed) {
267
+ if (request.kind === 'fork') {
268
+ if (request.host !== undefined && !HOST.test(request.host)) {
269
+ return { error: `not a host: ${JSON.stringify(request.host)}` };
270
+ }
271
+ const host = request.host ?? 'github.com';
272
+ try {
273
+ if (!allowed(host, request.repo)) {
274
+ return { error: `repository ${request.repo} is not in the allowlist for ${host}` };
275
+ }
276
+ }
277
+ catch (error) {
278
+ return { error: error.message };
279
+ }
280
+ try {
281
+ const { stdout, stderr } = await run(command, [...extra, 'repo', 'fork', request.repo], {
282
+ cwd: repo,
283
+ timeout: CREATE_TIMEOUT_MS,
284
+ maxBuffer: 1 << 20,
285
+ env: forkEnv(request.proxy, request.account, host),
286
+ });
287
+ const match = /https:\/\/[^\s]+\/[^\s/]+\/[^\s/]+/.exec(stdout);
288
+ if (match?.[0] !== undefined)
289
+ return { url: match[0] };
290
+ // With no TTY, gh prints the URL only for a fresh fork; an existing fork older than a minute
291
+ // is `owner/name already exists` on stderr with empty stdout and exit 0.
292
+ const existing = /^([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+) already exists$/m.exec(stderr);
293
+ if (existing?.[1] !== undefined) {
294
+ return { url: `https://${host}/${existing[1]}` };
295
+ }
296
+ return { error: `no fork URL in the output: ${(stdout.trim() || stderr.trim()).slice(0, 300)}` };
297
+ }
298
+ catch (error) {
299
+ const failure = error;
300
+ const reason = (failure.stderr ?? failure.message ?? 'the command failed').trim();
301
+ return { error: reason.slice(0, 300) || 'the command failed' };
302
+ }
303
+ }
206
304
  // The body goes to a private temp file: the program is given a path, never a string to interpret.
207
305
  const scratch = mkdtempSync(join(tmpdir(), 'gcb-'));
208
306
  const bodyFile = join(scratch, 'body.md');
209
307
  writeFileSync(bodyFile, request.body, 'utf8');
308
+ const issue = request.kind === 'issue';
210
309
  try {
211
310
  const { stdout, stderr } = await run(command, [
212
311
  ...extra,
213
- 'pr',
312
+ issue ? 'issue' : 'pr',
214
313
  'create',
215
314
  // No `--repo`: gh resolves the repository from the checkout it runs in, which is the checkout the
216
315
  // request was written in. That is a mechanism, not a boundary — the container can edit that checkout,
217
- // its remote included. What a deployment controls is which roots are served and which program runs;
218
- // what this reaches is whatever the person running it can reach.
219
- ...(request.draft === true ? ['--draft'] : []),
220
- '--base',
221
- request.base,
222
- '--head',
223
- request.head,
316
+ // its remote included. What a deployment controls is which roots are served, which program runs
317
+ // and which account directories exist; what this reaches is whatever the account the request
318
+ // names can reach.
319
+ ...(!issue && request.draft === true ? ['--draft'] : []),
320
+ ...(issue ? [] : ['--base', request.base, '--head', request.head]),
224
321
  '--title',
225
322
  request.title,
226
323
  '--body-file',
227
324
  bodyFile,
228
- ], { cwd: repo, timeout: CREATE_TIMEOUT_MS, maxBuffer: 1 << 20, env: openerEnv(request.proxy) });
229
- const found = pullRequestUrl(stdout);
325
+ ], { cwd: repo, timeout: CREATE_TIMEOUT_MS, maxBuffer: 1 << 20, env: openerEnv(request.proxy, request.account) });
326
+ const found = issue ? issueUrl(stdout) : pullRequestUrl(stdout);
230
327
  if (!found) {
231
- return { error: `no pull request URL in the output: ${(stdout.trim() || stderr.trim()).slice(0, 300)}` };
328
+ return {
329
+ error: `no ${issue ? 'issue' : 'pull request'} URL in the output: ${(stdout.trim() || stderr.trim()).slice(0, 300)}`,
330
+ };
232
331
  }
233
332
  return found;
234
333
  }
@@ -1 +1 @@
1
- {"version":3,"file":"host-opener.js","sourceRoot":"","sources":["../../src/commands/host-opener.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EACL,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,GAGZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,IAAI,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C;IACjE,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
package/lib/index.d.ts CHANGED
@@ -5,6 +5,6 @@
5
5
  */
6
6
  import { type CommandBackend } from 'gcb-core';
7
7
  export * from './gh.ts';
8
- export declare const HOST_HELP = "gcb-host \u2014 host-side gcb broker and administration commands.\n\nUsage: gcb <command> [options]\n\nCommands\n app Run the app broker (alias for daemon)\n host Run the host operations opener (alias for host-opener)\n daemon Run the broker (normally started by the service manager)\n init Create or update the broker config, and install the key\n stage Export a reviewed commit to where the broker will run\n compose Print a Docker sidecar definition for the broker\n config Validate the broker configuration\n diagnose Ask GitHub what the App can actually see\n authorize Authorize this app once for person-authored pull requests\n host-opener Watch for the container's pull-request requests and create them\n\nClient commands such as setup/probe/logs/pr are in gcb-client.";
8
+ export declare const HOST_HELP = "gcb-host \u2014 host-side gcb broker and administration commands.\n\nUsage: gcb <command> [options]\n\nCommands\n app Run the app broker (alias for daemon)\n host Run the host operations opener (alias for host-opener)\n daemon Run the broker (normally started by the service manager)\n init Create or update the broker config, and install the key\n stage Export a reviewed commit to where the broker will run\n compose Print a Docker sidecar definition for the broker\n config Validate or edit the broker configuration\n diagnose Ask GitHub what the App can actually see\n authorize Authorize this app once for person-authored pull requests\n host-opener Watch for the container's pull-request requests and create them\n\nClient commands such as setup/probe/logs/pr are in gcb-client.";
9
9
  export declare const hostBackend: CommandBackend;
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG9D,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,SAAS,g1BAgByC,CAAC;AAgChE,eAAO,MAAM,WAAW,EAAE,cAKzB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG9D,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,SAAS,w1BAgByC,CAAC;AAgChE,eAAO,MAAM,WAAW,EAAE,cAKzB,CAAC"}
package/lib/index.js CHANGED
@@ -17,7 +17,7 @@ Commands
17
17
  init Create or update the broker config, and install the key
18
18
  stage Export a reviewed commit to where the broker will run
19
19
  compose Print a Docker sidecar definition for the broker
20
- config Validate the broker configuration
20
+ config Validate or edit the broker configuration
21
21
  diagnose Ask GitHub what the App can actually see
22
22
  authorize Authorize this app once for person-authored pull requests
23
23
  host-opener Watch for the container's pull-request requests and create them
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAclE,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CA2BlE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAUjE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAerE;AAED,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAOzF"}
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAclE,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CA2BlE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAUjE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAiBrE;AAED,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAOzF"}
package/lib/policy.js CHANGED
@@ -79,11 +79,13 @@ export function parseAllowEntry(entry) {
79
79
  export function repoAllowed(allowList, full) {
80
80
  if (typeof full !== 'string' || !Array.isArray(allowList))
81
81
  return false;
82
- const slash = full.indexOf('/');
82
+ // Repository names are case-insensitive on GitHub; the caller may pass the spelling from a remote URL.
83
+ const normalized = full.toLowerCase();
84
+ const slash = normalized.indexOf('/');
83
85
  if (slash <= 0)
84
86
  return false;
85
- const owner = full.slice(0, slash);
86
- const repo = full.slice(slash + 1);
87
+ const owner = normalized.slice(0, slash);
88
+ const repo = normalized.slice(slash + 1);
87
89
  for (const raw of allowList) {
88
90
  const entry = parseAllowEntry(raw);
89
91
  if (!entry)
package/lib/policy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAgBA,kFAAkF;AAClF,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAE5C,4EAA4E;AAC5E,MAAM,YAAY,GAAG,mDAAmD,CAAC;AAEzE,4FAA4F;AAC5F,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,4DAA4D;AAC5D,MAAM,QAAQ,GAAG,GAAG,CAAC;AAQrB;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7C,IAAI,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5B,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,IAAI,IAAI,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,IAAI,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAEtD,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,C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  * @returns the number and the URL GitHub answered with.
559
559
  */
560
560
  async pullRequest(request) {
561
+ if (request.action === 'fork') {
562
+ let token = await personalToken();
563
+ const userToken = cfg.userTokens?.[request.owner];
564
+ if (token === undefined && userToken !== undefined) {
565
+ token = readFileSync(userToken, 'utf8').trim();
566
+ }
567
+ if (token === undefined) {
568
+ throw new ProviderConfigError('no user token for fork; run gcb authorize or configure userTokens');
569
+ }
570
+ const { text } = await callWithToken('POST', `${api}/repos/${request.owner}/${request.repo}/forks`, token);
571
+ let payload = null;
572
+ try {
573
+ payload = JSON.parse(text);
574
+ }
575
+ catch {
576
+ payload = null;
577
+ }
578
+ const forked = (payload ?? {});
579
+ if (typeof forked.full_name !== 'string' || typeof forked.html_url !== 'string') {
580
+ throw new ProviderConfigError('GitHub did not answer with a fork');
581
+ }
582
+ return { number: 0, url: forked.html_url };
583
+ }
561
584
  // The two actions a person may perform are decided first: when somebody has authorized this
562
585
  // deployment, their token is the whole authority for them, and requiring an installation as well
563
586
  // would refuse a repository the app was never installed on — the fork-to-upstream case the allowlist
564
587
  // exists to permit. Everything else still acts as the app, and only ever could.
565
- const personalForThis = request.action === 'open' || request.action === 'resolve';
588
+ const wantsApp = request.identity === 'app';
589
+ const wantsUser = request.identity === 'user';
590
+ const personalForThis = !wantsApp && (request.action === 'open' || request.action === 'resolve');
566
591
  const personToken = personalForThis ? await personalToken() : undefined;
567
592
  // `--status` also reads /actions/runs, which is checked against actions: read. Pre-flighting
568
593
  // pull_requests alone passed a grant that could not make that call, which is the opposite of what a
@@ -573,10 +598,11 @@ export function createGithubAppProvider(options) {
573
598
  // A token per owner is the other way a person acts. It counts exactly as the authorized token does:
574
599
  // whoever is acting, requiring an installation as well would refuse a repository the app was never
575
600
  // installed on — the fork-to-upstream case the allowlist exists to permit.
576
- const fileToken = request.action === 'open' || request.action === 'resolve'
577
- ? cfg.userTokens?.[request.owner]
578
- : undefined;
601
+ const fileToken = personalForThis ? cfg.userTokens?.[request.owner] : undefined;
579
602
  const actingToken = personToken ?? (fileToken === undefined ? undefined : readFileSync(fileToken, 'utf8').trim());
603
+ if (wantsUser && actingToken === undefined) {
604
+ throw new ProviderConfigError('no authorized user token for this request; run gcb authorize or configure userTokens');
605
+ }
580
606
  if (actingToken === undefined) {
581
607
  await ensurePermissions(request.owner, wanted);
582
608
  const installationId = await resolveInstallationId(request.owner);
@@ -747,66 +773,86 @@ export function createGithubAppProvider(options) {
747
773
  query: 'query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){reviewThreads(first:50){totalCount nodes{id isResolved path line comments(first:10){nodes{databaseId author{login} body}}}}}}}',
748
774
  variables: { owner: request.owner, name: request.repo, number: request.number },
749
775
  });
750
- let listed = null;
776
+ let listed;
751
777
  try {
752
778
  listed = JSON.parse(raw);
753
779
  }
754
780
  catch {
755
- listed = null;
781
+ throw new Error('GitHub did not answer with review-thread JSON');
756
782
  }
757
- // Nothing from a response body reaches the container — the broker answers with a generic
758
- // message for an ordinary Error — but the host log is where a reason belongs, and a refusal
759
- // that reads as "no threads" is worse than one that reads as a refusal.
760
- const refused = (listed ?? {});
783
+ // A refusal that reads as "no threads" is worse than one that reads as a refusal: malformed
784
+ // JSON, a GraphQL error, and a missing reviewThreads shape are all failures, not an empty list.
785
+ if (listed === null || typeof listed !== 'object') {
786
+ throw new Error('GitHub did not answer with review-thread JSON');
787
+ }
788
+ const refused = listed;
761
789
  if (Array.isArray(refused.errors) && refused.errors.length > 0) {
762
790
  throw new Error(`GitHub refused to list the review threads: ${JSON.stringify(refused.errors).slice(0, 300)}`);
763
791
  }
764
- const data = (listed ?? {});
765
- const nodes = data.data?.repository?.pullRequest?.reviewThreads?.nodes;
792
+ const data = listed;
793
+ const threads = data.data?.repository?.pullRequest?.reviewThreads;
794
+ if (threads === undefined || threads === null) {
795
+ throw new Error('GitHub did not answer with reviewThreads');
796
+ }
797
+ if (!Array.isArray(threads.nodes)) {
798
+ throw new Error('GitHub did not answer with reviewThreads.nodes');
799
+ }
800
+ if (typeof threads.totalCount !== 'number' || !Number.isInteger(threads.totalCount) || threads.totalCount < 0) {
801
+ throw new Error('GitHub did not answer with reviewThreads.totalCount');
802
+ }
803
+ if (threads.totalCount > 0 && threads.nodes.length === 0) {
804
+ throw new Error('GitHub answered with a thread count but no threads');
805
+ }
806
+ const nodes = threads.nodes;
766
807
  const report = [];
767
- if (Array.isArray(nodes)) {
768
- for (const node of nodes) {
769
- report.push(`${node.isResolved === true ? 'resolved' : 'open '} ${String(node.id ?? '')} ${String(node.path ?? '')}:${String(node.line ?? '')}`);
770
- const comments = node.comments?.nodes;
771
- if (!Array.isArray(comments))
772
- continue;
773
- for (const comment of comments) {
774
- // The whole comment, not its first line and not 120 characters of it: a review bot puts the finding
775
- // in the lines below the header, and a report that drops them sends the reader to the web UI for the
776
- // one thing this command exists to show.
777
- const body = String(comment.body ?? '');
778
- // The prose, not the first twelve lines of the comment: a review bot prefixes its finding with the
779
- // commands it ran and a fence of their output, so counting raw lines reads the preamble and never
780
- // reaches the claim. Fences and the bot's own metadata lines are dropped, and the cap then applies to
781
- // what is left, which is what the reader wants and what the writer meant.
782
- const bodyLines = body.split('\n');
783
- const kept = [];
784
- let inFence = false;
785
- for (const raw of bodyLines) {
786
- const line = raw.trim();
787
- if (line.startsWith('```')) {
788
- inFence = !inFence;
789
- continue;
790
- }
791
- if (inFence)
792
- continue;
793
- if (/^(🏁|🔎|⚙️|🌐|💡|💬|🔗|Repository:|Length of output:|Proposed fix$|---$|_?\s*[🔒📐🎯🩺🟡🟠])/u.test(line))
794
- continue;
795
- kept.push(line.replace(/<\/?[a-z][^>]*>/gi, '').trim());
808
+ for (const node of nodes) {
809
+ if (typeof node.id !== 'string' || node.id === '') {
810
+ throw new Error('GitHub did not answer with a review-thread id');
811
+ }
812
+ // The id is the handle `--resolve` needs; the body is the finding. Both are required.
813
+ report.push(`${node.isResolved === true ? 'resolved' : 'open '} ${node.id} ${String(node.path ?? '')}:${String(node.line ?? '')}`);
814
+ const comments = node.comments?.nodes;
815
+ if (!Array.isArray(comments)) {
816
+ throw new Error('GitHub did not answer with review-thread comments');
817
+ }
818
+ for (const comment of comments) {
819
+ // The whole comment, not its first line and not 120 characters of it: a review bot puts the finding
820
+ // in the lines below the header, and a report that drops them sends the reader to the web UI for the
821
+ // one thing this command exists to show.
822
+ if (typeof comment.body !== 'string') {
823
+ throw new Error('GitHub did not answer with a review-comment body');
824
+ }
825
+ const body = comment.body;
826
+ // The prose, not the first twelve lines of the comment: a review bot prefixes its finding with the
827
+ // commands it ran and a fence of their output, so counting raw lines reads the preamble and never
828
+ // reaches the claim. Fences and the bot's own metadata lines are dropped, and the cap then applies to
829
+ // what is left, which is what the reader wants and what the writer meant.
830
+ const bodyLines = body.split('\n');
831
+ const kept = [];
832
+ let inFence = false;
833
+ for (const raw of bodyLines) {
834
+ const line = raw.trim();
835
+ if (line.startsWith('```')) {
836
+ inFence = !inFence;
837
+ continue;
796
838
  }
797
- const shown = kept.filter((line) => line !== '').slice(0, 14);
798
- const more = kept.length > shown.length ? ` (+${kept.length - shown.length} more lines)` : '';
799
- report.push(` ${String(comment.databaseId ?? '')} @${String(comment.author?.login ?? '?')}:${more}`);
800
- for (const line of shown)
801
- report.push(` ${line.slice(0, 300)}`);
839
+ if (inFence)
840
+ continue;
841
+ if (/^(🏁|🔎|⚙️|🌐|💡|💬|🔗|Repository:|Length of output:|Proposed fix$|---$|_?\s*[🔒📐🎯🩺🟡🟠])/u.test(line))
842
+ continue;
843
+ kept.push(line.replace(/<\/?[a-z][^>]*>/gi, '').trim());
802
844
  }
845
+ const visible = kept.filter((line) => line !== '');
846
+ const shown = visible.slice(0, 14);
847
+ const more = visible.length > shown.length ? ` (+${visible.length - shown.length} more lines)` : '';
848
+ report.push(` ${String(comment.databaseId ?? '')} @${String(comment.author?.login ?? '?')}:${more}`);
849
+ for (const line of shown)
850
+ report.push(` ${line.slice(0, 300)}`);
803
851
  }
804
852
  }
805
853
  // A page is not the whole list. Saying which it is is the difference between a report and a guess.
806
- const shown = Array.isArray(nodes) ? nodes.length : 0;
807
- const counted = data.data?.repository?.pullRequest?.reviewThreads
808
- ?.totalCount;
809
- const total = typeof counted === 'number' ? counted : shown;
854
+ const shown = nodes.length;
855
+ const total = threads.totalCount;
810
856
  if (total > shown) {
811
857
  report.push(`... and ${total - shown} more: this asks for the first 50 threads, and the first 10 comments of each`);
812
858
  }