@impeccable/reviews 0.1.3 → 0.1.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Sets a repository up for Impeccable for PRs from your terminal. Run it in a checkout of the repository: it signs you in through the browser, then a setup agent reads the checkout, runs what it needs, saves the settings through Impeccable's setup API, asks you only what it cannot find out, opens a test drive pull request for Impeccable to review (and a setup pull request to merge, when the repository needs one) and writes a setup report. A web page mirrors the run as it goes and follows the review.
4
4
 
5
- You need Node 22.19 or newer, git, and the `gh` command signed in to GitHub as someone who can push branches to the repository (the agent opens the pull request as you). On Linux, `bubblewrap`, `socat` and `ripgrep` let the agent's commands run in a sandbox.
5
+ You need Node 22.19 or newer, git, and the `gh` command signed in to GitHub as someone who can push branches to the repository (the agent opens the pull request as you). Right after sign-in the command asks GitHub with a dry run of a push, which creates nothing, and when git cannot push it says which account git signs in as and stops before anything is made, unless you fix it and try again. On Linux, `bubblewrap`, `socat` and `ripgrep` let the agent's commands run in a sandbox.
6
6
 
7
7
  ## Run it
8
8
 
@@ -28,7 +28,7 @@ Keys: Enter goes on, Esc cancels the intro or the sign-in and skips a question (
28
28
  | `--model <id>` | the model the service hands out (Sonnet 5.5 today) | The model the setup agent runs on, through Impeccable's gateway. |
29
29
  | `--effort <level>` | `high` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh` or `max`. |
30
30
  | `--yes` | off | Runs the allowlisted commands without asking, which they already do; anything off the list is still refused. |
31
- | `--debug` | off | Writes a debug log and a transcript of the run (`transcript-<run>.md`, with its raw events in `transcript-<run>.jsonl`) to the temp folder, tokens removed, and prints where they are. |
31
+ | `--debug` | off | Writes a debug log and a transcript of the run (`transcript-<run>.md`, with its raw events in `transcript-<run>.jsonl`) to the temp folder, with tokens and whatever is shaped like a secret removed, and prints where they are. |
32
32
  | `--transcript <path>` | the temp folder | Writes the transcript there instead: a folder, or a `.md` file with the `.jsonl` beside it. |
33
33
  | `--scan-report` | off | Writes what the fence's content checks found (`scan-report-<run>.json`: each match's check, where it was, the tool and what it did, never the text, with counts per check) beside the transcript, and prints where it is. |
34
34
  | `--frames <dir>` | off | Writes each screen into the folder as it changes (`NNN-<state>.ansi` with its styling, `NNN-<state>.txt`, and `index.json`), for the eval. |
@@ -36,7 +36,7 @@ Keys: Enter goes on, Esc cancels the intro or the sign-in and skips a question (
36
36
 
37
37
  ## What happens
38
38
 
39
- 1. **Sign in.** The consent page names this repository, read from the checkout's `origin` remote; you approve, and it answers a small server on the first free port of 8239, 8238, 8240, 8237, 8236 and 8235, with PKCE and a state check, then sends the browser on to the run's web page. On a remote shell, press P and paste the address the browser ends on.
39
+ 1. **Sign in.** The consent page names this repository, read from the checkout's `origin` remote; you approve, and it answers a small server on the first free port of 8239, 8238, 8240, 8237, 8236 and 8235, with PKCE and a state check, then sends the browser on to the run's web page. The server holds its port on both loopback addresses (`127.0.0.1` and `::1`), since a browser takes `localhost` for either: a port another program holds on one of them counts as taken. On a remote shell, press P and paste the address the browser ends on.
40
40
  2. **A web front end?** Impeccable reviews web front ends, mobile web included. A checkout with none (a React Native, Expo or Flutter app without a web target, or a service with no page, template, stylesheet or web framework) ends here: the terminal and the web page say "Impeccable reviews web front ends, and this repository does not have one. Nothing was set up.", and it exits 2. When the checkout cannot tell, Impeccable's own scan decides. A checkout with a web front end that the scan skipped stops the same way, with the setup page, where the person chooses Add anyway before running it again.
41
41
  3. **Set up.** On a run with its own capped model token (model calls go through Impeccable's gateway, so this machine holds no model key), the agent reads the checkout, runs the build, saves settings through the setup API, and asks you in a dialog only what it cannot find out. It never asks you to run a command: what it cannot run goes into the report, with the command. When Vercel, Netlify or Cloudflare Pages already deploys previews of your pull requests, it opens the newest one (Netlify's it finds on GitHub, and through the Netlify CLI when you are signed in to it on this machine, read only; Cloudflare's in the check run and the comment Cloudflare's GitHub app posts, and through Cloudflare's CLI, cf, when you are signed in to it here, read only), and once that page is your app it takes the host's previews as they are, with no question and no setup pull request. When the repository is set up for Vercel or Netlify but that host has never previewed it, it asks you for one thing, to sign in to the host, and only when its CLI on this machine is signed out: one screen, Sign in or Skip, the login in your browser on Enter, and a retry when it did not complete (two failed retries count as a skip). Then it does the rest itself. On Vercel it creates the project with `vercel link` in the team the CLI's current scope names (asking which, only when you have several and none is current), connects the repository, puts Vercel's login in front of every address of the new project before pushing anything (Vercel makes a new project's first deployment production, whatever branch it builds, and would serve the test drive at the project's own address otherwise; the report says how to open production once your default branch is live), pushes the test drive and waits up to five minutes for Vercel's build of it (the task in progress reads "waiting for Vercel's preview · 1:05", counting up), proves that preview, takes Vercel's previews as they are and only then opens the test drive's pull request, so its review renders; a new project starts with Vercel Authentication on, which the run gets past with a bypass secret on your yes. On Netlify it creates the site in your Netlify team (asking which, only when you have several), connects the repository through Netlify's site settings and Netlify's GitHub app, so pull requests get deploy previews, pushes the test drive and opens it as a draft, which Impeccable leaves unreviewed, waits for its deploy preview, proves it, takes Netlify's previews as they are and marks the draft ready. When the host's GitHub app cannot reach the repository, one more screen opens the app's page on GitHub for you to give it access, and the run waits. On skip it builds Impeccable's own previews as usual.
42
42
  4. **Two pull requests,** opened as you with `gh`, even when something is left for a person, which goes into the report, both into the default branch and in this order:
@@ -80,10 +80,14 @@ Each report carries the step, how it ended, when, the command's version, Node's
80
80
 
81
81
  The setup token and the run token stay in memory. The agent never sees them: the tools add them to their own requests. The debug log and the transcript remove them.
82
82
 
83
+ The debug log and the transcript also remove whatever is shaped like a secret, wherever the agent wrote or read it: a cloud or GitHub key, a token, a private key through its end, and a random value under a secret-like name (`API_TOKEN=…`), whose name stays. So a call the fence refused for holding a secret leaves no copy of it there.
84
+
83
85
  A test account's password, typed hidden on the account's screen (after a screen that says why the run asks), goes from there to Impeccable's test-accounts setting: the agent only holds a reference to it, and the debug log and the transcript remove it.
84
86
 
87
+ What you type into any other question the agent asks, it reads. So a question whose title, prompt or hint names a token, a password, a secret, a key or a credential is typed hidden however the agent asked it, and the agent gets a reference, as for a test account's password. Every other question with a field says under it "Never enter a password, a token or a key here."
88
+
85
89
  Vercel's bypass secret, which lets reviews open previews behind Vercel's login, is handled the same way. When Vercel's login stands in front of a preview, the command asks you once, on one screen, whether to create a bypass secret for Impeccable, and on your yes creates it as you through the Vercel CLI, labelled "Impeccable reviews" (`vercel api` for Vercel's protection-bypass route; an older CLI's `vercel project protection enable --protection-bypass`), then reads it back from the project's settings. A project that already holds a secret with that label gives it without a question. When the CLI is signed out, this folder is not linked, or your role cannot make one, a screen names the settings page and takes the secret you type, hidden. It opens the preview with the secret first and saves it, with the setting that sends it in the `x-vercel-protection-bypass` header, only once the page shows your app. The agent never holds it: the secret goes from the command's own process to Vercel and to Impeccable's setting, and the debug log and the transcript remove it. Vercel documents this as Protection Bypass for Automation, which every plan includes; you revoke it in the project's Settings, Deployment Protection.
86
90
 
87
- Netlify's site password (Password Protection on Pro and Enterprise plans; "Project visibility: Password" on a credit-based Pro plan) is handled the same way. When a Netlify deploy preview asks for it, the command reads the site's settings through the Netlify CLI, signed in as you. For a password Netlify gives back, it asks you once, on one screen, whether to store the site password for Impeccable, and on your yes reads it from the site as you. When Netlify does not give the password back, the CLI is signed out or the site is in none of your teams, a screen takes the password you type, hidden (the run never sets one itself: the Netlify CLI takes a new password only on its command line, where any process could read it). It opens the preview with the password first, as basic credentials in the `Authorization` header (Netlify's password page asks for a password alone, so the credentials carry no username), and saves it, with the setting that sends that header, only once the page shows your app; a password that opens the preview on Netlify's own form but not in the header is reported, not saved, since reviews can send only a header. A site behind Netlify's team login (a private site, or team login protection) has no way in for tools: the run reports it and takes no method. The agent never holds the password: it goes from the command's own process to Netlify and to Impeccable's setting, and the debug log and the transcript remove it.
91
+ Netlify's site password (Password Protection on Pro and Enterprise plans; "Project visibility: Password" on a credit-based Pro plan) is handled the same way. When a Netlify deploy preview asks for it, the command reads the site's settings through the Netlify CLI, signed in as you. For a password Netlify gives back, it asks you once, on one screen, whether to store the site password for Impeccable, and on your yes reads it from the site as you. When Netlify does not give the password back, the CLI is signed out or the site is in none of your teams, a screen takes the password you type, hidden (the run never sets one itself: the Netlify CLI takes a new password only on its command line, where any process could read it). It opens the preview with the password first, as basic credentials in the `Authorization` header (Netlify's password page asks for a password alone, so the credentials carry no username), and saves it, with the setting that sends that header, only once the page shows your app; a password that opens the preview on Netlify's own form but not in the header is reported, not saved, since reviews can send only a header. A site behind Netlify's team login (a private site) has no way in for tools, so the command asks you once, on one screen, whether to make the site public, and on your yes makes it public as you through the Netlify CLI (`netlify api updateSite` with `sso_login` off); anyone with its address can then open it, the live site included, until you make it private again in Project configuration, General, Visitor access. Where Netlify refuses (your team's default keeps every project private, or your role cannot change it), the command opens that page in your browser and asks you to try again once you changed it there; a password you set there instead is stored as above. The agent never holds the password: it goes from the command's own process to Netlify and to Impeccable's setting, and the debug log and the transcript remove it.
88
92
 
89
93
  A Cloudflare Access service token, which lets reviews open Pages previews behind Access, is handled the same way. When Access stands in front of a preview, the command asks you once, on one screen, whether to create a service token for Impeccable. On your yes it creates the token as you through Cloudflare's CLI, cf (run through npx), named "Impeccable reviews", and allows it in a Service Auth policy of the Access application in front of the preview (a reusable policy added to the application's list). When cf here is not signed in with Access, your browser opens Cloudflare's sign-in first, for five scopes (`account:read`, `user:read`, `pages:read`, `access.write`, `access-service-token.write`), with a retry when it did not complete. Only where that sign-in cannot create the token (it grants no Access, cf does not run here, or the application runs on policies of its own, which cf has no command for) does the command ask for a Cloudflare API token with two permissions (Access: Apps and Policies, Edit; Access: Service Tokens, Edit), used for that run only and stored nowhere. On a skip, or where that cannot be done, a screen takes a client id and secret you paste, the secret hidden. It opens the preview with the token in the `CF-Access-Client-Id` and `CF-Access-Client-Secret` headers first and saves it, with the setting that sends them, only once the page shows your app; a token it made that opens nothing is deleted, with its policy. The agent never holds either, and the debug log and the transcript remove both. You revoke it in Zero Trust, Access controls, Service credentials, Service Tokens.
package/dist/agent.js CHANGED
@@ -36,8 +36,8 @@ function gatewayModel(modelRuntime, id) {
36
36
  * to the command's finish.
37
37
  */
38
38
  export async function runAgent(opts) {
39
- // Inside our command pi makes no calls of its own: no version check, no catalog refresh, no install telemetry.
40
- process.env.PI_OFFLINE ??= '1';
39
+ // Inside our command pi makes no calls of its own: no version check, no catalog refresh, no install telemetry, whatever the person's shell exports.
40
+ process.env.PI_OFFLINE = '1';
41
41
  // pi's own configuration stays out of this: no settings, credentials, extensions or sessions from ~/.pi.
42
42
  const agentDir = mkdtempSync(join(tmpdir(), 'impeccable-reviews-pi-'));
43
43
  process.on('exit', () => rmSync(agentDir, { recursive: true, force: true }));
package/dist/bin.js CHANGED
File without changes
package/dist/fence.js CHANGED
@@ -1183,6 +1183,10 @@ export function chooseHostTeam(log, questionId, team) {
1183
1183
  if (host && Object.hasOwn(HOST_CLIS, host) && hostsAgreed(log).has(host) && /^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/.test(team))
1184
1184
  teamsChosen(log).set(host, team);
1185
1185
  }
1186
+ /** The team picked or found for a host's CLI in this run, which its dashboard's addresses name. */
1187
+ export function chosenHostTeam(log, host) {
1188
+ return teamsChosen(log).get(host);
1189
+ }
1186
1190
  /** What impeccable_vercel_connect settled of the linked Vercel project's first deployment in this run, by the run's log. */
1187
1191
  const settledVercel = new WeakMap();
1188
1192
  export function settleVercelFirstDeployment(log, settlement) {
@@ -21,7 +21,20 @@ export const HOST_QUESTIONS = {
21
21
  };
22
22
  /** Where a person reads or changes a site's password in Netlify, as Netlify's docs name the page on every plan. */
23
23
  export const NETLIFY_PASSWORD_WHERE = 'Project configuration → General → Visitor access';
24
- /** The screens a tool shows on its own: a sign-in's retry, the one-time access the host's GitHub app needs, and the consent to a key for a host's lock (a bypass secret for Vercel's login, the site password for Netlify's, a service token for Cloudflare Access), with the paste where the run does not get one. */
24
+ /** The wait for a host's build that ran out: the page where the host's builds of pull requests are turned on, and the wait again. */
25
+ const buildWait = (id, name, where) => ({
26
+ [`${id}-build`]: {
27
+ id: `${id}-build`,
28
+ kind: 'confirm',
29
+ title: `Waiting for ${name}`,
30
+ hint: `Five minutes and no preview yet. If ${name} hasn't started a build, ${where} on the page that opens. The run carries on by itself once the preview is built.`,
31
+ prompt: `Open ${name} and keep waiting?`,
32
+ confirmLabel: 'Keep waiting',
33
+ skipLabel: 'Skip',
34
+ },
35
+ [`${id}-build-retry`]: { id: `${id}-build-retry`, kind: 'confirm', title: `Waiting for ${name}`, prompt: `Still no preview from ${name}.`, confirmLabel: 'Keep waiting', skipLabel: 'Skip' },
36
+ });
37
+ /** The screens a tool shows on its own: a sign-in's retry, the one-time access the host's GitHub app needs, and the consent to a key for a host's lock (a bypass secret for Vercel's login, the site password for Netlify's, a service token for Cloudflare Access), with the paste where the run does not get one, and to making a site behind Netlify's team login public. */
25
38
  export const HOST_SCREENS = {
26
39
  'netlify-signin-retry': { id: 'netlify-signin-retry', kind: 'confirm', title: 'Sign in to Netlify', prompt: 'The sign-in did not complete.', confirmLabel: 'Try again', skipLabel: 'Skip' },
27
40
  'netlify-access': {
@@ -45,6 +58,20 @@ export const HOST_SCREENS = {
45
58
  skipLabel: 'Skip',
46
59
  },
47
60
  'vercel-access-retry': { id: 'vercel-access-retry', kind: 'confirm', title: 'Vercel needs access on GitHub', prompt: "Vercel still can't see the repository.", confirmLabel: 'Try again', skipLabel: 'Skip' },
61
+ // Vercel refused the run's lock on a new project: the person turns it on, since the test drive's push is the project's first deployment.
62
+ 'vercel-lock': {
63
+ id: 'vercel-lock',
64
+ kind: 'confirm',
65
+ title: 'Lock the new Vercel project',
66
+ hint: "The test drive's push is the project's first deployment, which Vercel shows to anyone at the project's own address. Vercel didn't let the run put its login in front. Turn on Vercel Authentication for All Deployments on the page that opens. The run carries on by itself once it's on.",
67
+ prompt: 'Open Vercel to lock the project?',
68
+ confirmLabel: 'Open Vercel',
69
+ skipLabel: 'Skip',
70
+ },
71
+ 'vercel-lock-retry': { id: 'vercel-lock-retry', kind: 'confirm', title: 'Lock the new Vercel project', prompt: "The project isn't locked yet.", confirmLabel: 'Try again', skipLabel: 'Skip' },
72
+ ...buildWait('vercel', 'Vercel', 'connect the repository in Settings → Git'),
73
+ ...buildWait('netlify', 'Netlify', 'turn Deploy Previews on'),
74
+ ...buildWait('cloudflare', 'Cloudflare', 'connect the repository to the Pages project'),
48
75
  // Vercel's login in front of the previews: the one consent to a bypass secret the run creates as the person, and the paste when the CLI cannot.
49
76
  'vercel-bypass': {
50
77
  id: 'vercel-bypass',
@@ -81,6 +108,25 @@ export const HOST_SCREENS = {
81
108
  prompt: `Netlify keeps your previews behind the site password, and the run could not read it: the Netlify CLI here is signed out, the site is in none of your teams, or Netlify does not give the password back. Find it, or set a new one, in ${NETLIFY_PASSWORD_WHERE}. It is stored encrypted and used only to open previews.`,
82
109
  hint: 'Paste the password',
83
110
  },
111
+ // Netlify's team login in front of the previews: the one consent to making the site public as the person, and the retry once they changed it on Netlify's page where Netlify refused.
112
+ 'netlify-visibility': {
113
+ id: 'netlify-visibility',
114
+ kind: 'confirm',
115
+ title: 'Your Netlify previews are private',
116
+ hint: `Impeccable reviews each pull request on its preview, and Netlify keeps this site behind your team's login, which tools can't get past. The run makes the site public as you, so anyone with an address of it can open it, the live site too. Change it back any time in ${NETLIFY_PASSWORD_WHERE}.`,
117
+ prompt: 'Make the site public?',
118
+ confirmLabel: 'Make public',
119
+ skipLabel: 'Skip',
120
+ },
121
+ 'netlify-visibility-retry': {
122
+ id: 'netlify-visibility-retry',
123
+ kind: 'confirm',
124
+ title: 'Your Netlify previews are private',
125
+ hint: "Netlify still shows its login in front of the previews. On the Netlify page that opened, set Visitor access to Public (or Password protected, on Pro). Public is greyed out until the site has a live deploy, or while your team's default keeps it private (Team settings → General → Visitor access).",
126
+ prompt: 'Changed it?',
127
+ confirmLabel: 'Try again',
128
+ skipLabel: 'Skip',
129
+ },
84
130
  // Cloudflare Access in front of the previews: the one consent to a service token the run creates as the person through cf, the retry of cf's sign-in, the API token where that sign-in cannot create it, and the paste where the run does not create one.
85
131
  'cloudflare-access': {
86
132
  id: 'cloudflare-access',
package/dist/hosted.js CHANGED
@@ -136,6 +136,8 @@ async function inCheckout(root, words) {
136
136
  const UNSEEN = /<!--[\s\S]*?-->|<(script|style|noscript|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi;
137
137
  /** The words a visitor sees: the title and the text, without comments, scripts, styles, tags or attributes. */
138
138
  const visible = (html) => plain(html.replace(UNSEEN, ' ').replace(/<[^>]*>/g, ' '));
139
+ /** The team login's page, in its script: Netlify's edge-access login, the slashes escaped or not. */
140
+ const NETLIFY_TEAM_LOGIN = /https:\\?\/\\?\/app\.netlify\.com\\?\/edge-access\b/;
139
141
  /**
140
142
  * Netlify's own lock, never the status alone, as Netlify documents it: the basic challenge (`WWW-Authenticate: Basic`)
141
143
  * its Basic-Auth rules send, which "trigger the built-in basic browser authentication"
@@ -144,13 +146,14 @@ const visible = (html) => plain(html.replace(UNSEEN, ' ').replace(/<[^>]*>/g, '
144
146
  * (https://docs.netlify.com/manage/security/secure-access-to-sites/password-protection/); or the "Netlify-branded page"
145
147
  * its team login shows a visitor (https://docs.netlify.com/manage/security/secure-access-to-sites/project-visibility/),
146
148
  * whose title names Netlify other than in the site's own address: a mention in an app's own page, such as a footer, is
147
- * not one.
149
+ * not one. Today that page is a "Login Redirect" whose script sends the browser to Netlify's edge-access login, its
150
+ * address written with escaped slashes; that address is the team login's marker (#233).
148
151
  */
149
152
  function netlifyLock(challenge, html) {
150
153
  const seen = html.replace(UNSEEN, ' ');
151
154
  const fields = [...seen.matchAll(/<input\b[^>]*>/gi)].map(([tag]) => /\stype\s*=\s*["']?([\w-]+)/i.exec(tag)?.[1]?.toLowerCase() ?? 'text').filter((type) => !['hidden', 'submit', 'button', 'reset', 'image'].includes(type));
152
155
  const title = plain(/<title\b[^>]*>([\s\S]*?)<\/title\s*>/i.exec(seen)?.[1] ?? '');
153
- return /^basic\b/i.test(challenge ?? '') || (/<form\b/i.test(seen) && fields.join() === 'password') || /\bnetlify\b/.test(title.replace(/\S*\.netlify\.app\S*/g, ' '));
156
+ return /^basic\b/i.test(challenge ?? '') || (/<form\b/i.test(seen) && fields.join() === 'password') || /\bnetlify\b/.test(title.replace(/\S*\.netlify\.app\S*/g, ' ')) || NETLIFY_TEAM_LOGIN.test(html);
154
157
  }
155
158
  /** The first `max` bytes of a page, as text. */
156
159
  async function pageText(res, max = 1_000_000) {
@@ -256,7 +259,7 @@ export async function provePreview(url, words, root, deps = {}) {
256
259
  if (withPassword && deps.form && (await formOpens(target, deps.password, phrase, open, signal))) {
257
260
  return { ...unproven("The password opens the address on Netlify's own form, but not in the Authorization header, the one way reviews can send it.", res.status), gate, formOpened: true };
258
261
  }
259
- return { ...unproven(`The address asked for ${name}'s login or password${still}.`, res.status), gate };
262
+ return { ...unproven(`The address asked for ${name}'s login or password${still}.`, res.status), gate, ...(host === 'netlify' && NETLIFY_TEAM_LOGIN.test(page) ? { teamLogin: true } : {}) };
260
263
  }
261
264
  if (res.status < 200 || res.status >= 300) {
262
265
  await res.body?.cancel().catch(() => { });
package/dist/log.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { appendFileSync } from 'node:fs';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { join } from 'node:path';
4
+ import { redactShapes } from './scan.js';
4
5
  /** An error whose message is written for the person at the terminal; `step` is the onboarding step it ends, which the command reports (report.ts). */
5
6
  export class UserError extends Error {
6
7
  step;
@@ -21,6 +22,10 @@ export function redact(text, secrets = []) {
21
22
  out = out.split(secret).join('[redacted]');
22
23
  return out.replace(TOKEN, '$1_[redacted]').replace(FIELD, '$1[redacted]');
23
24
  }
25
+ /** What a file about the run may hold: `redact`, and nothing shaped like a secret, which the text of a call the fence refused would otherwise leave there. `field` names the field the text is the value of, when it has one. */
26
+ export function scrub(text, secrets = [], field) {
27
+ return redactShapes(redact(text, secrets), field);
28
+ }
24
29
  export function createLog(debug, dir = tmpdir()) {
25
30
  const secrets = new Set();
26
31
  const secret = (value) => void secrets.add(value);
@@ -33,7 +38,7 @@ export function createLog(debug, dir = tmpdir()) {
33
38
  write(message, data) {
34
39
  const detail = data === undefined ? '' : ` ${typeof data === 'string' ? data : JSON.stringify(data)}`;
35
40
  try {
36
- appendFileSync(path, `${redact(`${new Date().toISOString()} ${message}${detail}`, secrets)}\n`, { mode: 0o600 });
41
+ appendFileSync(path, `${scrub(`${new Date().toISOString()} ${message}${detail}`, secrets)}\n`, { mode: 0o600 });
37
42
  }
38
43
  catch {
39
44
  // A debug log that cannot be written is not worth stopping the run for.
package/dist/login.js CHANGED
@@ -47,12 +47,14 @@ function waitingPage(res, state) {
47
47
  page(res, 200, 'Signed in. One moment…', `<noscript><p><a href="/go?state=${escapeHtml(encodeURIComponent(state))}">Go on to the progress page</a></p></noscript>${script}`);
48
48
  }
49
49
  /**
50
- * Listens on the first free port of `ports` for `/callback?code=&state=`. A
51
- * wrong state gets a 400 and the wait goes on; the right one hands over the
52
- * code and answers at once with a page that asks `/next` where to go, which
53
- * says "not yet" until `land` knows (a JSON `wait`), then the page or what
54
- * went wrong. `/go` is the same for a tab without scripts: a redirect, or
55
- * the waiting page again.
50
+ * Listens on the first free port of `ports` for `/callback?code=&state=`, on
51
+ * both loopback addresses: a browser takes `localhost` for either, so a port
52
+ * another process holds on one of them is taken, and no other process hears
53
+ * the callback. A wrong state gets a 400 and the wait goes on; the right one
54
+ * hands over the code and answers at once with a page that asks `/next` where
55
+ * to go, which says "not yet" until `land` knows (a JSON `wait`), then the
56
+ * page or what went wrong. `/go` is the same for a tab without scripts: a
57
+ * redirect, or the waiting page again.
56
58
  */
57
59
  export async function startCallbackServer(state, ports = CALLBACK_PORTS) {
58
60
  let resolve;
@@ -66,7 +68,7 @@ export async function startCallbackServer(state, ports = CALLBACK_PORTS) {
66
68
  let landing;
67
69
  let heard = () => { };
68
70
  const told = new Promise((r) => (heard = r)).finally(() => untold.delete(told));
69
- const server = createServer((req, res) => {
71
+ const answer = (req, res) => {
70
72
  const url = new URL(req.url ?? '/', 'http://localhost');
71
73
  const route = req.method === 'GET' ? url.pathname : '';
72
74
  if (!['/callback', '/next', '/go'].includes(route))
@@ -94,33 +96,59 @@ export async function startCallbackServer(state, ports = CALLBACK_PORTS) {
94
96
  visited = true;
95
97
  resolve(got);
96
98
  waitingPage(res, state);
97
- });
99
+ };
100
+ /** One server for each loopback address, on the port in use. */
101
+ let servers = [];
98
102
  const shut = () => {
99
103
  heard();
100
- server.close();
101
- server.closeIdleConnections();
104
+ for (const server of servers) {
105
+ server.close();
106
+ server.closeIdleConnections();
107
+ }
102
108
  };
103
109
  let closing = false;
104
110
  const shutLater = () => void setTimeout(shut, LANDED_MS).unref();
111
+ /** A server on one loopback address: false when the port is taken there, null when this machine has no IPv6 loopback, where no other process listens either. */
112
+ const listen = (address, port) => new Promise((done, fail) => {
113
+ const server = createServer(answer);
114
+ const onError = (err) => {
115
+ if (err.code === 'EADDRINUSE' || err.code === 'EACCES')
116
+ done(false);
117
+ else if (address === '::1' && (err.code === 'EADDRNOTAVAIL' || err.code === 'EAFNOSUPPORT'))
118
+ done(null);
119
+ else
120
+ fail(err);
121
+ };
122
+ server.once('error', onError);
123
+ server.listen(port, address, () => {
124
+ server.off('error', onError);
125
+ done(server);
126
+ });
127
+ });
105
128
  for (const port of ports) {
106
- const listening = await new Promise((done, fail) => {
107
- const onError = (err) => (err.code === 'EADDRINUSE' || err.code === 'EACCES' ? done(false) : fail(err));
108
- server.once('error', onError);
109
- server.listen(port, '127.0.0.1', () => {
110
- server.off('error', onError);
111
- done(true);
112
- });
129
+ const v4 = await listen('127.0.0.1', port);
130
+ if (!v4)
131
+ continue;
132
+ const actual = v4.address().port;
133
+ // The port is let go on IPv4 whenever IPv6 does not follow: taken there, or failing for a reason of its own, which stops the sign-in.
134
+ const v6 = await listen('::1', actual).catch((err) => {
135
+ v4.close();
136
+ throw err;
113
137
  });
114
- if (!listening)
138
+ if (v6 === false) {
139
+ v4.close();
115
140
  continue;
116
- const actual = server.address().port;
141
+ }
142
+ servers = v6 ? [v4, v6] : [v4];
117
143
  return {
118
144
  redirectUri: `http://localhost:${actual}/callback`,
145
+ addresses: v6 ? ['127.0.0.1', '::1'] : ['127.0.0.1'],
119
146
  code,
120
147
  land: (next) => void next.then((url) => void (landing ??= { page: url }), (err) => void (landing ??= { error: err instanceof UserError ? err.message : 'Sign-in did not finish. Back to your terminal.' })).then(() => closing && shutLater()),
121
148
  close: () => {
122
149
  // The tab asks again every half second; it is never a reason for the command to stay.
123
- server.unref();
150
+ for (const server of servers)
151
+ server.unref();
124
152
  if (!visited)
125
153
  return shut();
126
154
  // It stops a while after the tab has somewhere to go, however long that takes to know.
@@ -229,7 +257,7 @@ export async function signIn(host, repo, log, prompt, check = (t) => t, landing
229
257
  const server = await startCallbackServer(state);
230
258
  const authorize = new URL(`${host}/app/cli/authorize`);
231
259
  authorize.search = new URLSearchParams({ redirect_uri: server.redirectUri, state, code_challenge: challenge, code_challenge_method: 'S256', repo }).toString();
232
- log.write(`callback server at ${server.redirectUri}`);
260
+ log.write(`callback server at ${server.redirectUri}`, `on ${server.addresses.join(' and ')}`);
233
261
  prompt.show(authorize.href);
234
262
  openBrowser(authorize.href);
235
263
  let stopPaste = () => { };
package/dist/main.js CHANGED
@@ -15,8 +15,10 @@ import { startSandbox } from './sandbox.js';
15
15
  import { scanRecorder } from './scan.js';
16
16
  import { createReporter, reportingOff } from './report.js';
17
17
  import { createSessionSync, syncExtension } from './sync.js';
18
+ import { checkPushAccess, readPushAccess } from './push-access.js';
18
19
  import { createTools, resultLine } from './tools.js';
19
20
  import { transcriptPaths } from './transcript.js';
21
+ import { askPerson } from './ui/bridge.js';
20
22
  import { atExit, closeScreens, helpMark, onScreenExit, recordFrames, showIntro, showOutro, showPullRequest, showRun, showSignIn } from './ui/screens.js';
21
23
  const say = (line = '') => console.log(line);
22
24
  const execFileAsync = promisify(execFile);
@@ -126,7 +128,7 @@ export async function main(argv) {
126
128
  }
127
129
  return t;
128
130
  };
129
- const token = await signIn(flags.host, slug, log, screenPrompt(showSignIn), accept, () => landing);
131
+ const token = await signIn(flags.host, slug, log, screenPrompt((link, on) => showSignIn(link, { ...on, checkout: { repository: slug, folder: checkout.root } })), accept, () => landing);
130
132
  const setupApi = token.setup_api.replace(/\/$/, '');
131
133
  const cliApi = token.cli_api.replace(/\/$/, '');
132
134
  // Signed in: what the command held goes now, on the person who approved.
@@ -189,6 +191,17 @@ export async function main(argv) {
189
191
  const setupPage = state.data.account?.setupPage;
190
192
  await nothingToSetUp(liveSync, reporter, 'skipped_repo', 'Repository skipped', SKIPPED, [...(typeof setupPage === 'string' && onHost(setupPage) ? [{ label: 'Setup page', url: setupPage }] : []), webPage]);
191
193
  }
194
+ // The setup pushes as the person, so whether git may push is asked of GitHub now, before anything is created.
195
+ const push = await checkPushAccess(slug, () => readPushAccess(checkout.root), async (screen) => {
196
+ liveSync.update({ phase: 'waiting', question: { id: screen.id, prompt: screen.prompt } });
197
+ const answer = await askPerson({ ...screen, skippable: true });
198
+ liveSync.update({ phase: 'running', question: null });
199
+ return answer;
200
+ });
201
+ log.write('push access', push.outcome);
202
+ if (push.outcome === 'refused' || push.outcome === 'signed-out') {
203
+ await nothingToSetUp(liveSync, reporter, 'stopped', "Git can't push", `Git can't push to ${slug}${push.account ? ` as ${push.account}` : ''}, so nothing was set up. Sign git in as an account that can, then run this again.`, [webPage]);
204
+ }
192
205
  if (!interactive)
193
206
  say('Signed in.\n');
194
207
  // Beside the transcript, named after the run as it is, so a run never writes over another's in the temp folder.
@@ -272,6 +285,7 @@ export async function main(argv) {
272
285
  log,
273
286
  previewWait: previewWait(),
274
287
  sandbox,
288
+ pushAccess: push.outcome,
275
289
  }),
276
290
  extensions: [
277
291
  fenceExtension(checkout.root, log, checkout.protectedBranches, scratch, scans),
@@ -7,7 +7,8 @@
7
7
  * no password goes back to the model. The person consents once, on the tool's screen, before the password is stored;
8
8
  * a password opens the locked address before anything saves it. A password Netlify does not give back is the
9
9
  * person's to type: setting one through the CLI would put it on the command line, where any process could read it.
10
- * Netlify's team login (a private site, or team login protection) has no way in for tools, and is reported as such.
10
+ * Netlify's team login (a private site) has no way in for tools, so on the person's yes the run makes the site public
11
+ * through the CLI; where Netlify refuses, the person changes Visitor access on Netlify's page and the run tries again.
11
12
  */
12
13
  /** The header reviews send the password in. */
13
14
  export const PASSWORD_HEADER = 'Authorization';
@@ -15,6 +16,13 @@ export const PASSWORD_HEADER = 'Authorization';
15
16
  export const basicCredentials = (password) => `Basic ${Buffer.from(`:${password}`).toString('base64')}`;
16
17
  /** The CLI's read of a site by the address every deploy preview of it carries (`site_id` takes the site's default domain), an authenticated call of Netlify's API. */
17
18
  export const readSiteCall = (site) => ['api', 'getSite', '--data', JSON.stringify({ site_id: `${site}.netlify.app` })];
19
+ /**
20
+ * The CLI's change of a site's visitor access to Public: the team login off. `updateSite` documents no such field, but
21
+ * `getSite` reads it back and Netlify's own tools send it; `sso_login_context` stays out, since Netlify answers 422 with it.
22
+ */
23
+ export const publicSiteCall = (id) => ['api', 'updateSite', '--data', JSON.stringify({ site_id: id, body: { sso_login: false } })];
24
+ /** Netlify's page where a site's Visitor access is changed. */
25
+ export const visitorAccessPage = (site) => `https://app.netlify.com/projects/${site}/configuration/general#visitor-access`;
18
26
  const record = (value) => (value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined);
19
27
  /** A site's name and id as Netlify makes them. */
20
28
  const NAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
@@ -38,11 +46,19 @@ export async function readSite(run, site) {
38
46
  /**
39
47
  * Gets the site password in place for the address Netlify's lock stands in front of, and saves only one that opens it.
40
48
  * The site's settings say what the lock is: a password, which the person's yes has the run store when Netlify gives it
41
- * back; the team login, which no tool gets past; or neither. When the CLI cannot read the site, or Netlify gives no
42
- * password back, the person may paste the password.
49
+ * back; the team login, which the person's yes has the run lift by making the site public; or neither. When the CLI
50
+ * cannot read the site, or Netlify gives no password back, the person may paste the password.
43
51
  */
44
52
  export async function passNetlifyLock(deps) {
45
- const site = await readSite(deps.run, deps.site);
53
+ let site = await readSite(deps.run, deps.site);
54
+ // The team login, as the site's settings or the address show it: the CLI may be signed out, or the site another team's, or the login the team's own. The person is asked the same one question.
55
+ if (!site?.hasPassword && (site?.teamLogin || deps.teamLogin)) {
56
+ const opened = await openToVisitors(deps, site);
57
+ if ('status' in opened)
58
+ return opened;
59
+ // The person picked Password protected on Netlify's page: the password is got in place as any site password is.
60
+ site = opened;
61
+ }
46
62
  const from = site ? { site: site.name } : {};
47
63
  const finish = async (password, how) => {
48
64
  deps.remember(password);
@@ -73,9 +89,6 @@ export async function passNetlifyLock(deps) {
73
89
  return { status: 'refused', reason: done.locked ? "Netlify's own site password opened the address neither in the header nor on Netlify's form: the page asks for the app's own sign-in past the lock, or Netlify did not answer. Prove a page a visitor opens without signing in, and call this tool again." : done.reason, protection: 'password', ...from };
74
90
  }
75
91
  }
76
- else if (site.teamLogin) {
77
- return { status: 'login', protection: 'team-login', reason: "Netlify's team login stands in front of the previews: they open for a member of the Netlify team signed in in their browser, and Netlify gives tools no way in.", ...from };
78
- }
79
92
  else {
80
93
  return { status: 'refused', protection: 'none', reason: "Netlify's settings show neither a password nor the team login on the site: the sign-in is the app's own, so prove a page a visitor opens without signing in.", ...from };
81
94
  }
@@ -87,3 +100,48 @@ export async function passNetlifyLock(deps) {
87
100
  const done = await finish(typed, 'typed');
88
101
  return 'status' in done ? done : { status: 'refused', reason: done.locked ? `The password typed did not open the address: it is not the site's password, or the page asks for the app's own sign-in past the lock. ${done.reason}` : done.reason, ...from };
89
102
  }
103
+ /**
104
+ * A site behind Netlify's team login made public on the person's yes: the CLI's change, read back, then the preview
105
+ * proven. Where Netlify refuses (the team's default keeps every project private, the field is not taken, the role
106
+ * cannot) or the preview still asks for the login, its Visitor access page opens and the person tries again, twice at
107
+ * most. A password the person set there instead comes back as the site, for the password's own steps.
108
+ */
109
+ async function openToVisitors(deps, site) {
110
+ const from = { site: site?.name ?? deps.site, protection: 'team-login' };
111
+ if (!(await deps.makePublic()))
112
+ return { status: 'skipped', reason: 'The person skipped making the site public.', ...from };
113
+ // A site the CLI could not read: signed in on the yes, it is read again; still unreadable, it is another team's, and Netlify's page is the person's.
114
+ let read = site ?? ((await deps.signIn()) ? await readSite(deps.run, deps.site) : null);
115
+ /** The run's change went through: the site stays public whatever comes after, and every later answer says so. */
116
+ let ranPublic = false;
117
+ const kept = () => (ranPublic ? { madePublic: 'run' } : {});
118
+ for (let tries = 0;; tries++) {
119
+ if (read?.teamLogin && !read.hasPassword) {
120
+ try {
121
+ await deps.run(publicSiteCall(read.id));
122
+ read = await readSite(deps.run, deps.site);
123
+ if (read && !read.teamLogin)
124
+ ranPublic = true;
125
+ }
126
+ catch {
127
+ // Refused: the site as read stays, and the person's page is next.
128
+ }
129
+ }
130
+ if (read?.hasPassword)
131
+ return read;
132
+ // A site read as public, or one the CLI cannot read once the person changed it on Netlify's page: the preview says.
133
+ if (read ? !read.teamLogin : tries > 0) {
134
+ const proof = await deps.prove(undefined, false);
135
+ if (proof.proven)
136
+ return { status: 'opened', madePublic: ranPublic ? 'run' : 'person', ...from };
137
+ // Past the login, a page that is not the app's: the proof says why.
138
+ if (proof.gate === undefined)
139
+ return { status: 'refused', reason: proof.reason ?? 'The address did not open.', site: from.site, protection: 'none', ...kept() };
140
+ }
141
+ if (tries === 2)
142
+ return { status: 'login', reason: "Netlify kept its team login in front of the previews.", ...from, ...kept() };
143
+ if (!(await deps.retry(visitorAccessPage(from.site), tries === 0)))
144
+ return { status: 'skipped', reason: "The person skipped changing Visitor access on Netlify's page.", ...from, ...kept() };
145
+ read = await readSite(deps.run, deps.site);
146
+ }
147
+ }
@@ -9,9 +9,10 @@ Netlify deploys previews of the pull requests: impeccable_netlify_previews lists
9
9
 
10
10
  ### Reference
11
11
 
12
- - **Behind a password or Netlify's login** (`gate: "netlify-protection"`): the site password, or Netlify's team login, stands in front of the previews. That is the preview-protection case's, whose steps come before step 2: the password is got past on the person's yes, the team login is not.
12
+ - **The aim** holds here: the CLI does the work, and the person is asked only what the playbook's aim allows.
13
+ - **Behind a password or Netlify's login** (`gate: "netlify-protection"`): the site password, or Netlify's team login, stands in front of the previews. That is the preview-protection case's, whose steps come before step 2: on the person's yes the password is stored, or the site behind the team login made public.
13
14
  - **Another app, or no answer from any of the three**: Netlify's previews do not show this app. Set the preview up as server-previews or static-site says instead, and say under "What is not verified" what the Netlify address answered.
14
15
  - **Nothing listed**: Netlify's previews are not on record. Where the checkout is set up for Netlify that is the netlify-setup case's; else set the preview up as server-previews or static-site says. An `error` means a read failed, so a preview may exist that is not listed: say so under "What is not verified".
15
16
  - **The pull requests**: no setup pull request; the test drive branches from the default branch. Netlify builds a deploy preview only for a pull request, so the test drive opens as a draft, its deploy preview is waited for and the test drive's page proven on it, and then the draft is marked ready: pull-requests' step 4. In place of pull-requests' step 3, build the test drive branch once with the build Netlify runs (`netlify.toml`'s `[build]` `command`, else the package's `build` script), so a page that does not build is never pushed.
16
- - The evidence is read only: link, deploy and change nothing on Netlify. Netlify does not report its previews as GitHub deployments, so Impeccable finds them by their address pattern: save the pattern the proof answered, and no other.
17
+ - The evidence is read only: link, deploy and change nothing on Netlify, beyond what impeccable_netlify_password does on the person's yes. Netlify does not report its previews as GitHub deployments, so Impeccable finds them by their address pattern: save the pattern the proof answered, and no other.
17
18
  - The report names the address that answered with this app under "What we found", and the pattern saved under "What was configured, and by whom". The test drive's own preview, which Netlify builds after the run, goes under "What is not verified".
@@ -15,10 +15,11 @@ The checkout is set up for Netlify: a `netlify.toml`, a `.netlify/` folder, or a
15
15
 
16
16
  ### Reference
17
17
 
18
+ - **The aim** holds here: the CLI does the work, and the person is asked only what the playbook's aim allows.
18
19
  - **A step fails before the test drive is pushed** (the sign-in skipped or not completed, the site not created, the repository not connected): the Netlify setup ends there. Set the preview up as server-previews or static-site says, say under "What was skipped, and why" what stopped it, and put the person's step in `left` when there is one, such as "Give Netlify's GitHub app access to the repository", with the `access` page in the report.
19
20
  - **No preview for the draft**: save no method, set up no other preview, and leave the draft as it is, unrecorded, as pull-requests' "No preview, no test drive" says; the site and the connection stay, and the report names them.
20
21
  - **The build failed** (`state` is `error` or `failure`): say so under "What is not verified", with the command that builds this linked checkout as Netlify does and prints why, for the person to run: `netlify deploy --build --context deploy-preview`. It never runs here, since it builds with their Netlify sign-in.
21
- - **No deploy preview within five minutes**: the build had not finished, or Netlify builds no deploy preview for pull requests here: Deploy Previews may be off in the site's settings, so put "Turn Deploy Previews on in the site's Netlify settings" in `left`.
22
- - **Behind a password or Netlify's login** (`gate: "netlify-protection"`): the preview-protection case's, whose steps come before the save in step 5. A team that keeps new sites private puts Netlify's team login in front of the new site's previews, which no tool gets past: put "Make the site public, or password-protected, in Project configuration → General → Visitor access" in `left`.
22
+ - **No deploy preview within five minutes**: the wait's own screen opens the site's deploy settings, where Deploy Previews are turned on, and waits again on the person's yes. When they skip it, or none came after its retries, say under "What is not verified" that Netlify built no deploy preview here, and that Deploy Previews may be off in the site's settings.
23
+ - **Behind a password or Netlify's login** (`gate: "netlify-protection"`): the preview-protection case's, whose steps come before the save in step 5. A team that keeps new sites private puts Netlify's team login in front of the new site's previews: the tool makes the site public on the person's yes, and step 5 goes on once it answers `opened`.
23
24
  - **The report** names the Netlify site under "What was configured, and by whom", whichever way the run ended, since it stays in the person's Netlify account, with how the repository was connected and the CLI's install when there was one. The site's environment variables are the person's: when the app needs some (`.env.example`), list their names, never their values, under "Before you merge".
24
25
  - **Status lines**: the sign-in, the link and the connection belong to the Preview method task; from the page on, the Test drive task, so name the test drive in each line about its build, its push, the draft, the wait for its preview, the proof and the save (*"Saving the test drive's preview as the method"*). Word Netlify's login as a login, since a line about signing in belongs to the Sign-in task.
@@ -1,21 +1,23 @@
1
1
  ### When this applies
2
2
 
3
- impeccable_prove_preview answered a `gate`: the host's own lock stands in front of a preview the host made, and a visitor gets its login or its password page. Three locks have a way in for a tool, each with a tool of its own that works as the person in the command's own process, so no key ever reaches you: Vercel's Deployment Protection (`gate: "vercel-protection"`: Vercel Authentication, or Password Protection, which shows the same gate), whose way in is a bypass secret of the project, sent in a header, which every plan has; Netlify's site password (`gate: "netlify-protection"`), sent as basic credentials in the Authorization header; and Cloudflare Access in front of a Pages preview (`gate: "cloudflare-access"`), whose way in is a service token that a Service Auth policy of the Access application allows, sent in two headers. Netlify's team login, which the same gate answers for, has none. A project the Vercel CLI creates starts protected, so vercel-setup's new project ends here as well, and so does netlify-setup's new site on a team that keeps new sites private: these steps come between the proof and the save of the method, in vercel-previews', netlify-previews' or cloudflare-previews' step 2 or vercel-setup's or netlify-setup's step 5, before the test drive's pull request opens (on Netlify, before its draft is marked ready), and end with the preview opened.
3
+ impeccable_prove_preview answered a `gate`: the host's own lock stands in front of a preview the host made, and a visitor gets its login or its password page. Three locks have a way in for a tool, each with a tool of its own that works as the person in the command's own process, so no key ever reaches you: Vercel's Deployment Protection (`gate: "vercel-protection"`: Vercel Authentication, or Password Protection, which shows the same gate), whose way in is a bypass secret of the project, sent in a header, which every plan has; Netlify's site password (`gate: "netlify-protection"`), sent as basic credentials in the Authorization header; and Cloudflare Access in front of a Pages preview (`gate: "cloudflare-access"`), whose way in is a service token that a Service Auth policy of the Access application allows, sent in two headers. Netlify's team login, which the same gate answers for, has none, so the tool makes the site public on the person's yes. A project the Vercel CLI creates starts protected, so vercel-setup's new project ends here as well, and so does netlify-setup's new site on a team that keeps new sites private: these steps come between the proof and the save of the method, in vercel-previews', netlify-previews' or cloudflare-previews' step 2 or vercel-setup's or netlify-setup's step 5, before the test drive's pull request opens (on Netlify, before its draft is marked ready), and end with the preview opened.
4
4
 
5
5
  ### Steps
6
6
 
7
- 1. **Get the key in place** (the Preview method task): impeccable_vercel_bypass for Vercel's login, under the status line *"Getting past Vercel's login"*; impeccable_netlify_password for Netlify's lock, under *"Getting past Netlify's password"*; impeccable_cloudflare_access for Cloudflare Access, under *"Getting past Cloudflare Access"*. The tool does the rest: it finds the project's secret labelled "Impeccable reviews", or reads what Netlify's settings say stands in front of the site; shows one screen asking to create the secret, to store the site password Netlify gives back, or to create a service token (then Cloudflare's sign-in in the browser where cf here lacks it, and it creates the token as the person and allows it in the Access application's policy; a screen takes a Cloudflare API token only where that sign-in cannot), or, when it cannot make or read one, one screen taking a pasted one; opens the preview with it; and saves it for reviews. The key never comes back to you. Done when it answered `status`:
7
+ 1. **Get the key in place** (the Preview method task): impeccable_vercel_bypass for Vercel's login, under the status line *"Getting past Vercel's login"*; impeccable_netlify_password for Netlify's lock, under *"Getting past Netlify's password"*; impeccable_cloudflare_access for Cloudflare Access, under *"Getting past Cloudflare Access"*. The tool does the rest: it finds the project's secret labelled "Impeccable reviews", or reads what Netlify's settings say stands in front of the site; shows one screen asking to create the secret, to store the site password Netlify gives back, to make a site behind Netlify's team login public (signing the Netlify CLI in, in the browser, on that yes where it is signed out; where Netlify refuses, it opens Netlify's Visitor access page and asks the person to try again once they changed it there), or to create a service token (then Cloudflare's sign-in in the browser where cf here lacks it, and it creates the token as the person and allows it in the Access application's policy; a screen takes a Cloudflare API token only where that sign-in cannot), or, when it cannot make or read one, one screen taking a pasted one (Vercel's with the page where it is made opened); opens the preview with it; and saves it for reviews. The key never comes back to you. Done when it answered `status`:
8
8
  - `saved`: the preview is proven (`proven: true`); `secret`, `password` or `token` says whether it was created, existing or typed, and `project`, `site` or `application` which one holds or allows it; Cloudflare's `pattern` is the address pattern to save with the method, and `apiToken` says a Cloudflare API token the person made created the token. Step 2.
9
- - `login` (Netlify): the site is behind Netlify's team login, which no tool gets past; `reason` says so. Step 3.
9
+ - `opened` (Netlify): the site is public now and the preview proven (`proven: true`); `madePublic` says whether the run or the person made it public, and `site` which site. Step 2.
10
+ - `login` (Netlify): Netlify kept its team login in front through the retries; `reason` says so. Step 3.
11
+ - Any answer with `madePublic` but `opened`: the run made the Netlify site public and it stays so, though the preview did not open; the report names that change as the bullet below says, whatever step comes next.
10
12
  - `refused` whose `reason` says to prove a page a visitor opens: Netlify's own site password opened neither the header nor Netlify's form, so the page you proved asks for the app's own sign-in past the lock, or Netlify did not answer. Prove a page a visitor opens without signing in, as netlify-previews' step 1 says, and call the tool again; the consent is not asked a second time. Refused again, step 3.
11
13
  - Any other `skipped` or `refused`: nothing was saved; `reason` says what stopped it. Step 3.
12
14
  - `save-failed`: the setup API did not take it all; `reason` says how far it got. Call the tool once more; when it fails again, step 3, with "Save the Vercel bypass secret on the setup page", "Save the Netlify site password on the setup page" or "Save the Cloudflare service token on the setup page" in `left`.
13
15
  2. **Check it from Impeccable's side**: impeccable_write to `connection-check` with `{"appKey": "main"}`, and report what it answered. Then go on with the case that sent you here: the proof stands, so save the method as vercel-previews', netlify-previews' or cloudflare-previews' step 2 says, Cloudflare's with the tool's `pattern`. Done when the method is saved.
14
- 3. **When nothing was saved**, save no method and set up no other preview, whatever the checkup's `next` says, and open no test drive (pull-requests' "No preview, no test drive"). Say under "What is not verified" that the previews are behind the host's lock, with the tool's `reason`, and name the settings page where the person makes the key (the report's bullet below); end the report's "Not part of this setup" line with the lock the tool met: "Vercel's Deployment Protection in front of the previews", "Netlify's password in front of the previews", "Netlify's team login in front of the previews", or "Cloudflare Access in front of the previews". Done when the report says so.
16
+ 3. **When nothing was saved**, save no method and set up no other preview, whatever the checkup's `next` says, and open no test drive (pull-requests' "No preview, no test drive"). Say under "What is not verified" that the previews are behind the host's lock, with the tool's `reason`, and name the settings page where the person makes the key, or makes the Netlify site public (the report's bullet below); put the person's one step in `left`, the settings action alone and never running the setup again (for Netlify's team login, none: the person was asked in this run, so `left` stays empty and the report names the Visitor access page); end the report's "Not part of this setup" line with the lock the tool met: "Vercel's Deployment Protection in front of the previews", "Netlify's password in front of the previews", "Netlify's team login in front of the previews", or "Cloudflare Access in front of the previews". Done when the report says so.
15
17
 
16
18
  ### Reference
17
19
 
18
- - **The report** names, under "What was configured, and by whom", the Vercel project that holds the secret named "Impeccable reviews" (`project`), whether this run created it, found it there or the person typed it, and where it is revoked: the project's Settings → Deployment Protection → Protection Bypass for Automation; or the Netlify site (`site`) whose password is stored, whether this run read it from the site or the person typed it, and where it is changed: the site's Project configuration → General → Visitor access; or the service token named "Impeccable reviews", whether this run created it or the person typed it, the Access application whose policy allows it (`application`), when a created one runs out (`expires`), and where it is revoked: Zero Trust → Access controls → Service credentials → Service Tokens; with `apiToken`, the Cloudflare API token the person made for the run is theirs to delete (dash.cloudflare.com/profile/api-tokens). Revoking, regenerating or changing it stops reviews until this setup is run again.
20
+ - **The report** names, under "What was configured, and by whom", the Vercel project that holds the secret named "Impeccable reviews" (`project`), whether this run created it, found it there or the person typed it, and where it is revoked: the project's Settings → Deployment Protection → Protection Bypass for Automation; or the Netlify site (`site`) whose password is stored, whether this run read it from the site or the person typed it, and where it is changed: the site's Project configuration → General → Visitor access; or, with `opened`, the Netlify site made public, by this run on the person's yes or by the person on Netlify's page (`madePublic`), so anyone with its address opens it, and where it is made private again: the same Visitor access; or the service token named "Impeccable reviews", whether this run created it or the person typed it, the Access application whose policy allows it (`application`), when a created one runs out (`expires`), and where it is revoked: Zero Trust → Access controls → Service credentials → Service Tokens; with `apiToken`, the Cloudflare API token the person made for the run is theirs to delete (dash.cloudflare.com/profile/api-tokens). Revoking, regenerating or changing it stops reviews until a new one is saved on the setup page.
19
21
  - **The tool does the writes**: the key as Impeccable's credential for the lock, and the setting that sends it in the host's header (`x-vercel-protection-bypass`, `Authorization`, or `CF-Access-Client-Id` and `CF-Access-Client-Secret`), both through the setup API, so impeccable_write refuses those two. The state's `preview-protection` item words the same calls, and shows `keySaved` once they are done.
20
22
  - **A key saved before** (the item shows `keySaved` and a `check` that `passed`): the lock was handled by an earlier run or the person. Run step 2's check and go on; call the tool only when that check fails.
21
23
  - **The key is never yours**: it goes from the command's own process to the host and to Impeccable, and into no message, status line, file, command or report. `vercel project protection`, `vercel api`, `vercel curl` and `netlify api` print it, and the fence refuses them.