omniqa 0.7.0 → 0.9.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.
Files changed (154) hide show
  1. package/README.md +10 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/auth.d.ts +17 -0
  4. package/dist/auth.d.ts.map +1 -1
  5. package/dist/auth.js +29 -1
  6. package/dist/auth.js.map +1 -1
  7. package/dist/cli.js +18 -5
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands/chat.js +1 -1
  10. package/dist/commands/chat.js.map +1 -1
  11. package/dist/commands/crawl.d.ts.map +1 -1
  12. package/dist/commands/crawl.js +17 -5
  13. package/dist/commands/crawl.js.map +1 -1
  14. package/dist/commands/doctor.d.ts +23 -0
  15. package/dist/commands/doctor.d.ts.map +1 -1
  16. package/dist/commands/doctor.js +152 -6
  17. package/dist/commands/doctor.js.map +1 -1
  18. package/dist/commands/generate.js +1 -1
  19. package/dist/commands/generate.js.map +1 -1
  20. package/dist/commands/init.d.ts +3 -1
  21. package/dist/commands/init.d.ts.map +1 -1
  22. package/dist/commands/init.js +217 -50
  23. package/dist/commands/init.js.map +1 -1
  24. package/dist/commands/knowledge.d.ts +61 -1
  25. package/dist/commands/knowledge.d.ts.map +1 -1
  26. package/dist/commands/knowledge.js +232 -50
  27. package/dist/commands/knowledge.js.map +1 -1
  28. package/dist/commands/persist.d.ts +6 -0
  29. package/dist/commands/persist.d.ts.map +1 -1
  30. package/dist/commands/persist.js +9 -2
  31. package/dist/commands/persist.js.map +1 -1
  32. package/dist/commands/plan-add.d.ts.map +1 -1
  33. package/dist/commands/plan-add.js +13 -3
  34. package/dist/commands/plan-add.js.map +1 -1
  35. package/dist/commands/plan-review.d.ts +6 -2
  36. package/dist/commands/plan-review.d.ts.map +1 -1
  37. package/dist/commands/plan-review.js +16 -5
  38. package/dist/commands/plan-review.js.map +1 -1
  39. package/dist/commands/plan.d.ts +15 -0
  40. package/dist/commands/plan.d.ts.map +1 -1
  41. package/dist/commands/plan.js +103 -32
  42. package/dist/commands/plan.js.map +1 -1
  43. package/dist/commands/reindex.d.ts +1 -1
  44. package/dist/commands/reindex.d.ts.map +1 -1
  45. package/dist/commands/reindex.js +15 -1
  46. package/dist/commands/reindex.js.map +1 -1
  47. package/dist/commands/security.d.ts +4 -2
  48. package/dist/commands/security.d.ts.map +1 -1
  49. package/dist/commands/security.js +18 -7
  50. package/dist/commands/security.js.map +1 -1
  51. package/dist/commands/serve.d.ts +2 -0
  52. package/dist/commands/serve.d.ts.map +1 -1
  53. package/dist/commands/serve.js +126 -30
  54. package/dist/commands/serve.js.map +1 -1
  55. package/dist/commands/sync.d.ts.map +1 -1
  56. package/dist/commands/sync.js +19 -2
  57. package/dist/commands/sync.js.map +1 -1
  58. package/dist/commands/test.d.ts +5 -1
  59. package/dist/commands/test.d.ts.map +1 -1
  60. package/dist/commands/test.js +106 -6
  61. package/dist/commands/test.js.map +1 -1
  62. package/dist/commands/write.d.ts +8 -2
  63. package/dist/commands/write.d.ts.map +1 -1
  64. package/dist/commands/write.js +101 -18
  65. package/dist/commands/write.js.map +1 -1
  66. package/dist/devices.d.ts +3 -1
  67. package/dist/devices.d.ts.map +1 -1
  68. package/dist/devices.js +5 -3
  69. package/dist/devices.js.map +1 -1
  70. package/dist/fixer.d.ts.map +1 -1
  71. package/dist/fixer.js +19 -9
  72. package/dist/fixer.js.map +1 -1
  73. package/dist/jobs.d.ts +6 -0
  74. package/dist/jobs.d.ts.map +1 -1
  75. package/dist/jobs.js +10 -1
  76. package/dist/jobs.js.map +1 -1
  77. package/dist/mcp/server.d.ts +1 -1
  78. package/dist/mcp/server.d.ts.map +1 -1
  79. package/dist/mcp/server.js +1 -1
  80. package/dist/mcp/server.js.map +1 -1
  81. package/dist/mcp/session.d.ts.map +1 -1
  82. package/dist/mcp/session.js +7 -7
  83. package/dist/mcp/session.js.map +1 -1
  84. package/dist/mcp/tools.d.ts.map +1 -1
  85. package/dist/mcp/tools.js +9 -6
  86. package/dist/mcp/tools.js.map +1 -1
  87. package/dist/page.d.ts +1 -1
  88. package/dist/page.d.ts.map +1 -1
  89. package/dist/page.js +11 -0
  90. package/dist/page.js.map +1 -1
  91. package/dist/planner.d.ts.map +1 -1
  92. package/dist/planner.js +8 -4
  93. package/dist/planner.js.map +1 -1
  94. package/dist/prompt.d.ts +7 -1
  95. package/dist/prompt.d.ts.map +1 -1
  96. package/dist/prompt.js +23 -4
  97. package/dist/prompt.js.map +1 -1
  98. package/dist/qa.d.ts +7 -0
  99. package/dist/qa.d.ts.map +1 -1
  100. package/dist/qa.js +34 -9
  101. package/dist/qa.js.map +1 -1
  102. package/dist/runner.d.ts +7 -2
  103. package/dist/runner.d.ts.map +1 -1
  104. package/dist/runner.js +28 -8
  105. package/dist/runner.js.map +1 -1
  106. package/dist/security-checks.d.ts +46 -4
  107. package/dist/security-checks.d.ts.map +1 -1
  108. package/dist/security-checks.js +114 -39
  109. package/dist/security-checks.js.map +1 -1
  110. package/dist/security-gates.d.ts +64 -7
  111. package/dist/security-gates.d.ts.map +1 -1
  112. package/dist/security-gates.js +125 -16
  113. package/dist/security-gates.js.map +1 -1
  114. package/dist/security-mask.d.ts +35 -0
  115. package/dist/security-mask.d.ts.map +1 -0
  116. package/dist/security-mask.js +104 -0
  117. package/dist/security-mask.js.map +1 -0
  118. package/dist/security-report.d.ts +93 -2
  119. package/dist/security-report.d.ts.map +1 -1
  120. package/dist/security-report.js +153 -14
  121. package/dist/security-report.js.map +1 -1
  122. package/dist/security-request.d.ts +27 -4
  123. package/dist/security-request.d.ts.map +1 -1
  124. package/dist/security-request.js +56 -14
  125. package/dist/security-request.js.map +1 -1
  126. package/dist/security-research.d.ts +132 -0
  127. package/dist/security-research.d.ts.map +1 -0
  128. package/dist/security-research.js +599 -0
  129. package/dist/security-research.js.map +1 -0
  130. package/dist/security-scan.d.ts +98 -0
  131. package/dist/security-scan.d.ts.map +1 -0
  132. package/dist/security-scan.js +463 -0
  133. package/dist/security-scan.js.map +1 -0
  134. package/dist/security.d.ts +18 -4
  135. package/dist/security.d.ts.map +1 -1
  136. package/dist/security.js +181 -37
  137. package/dist/security.js.map +1 -1
  138. package/dist/sync.d.ts +55 -3
  139. package/dist/sync.d.ts.map +1 -1
  140. package/dist/sync.js +403 -54
  141. package/dist/sync.js.map +1 -1
  142. package/dist/test.d.ts +26 -2
  143. package/dist/test.d.ts.map +1 -1
  144. package/dist/test.js +152 -29
  145. package/dist/test.js.map +1 -1
  146. package/dist/writer.d.ts +29 -10
  147. package/dist/writer.d.ts.map +1 -1
  148. package/dist/writer.js +116 -36
  149. package/dist/writer.js.map +1 -1
  150. package/package.json +7 -7
  151. package/skills/knowledge.md +1 -1
  152. package/skills/security-research.md +57 -0
  153. package/skills/security-review.md +27 -0
  154. package/skills/onboarding.md +0 -5
package/dist/security.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
2
2
  import { tmpdir } from "node:os";
3
- import { join, relative } from "node:path";
4
- import { addCases, caseTags, deniedBy, GUARD_CHECK, KNOWLEDGE_DIR, loadConfig, loadProduct, OWASP_2025, parseSecurity, planPath, PRODUCT_FILE, readPlan, recordFirstRun, recordSecurityChecks, recordTests, SECURITY_FILE, setSecurityChecks, testTitle, writeCoverageFile, writePlan } from "@omniqa/core";
3
+ import { dirname, join, relative } from "node:path";
4
+ import { addCases, caseTags, deniedBy, GUARD_CHECK, KNOWLEDGE_DIR, loadConfig, loadProduct, OWASP_2025, parseSecurity, planPath, PRODUCT_FILE, readPlan, readState, recordFirstRun, recordSecurityChecks, recordTests, SECURITY_FILE, setSecurityChecks, testTitle, writeCoverageFile, writePlan, writeState, testIds } from "@omniqa/core";
5
5
  import { posix } from "./devices.js";
6
6
  import { requestRoute } from "@omniqa/web";
7
7
  import { checkNamed, CHECKS, turnedDown } from "./security-checks.js";
8
8
  import { ANTI_FORGERY } from "./security-request.js";
9
- import { clearFinding, REPORT_FILE, setFinding } from "./security-report.js";
10
- import { runCase, setCaseStatus, suiteFile, writeBlock } from "./writer.js";
9
+ import { clearFinding, REPORT_FILE, setFinding, setLeftOut } from "./security-report.js";
10
+ import { removeTest, runCase, setCaseStatus, suiteFile, writeBlock } from "./writer.js";
11
11
  /** The pages a guard walks at most. */
12
12
  const GUARD_PAGES = 15;
13
13
  /** One guard per actor the pass walked as: the pages it asked for, walked again, and no finding beyond the accepted ones. A signed-in guard mutates, as every case that signs in. */
@@ -64,7 +64,10 @@ const SIGN_IN_FIELDS = "the sign-in's fields";
64
64
  */
65
65
  const GROUPS = [
66
66
  { priority: "P0", checks: ["no-session", "other-account", "lower-role", "csrf", "redirect", "traversal", "reflection", "sql", "template", "header", "exposed-files"] },
67
- { priority: "P1", checks: ["after-logout", "fixation", "enumeration", "default-credentials"] },
67
+ { priority: "P1", checks: ["after-logout", "fixation"] },
68
+ // What sends wrong passwords follows every check that signs in, for every account: taken in turn with those, the six
69
+ // failing sign-ins of these two came before the next account's own sign-in, which a product that locks or slows down refused.
70
+ { priority: "P1", checks: ["enumeration", "default-credentials"] },
68
71
  { priority: "P1", checks: ["throttle"] },
69
72
  { priority: "P1", checks: [SIGN_IN_FIELDS] },
70
73
  { priority: "P2", checks: ["origin", "token", "errors"] },
@@ -105,6 +108,16 @@ const basicChecks = (k, ctx) => {
105
108
  const walked = k.actors.filter((actor) => actor !== "guest" && ctx.product.accounts[actor] !== undefined);
106
109
  /** The accounts a test can sign in as: of product.yaml, walked, where a test may change state (signing in does). */
107
110
  const accounts = ctx.environment?.mutations === false ? [] : walked;
111
+ /**
112
+ * The requests a press recorded and the proxy kept from the server. One rule plans them, below, and no other rule reads
113
+ * them: what such a request does was never done, and every other check would send it as an account whose own action it is.
114
+ * ponytail: a row is a method and a route, so where a form that is sent and a button that is pressed post to one address
115
+ * (a page that posts everything back to itself) the whole row counts as kept back, and the sent form's request loses the
116
+ * checks on its parameters. A row a form, if a product is built that way.
117
+ */
118
+ const keptBack = k.requests.filter((row) => row.keptBack.length > 0);
119
+ /** The requests every other rule reads. */
120
+ const requests = k.requests.filter((row) => row.keptBack.length === 0);
108
121
  const documents = new Set(Object.values(k.pages).flat());
109
122
  const isPage = (row) => row.request.startsWith("GET ") && documents.has(row.request.slice(4));
110
123
  /**
@@ -117,17 +130,18 @@ const basicChecks = (k, ctx) => {
117
130
  * An account the product was seen keeping from a request: turned away from the request itself, or from a page that makes
118
131
  * it. product.yaml names roles and ties them to no account, so this is what tells a lower role: two walks that merely
119
132
  * differ (a page one of them did not open) say nothing, and asking with either session would report what the product
120
- * rightly answers.
133
+ * rightly answers. `pages` are the pages that make it, where they are not the row's own list: the pages of its forms.
121
134
  */
122
- const keptFrom = (row, actor) => turnedAway(row.statuses[actor]) || row.pages.some((page) => turnedAway(k.requests.find((other) => other.request === `GET ${page}`)?.statuses[actor]));
123
- /** The per-account checks the plan already has, by what security.md › Checks says: a later build that lists another request first plans no second one. */
124
- const has = (check, actor) => k.checks.some((row) => row.check === check && row.actor === actor);
135
+ const keptFrom = (row, actor, pages = row.pages) => turnedAway(row.statuses[actor]) || pages.some((page) => turnedAway(k.requests.find((other) => other.request === `GET ${page}`)?.statuses[actor]));
136
+ /** The per-account checks the plan already has, by what security.md › Checks says: a later build that lists another request first plans no second one. One on a request that was kept back is that request's, not the account's. */
137
+ const has = (check, actor) => k.checks.some((row) => row.check === check && row.actor === actor && !keptBack.some((kept) => kept.request === row.request));
125
138
  /**
126
139
  * How a test of `actor` has the request made: the page of the actor's walk it opens, the first that makes the request or,
127
140
  * for a request the actor was answered a page on, that page itself (another page that asks for its route, a router's
128
141
  * script, is answered data). Where no page makes it by being opened, the form of the walk that does, with the page it is
129
- * on: the test sends it, which only an environment that allows a change lets it do. A button whose text echoed an
130
- * account's value is written without it, and a test could not find its form by that.
142
+ * on: the test sends it (or, for a request that was kept back, presses its button the same way), which only an environment
143
+ * that allows a change lets it do. A button whose text echoed an account's value is written without it, and a test could
144
+ * not find its form by that.
131
145
  */
132
146
  const madeBy = (row, actor) => {
133
147
  const opens = (page) => literal(page) && (k.pages[actor] ?? []).includes(page);
@@ -171,7 +185,39 @@ const basicChecks = (k, ctx) => {
171
185
  else if (k.requests.length === 0)
172
186
  ctx.leave(`${all}: this ${SECURITY_FILE} lists no request (omniqa knowledge build reads them off the walk)`);
173
187
  else {
174
- for (const row of k.requests) {
188
+ // A request that was kept back was never answered: it is planned for by what it is, the action of a signed-in account,
189
+ // and only as somebody who must be refused (the maintainer, 2026-11-19: another site among them).
190
+ for (const row of keptBack) {
191
+ /** Whoever the walk saw make it too is not somebody who must be refused: a press of theirs recorded it as well, or the product answered them. */
192
+ const own = (actor) => row.keptBack.includes(actor) || went(row.statuses[actor]);
193
+ const owner = accounts.find((actor) => row.keptBack.includes(actor));
194
+ // With no session on it, or where a guest makes it too, there is nobody the product must refuse: no check has anything to show.
195
+ if (owner === undefined || !hasSession(row) || own("guest"))
196
+ continue;
197
+ plan(named("no-session"), owner, row);
198
+ // A lower role is told as for any request, by the page it was turned away from: here the page the button is on.
199
+ const lower = ctx.product.roles.length > 1 ? accounts.find((actor) => actor !== owner && !own(actor) && keptFrom(row, actor, row.forms.map((form) => form.page))) : undefined;
200
+ if (lower !== undefined)
201
+ plan(named("lower-role"), owner, row, lower);
202
+ // Another account, once: not the lower one again. Only where something shows that the product must refuse it: the
203
+ // request names what it acts on in its address (an order's number), so that with any session it is still the first
204
+ // account's thing, or the account was seen turned away from the page the button is on. That an account's walk pressed
205
+ // no such button shows nothing (the walk may have ended before the page, or its press left nothing), and an id in a
206
+ // field shows too little: a product may act on the session and leave the field unread, and then what goes is the
207
+ // other account's own.
208
+ // ponytail: a request that names its thing in a field alone (a hidden account_id) gets no such check. Compare the
209
+ // field's value between two accounts' recordings at the build, and mark the row, if a product's forms are built that way.
210
+ const second = accounts.find((actor) => actor !== owner && actor !== lower && (row.request.includes("{") || (!own(actor) && keptFrom(row, actor, row.forms.map((form) => form.page)))));
211
+ if (second !== undefined)
212
+ plan(named("other-account"), owner, row, second);
213
+ if (row.carries.includes("cookie"))
214
+ plan(named("csrf"), owner, row);
215
+ // As for any request: a page a test can open to sign out on, and a cookie that shows the session ended.
216
+ const session = k.sessions.find((candidate) => candidate.account === owner);
217
+ if (session?.signOut !== undefined && literal(session.signOut) && session.cookies.length > 0)
218
+ plan(named("after-logout"), owner, row, "", { routes: [session.signOut], section: "Sessions" });
219
+ }
220
+ for (const row of requests) {
175
221
  const member = accounts.find((actor) => membersOnly(row, actor));
176
222
  if (member !== undefined)
177
223
  plan(named("no-session"), member, row);
@@ -196,20 +242,33 @@ const basicChecks = (k, ctx) => {
196
242
  }
197
243
  // Per account: the session a sign-out ends, and the one a sign-in must not keep, each shown on a request a guest does not get.
198
244
  const noSignOut = [];
245
+ // Two cases no test can write, which every omniqa write would fail again: a sign-out that changes no cookie shows no
246
+ // session that ended (the test says so and stops), and fixation compares with the cookies of before a sign-in it must see.
247
+ const headerAlone = [];
248
+ const noSignIn = [];
249
+ const signIns = requests.filter(isSignIn);
199
250
  for (const account of accounts) {
200
- const row = k.requests.find((candidate) => membersOnly(candidate, account) && Array.isArray(routesFor(candidate, account)));
201
- const signOut = k.sessions.find((session) => session.account === account)?.signOut;
251
+ // A request a guest was seen turned away from, where the walk has one: on one no guest was seen making, a session that
252
+ // ended and a request that is anyone's to read answer alike, and the check would report the second as the first.
253
+ const rows = requests.filter((candidate) => membersOnly(candidate, account) && Array.isArray(routesFor(candidate, account)));
254
+ const row = rows.find((candidate) => turnedAway(candidate.statuses.guest)) ?? rows[0];
255
+ const session = k.sessions.find((candidate) => candidate.account === account);
256
+ const signOut = session?.signOut;
202
257
  if (row === undefined)
203
258
  continue;
204
259
  if (signOut === undefined || !literal(signOut))
205
260
  noSignOut.push(account);
261
+ else if (session !== undefined && session.cookies.length === 0)
262
+ headerAlone.push(account);
206
263
  else if (!has("after-logout", account))
207
264
  plan(named("after-logout"), account, row, "", { routes: [signOut], section: "Sessions" });
208
- if (!has("fixation", account))
265
+ if (!signIns.some((signIn) => signIn.statuses[account] !== undefined))
266
+ noSignIn.push(account);
267
+ else if (!has("fixation", account))
209
268
  plan(named("fixation"), account, row, "", { section: "Sessions" });
210
269
  }
211
270
  // On the sign-in itself, known by the password it carried.
212
- const signIn = k.requests.find((row) => isSignIn(row) && accounts.some((actor) => row.statuses[actor] !== undefined));
271
+ const signIn = requests.find((row) => isSignIn(row) && accounts.some((actor) => row.statuses[actor] !== undefined));
213
272
  if (signIn !== undefined)
214
273
  for (const check of CHECKS.filter((c) => c.signIn === true))
215
274
  plan(check, accounts.find((actor) => signIn.statuses[actor] !== undefined), signIn);
@@ -232,11 +291,17 @@ const basicChecks = (k, ctx) => {
232
291
  if (name === "after-logout")
233
292
  for (const account of noSignOut)
234
293
  ctx.leave(`after-logout as ${account} is left out: the walk saw no link or button named Log out or Sign out on a page of ${account}`);
294
+ if (name === "after-logout")
295
+ for (const account of headerAlone)
296
+ ctx.leave(`after-logout as ${account} is left out: its session is carried in a header alone, so no cookie changes when it signs out and a test has nothing that shows the session ended`);
297
+ if (name === "fixation")
298
+ for (const account of noSignIn)
299
+ ctx.leave(`fixation as ${account} is left out: the pass saw no sign-in of ${account} (a request that carried its password), and the check compares with the cookies of before it`);
235
300
  if (!none(name))
236
301
  continue;
237
302
  if (name === "enumeration")
238
303
  ctx.leave("enumeration, throttle and default-credentials are left out: the pass saw no request that carried an account's password (the sign-in)");
239
- else if (needs[name] !== undefined && !(name === "fixation" && none("no-session")))
304
+ else if (needs[name] !== undefined && !(name === "fixation" && (none("no-session") || noSignIn.length > 0)))
240
305
  ctx.leave(`${name} is left out: ${needs[name]}`);
241
306
  }
242
307
  }
@@ -250,7 +315,7 @@ const basicChecks = (k, ctx) => {
250
315
  const asker = (row, answer) => got(row, answer).find((actor) => Array.isArray(routesFor(row, actor))) ?? got(row, answer)[0];
251
316
  // A request with a parameter a test can name. One that writes is asked too, where a test may change state and only there: each
252
317
  // value is that change once more, so mutations: false keeps a probe out of it. The sign-in is a list of its own (above).
253
- const withParameter = k.requests.filter((row) => (row.request.startsWith("GET ") || WRITES.test(row.request)) && !isSignIn(row) && askable(row.parameters).length > 0);
318
+ const withParameter = requests.filter((row) => (row.request.startsWith("GET ") || WRITES.test(row.request)) && !isSignIn(row) && askable(row.parameters).length > 0);
254
319
  const reads = withParameter.filter((row) => row.request.startsWith("GET ") || ctx.environment?.mutations !== false);
255
320
  const kept = withParameter.length - reads.length;
256
321
  if (kept > 0)
@@ -266,7 +331,7 @@ const basicChecks = (k, ctx) => {
266
331
  * counted. The sign-in's own row is another list's: it takes none either.
267
332
  */
268
333
  const sweep = (name, rows, answer) => {
269
- const have = k.checks.filter((row) => row.check === name && !k.requests.some((request) => isSignIn(request) && request.request === row.request)).map((row) => row.request);
334
+ const have = k.checks.filter((row) => row.check === name && !requests.some((request) => isSignIn(request) && request.request === row.request)).map((row) => row.request);
270
335
  const writable = rows.filter((row) => Array.isArray(routesFor(row, asker(row, answer))));
271
336
  for (const writes of [false, true]) {
272
337
  const places = Math.max(0, SWEPT - have.filter((request) => WRITES.test(request) === writes).length);
@@ -290,7 +355,7 @@ const basicChecks = (k, ctx) => {
290
355
  sweep("reflection", wide.filter((row) => asker(row, shown) !== undefined), shown);
291
356
  // Nothing with a parameter is one thing left out, not three. Where the sign-in is the one request with any, the line says so, and
292
357
  // names the checks that are left: the ones that ask its fields are planned where a test may sign in (the lines above say where not).
293
- const onSignIn = k.requests.some((row) => isSignIn(row) && askable(row.parameters).length > 0);
358
+ const onSignIn = requests.some((row) => isSignIn(row) && askable(row.parameters).length > 0);
294
359
  unseen((reads.length === 0 ? SWEEPS : EVERY_PARAMETER).filter(none), "request with a parameter", withParameter.length, onSignIn ? ", the sign-in aside" : "");
295
360
  if (reads.length > 0)
296
361
  unseen(["reflection"], "page that takes a parameter", reads.filter((row) => asker(row, shown) !== undefined).length);
@@ -308,7 +373,7 @@ const basicChecks = (k, ctx) => {
308
373
  if (reads.length > 0)
309
374
  unseen(["traversal"], "request with a file name in a parameter", filed.length);
310
375
  // Who may read an answer: one request of the API, a member's own where a test can sign in (what another site would read is the member's).
311
- const api = k.requests.filter((row) => row.request.startsWith("GET ") && !isSignIn(row) && !isPage(row));
376
+ const api = requests.filter((row) => row.request.startsWith("GET ") && !isSignIn(row) && !isPage(row));
312
377
  const readers = [...api.flatMap((row) => accounts.filter((actor) => membersOnly(row, actor)).slice(0, 1).map((actor) => [row, actor])), ...api.flatMap((row) => (asker(row, answered) === undefined ? [] : [[row, asker(row, answered)]]))];
313
378
  const reader = readers.find(([row, actor]) => Array.isArray(routesFor(row, actor))) ?? readers[0];
314
379
  // Once: a later build that lists another request first plans no second one.
@@ -387,7 +452,7 @@ export async function planSecurity(cwd, env, o = {}) {
387
452
  if (waiting > 0)
388
453
  left.push(`${plural(waiting, "more security case")} ${waiting === 1 ? "waits" : "wait"} for the next round: omniqa plan add --security plans ${waiting === 1 ? "it" : "them"}`);
389
454
  const added = planned.length === 0 ? [] : await (async () => {
390
- const appended = addCases(plan, planned.map((p) => p.addition));
455
+ const appended = addCases(plan, planned.map((p) => p.addition), await testIds(cwd, dirname(planFile)));
391
456
  await writePlan(planFile, appended.plan);
392
457
  return appended.added;
393
458
  })();
@@ -445,9 +510,11 @@ export function renderGuard(c, actor, accepted, date) {
445
510
  * product answered when the test was written (`observed`; without it the test only sends, which is the run that learns the
446
511
  * answer); the others are run by name and throw by themselves. `query` are the parameters the page is opened with, each
447
512
  * holding a placeholder: security.md keeps their names, never a value. `button` is what the button says of the form the
448
- * test sends on that page, for a request that only a sent form makes.
513
+ * test sends on that page, for a request that only a sent form makes. `pressed` is for a request that was kept back: the
514
+ * test presses that button as the walk did, with the proxy letting nothing through (`security.keepBack`), and never
515
+ * sends the form.
449
516
  */
450
- export function renderCheck(c, row, check, observed, query = [], signIn = check.signIn === true, button) {
517
+ export function renderCheck(c, row, check, observed, query = [], signIn = check.signIn === true, button, pressed = false) {
451
518
  const [page = "/", signOutPage = page] = c.routes;
452
519
  const signedIn = row.actor !== "guest";
453
520
  const found = `security.request(${q(row.request)})`;
@@ -459,21 +526,22 @@ export function renderCheck(c, row, check, observed, query = [], signIn = check.
459
526
  ? [` await (await ${found}).check(${q(check.name)});`]
460
527
  : [
461
528
  ` const request = await ${found};`,
462
- // A session that a sign-out ended: the request is the one made before it.
463
- ...(replay.signOut === true ? [...(signOutPage === page ? [] : [` await page.goto(${q(signOutPage)});`]), " await security.signOut();"] : []),
529
+ // A session that a sign-out ended: the request is the one made before it. A press leaves its page (the proxy lets
530
+ // requests through again only once that page is gone), so the page the account signs out on is opened whichever it is.
531
+ ...(replay.signOut === true ? [...(signOutPage === page && !pressed ? [] : [` await page.goto(${q(signOutPage)});`]), " await security.signOut();"] : []),
464
532
  observed === undefined ? ` await ${call};` : observed.location === undefined ? ` expect((await ${call}).status).toBe(${observed.status});` : ` expect(await ${call}).toEqual({ status: ${observed.status}, location: ${q(observed.location)} });`,
465
533
  ];
466
534
  return [
467
535
  `test(${q(testTitle(c))}, { tag: [${caseTags(c).map(q).join(", ")}] }, async ({ ${signIn ? "" : "page, "}${signedIn ? "logIn, " : ""}security }) => {`,
468
536
  ...(signedIn ? [` await logIn(${q(row.actor)});`] : []),
469
537
  // A check on the sign-in works on the request logIn made: there is no page to open for it.
470
- ...(signIn ? [] : [` await page.goto(${q(`${page}${query.length === 0 ? "" : `?${query.map((name) => `${encodeURIComponent(name)}=1`).join("&")}`}`)});`, ...(button === undefined ? [] : [` await security.submit(${q(button)});`])]),
538
+ ...(signIn ? [] : [` await page.goto(${q(`${page}${query.length === 0 ? "" : `?${query.map((name) => `${encodeURIComponent(name)}=1`).join("&")}`}`)});`, ...(button === undefined ? [] : [` await security.${pressed ? "keepBack" : "submit"}(${q(button)});`])]),
471
539
  ...steps,
472
540
  "});",
473
541
  ].join("\n");
474
542
  }
475
543
  /** Why a run of one test is not a pass: its failure's first line, the reason it was skipped, or that it left no report. */
476
- function notPassed(run) {
544
+ export function notPassed(run) {
477
545
  if (run.report === undefined || run.summary === undefined)
478
546
  return run.error ?? "the run left no report";
479
547
  const failed = run.summary.failures[0]?.error;
@@ -484,6 +552,30 @@ function notPassed(run) {
484
552
  const skipped = (run.report.suites ?? []).flatMap((s) => s.specs ?? []).flatMap((spec) => spec.tests ?? []).flatMap((t) => t.annotations ?? []).find((a) => a.type === "skip")?.description;
485
553
  return skipped ?? "the test did not run";
486
554
  }
555
+ /** Who each check planned on a request that was kept back sends it as, in the report's words; `other` is the account whose session the check asks with. */
556
+ const SENT_AS = {
557
+ "no-session": () => "nobody",
558
+ "other-account": (other) => other,
559
+ "lower-role": (other) => other,
560
+ "after-logout": () => "the session it signed out of",
561
+ csrf: () => "the account itself, from another site",
562
+ };
563
+ /**
564
+ * What a finding says more where the walk kept the request back for the check's account (`made` is the request's row of
565
+ * security.md): the check was the first to send it to the product, so where the product took it, what the request does was
566
+ * done, to the account its button was pressed as (or, with another account's session on a request that names nothing in
567
+ * its address, perhaps to that account: both are named). `status` is what answered, where the check is one replay: a 5xx is a
568
+ * finding there as it is for any request, but it is the product failing, neither a refusal nor a yes, and nothing says
569
+ * that the action was done. Undefined for any other request too, and for a check no rule plans on such a request.
570
+ */
571
+ export function doneAs(check, made, status) {
572
+ if (made?.keptBack.includes(check.actor) !== true || (status !== undefined && status >= 500))
573
+ return undefined;
574
+ const as = SENT_AS[check.check]?.(check.with);
575
+ // With another account's session, a request that names nothing in its address may have acted on that session's own account.
576
+ const account = check.with !== "" && !check.request.includes("{") ? `${check.actor} or ${check.with}` : check.actor;
577
+ return as === undefined ? undefined : { as, account };
578
+ }
487
579
  /**
488
580
  * Write one security case by code, from its row in security.md › Checks. A guard is walked once with nothing accepted, in a run
489
581
  * that lists what the sidecar saw instead of failing on it (OMNIQA_SECURITY_ACCEPT), then written with that list accepted and
@@ -525,11 +617,13 @@ export async function writeSecurity(o) {
525
617
  /**
526
618
  * The check does not hold: a hole that was there before the test is no red test. What was found goes to the report
527
619
  * outside git; the test, the plan and the state say that the case needs a human and where to look, and nothing else.
620
+ * `done` is for a request that was kept back (doneAs): that its action was done is said in the report's entry, under
621
+ * what was found, and nowhere else.
528
622
  */
529
- const finding = async (sentence) => {
623
+ const finding = async (sentence, done) => {
530
624
  const found = o.redact(sentence);
531
625
  const category = OWASP_2025.find((x) => x.id === basic.category);
532
- await setFinding(o.cwd, { id: c.id, title: c.title, finding: found, check: basic.name, category: `${basic.category}${category === undefined ? "" : ` ${category.name}`}`, cwe: basic.cwe, environment: o.envName, date: today });
626
+ await setFinding(o.cwd, { id: c.id, title: c.title, finding: found, check: basic.name, category: `${basic.category}${category === undefined ? "" : ` ${category.name}`}`, cwe: basic.cwe, environment: o.envName, date: today, ...(done === undefined ? {} : { keptBack: { as: o.redact(done.as), account: o.redact(done.account) } }) });
533
627
  // A block of its own, closed on a line of its own: that line is where the next write of this case knows it ends.
534
628
  await writeBlock(c, file, `// needs a human: see ${REPORT_FILE}\ntest.fixme(${q(testTitle(c))}, { tag: [${caseTags(c).map(q).join(", ")}] }, async () => {\n});`, "security");
535
629
  await setCaseStatus(planPath(o.testDir), c.id, "needs-human", rel);
@@ -539,10 +633,39 @@ export async function writeSecurity(o) {
539
633
  o.tell(`${c.id} finding: ${found}; OWASP ${basic.category}, ${basic.cwe.join(", ")}; in ${REPORT_FILE}; the case needs a human`);
540
634
  return r;
541
635
  };
636
+ /**
637
+ * The check cannot say, whatever the product answers. That is no finding and nothing to try again on every run: the case is
638
+ * skipped in the plan (omniqa write --case asks again, and so does ticking it on the review page), its draft and an earlier
639
+ * test or finding of it go. The sentence names what answered, so it is said on the terminal alone, as a finding is.
640
+ */
641
+ const leftOut = async (sentence) => {
642
+ const rest = untouched === undefined ? undefined : removeTest(untouched, c.id);
643
+ if (rest === undefined)
644
+ await rm(file, { force: true });
645
+ else
646
+ await writeFile(file, rest);
647
+ // Why is kept where the findings are, outside git: the plan's row reads like one somebody unticked, and the line a
648
+ // commit keeps names nothing that answered.
649
+ const category = OWASP_2025.find((x) => x.id === basic.category);
650
+ await setLeftOut(o.cwd, { id: c.id, title: c.title, why: o.redact(sentence), check: basic.name, category: `${basic.category}${category === undefined ? "" : ` ${category.name}`}`, environment: o.envName, date: today });
651
+ await setCaseStatus(planPath(o.testDir), c.id, "skipped");
652
+ const state = await readState(o.cwd);
653
+ if (state.tests?.cases?.[c.id] !== undefined) {
654
+ delete state.tests.cases[c.id];
655
+ await writeState(o.cwd, state);
656
+ }
657
+ o.tell(`${c.id} cannot say: ${o.redact(sentence)}`);
658
+ // What is kept of it (a commit's body, a pull request's) stands by itself and names nothing that answered.
659
+ o.out(`${c.id}: skipped: the ${basic.name} check cannot say whether what its request asks for is members' alone (${REPORT_FILE} says why); omniqa write --case ${c.id} asks again and says what answered`);
660
+ // The file the case's draft or earlier test left, and the plan's row, are what a run that persists commits of it.
661
+ return result("skipped", { removed: rel });
662
+ };
542
663
  // A request the case's page does not make by being opened is made by the form of that page the walk sent: the test sends it too.
543
664
  const made = known?.requests.find((row) => row.request === check.request);
544
665
  const signIn = basic.signIn === true || made?.carries.includes("credentials") === true;
545
666
  const button = made === undefined || made.pages.includes(c.routes[0] ?? "/") ? undefined : made.forms.find((form) => form.page === c.routes[0])?.button;
667
+ // One the walk kept from the product for this account is made the same way: its button pressed with nothing let through.
668
+ const pressed = made?.keptBack.includes(check.actor) === true;
546
669
  // The page is opened with the parameters the pass saw it asked for with, each holding a placeholder: a check that asks each parameter
547
670
  // needs the page's own request made with some, and what a page's script asks only when the page is given one (a search's results)
548
671
  // is made for any check, a replay included.
@@ -551,12 +674,12 @@ export async function writeSecurity(o) {
551
674
  const query = button === undefined ? askable(known?.requests.find((row) => row.request === `GET ${c.routes[0]}`)?.parameters ?? []) : [];
552
675
  if (basic.replay === undefined) {
553
676
  // The check throws by itself on a reply that does not hold: its one run is the observation and the first run alike.
554
- await writeBlock(c, file, renderCheck(c, check, basic, undefined, query, signIn, button), "security");
677
+ await writeBlock(c, file, renderCheck(c, check, basic, undefined, query, signIn, button, pressed), "security");
555
678
  const ran = await run(o.env);
556
679
  const first = notPassed(ran);
557
680
  const open = /omniqa: \S+ does not hold: (.+)$/.exec(first ?? "");
558
681
  if (open !== null)
559
- return await finding(open[1]);
682
+ return await finding(open[1], doneAs(check, made));
560
683
  await recordFirstRun(o.cwd, c.id, first === undefined);
561
684
  if (first !== undefined)
562
685
  throw new Error(first);
@@ -565,21 +688,42 @@ export async function writeSecurity(o) {
565
688
  return await written([`${basic.name} holds`, ...notes].join("; "));
566
689
  }
567
690
  // One replay: sent once to learn what the product answers, then written with that answer and run as written.
568
- await writeBlock(c, file, renderCheck(c, check, basic, undefined, query, signIn, button), "security");
691
+ await writeBlock(c, file, renderCheck(c, check, basic, undefined, query, signIn, button, pressed), "security");
569
692
  const learned = notPassed(await run({ ...o.env, OMNIQA_SECURITY_ACCEPT: seen }));
570
693
  if (learned !== undefined)
571
694
  throw new Error(learned);
572
- const answer = /^replay (\d{3})(?: (\S+))?$/m.exec((await readFile(seen, "utf8").catch(() => "")).trim().split("\n").at(-1) ?? "");
695
+ // What that run said: the replay's answer, and where the login page sends a guest on to when the answer was a redirect elsewhere (test.ts).
696
+ const said = (await readFile(seen, "utf8").catch(() => "")).trim().split("\n");
697
+ const answer = /^replay (\d{3})(?: (\S+))?$/.exec(said.findLast((line) => line.startsWith("replay ")) ?? "");
573
698
  if (answer === null)
574
699
  throw new Error("the check's run re-sent nothing");
575
700
  const status = Number(answer[1]);
576
701
  const location = answer[2];
702
+ const sentOn = said.flatMap((line) => (line.startsWith("login ") ? [line.slice("login ".length)] : []));
577
703
  const loginPath = (await loadProduct(o.cwd, o.env)).crawl.loginPath;
578
704
  // Where a redirect points is said and asserted when it is a name: a path with an id in it, or one that echoes an account's value, is a value in a committed test.
579
705
  const isName = location !== undefined && requestRoute(URL.parse(location)?.pathname ?? location) === (URL.parse(location)?.pathname ?? location) && o.redact(location) === location;
580
- if (!turnedDown(check.request.split(" ")[0], { status, ...(location === undefined ? {} : { location }) }, loginPath))
581
- return await finding(basic.open({ request: check.request, actor: check.actor, with: check.with, answer: `${status}${isName ? ` to ${location}` : ""}` }));
582
- await writeBlock(c, file, renderCheck(c, check, basic, { status, ...(isName ? { location } : {}) }, query, signIn, button), "security");
706
+ if (!turnedDown(check.request.split(" ")[0], { status, ...(location === undefined ? {} : { location }) }, loginPath, sentOn)) {
707
+ // Asked without a session, a request no guest was seen making answers: it may be anyone's to read (a list of plans, a flag), and
708
+ // the walk has nothing that tells that from a hole. No finding and no test: the case leaves the plan's work, and one line says why.
709
+ // Only for a request that reads: a write that goes through without a session is nobody's to make. And only for a case that
710
+ // was not written yet: one whose test asserted a refusal says the product once kept this for its members.
711
+ if (basic.replay.without !== undefined && status >= 200 && status < 300 && ["GET", "HEAD"].includes(check.request.split(" ")[0].toUpperCase()) && c.status !== "written" && made !== undefined && made.statuses.guest === undefined)
712
+ return await leftOut(`${check.request} answered ${status} without a session, and the walk saw no guest ask for it: it may be anyone's to read, which no check can tell from a hole. If only members should get it, the product is open there; once it refuses a guest, omniqa write --case ${c.id} writes the test`);
713
+ // The same after a sign-out, on a request no guest was seen making: answered, it shows a session that was not ended or
714
+ // a request that is anyone's to read. Asked once more with no session at all, as the no-session check asks: answered
715
+ // then too, nothing tells the two apart, and a finding (a test.fixme for good) would name a product that may be closed.
716
+ const bare = checkNamed("no-session");
717
+ if (basic.replay.signOut === true && bare !== undefined && status >= 200 && status < 300 && ["GET", "HEAD"].includes(check.request.split(" ")[0].toUpperCase()) && c.status !== "written" && made !== undefined && made.statuses.guest === undefined) {
718
+ await writeBlock(c, file, renderCheck(c, { ...check, check: bare.name }, bare, undefined, query, signIn, button, pressed), "security");
719
+ const asked = notPassed(await run({ ...o.env, OMNIQA_SECURITY_ACCEPT: seen }));
720
+ const guest = asked !== undefined ? null : /^replay (\d{3})(?: (\S+))?$/.exec((await readFile(seen, "utf8").catch(() => "")).trim().split("\n").findLast((line) => line.startsWith("replay ")) ?? "");
721
+ if (guest !== null && Number(guest[1]) >= 200 && Number(guest[1]) < 300)
722
+ return await leftOut(`${check.request} answered ${status} with the session ${check.actor} signed out of, and ${guest[1]} with no session at all, and the walk saw no guest ask for it: it may be anyone's to read, which no check can tell from a session that did not end. If only members should get it, the product is open there; once it refuses a guest, omniqa write --case ${c.id} writes the test`);
723
+ }
724
+ return await finding(basic.open({ request: check.request, actor: check.actor, with: check.with, answer: `${status}${isName ? ` to ${location}` : ""}` }), doneAs(check, made, status));
725
+ }
726
+ await writeBlock(c, file, renderCheck(c, check, basic, { status, ...(isName ? { location } : {}) }, query, signIn, button, pressed), "security");
583
727
  const first = notPassed(await run(o.env));
584
728
  await recordFirstRun(o.cwd, c.id, first === undefined);
585
729
  if (first !== undefined)