omniqa 0.7.0 → 0.8.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 (63) hide show
  1. package/README.md +10 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cli.js +5 -2
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/doctor.d.ts +7 -0
  6. package/dist/commands/doctor.d.ts.map +1 -1
  7. package/dist/commands/doctor.js +30 -4
  8. package/dist/commands/doctor.js.map +1 -1
  9. package/dist/commands/init.d.ts +3 -1
  10. package/dist/commands/init.d.ts.map +1 -1
  11. package/dist/commands/init.js +91 -16
  12. package/dist/commands/init.js.map +1 -1
  13. package/dist/commands/plan.d.ts.map +1 -1
  14. package/dist/commands/plan.js +3 -2
  15. package/dist/commands/plan.js.map +1 -1
  16. package/dist/commands/security.d.ts +2 -2
  17. package/dist/commands/security.d.ts.map +1 -1
  18. package/dist/commands/security.js +13 -6
  19. package/dist/commands/security.js.map +1 -1
  20. package/dist/commands/test.d.ts +5 -0
  21. package/dist/commands/test.d.ts.map +1 -1
  22. package/dist/commands/test.js +52 -5
  23. package/dist/commands/test.js.map +1 -1
  24. package/dist/commands/write.d.ts.map +1 -1
  25. package/dist/commands/write.js +26 -0
  26. package/dist/commands/write.js.map +1 -1
  27. package/dist/mcp/tools.d.ts.map +1 -1
  28. package/dist/mcp/tools.js +2 -1
  29. package/dist/mcp/tools.js.map +1 -1
  30. package/dist/qa.d.ts.map +1 -1
  31. package/dist/qa.js +2 -1
  32. package/dist/qa.js.map +1 -1
  33. package/dist/security-gates.d.ts +14 -5
  34. package/dist/security-gates.d.ts.map +1 -1
  35. package/dist/security-gates.js +11 -5
  36. package/dist/security-gates.js.map +1 -1
  37. package/dist/security-mask.d.ts +35 -0
  38. package/dist/security-mask.d.ts.map +1 -0
  39. package/dist/security-mask.js +104 -0
  40. package/dist/security-mask.js.map +1 -0
  41. package/dist/security-report.d.ts +71 -2
  42. package/dist/security-report.d.ts.map +1 -1
  43. package/dist/security-report.js +135 -14
  44. package/dist/security-report.js.map +1 -1
  45. package/dist/security-research.d.ts +131 -0
  46. package/dist/security-research.d.ts.map +1 -0
  47. package/dist/security-research.js +581 -0
  48. package/dist/security-research.js.map +1 -0
  49. package/dist/security-scan.d.ts +98 -0
  50. package/dist/security-scan.d.ts.map +1 -0
  51. package/dist/security-scan.js +415 -0
  52. package/dist/security-scan.js.map +1 -0
  53. package/dist/security.d.ts +3 -1
  54. package/dist/security.d.ts.map +1 -1
  55. package/dist/security.js +1 -1
  56. package/dist/security.js.map +1 -1
  57. package/dist/test.d.ts +7 -0
  58. package/dist/test.d.ts.map +1 -1
  59. package/dist/test.js +10 -3
  60. package/dist/test.js.map +1 -1
  61. package/package.json +6 -6
  62. package/skills/security-research.md +57 -0
  63. package/skills/security-review.md +27 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
- * The gates a request of OmniQA's own passes before it leaves, whoever composed it: a basic check today, the researcher's
3
- * tools later. The worst outcome of a security test is harm to the production it guards, so these are code, checked on what
4
- * would be sent, and nothing sends without them.
2
+ * The gates a request of OmniQA's own passes before it leaves, whoever composed it: a basic check, or an agent of the scan
3
+ * through its tools. The worst outcome of a security test is harm to the production it guards, and an agent can be steered
4
+ * by what it reads, so these are code, checked on what would be sent, and nothing sends without them.
5
5
  */
6
6
  /** The requests one basic check sends at most: a check is never load. */
7
7
  export declare const CHECK_REQUESTS = 30;
@@ -14,15 +14,24 @@ export interface Outgoing {
14
14
  /** The names of its headers. */
15
15
  headers?: string[];
16
16
  }
17
+ /** What makes a request an agent's own: the budget of the agent that composed it (the scan's ceiling for its requests) and whose it is, as a refusal says it. */
18
+ export interface ScanBudget {
19
+ requests: number;
20
+ /** `the researcher`, `the reviewer`. */
21
+ whose: string;
22
+ }
17
23
  /**
18
24
  * Why this request is not sent, or undefined when it may be: only to the product's own hosts, never what the environment's
19
25
  * deny list matches, nothing that changes state where mutations are off, no session over plain http where the environment
20
- * is https, and `sent` (the requests this test has already sent) under the cap. A refusal names the request by its method and route, never its query or an id: it ends in a run's output.
26
+ * is https, and `sent` (the requests this test has already sent) under the cap. A request an agent composed (`scan`) also
27
+ * needs the environment to say `securityScan: on`, and its cap is that agent's budget instead of a basic check's.
28
+ * A refusal names the request by its method and route, never its query or an id: it ends in a run's output.
21
29
  */
22
30
  export declare function gate(environment: {
23
31
  name: string;
24
32
  url: string;
25
33
  mutations: boolean;
26
34
  deny: string[];
27
- }, request: Outgoing, sent: number): string | undefined;
35
+ securityScan?: string;
36
+ }, request: Outgoing, sent: number, scan?: ScanBudget): string | undefined;
28
37
  //# sourceMappingURL=security-gates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"security-gates.d.ts","sourceRoot":"","sources":["../src/security-gates.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,yEAAyE;AACzE,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAID;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiBxJ"}
1
+ {"version":3,"file":"security-gates.d.ts","sourceRoot":"","sources":["../src/security-gates.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,yEAAyE;AACzE,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAID,iKAAiK;AACjK,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAmBlM"}
@@ -1,9 +1,9 @@
1
1
  import { deniedBy, PRODUCT_FILE } from "@omniqa/core";
2
2
  import { hostPatterns, requestRoute } from "@omniqa/web";
3
3
  /**
4
- * The gates a request of OmniQA's own passes before it leaves, whoever composed it: a basic check today, the researcher's
5
- * tools later. The worst outcome of a security test is harm to the production it guards, so these are code, checked on what
6
- * would be sent, and nothing sends without them.
4
+ * The gates a request of OmniQA's own passes before it leaves, whoever composed it: a basic check, or an agent of the scan
5
+ * through its tools. The worst outcome of a security test is harm to the production it guards, and an agent can be steered
6
+ * by what it reads, so these are code, checked on what would be sent, and nothing sends without them.
7
7
  */
8
8
  /** The requests one basic check sends at most: a check is never load. */
9
9
  export const CHECK_REQUESTS = 30;
@@ -11,14 +11,18 @@ const MUTATING = new Set(["POST", "PUT", "PATCH", "DELETE"]);
11
11
  /**
12
12
  * Why this request is not sent, or undefined when it may be: only to the product's own hosts, never what the environment's
13
13
  * deny list matches, nothing that changes state where mutations are off, no session over plain http where the environment
14
- * is https, and `sent` (the requests this test has already sent) under the cap. A refusal names the request by its method and route, never its query or an id: it ends in a run's output.
14
+ * is https, and `sent` (the requests this test has already sent) under the cap. A request an agent composed (`scan`) also
15
+ * needs the environment to say `securityScan: on`, and its cap is that agent's budget instead of a basic check's.
16
+ * A refusal names the request by its method and route, never its query or an id: it ends in a run's output.
15
17
  */
16
- export function gate(environment, request, sent) {
18
+ export function gate(environment, request, sent, scan) {
17
19
  const method = request.method.toUpperCase();
18
20
  const url = URL.parse(request.url);
19
21
  const refused = (why) => `${method} ${url === null ? request.url.split("?")[0] : requestRoute(url.pathname)} is not sent: ${why}`;
20
22
  if (url === null)
21
23
  return refused("it has no host: a request of a security test is a whole url");
24
+ if (scan !== undefined && environment.securityScan !== "on")
25
+ return refused(`a request an agent composed needs securityScan: on for ${environment.name}, which says ${environment.securityScan ?? "off"} (${PRODUCT_FILE})`);
22
26
  const hostPort = `${url.hostname}:${url.port || (url.protocol === "https:" ? "443" : "80")}`;
23
27
  if (!hostPatterns(environment.url).some((pattern) => new RegExp(pattern).test(hostPort)))
24
28
  return refused(`${url.hostname} is not a host of ${environment.name} (a security test asks the hosts under its url in ${PRODUCT_FILE} and no other)`);
@@ -33,6 +37,8 @@ export function gate(environment, request, sent) {
33
37
  const session = (request.headers ?? []).filter((name) => ["cookie", "authorization"].includes(name.toLowerCase()));
34
38
  if (url.protocol === "http:" && URL.parse(environment.url)?.protocol === "https:" && session.length > 0)
35
39
  return refused(`it would carry the page's ${session.join(" and ")} over plain http, and ${environment.name} is served over https`);
40
+ if (scan !== undefined)
41
+ return sent >= scan.requests ? refused(`${scan.whose}'s ${scan.requests} requests are spent (--scan-requests raises the budget)`) : undefined;
36
42
  if (sent >= CHECK_REQUESTS)
37
43
  return refused(`a basic check sends ${CHECK_REQUESTS} requests at most`);
38
44
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"security-gates.js","sourceRoot":"","sources":["../src/security-gates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QA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AI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACnH,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,6BAA6B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,WAAW,CAAC,IAAI,uBAAuB,CAAC,CAAC;IAC5O,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,QAAQ,yDAAyD,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtK,IAAI,IAAI,IAAI,cAAc;QAAE,OAAO,OAAO,CAAC,uBAAuB,cAAc,mBAAmB,CAAC,CAAC;IACrG,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * What an agent is shown of the traffic has every credential replaced by a placeholder that names its owner, and what an
3
+ * agent composes gets the values back before it leaves: a session cookie, an Authorization token and an account's fields
4
+ * never reach a prompt, a transcript or the report. The agents of a scan read excerpts of live traffic through a model
5
+ * provider, so this is code on every text shown, not a rule in a skill.
6
+ */
7
+ export interface Secret {
8
+ /** `<session:free:sid>`, `<authorization:free>`, `<password:free>`: the kind, the owner, and for a cookie its name. */
9
+ placeholder: string;
10
+ value: string;
11
+ }
12
+ /** An actor's session as secrets: each cookie of its browser that is long enough to be one, and the token of each Authorization header its pages sent. */
13
+ export declare function sessionSecrets(owner: string, cookies: [string, string][], authorization?: string[]): Secret[];
14
+ /** The accounts of product.yaml as secrets: each field under its own name, `<password:free>`, `<email:free>`. */
15
+ export declare function accountSecrets(accounts: Record<string, Record<string, string>>): Secret[];
16
+ /**
17
+ * `text` as an agent may read it: every secret replaced by its placeholder, in whatever form it stands (plain, url-encoded,
18
+ * as a form field, base64), in a request's text and in an answer's headers and body alike. A credential that is nobody's
19
+ * of the scan is masked by where it stands: a cookie's value on a Cookie or a Set-Cookie line, what follows the scheme on
20
+ * an Authorization line, anything shaped like a JSON Web Token, and the value of whatever is called like a credential (a
21
+ * JSON field, a parameter of a query or a form, a header of the product's own): a token an answer hands out is one too.
22
+ * ponytail: a token's claims are masked with it; its header and payload decoded into the placeholder when the researcher needs to read them.
23
+ */
24
+ export declare function mask(text: string, secrets: Secret[]): string;
25
+ /**
26
+ * What an agent composed, with the values back where it wrote their placeholders, each in the form its placeholder names.
27
+ * A placeholder the scan holds no value for is an error that says why: the agent named an account nobody signed in as, or a
28
+ * session the product handed one of its own requests, which is never kept (a probe that gets in ends there).
29
+ */
30
+ export declare function unmask(text: string, secrets: Secret[]): string;
31
+ /** How much of a text an agent is shown at once, in characters. */
32
+ export declare const WINDOW = 8192;
33
+ /** 8 KB of a text from an offset, with how much is left and where the next part starts: a body is read a part at a time. */
34
+ export declare function window(text: string, from?: number): string;
35
+ //# sourceMappingURL=security-mask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-mask.d.ts","sourceRoot":"","sources":["../src/security-mask.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,uHAAuH;IACvH,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AASD,0JAA0J;AAC1J,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,aAAa,GAAE,MAAM,EAAO,GAAG,MAAM,EAAE,CAKjH;AAED,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,CAEzF;AAkCD;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAW5D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAa9D;AAED,mEAAmE;AACnE,eAAO,MAAM,MAAM,OAAO,CAAC;AAE3B,4HAA4H;AAC5H,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,MAAM,CAIrD"}
@@ -0,0 +1,104 @@
1
+ import { ANTI_FORGERY, isJwt } from "./security-request.js";
2
+ /** A cookie's value shorter than this is a flag or a choice (a theme, a consent), and replacing it would rewrite the text around it. */
3
+ const SESSION_LENGTH = 8;
4
+ /** An account's field shorter than this is not masked, as the transcripts' redactor leaves it. */
5
+ const FIELD_LENGTH = 4;
6
+ /** The owner of a credential no actor of the scan holds: one the product handed out in an answer. */
7
+ const UNKNOWN = "unknown";
8
+ /** An actor's session as secrets: each cookie of its browser that is long enough to be one, and the token of each Authorization header its pages sent. */
9
+ export function sessionSecrets(owner, cookies, authorization = []) {
10
+ return [
11
+ ...cookies.filter(([, value]) => value.length >= SESSION_LENGTH).map(([name, value]) => ({ placeholder: `<session:${owner}:${name}>`, value })),
12
+ ...[...new Set(authorization.map((line) => line.trim().split(/\s+/).at(-1) ?? ""))].filter((token) => token !== "").map((value) => ({ placeholder: `<authorization:${owner}>`, value })),
13
+ ];
14
+ }
15
+ /** The accounts of product.yaml as secrets: each field under its own name, `<password:free>`, `<email:free>`. */
16
+ export function accountSecrets(accounts) {
17
+ return Object.entries(accounts).flatMap(([owner, fields]) => Object.entries(fields).filter(([, value]) => value.length >= FIELD_LENGTH).map(([field, value]) => ({ placeholder: `<${field}:${owner}>`, value })));
18
+ }
19
+ /** The forms a value travels in, the plain one first: a form that reads like an earlier one is that one. */
20
+ const FORMS = [
21
+ ["", (value) => value],
22
+ ["url", encodeURIComponent],
23
+ ["form", (value) => new URLSearchParams({ v: value }).toString().slice(2)],
24
+ ["base64", (value) => Buffer.from(value).toString("base64")],
25
+ ["base64url", (value) => Buffer.from(value).toString("base64url")],
26
+ ];
27
+ const formed = (placeholder, form) => (form === "" ? placeholder : `${placeholder.slice(0, -1)}|${form}>`);
28
+ /** Each text a secret may stand as, with the placeholder that says which form it was. */
29
+ function needles(secrets) {
30
+ const found = new Map();
31
+ // Every value as it is before any encoded form: a session whose value reads like an account's encoded field (a cookie that is the user's email) is that session.
32
+ for (const [form, encode] of FORMS)
33
+ for (const secret of secrets)
34
+ if (!found.has(encode(secret.value)))
35
+ found.set(encode(secret.value), formed(secret.placeholder, form));
36
+ // The longest first: a value inside a longer one (a token that holds an id) must not break the longer one up.
37
+ return [...found].toSorted(([a], [b]) => b.length - a.length);
38
+ }
39
+ /** What a product calls a credential, in a field, a parameter or a header of its own: the names, since the value says nothing. ponytail: a list; a product's own word for its key is not on it, and its value is then masked only where the scan holds it. */
40
+ const SECRET_NAME = /token|secret|passw|session|api[-_]?key|jwt|credential/i;
41
+ /** A name whose value is masked by what it is called: a credential's, and not the anti-forgery token's, which an agent composes with. */
42
+ const secretName = (name) => SECRET_NAME.test(name) && !ANTI_FORGERY.test(name);
43
+ const PLACEHOLDER = /<([a-z_][\w-]*):([^:<>|\s]+)(?::([^<>|\s]+))?(?:\|(url|form|base64|base64url))?>/gi;
44
+ const masked = (value) => value.startsWith("<") && value.endsWith(">");
45
+ /** A `name=value` of a Cookie or a Set-Cookie line whose value no secret of the scan is: long enough to be a session, it is one nobody holds. */
46
+ const unknownCookie = (cookie) => {
47
+ const at = cookie.indexOf("=");
48
+ const [name, value] = at < 0 ? [cookie.trim(), ""] : [cookie.slice(0, at).trim(), cookie.slice(at + 1).trim()];
49
+ return at < 0 || value.length < SESSION_LENGTH || masked(value) ? cookie : `${cookie.slice(0, at + 1)}<session:${UNKNOWN}:${name}>`;
50
+ };
51
+ const JWT_SHAPED = /[\w-]{8,}\.[\w-]{8,}\.[\w-]*/g;
52
+ /**
53
+ * `text` as an agent may read it: every secret replaced by its placeholder, in whatever form it stands (plain, url-encoded,
54
+ * as a form field, base64), in a request's text and in an answer's headers and body alike. A credential that is nobody's
55
+ * of the scan is masked by where it stands: a cookie's value on a Cookie or a Set-Cookie line, what follows the scheme on
56
+ * an Authorization line, anything shaped like a JSON Web Token, and the value of whatever is called like a credential (a
57
+ * JSON field, a parameter of a query or a form, a header of the product's own): a token an answer hands out is one too.
58
+ * ponytail: a token's claims are masked with it; its header and payload decoded into the placeholder when the researcher needs to read them.
59
+ */
60
+ export function mask(text, secrets) {
61
+ let out = text;
62
+ for (const [needle, placeholder] of needles(secrets))
63
+ out = out.split(needle).join(placeholder);
64
+ return out
65
+ .replace(/^(cookie[ \t]*:)(.*)$/gim, (_line, head, cookies) => `${head}${cookies.split(";").map(unknownCookie).join(";")}`)
66
+ .replace(/^(set-cookie[ \t]*:)([^;\n]*)(.*)$/gim, (_line, head, cookie, attributes) => `${head}${unknownCookie(cookie)}${attributes}`)
67
+ .replace(/^((?:proxy-)?authorization[ \t]*:[ \t]*)(.*?)(\S+)[ \t]*$/gim, (line, head, scheme, token) => (masked(token) ? line : `${head}${scheme}<authorization:${UNKNOWN}>`))
68
+ .replace(JWT_SHAPED, (token) => (isJwt(token) ? `<token:${UNKNOWN}>` : token))
69
+ .replace(/^([\w-]+)([ \t]*:[ \t]*)(\S.{7,})$/gm, (line, name, colon, value) => (secretName(name) && !/^(set-)?cookie$|authorization$/i.test(name) && !value.includes("<") ? `${name}${colon}<secret:${UNKNOWN}:${name}>` : line))
70
+ .replace(/"([\w.-]+)"(\s*:\s*)"([^"\\<]{8,})"/g, (field, name, colon) => (secretName(name) ? `"${name}"${colon}"<secret:${UNKNOWN}:${name}>"` : field))
71
+ .replace(/([?&#;]|^)([\w.-]+)=([^&\s"'<>;]{8,})/gm, (parameter, before, name) => (secretName(name) ? `${before}${name}=<secret:${UNKNOWN}:${name}>` : parameter));
72
+ }
73
+ /**
74
+ * What an agent composed, with the values back where it wrote their placeholders, each in the form its placeholder names.
75
+ * A placeholder the scan holds no value for is an error that says why: the agent named an account nobody signed in as, or a
76
+ * session the product handed one of its own requests, which is never kept (a probe that gets in ends there).
77
+ */
78
+ export function unmask(text, secrets) {
79
+ const owners = new Set(secrets.map((s) => /^<[^:<>]+:([^:<>|]+)/.exec(s.placeholder)?.[1]));
80
+ return text.replace(PLACEHOLDER, (written, kind, owner, name, form) => {
81
+ const plain = `<${kind}:${owner}${name === undefined ? "" : `:${name}`}>`;
82
+ const secret = secrets.find((s) => s.placeholder === plain);
83
+ if (secret !== undefined)
84
+ return FORMS.find(([f]) => f === (form ?? ""))[1](secret.value);
85
+ const session = ["session", "authorization", "token", "secret"].includes(kind.toLowerCase());
86
+ // Anything else between angle brackets with a colon in it is the agent's own text: an element of a namespace in an XML body.
87
+ if (!session && !owners.has(owner))
88
+ return written;
89
+ if (owner === UNKNOWN)
90
+ throw new Error(`${written} cannot be put back: a session the product handed a request of yours is not kept; report what got in and leave it unused`);
91
+ const signedIn = secrets.some((s) => new RegExp(`^<(session|authorization):${owner.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[:>]`).test(s.placeholder));
92
+ throw new Error(session && !signedIn ? `${written} cannot be put back: ${owner} is not signed in in this scan (browse as ${owner} first)` : `${written} cannot be put back: this scan holds no such value of ${owner}`);
93
+ });
94
+ }
95
+ /** How much of a text an agent is shown at once, in characters. */
96
+ export const WINDOW = 8192;
97
+ /** 8 KB of a text from an offset, with how much is left and where the next part starts: a body is read a part at a time. */
98
+ export function window(text, from = 0) {
99
+ if (from > 0 && from >= text.length)
100
+ return `nothing from ${from} on: the text has ${text.length} characters`;
101
+ const left = text.length - from - WINDOW;
102
+ return left <= 0 ? text.slice(from) : `${text.slice(from, from + WINDOW)}\n… ${left} more characters: from ${from + WINDOW} shows the next part`;
103
+ }
104
+ //# sourceMappingURL=security-mask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-m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AW,CAAC,CAAC,CAAC;QACtJ,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,wBAAwB,KAAK,6CAA6C,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,yDAAyD,KAAK,EAAE,CAAC,CAAC;IAC1N,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;AAE3B,4HAA4H;AAC5H,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,IAAI,GAAG,CAAC;IAC3C,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,gBAAgB,IAAI,qBAAqB,IAAI,CAAC,MAAM,aAAa,CAAC;IAC9G,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;IACzC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,IAAI,0BAA0B,IAAI,GAAG,MAAM,sBAAsB,CAAC;AACnJ,CAAC"}
@@ -1,6 +1,9 @@
1
+ import type { Claimed, ProofRequest, Severity } from "./security-research.ts";
1
2
  /**
2
- * `.omniqa/security/report.md`: where the security checks found the product open. It is the one place that says so: the
3
- * folder is not in git, and what git tracks (the plan, the test, security.md, state.json) says no more than to look here.
3
+ * `.omniqa/security/report.md`: where the security checks and the agent scan found the product open. It is the one place that
4
+ * says so: the folder is not in git, and what git tracks (the plan, the test, security.md, state.json) says no more than to
5
+ * look here. Two parts: the basic checks that do not hold, a section a case that `omniqa write` keeps; and the last scan,
6
+ * replaced by each scan.
4
7
  */
5
8
  export declare const REPORT_FILE = ".omniqa/security/report.md";
6
9
  export interface Finding {
@@ -17,8 +20,74 @@ export interface Finding {
17
20
  /** The day it was seen, ISO. */
18
21
  date: string;
19
22
  }
23
+ /** A claim the reviewer confirmed, as the report keeps it between runs. */
24
+ export interface Claim extends Claimed {
25
+ /** `claim-1`: what `omniqa write --claim` takes. A claim keeps its id while it stays open. */
26
+ id: string;
27
+ environment: string;
28
+ /** The day it was first confirmed, ISO. */
29
+ date: string;
30
+ /** What the reviewer said. */
31
+ reason: string;
32
+ /** The model that confirmed it. */
33
+ by?: string;
34
+ }
35
+ /** One agent of a scan: its model as configured, what it spent of its budgets, and the models that answered. */
36
+ export interface AgentLine {
37
+ /** `anthropic/claude-opus-5.5 (high, fallback anthropic/claude-opus-4.8)`. */
38
+ model: string;
39
+ calls: number;
40
+ callLimit: number;
41
+ requests: number;
42
+ requestLimit: number;
43
+ /** The model that answered → how many answers were its. */
44
+ answered: Record<string, number>;
45
+ }
46
+ export interface ScanReport {
47
+ environment: string;
48
+ /** The day of the scan, ISO. */
49
+ date: string;
50
+ researcher: AgentLine;
51
+ reviewer: AgentLine;
52
+ /** `known`: the report the run started with had it, and its proof still holds; `unsettled`: it had it, and why its proof sent again says neither open nor fixed; `claimed`: the researcher's severity where the reviewer stands behind another. */
53
+ confirmed: (Claim & {
54
+ known?: boolean;
55
+ unsettled?: string;
56
+ claimed?: Severity;
57
+ })[];
58
+ discarded: {
59
+ title: string;
60
+ category: string;
61
+ severity: Severity;
62
+ reason: string;
63
+ }[];
64
+ /** The claims the reviewer gave no verdict on, each with why. */
65
+ unreviewed: (Claimed & {
66
+ why: string;
67
+ })[];
68
+ /** What the researcher tried and found closed. */
69
+ tried: string[];
70
+ /** What the researcher sent, each request by its route with how it was answered and the reason given: listed where it ended without saying what it tried (its calls ran out). */
71
+ sent?: string[];
72
+ /** What was not done: a model declined a step, a budget was reached, a switch refused a request. */
73
+ notDone: string[];
74
+ }
20
75
  /** The finding of a case, in place of what the report said of that case before. */
21
76
  export declare function setFinding(cwd: string, f: Finding): Promise<void>;
22
77
  /** A case that now holds leaves the report; a report with nothing in it leaves the disk. */
23
78
  export declare function clearFinding(cwd: string, id: string): Promise<void>;
79
+ /** The basic checks that do not hold, as the report lists them: `sec-access-2: <title>`, then what was found. What a scan's researcher is told not to repeat. */
80
+ export declare function openFindings(cwd: string): Promise<string[]>;
81
+ /** A proof by request pattern: `1. POST /api/cart/coupon as free → 200`. The requests themselves are the lines under it. */
82
+ export declare const proofSteps: (proof: ProofRequest[]) => string;
83
+ /** The scan's sections in place of the last scan's; the basic checks' findings stay as they are. */
84
+ export declare function writeScan(cwd: string, scan: ScanReport): Promise<void>;
85
+ /** The confirmed claims of a report, each as it was written: what the next scan sends again, and what `omniqa write --claim` turns into a test. */
86
+ export declare function parseClaims(text: string | undefined): Claim[];
87
+ export declare function readClaims(cwd: string): Promise<Claim[]>;
88
+ /**
89
+ * A claim that was fixed and is kept as a test leaves the list of what is open: its section goes, and the scan's lines say
90
+ * what became of it. The rest of the scan's sections stay as that scan wrote them.
91
+ */
92
+ export declare function closeClaim(cwd: string, id: string, test: string): Promise<void>;
24
93
  //# sourceMappingURL=security-report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"security-report.d.ts","sourceRoot":"","sources":["../src/security-report.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,eAAO,MAAM,WAAW,+BAA+B,CAAC;AAGxD,MAAM,WAAW,OAAO;IACtB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AA+BD,mFAAmF;AACnF,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,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q,oGAAoG;AACpG,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;AAED,mJAAmJ;AACnJ,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,EAAE,CAgC7D;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAE9D;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrF"}
@@ -1,8 +1,14 @@
1
1
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
2
2
  import { dirname, join } from "node:path";
3
+ import { OWASP_2025 } from "@omniqa/core";
4
+ import { requestRoute } from "@omniqa/web";
5
+ import { parseRequest } from "./security-request.js";
6
+ import { SEVERITIES } from "./security-research.js";
3
7
  /**
4
- * `.omniqa/security/report.md`: where the security checks found the product open. It is the one place that says so: the
5
- * folder is not in git, and what git tracks (the plan, the test, security.md, state.json) says no more than to look here.
8
+ * `.omniqa/security/report.md`: where the security checks and the agent scan found the product open. It is the one place that
9
+ * says so: the folder is not in git, and what git tracks (the plan, the test, security.md, state.json) says no more than to
10
+ * look here. Two parts: the basic checks that do not hold, a section a case that `omniqa write` keeps; and the last scan,
11
+ * replaced by each scan.
6
12
  */
7
13
  export const REPORT_FILE = ".omniqa/security/report.md";
8
14
  const IGNORED = ".omniqa/security/";
@@ -10,9 +16,9 @@ const HEAD = `# Security report
10
16
 
11
17
  Where OmniQA's security checks found this product open. This file is not in git (.gitignore has ${IGNORED}), and nothing
12
18
  in git names what is in it: keep it that way.
13
-
14
- ## Basic checks that do not hold
15
19
  `;
20
+ const BASIC = "## Basic checks that do not hold";
21
+ const SCAN = "## Agent scan";
16
22
  const section = (f) => `### ${f.id}: ${f.title}
17
23
 
18
24
  - found: ${f.finding}
@@ -20,30 +26,145 @@ const section = (f) => `### ${f.id}: ${f.title}
20
26
  - seen on ${f.environment} on ${f.date} by omniqa write
21
27
  - after the fix, omniqa write --case ${f.id} writes the test
22
28
  `;
23
- /** The report's sections, one per case, each starting at its `### <id>: ` line. */
24
- const sections = (text) => (text ?? "").split(/^(?=### )/m).slice(1).map((s) => `${s.trimEnd()}\n`);
29
+ /** The report's two parts: the basic checks' sections, one per case, each starting at its `### <id>: ` line, and the last scan as it stands, from its heading on. */
30
+ function parts(text) {
31
+ const all = text ?? "";
32
+ const at = all.search(new RegExp(`^${SCAN}$`, "m"));
33
+ const [before, scan] = at < 0 ? [all, ""] : [all.slice(0, at), all.slice(at)];
34
+ return { basic: before.split(/^(?=### )/m).slice(1).map((s) => `${s.trimEnd()}\n`), scan: scan.trimEnd() === "" ? "" : `${scan.trimEnd()}\n` };
35
+ }
25
36
  const of = (id) => (s) => s.startsWith(`### ${id}: `);
26
- async function write(cwd, kept) {
37
+ async function write(cwd, basic, scan) {
27
38
  const file = join(cwd, REPORT_FILE);
28
- if (kept.length === 0)
39
+ if (basic.length === 0 && scan === "")
29
40
  return void (await rm(file, { force: true }));
30
41
  await mkdir(dirname(file), { recursive: true });
31
- await writeFile(file, `${HEAD}\n${kept.join("\n")}`);
42
+ await writeFile(file, [HEAD, ...(basic.length === 0 ? [] : [`${BASIC}\n`, ...basic]), ...(scan === "" ? [] : [scan])].join("\n"));
32
43
  // A project set up before the kind existed, or by hand, may not ignore the folder yet: a report must never be one `git add` away.
33
44
  const ignore = join(cwd, ".gitignore");
34
45
  const lines = await readFile(ignore, "utf8").catch(() => "");
35
46
  if (!lines.split("\n").some((line) => line.trim() === IGNORED))
36
47
  await writeFile(ignore, `${lines === "" || lines.endsWith("\n") ? lines : `${lines}\n`}${IGNORED}\n`);
37
48
  }
49
+ const read = (cwd) => readFile(join(cwd, REPORT_FILE), "utf8").catch(() => undefined);
38
50
  /** The finding of a case, in place of what the report said of that case before. */
39
51
  export async function setFinding(cwd, f) {
40
- const text = await readFile(join(cwd, REPORT_FILE), "utf8").catch(() => undefined);
41
- await write(cwd, [...sections(text).filter((s) => !of(f.id)(s)), section(f)]);
52
+ const { basic, scan } = parts(await read(cwd));
53
+ await write(cwd, [...basic.filter((s) => !of(f.id)(s)), section(f)], scan);
42
54
  }
43
55
  /** A case that now holds leaves the report; a report with nothing in it leaves the disk. */
44
56
  export async function clearFinding(cwd, id) {
45
- const text = await readFile(join(cwd, REPORT_FILE), "utf8").catch(() => undefined);
46
- if (text !== undefined && sections(text).some(of(id)))
47
- await write(cwd, sections(text).filter((s) => !of(id)(s)));
57
+ const text = await read(cwd);
58
+ const { basic, scan } = parts(text);
59
+ if (text !== undefined && basic.some(of(id)))
60
+ await write(cwd, basic.filter((s) => !of(id)(s)), scan);
61
+ }
62
+ /** The basic checks that do not hold, as the report lists them: `sec-access-2: <title>`, then what was found. What a scan's researcher is told not to repeat. */
63
+ export async function openFindings(cwd) {
64
+ return parts(await read(cwd)).basic.map((s) => `${(/^### (.*)$/m.exec(s)?.[1] ?? "").trim()}: ${(/^- found: (.*)$/m.exec(s)?.[1] ?? "").trim()}`);
65
+ }
66
+ const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
67
+ const owasp = (id) => `OWASP ${id}${OWASP_2025.find((c) => c.id === id) === undefined ? "" : ` ${OWASP_2025.find((c) => c.id === id)?.name}`}`;
68
+ const rank = (severity) => SEVERITIES.indexOf(severity);
69
+ /** A path as a report's step names it: by its route, as every line that says what was asked. */
70
+ const routed = (target) => requestRoute(URL.parse(target, "http://request")?.pathname ?? target);
71
+ /** A proof by request pattern: `1. POST /api/cart/coupon as free → 200`. The requests themselves are the lines under it. */
72
+ export const proofSteps = (proof) => proof.map((p, i) => `${i + 1}. ${parseRequest(p.request).method} ${routed(parseRequest(p.request).target)} as ${p.as} → ${p.status}${p.location === undefined ? "" : ` to ${routed(p.location)}`}`).join("; ");
73
+ const answers = (line) => {
74
+ const total = Object.values(line.answered).reduce((n, m) => n + m, 0);
75
+ const models = Object.entries(line.answered);
76
+ return models.length === 0 ? "no answer" : models.length === 1 ? `${plural(total, "answer")} from ${models[0]?.[0]}` : models.map(([model, n]) => `${n} of ${total} answers from ${model}`).join(", ");
77
+ };
78
+ const agentLine = (name, line) => `- ${name}: ${line.model}; ${line.calls} of ${line.callLimit} model calls, ${line.requests} of ${line.requestLimit} requests; ${answers(line)}`;
79
+ /** What a claim's section holds whoever judged it: what is at stake, the fix, the steps, the proof to send again. */
80
+ const claimBody = (c) => [`- impact: ${c.impact}`, `- fix: ${c.fix}`, `- steps: ${proofSteps(c.proof)}`, `- in the researcher's words: ${c.steps.join("; ")}`];
81
+ // One request a line, as JSON: whatever a body holds (a fence, a heading) stays inside its line, and reads back as it was written.
82
+ const proofBlock = (proof) => ["```proof", ...proof.map((p) => JSON.stringify({ as: p.as, request: p.request, status: p.status, ...(p.location === undefined ? {} : { location: p.location }) })), "```"];
83
+ function renderScan(r) {
84
+ const confirmed = r.confirmed.toSorted((a, b) => rank(a.severity) - rank(b.severity) || Number(b.id.replace(/\D/g, "")) - Number(a.id.replace(/\D/g, "")));
85
+ const bySeverity = SEVERITIES.map((severity) => [severity, confirmed.filter((c) => c.severity === severity).length]).filter(([, n]) => n > 0).map(([severity, n]) => `${n} ${severity}`);
86
+ return [
87
+ SCAN,
88
+ "",
89
+ `- ${r.environment}, ${r.date}`,
90
+ agentLine("researcher", r.researcher),
91
+ agentLine("reviewer", r.reviewer),
92
+ `- ${confirmed.length} confirmed${bySeverity.length === 0 ? "" : ` (${bySeverity.join(", ")})`}, ${r.discarded.length} discarded${r.unreviewed.length === 0 ? "" : `, ${r.unreviewed.length} without a verdict`}`,
93
+ ...(confirmed.length === 0 ? [] : ["", "## Confirmed claims", ...confirmed.flatMap((c) => [
94
+ "",
95
+ `### ${c.id}: ${c.title}`,
96
+ "",
97
+ `- severity: ${c.severity}${c.claimed === undefined || c.claimed === c.severity ? "" : ` (the researcher said ${c.claimed})`}; ${owasp(c.category)}`,
98
+ `- confirmed on ${c.environment} on ${c.date}${c.by === undefined ? "" : ` by ${c.by}`}: ${c.reason}`,
99
+ ...(c.known === true ? [`- still open on ${r.date}: its proof was sent again and answered as before`] : []),
100
+ ...(c.unsettled === undefined ? [] : [`- not settled on ${r.date}: ${c.unsettled}`]),
101
+ ...claimBody(c),
102
+ `- after the fix, omniqa write --claim ${c.id} writes the test`,
103
+ "",
104
+ ...proofBlock(c.proof),
105
+ ])]),
106
+ ...(r.discarded.length === 0 ? [] : ["", "## Discarded claims", "", ...r.discarded.map((d) => `- ${d.title} (OWASP ${d.category}, claimed ${d.severity}): ${d.reason}`)]),
107
+ ...(r.unreviewed.length === 0 ? [] : ["", "## Claims without a verdict", ...r.unreviewed.flatMap((c) => ["", `### ${c.title}`, "", `- no verdict: ${c.why}`, `- claimed ${c.severity}; ${owasp(c.category)}`, ...claimBody(c), "", ...proofBlock(c.proof)])]),
108
+ "",
109
+ "## Tried and found closed",
110
+ "",
111
+ ...(r.tried.length > 0 ? r.tried.map((line) => `- ${line}`) : (r.sent ?? []).length === 0 ? ["Nothing: the researcher ended without a list."] : ["Nothing: the researcher ended without a list. What it sent, each with the reason it gave:", "", ...r.sent.map((line) => `- ${line}`)]),
112
+ ...(r.notDone.length === 0 ? [] : ["", "## Not done", "", ...r.notDone.map((line) => `- ${line}`)]),
113
+ "",
114
+ ].join("\n");
115
+ }
116
+ /** The scan's sections in place of the last scan's; the basic checks' findings stay as they are. */
117
+ export async function writeScan(cwd, scan) {
118
+ await write(cwd, parts(await read(cwd)).basic, renderScan(scan));
119
+ }
120
+ /** The confirmed claims of a report, each as it was written: what the next scan sends again, and what `omniqa write --claim` turns into a test. */
121
+ export function parseClaims(text) {
122
+ const confirmed = /^## Confirmed claims$([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(parts(text).scan)?.[1] ?? "";
123
+ return confirmed.split(/^(?=### )/m).slice(1).flatMap((s) => {
124
+ const head = /^### (claim-\d+): (.*)$/m.exec(s);
125
+ const line = (key) => new RegExp(`^- ${key}: (.*)$`, "m").exec(s)?.[1] ?? "";
126
+ const severity = /^- severity: (\w+)(?: \([^)]*\))?; OWASP (A\d\d)/m.exec(s);
127
+ const seen = /^- confirmed on (.+?) on (\d{4}-\d\d-\d\d)(?: by (\S+))?: (.*)$/m.exec(s);
128
+ const proof = /^```proof\n([\s\S]*?)^```$/m.exec(s)?.[1] ?? "";
129
+ if (head === null || severity === null || seen === null)
130
+ return [];
131
+ return [{
132
+ id: head[1],
133
+ title: head[2],
134
+ category: severity[2],
135
+ severity: severity[1],
136
+ steps: line("in the researcher's words").split("; ").filter((step) => step !== ""),
137
+ impact: line("impact"),
138
+ fix: line("fix"),
139
+ // A line that is no longer what was written costs that line: a report must never be what keeps the next scan from starting.
140
+ proof: proof.split("\n").filter((row) => row.trim() !== "").flatMap((row) => {
141
+ try {
142
+ const p = JSON.parse(row);
143
+ return typeof p?.as === "string" && typeof p.request === "string" && typeof p.status === "number" ? [p] : [];
144
+ }
145
+ catch {
146
+ return [];
147
+ }
148
+ }),
149
+ environment: seen[1],
150
+ date: seen[2],
151
+ reason: seen[4],
152
+ ...(seen[3] === undefined ? {} : { by: seen[3] }),
153
+ }];
154
+ });
155
+ }
156
+ export async function readClaims(cwd) {
157
+ return parseClaims(await read(cwd));
158
+ }
159
+ /**
160
+ * A claim that was fixed and is kept as a test leaves the list of what is open: its section goes, and the scan's lines say
161
+ * what became of it. The rest of the scan's sections stay as that scan wrote them.
162
+ */
163
+ export async function closeClaim(cwd, id, test) {
164
+ const { basic, scan } = parts(await read(cwd));
165
+ const without = scan.replace(new RegExp(`^### ${id}: [\\s\\S]*?(?=^###? |(?![\\s\\S]))`, "m"), "").replace(/^## Confirmed claims\n+(?=## |(?![\s\S]))/m, "");
166
+ if (without === scan)
167
+ return;
168
+ await write(cwd, basic, without.replace(/^(- \d+ confirmed[^\n]*\n)/m, `$1- since then: ${id} is fixed and kept as the test ${test}\n`));
48
169
  }
49
170
  //# sourceMappingURL=security-report.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"security-report.js","sourceRoot":"","sources":["../src/security-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AACxD,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAiBpC,MAAM,IAAI,GAAG;;kGAEqF,OAAO;;;;CAIxG,CAAC;AACF,MAAM,OAAO,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK;;WAEpD,CAAC,CAAC,OAAO;WACT,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAChD,CAAC,CAAC,WAAW,OAAO,CAAC,CAAC,IAAI;uCACC,CAAC,CAAC,EAAE;CAC1C,CAAC;AACF,mFAAmF;AACnF,MAAM,QAAQ,GAAG,CAAC,IAAwB,EAAY,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAClI,MAAM,EAAE,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAE/E,KAAK,UAAU,KAAK,CAAC,GAAW,EAAE,IAAc;IAC9C,MAAM,IAAI,GAAG,IAAI,CA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