Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions AGENT-INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ When setup is finished, the person reads one short message, not a transcript of

### 🛡️ Checked 69 packages: 5 vulnerabilities in 3 packages (highest severity: high)

#### 👉 Connect your Patchstack account to see the details and turn on protection
#### 👉 Connect your Patchstack account to see the details and protect your live app from common attacks, secret leaks and future vulnerabilities

https://api.patchstack.com/monitor/claim?site=…

When you've connected, say **done**.
When you've connected, say **done**, and we'll get your live app protected.

#### What Patchstack found
🔴 High **1** · 🟠 Medium **3** · 🔵 Low **1** · 12 packages outdated · 12 protection rules available
Expand All @@ -175,7 +175,7 @@ The parts always come in that order. Fill each from the output, and leave out a

1. **Mark.** The two-line Patchstack mark in a code block, as in the layout above.
2. **Headline.** What was checked and found, as the heading. When the output gives no counts, write "Patchstack is now watching your app." Never estimate a count the output did not print.
3. **What to do now.** The next step from the `Next:` line, as the heading, with its link or command written out in full on its own line. Only that step: the items under `To do` are yours to finish, not the person's. Then: "When you've connected, say **done**." (or "When that's done, say **done**." for any other step).
3. **What to do now.** The next step from the `Next:` line, as the heading, with its link or command written out in full on its own line. Only that step: the items under `To do` are yours to finish, not the person's. Then: "When you've connected, say **done**, and we'll get your live app protected." ("When you've connected, say **done**." when setup found no server; "When that's done, say **done**." for any other step).
4. **What Patchstack found.** The severity counts, outdated packages and protection rules exactly as the output lists them. Leave it out when nothing was found: the headline already says so.
5. **Notes.** "**Reload your app's preview page.** The Patchstack widget appears in a bottom corner of the page." when setup added the widget; any line the output marks `ℹ`, except the one about no server.
6. **What changed.** One line in italics: that Patchstack is now part of the install and build, and where the API key is (git ignores it; never share it).
Expand Down
9 changes: 7 additions & 2 deletions src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,15 @@ export function renderSummary(report: StatusReport, progress: Progress, context:
if (next !== null) {
const vulnerable = (findings?.vulnerable ?? 0) > 0;
const rest =
next !== 'connected' ? '' : !canProtect ? ' to see the details' : vulnerable ? ' to see the details and turn on protection' : ' to turn on protection';
next !== 'connected' ? '' : !canProtect ? ' to see the details' : vulnerable ? ` to see the details and ${PROTECTS}` : ` to ${PROTECTS}`;
const lead = next === 'connected' ? 'Connect your Patchstack account' : capitalise(plainNextStepTitle(next, context));
const [first] = plainNextStepLines(next, context);
const action = first?.startsWith('Open ') === true ? first.slice('Open '.length) : first;
// The link goes in a paragraph of its own, so it renders on its own line.
lines.push(`#### 👉 ${lead}${rest}`, '', ...(action !== undefined ? [action, ''] : []));
lines.push(next === 'connected' ? `When you've connected, say **${NEXT_REPLY}**.` : `When that's done, say **${NEXT_REPLY}**.`, '');
// Protection runs where the app is deployed, so connecting leads on to going live; with no server there is nothing to protect.
const connected = canProtect ? `When you've connected, say **${NEXT_REPLY}**, and we'll get your live app protected.` : `When you've connected, say **${NEXT_REPLY}**.`;
lines.push(next === 'connected' ? connected : `When that's done, say **${NEXT_REPLY}**.`, '');
}

if (canProtect && report.confirmed?.length) {
Expand Down Expand Up @@ -399,6 +401,9 @@ export function renderSummary(report: StatusReport, progress: Progress, context:
return lines;
}

/** What connecting turns on, in the summary's next step: the guard's hardening, secret-exposure and live vulnerability rules. */
const PROTECTS = 'protect your live app from common attacks, secret leaks and future vulnerabilities';

/** What the person can ask, in a later conversation, to see this summary again. AGENT-INSTALL.md lists it. */
export const SUMMARY_AGAIN = 'Show my Patchstack summary';

Expand Down
8 changes: 6 additions & 2 deletions tests/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,21 @@ describe('renderSummary', () => {
...LOGO,
'### 🛡️ Checked 89 packages: 5 vulnerabilities in 3 packages (highest severity: high)',
'',
'#### 👉 Connect your Patchstack account to see the details and turn on protection',
'#### 👉 Connect your Patchstack account to see the details and protect your live app from common attacks, secret leaks and future vulnerabilities',
'',
context.claimUrl,
'',
`When you've connected, say **done**.`,
`When you've connected, say **done**, and we'll get your live app protected.`,
'',
'#### What Patchstack found',
'🔴 High **1** · 🟠 Medium **3** · 🔵 Low **1** · 12 packages outdated · 12 protection rules available',
'',
"**Reload your app's preview page.** The Patchstack widget appears in a bottom corner of the page.",
]);
const clean = summary({ vulnerable: 0, outdated: 0, severity: { high: 0, medium: 0, low: 0, unknown: 0 } });
expect(renderSummary(report({ findings: clean }), notConnected, context, { widgetOnPage: false, dashboardUrl: null })).toContain(
'#### 👉 Connect your Patchstack account to protect your live app from common attacks, secret leaks and future vulnerabilities',
);
});

it('gives a browser-only app with nothing found one path: the link, then the word to say', () => {
Expand Down