@secureport/core 0.2.1 → 0.4.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 (100) hide show
  1. package/README.md +146 -33
  2. package/dist/coverage.d.ts +21 -0
  3. package/dist/coverage.d.ts.map +1 -0
  4. package/dist/coverage.js +65 -0
  5. package/dist/coverage.js.map +1 -0
  6. package/dist/finding.d.ts +89 -0
  7. package/dist/finding.d.ts.map +1 -0
  8. package/dist/finding.js +2 -0
  9. package/dist/finding.js.map +1 -0
  10. package/dist/fingerprint.d.ts +185 -0
  11. package/dist/fingerprint.d.ts.map +1 -0
  12. package/dist/fingerprint.js +247 -0
  13. package/dist/fingerprint.js.map +1 -0
  14. package/dist/import/burp.d.ts +19 -0
  15. package/dist/import/burp.d.ts.map +1 -0
  16. package/dist/import/burp.js +114 -0
  17. package/dist/import/burp.js.map +1 -0
  18. package/dist/import/generic.d.ts +90 -0
  19. package/dist/import/generic.d.ts.map +1 -0
  20. package/dist/import/generic.js +159 -0
  21. package/dist/import/generic.js.map +1 -0
  22. package/dist/import/nessus.d.ts +32 -0
  23. package/dist/import/nessus.d.ts.map +1 -0
  24. package/dist/import/nessus.js +125 -0
  25. package/dist/import/nessus.js.map +1 -0
  26. package/dist/import/nuclei.d.ts +39 -0
  27. package/dist/import/nuclei.d.ts.map +1 -0
  28. package/dist/import/nuclei.js +115 -0
  29. package/dist/import/nuclei.js.map +1 -0
  30. package/dist/import/xml.d.ts +47 -0
  31. package/dist/import/xml.d.ts.map +1 -0
  32. package/dist/import/xml.js +157 -0
  33. package/dist/import/xml.js.map +1 -0
  34. package/dist/import/zap.d.ts +26 -0
  35. package/dist/import/zap.d.ts.map +1 -0
  36. package/dist/import/zap.js +119 -0
  37. package/dist/import/zap.js.map +1 -0
  38. package/dist/index.d.ts +41 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +29 -2
  41. package/dist/index.js.map +1 -1
  42. package/dist/issue.d.ts +190 -11
  43. package/dist/issue.d.ts.map +1 -1
  44. package/dist/reconcile.d.ts +115 -10
  45. package/dist/reconcile.d.ts.map +1 -1
  46. package/dist/reconcile.js +306 -12
  47. package/dist/reconcile.js.map +1 -1
  48. package/dist/report/html.d.ts +21 -0
  49. package/dist/report/html.d.ts.map +1 -0
  50. package/dist/report/html.js +324 -0
  51. package/dist/report/html.js.map +1 -0
  52. package/dist/report/json.d.ts +81 -0
  53. package/dist/report/json.d.ts.map +1 -0
  54. package/dist/report/json.js +47 -0
  55. package/dist/report/json.js.map +1 -0
  56. package/dist/report/markdown.d.ts +24 -0
  57. package/dist/report/markdown.d.ts.map +1 -0
  58. package/dist/report/markdown.js +304 -0
  59. package/dist/report/markdown.js.map +1 -0
  60. package/dist/report/model.d.ts +215 -0
  61. package/dist/report/model.d.ts.map +1 -0
  62. package/dist/report/model.js +197 -0
  63. package/dist/report/model.js.map +1 -0
  64. package/dist/run.d.ts +134 -0
  65. package/dist/run.d.ts.map +1 -0
  66. package/dist/run.js +2 -0
  67. package/dist/run.js.map +1 -0
  68. package/dist/severity.d.ts +191 -0
  69. package/dist/severity.d.ts.map +1 -0
  70. package/dist/severity.js +171 -0
  71. package/dist/severity.js.map +1 -0
  72. package/dist/snapshot-builder.d.ts +78 -0
  73. package/dist/snapshot-builder.d.ts.map +1 -0
  74. package/dist/snapshot-builder.js +172 -0
  75. package/dist/snapshot-builder.js.map +1 -0
  76. package/dist/snapshot.d.ts +125 -0
  77. package/dist/snapshot.d.ts.map +1 -0
  78. package/dist/snapshot.js +2 -0
  79. package/dist/snapshot.js.map +1 -0
  80. package/package.json +5 -4
  81. package/src/coverage.ts +65 -0
  82. package/src/finding.ts +112 -0
  83. package/src/fingerprint.ts +315 -0
  84. package/src/import/burp.ts +126 -0
  85. package/src/import/generic.ts +258 -0
  86. package/src/import/nessus.ts +136 -0
  87. package/src/import/nuclei.ts +173 -0
  88. package/src/import/xml.ts +187 -0
  89. package/src/import/zap.ts +161 -0
  90. package/src/index.ts +75 -2
  91. package/src/issue.ts +244 -11
  92. package/src/reconcile.ts +421 -17
  93. package/src/report/html.ts +449 -0
  94. package/src/report/json.ts +134 -0
  95. package/src/report/markdown.ts +435 -0
  96. package/src/report/model.ts +462 -0
  97. package/src/run.ts +163 -0
  98. package/src/severity.ts +250 -0
  99. package/src/snapshot-builder.ts +225 -0
  100. package/src/snapshot.ts +146 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic.js","sourceRoot":"","sources":["../../src/import/generic.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAuF9E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAS,cAAc,CAAC,CAAC;AAEnD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE,CAC7C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAElE,mCAAmC;AACnC,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE,CAC7C,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAU,EAAE,CACzC,KAAK;KACF,WAAW,EAAE;KACb,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC;KAC5B,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAE5B,iDAAiD;AACjD,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAwB,EAAE;IACpD,IAAI,CAAC,KAAK,CAAC,O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O,CAAC,GAAG;SACL,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { Finding } from '../finding.js';
2
+ import type { ImportOptions } from './nuclei.js';
3
+ /**
4
+ * Turns a `.nessus` export into {@link Finding}s.
5
+ *
6
+ * Nessus is host-oriented: every `ReportItem` hangs off a `ReportHost`, and the
7
+ * port and protocol are attributes rather than part of a URL. The location is
8
+ * assembled as `host:port`, which is **the only place the port survives** —
9
+ * `00-DOMAIN.md` §3 defines no `port` on a finding, so anything not in the
10
+ * location is lost. A network finding with no path still fingerprints
11
+ * distinctly per service because the port is inside its location.
12
+ *
13
+ * A consequence worth knowing: the fingerprint's last component is
14
+ * `parameter ?? port ?? ''`, so a Nessus port is counted twice — once inside
15
+ * the location and once as that component. Harmless, but it means a port
16
+ * cannot be recovered from a finding except by parsing its location. Recorded
17
+ * as backlog **B42**.
18
+ *
19
+ * Severity comes from the CVSS v3 base score where Nessus supplies one, and from
20
+ * its own numeric rating otherwise.
21
+ *
22
+ * A `ReportItem` with severity `0` and no port — Nessus's host-inventory
23
+ * plugins — still imports: an advisory is still a finding, and dropping it here
24
+ * would make coverage look narrower than it was.
25
+ *
26
+ * @param xml - The contents of a `.nessus` file.
27
+ * @param options - Ownership, and the injected clock and id source.
28
+ * @returns One finding per report item, in document order.
29
+ * @throws SyntaxError If the document is not well-formed XML.
30
+ */
31
+ export declare function importNessus(xml: string, options: ImportOptions): Finding[];
32
+ //# sourceMappingURL=nessus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nessus.d.ts","sourceRoot":"","sources":["../../src/import/nessus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,EAAE,CAsF3E"}
@@ -0,0 +1,125 @@
1
+ import { severityFromCvss } from '../severity.js';
2
+ import { fingerprint, vulnKey, FINGERPRINT_VERSION } from '../fingerprint.js';
3
+ import { childText, findAll, parseXml } from './xml.js';
4
+ /**
5
+ * Nessus reports severity as a number on the `ReportItem`.
6
+ *
7
+ * `0` is Info, which is the bottom of the scale here rather than a separate
8
+ * category. Nessus does reach `4` (Critical), unlike ZAP and Burp.
9
+ */
10
+ const NESSUS_SEVERITY = Object.freeze({
11
+ '4': 'critical',
12
+ '3': 'high',
13
+ '2': 'medium',
14
+ '1': 'low',
15
+ '0': 'advisory',
16
+ });
17
+ /**
18
+ * Turns a `.nessus` export into {@link Finding}s.
19
+ *
20
+ * Nessus is host-oriented: every `ReportItem` hangs off a `ReportHost`, and the
21
+ * port and protocol are attributes rather than part of a URL. The location is
22
+ * assembled as `host:port`, which is **the only place the port survives** —
23
+ * `00-DOMAIN.md` §3 defines no `port` on a finding, so anything not in the
24
+ * location is lost. A network finding with no path still fingerprints
25
+ * distinctly per service because the port is inside its location.
26
+ *
27
+ * A consequence worth knowing: the fingerprint's last component is
28
+ * `parameter ?? port ?? ''`, so a Nessus port is counted twice — once inside
29
+ * the location and once as that component. Harmless, but it means a port
30
+ * cannot be recovered from a finding except by parsing its location. Recorded
31
+ * as backlog **B42**.
32
+ *
33
+ * Severity comes from the CVSS v3 base score where Nessus supplies one, and from
34
+ * its own numeric rating otherwise.
35
+ *
36
+ * A `ReportItem` with severity `0` and no port — Nessus's host-inventory
37
+ * plugins — still imports: an advisory is still a finding, and dropping it here
38
+ * would make coverage look narrower than it was.
39
+ *
40
+ * @param xml - The contents of a `.nessus` file.
41
+ * @param options - Ownership, and the injected clock and id source.
42
+ * @returns One finding per report item, in document order.
43
+ * @throws SyntaxError If the document is not well-formed XML.
44
+ */
45
+ export function importNessus(xml, options) {
46
+ const root = parseXml(xml);
47
+ const findings = [];
48
+ for (const host of findAll(root, 'ReportHost')) {
49
+ const hostName = host.attrs['name'] ?? '';
50
+ for (const item of findAll(host, 'ReportItem')) {
51
+ const pluginId = item.attrs['pluginID'];
52
+ const title = item.attrs['pluginName'];
53
+ if (pluginId === undefined || title === undefined)
54
+ continue;
55
+ const portText = item.attrs['port'];
56
+ const port = portText !== undefined && portText !== '0' ? Number(portText) : undefined;
57
+ const location = port === undefined ? hostName : `${hostName}:${String(port)}`;
58
+ if (location === '')
59
+ continue;
60
+ const scoreText = childText(item, 'cvss3_base_score') ?? childText(item, 'cvss_base_score');
61
+ const score = scoreText === undefined ? undefined : Number(scoreText);
62
+ let detectedSeverity;
63
+ let severitySource;
64
+ if (score !== undefined && Number.isFinite(score) && score >= 0 && score <= 10) {
65
+ detectedSeverity = severityFromCvss(score);
66
+ severitySource = 'cvss';
67
+ }
68
+ else {
69
+ detectedSeverity = NESSUS_SEVERITY[item.attrs['severity'] ?? ''] ?? 'advisory';
70
+ severitySource = 'engine_default';
71
+ }
72
+ // Nessus writes the bare number, e.g. `79`.
73
+ const rawCwe = childText(item, 'cwe');
74
+ const cwe = rawCwe === undefined ? undefined : `CWE-${rawCwe.replace(/^CWE-/iu, '')}`;
75
+ const family = item.attrs['pluginFamily'];
76
+ const key = vulnKey({
77
+ sourceEngine: 'nessus',
78
+ sourceRuleId: pluginId,
79
+ ...(cwe === undefined ? {} : { cwe }),
80
+ ...(family === undefined ? {} : { category: family }),
81
+ });
82
+ const references = childText(item, 'see_also')
83
+ ?.split(/\s+/u)
84
+ .filter((token) => token.startsWith('http'));
85
+ findings.push({
86
+ id: options.newId(),
87
+ orgId: options.orgId,
88
+ runId: options.runId,
89
+ fingerprint: fingerprint({
90
+ targetId: options.targetId,
91
+ vulnKey: key,
92
+ location,
93
+ ...(port === undefined ? {} : { port }),
94
+ }),
95
+ fingerprintVersion: FINGERPRINT_VERSION,
96
+ title,
97
+ ...(childText(item, 'description') === undefined
98
+ ? {}
99
+ : { description: childText(item, 'description') }),
100
+ detectedSeverity,
101
+ severitySource,
102
+ ...(score === undefined || !Number.isFinite(score) ? {} : { cvssScore: score }),
103
+ ...(childText(item, 'cvss3_vector') === undefined
104
+ ? {}
105
+ : { cvssVector: childText(item, 'cvss3_vector') }),
106
+ ...(cwe === undefined ? {} : { cwe }),
107
+ ...(childText(item, 'cve') === undefined
108
+ ? {}
109
+ : { cve: childText(item, 'cve').toUpperCase() }),
110
+ vulnKey: key,
111
+ ...(family === undefined ? {} : { category: family.toLowerCase() }),
112
+ location,
113
+ ...(childText(item, 'solution') === undefined
114
+ ? {}
115
+ : { recommendation: childText(item, 'solution') }),
116
+ ...(references === undefined || references.length === 0 ? {} : { references }),
117
+ sourceEngine: 'nessus',
118
+ sourceRuleId: pluginId,
119
+ createdAt: options.now,
120
+ });
121
+ }
122
+ }
123
+ return findings;
124
+ }
125
+ //# sourceMappingURL=nessus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nessus.js","sourceRoot":"","sources":["../../src/import/nessus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGxD;;;;;GAKG;AACH,MAAM,eAAe,GAAuC,MAAM,CAAC,MAAM,CAAC;IACxE,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,UAAU;CAChB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,OAAsB;IAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAc,EAAE,CAAC;IAE/B,KAA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,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;gBACnE,QAAQ;gBACR,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,SAAS;oBAC3C,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC,EAAE,cAAc,EAAE,SAAS,CAAC,IAAI,EAAE,UAAU,CAAE,EAAE,CAAC;gBACrD,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;gBAC9E,YAAY,EAAE,QAAQ;gBACtB,YAAY,EAAE,QAAQ;gBACtB,SAAS,EAAE,OAAO,CAAC,GAAG;aACvB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { Finding } from '../finding.js';
2
+ /**
3
+ * What an importer needs that a scanner's output cannot tell it.
4
+ *
5
+ * A scanner knows what it found; it does not know which organisation, run or
6
+ * target the result belongs to, and it must not invent ids. All of it is
7
+ * supplied, so importing stays pure and repeatable.
8
+ */
9
+ export interface ImportOptions {
10
+ /** Organisation the findings belong to. */
11
+ readonly orgId: string;
12
+ /** The run that produced them. */
13
+ readonly runId: string;
14
+ /** The target they are against. Part of every fingerprint. */
15
+ readonly targetId: string;
16
+ /** When the import happened. No importer reads the clock. */
17
+ readonly now: Date;
18
+ /** Supplies finding ids. Injected so importing is deterministic. */
19
+ readonly newId: () => string;
20
+ }
21
+ /**
22
+ * Turns Nuclei's JSONL output into {@link Finding}s.
23
+ *
24
+ * Nuclei writes **one JSON object per line** (`-jsonl`), so the file is not
25
+ * itself valid JSON. Blank lines are skipped, and a line that will not parse is
26
+ * skipped rather than thrown on: a single malformed record should not cost a
27
+ * user every other result in the file. Records with no `template-id` or no
28
+ * location are skipped for the same reason — there is nothing to fingerprint.
29
+ *
30
+ * Severity comes from the CVSS score where Nuclei supplies one, and from its own
31
+ * rating otherwise; `severitySource` records which, because a severity with no
32
+ * provenance is not evidence.
33
+ *
34
+ * @param jsonl - The contents of a Nuclei JSONL file.
35
+ * @param options - Ownership, and the injected clock and id source.
36
+ * @returns One finding per usable record, in file order.
37
+ */
38
+ export declare function importNuclei(jsonl: string, options: ImportOptions): Finding[];
39
+ //# sourceMappingURL=nuclei.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuclei.d.ts","sourceRoot":"","sources":["../../src/import/nuclei.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK7C;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IAEnB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC;CAC9B;AAoDD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,EAAE,CA4E7E"}
@@ -0,0 +1,115 @@
1
+ import { severityFromCvss } from '../severity.js';
2
+ import { fingerprint, vulnKey, FINGERPRINT_VERSION } from '../fingerprint.js';
3
+ /**
4
+ * Nuclei's severity vocabulary, mapped onto {@link Severity}.
5
+ *
6
+ * `info` and `unknown` both become `advisory`: this model has no
7
+ * "informational" category separate from the bottom of the scale, and an
8
+ * unrated finding is not evidence of low risk — it is evidence of nothing, which
9
+ * is what `advisory` means here.
10
+ */
11
+ const NUCLEI_SEVERITY = Object.freeze({
12
+ critical: 'critical',
13
+ high: 'high',
14
+ medium: 'medium',
15
+ low: 'low',
16
+ info: 'advisory',
17
+ unknown: 'advisory',
18
+ });
19
+ const str = (v) => typeof v === 'string' && v.trim() !== '' ? v.trim() : undefined;
20
+ const firstOf = (v) => (Array.isArray(v) ? str(v[0]) : str(v));
21
+ const allOf = (v) => {
22
+ if (!Array.isArray(v))
23
+ return str(v) === undefined ? undefined : [str(v)];
24
+ const items = v.map(str).filter((x) => x !== undefined);
25
+ return items.length > 0 ? items : undefined;
26
+ };
27
+ /**
28
+ * Turns Nuclei's JSONL output into {@link Finding}s.
29
+ *
30
+ * Nuclei writes **one JSON object per line** (`-jsonl`), so the file is not
31
+ * itself valid JSON. Blank lines are skipped, and a line that will not parse is
32
+ * skipped rather than thrown on: a single malformed record should not cost a
33
+ * user every other result in the file. Records with no `template-id` or no
34
+ * location are skipped for the same reason — there is nothing to fingerprint.
35
+ *
36
+ * Severity comes from the CVSS score where Nuclei supplies one, and from its own
37
+ * rating otherwise; `severitySource` records which, because a severity with no
38
+ * provenance is not evidence.
39
+ *
40
+ * @param jsonl - The contents of a Nuclei JSONL file.
41
+ * @param options - Ownership, and the injected clock and id source.
42
+ * @returns One finding per usable record, in file order.
43
+ */
44
+ export function importNuclei(jsonl, options) {
45
+ const findings = [];
46
+ for (const line of jsonl.split('\n')) {
47
+ const trimmed = line.trim();
48
+ if (trimmed === '')
49
+ continue;
50
+ let record;
51
+ try {
52
+ record = JSON.parse(trimmed);
53
+ }
54
+ catch {
55
+ // One unparseable line must not cost the user the rest of the file.
56
+ continue;
57
+ }
58
+ const templateId = str(record['template-id']);
59
+ const location = str(record['matched-at']) ?? str(record.host);
60
+ if (templateId === undefined || location === undefined)
61
+ continue;
62
+ const info = record.info ?? {};
63
+ const classification = info.classification ?? {};
64
+ const cvss = typeof classification['cvss-score'] === 'number' ? classification['cvss-score'] : undefined;
65
+ const rated = NUCLEI_SEVERITY[str(info.severity)?.toLowerCase() ?? ''];
66
+ let detectedSeverity;
67
+ let severitySource;
68
+ if (cvss !== undefined && cvss >= 0 && cvss <= 10) {
69
+ detectedSeverity = severityFromCvss(cvss);
70
+ severitySource = 'cvss';
71
+ }
72
+ else {
73
+ detectedSeverity = rated ?? 'advisory';
74
+ severitySource = 'engine_default';
75
+ }
76
+ // Nuclei writes CWE as `cwe-502`; the rest of the model uses `CWE-502`.
77
+ const cwe = firstOf(classification['cwe-id'])?.toUpperCase();
78
+ const category = firstOf(info.tags);
79
+ const key = vulnKey({
80
+ sourceEngine: 'nuclei',
81
+ sourceRuleId: templateId,
82
+ ...(cwe === undefined ? {} : { cwe }),
83
+ ...(category === undefined ? {} : { category }),
84
+ });
85
+ findings.push({
86
+ id: options.newId(),
87
+ orgId: options.orgId,
88
+ runId: options.runId,
89
+ fingerprint: fingerprint({ targetId: options.targetId, vulnKey: key, location }),
90
+ fingerprintVersion: FINGERPRINT_VERSION,
91
+ title: str(info.name) ?? templateId,
92
+ ...(str(info.description) === undefined ? {} : { description: str(info.description) }),
93
+ detectedSeverity,
94
+ severitySource,
95
+ ...(cvss === undefined ? {} : { cvssScore: cvss }),
96
+ ...(str(classification['cvss-metrics']) === undefined
97
+ ? {}
98
+ : { cvssVector: str(classification['cvss-metrics']) }),
99
+ ...(cwe === undefined ? {} : { cwe }),
100
+ ...(firstOf(classification['cve-id']) === undefined
101
+ ? {}
102
+ : { cve: firstOf(classification['cve-id']).toUpperCase() }),
103
+ vulnKey: key,
104
+ ...(category === undefined ? {} : { category }),
105
+ location,
106
+ ...(str(info.remediation) === undefined ? {} : { recommendation: str(info.remediation) }),
107
+ ...(allOf(info.reference) === undefined ? {} : { references: allOf(info.reference) }),
108
+ sourceEngine: 'nuclei',
109
+ sourceRuleId: templateId,
110
+ createdAt: options.now,
111
+ });
112
+ }
113
+ return findings;
114
+ }
115
+ //# sourceMappingURL=nuclei.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuclei.js","sourceRoot":"","sources":["../../src/import/nuclei.ts"],"names":[],"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E,OAAO,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A parsed XML element.
3
+ *
4
+ * Deliberately minimal: a name, its attributes, its child elements and its
5
+ * text. No namespaces, no processing instructions, no mixed-content ordering —
6
+ * none of which appears in a Burp or Nessus export.
7
+ */
8
+ export interface XmlNode {
9
+ /** The element name, as written. */
10
+ readonly name: string;
11
+ /** Attributes, with entities decoded. */
12
+ readonly attrs: Readonly<Record<string, string>>;
13
+ /** Child elements, in document order. */
14
+ readonly children: readonly XmlNode[];
15
+ /** All direct text and CDATA of this element, concatenated and trimmed. */
16
+ readonly text: string;
17
+ }
18
+ /**
19
+ * Parses the subset of XML that scanner exports actually use.
20
+ *
21
+ * **Deliberately narrow, and it throws rather than guesses.** Burp and Nessus
22
+ * both export machine-generated XML with a fixed shape: elements, attributes,
23
+ * text and CDATA. This handles exactly that, plus comments, the XML
24
+ * declaration, a DOCTYPE, self-closing tags and the five named entities with
25
+ * numeric character references.
26
+ *
27
+ * It does **not** handle namespaces, entity definitions or mixed-content
28
+ * ordering, and it has no opinion about schemas. Anything structurally
29
+ * unexpected — an unclosed element, a mismatched end tag, two root elements —
30
+ * is an error, because a parser that guesses at broken input produces findings
31
+ * that are quietly wrong, and a wrong finding is worse than a failed import.
32
+ *
33
+ * Hand-written rather than taken from a library because `@secureport/core` ships
34
+ * with zero runtime dependencies: it is imported by the hosted API and by third
35
+ * parties on equal terms, and a domain model that drags an XML parser in with it
36
+ * is a supply-chain decision made on everyone's behalf.
37
+ *
38
+ * @param source - The XML document.
39
+ * @returns The root element.
40
+ * @throws SyntaxError If the document is not well-formed, or has no root.
41
+ */
42
+ export declare function parseXml(source: string): XmlNode;
43
+ /** Every descendant with this name, at any depth. */
44
+ export declare function findAll(node: XmlNode, name: string): XmlNode[];
45
+ /** The text of the first direct child with this name, if it has any. */
46
+ export declare function childText(node: XmlNode, name: string): string | undefined;
47
+ //# sourceMappingURL=xml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../src/import/xml.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjD,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAEtC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AA0CD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAmFhD;AAED,qDAAqD;AACrD,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,CAQ9D;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIzE"}
@@ -0,0 +1,157 @@
1
+ const ENTITIES = Object.freeze({
2
+ amp: '&',
3
+ lt: '<',
4
+ gt: '>',
5
+ quot: '"',
6
+ apos: "'",
7
+ });
8
+ /** Decodes the five XML entities and numeric character references. */
9
+ function decodeEntities(text) {
10
+ return text.replace(/&(#x?[0-9a-f]+|[a-z]+);/giu, (whole, body) => {
11
+ if (body.startsWith('#')) {
12
+ const code = body[1]?.toLowerCase() === 'x' ? parseInt(body.slice(2), 16) : parseInt(body.slice(1), 10);
13
+ return Number.isFinite(code) && code >= 0 && code <= 0x10ffff
14
+ ? String.fromCodePoint(code)
15
+ : whole;
16
+ }
17
+ return ENTITIES[body.toLowerCase()] ?? whole;
18
+ });
19
+ }
20
+ /** Reads the attributes out of a start tag's body. */
21
+ function parseAttrs(body) {
22
+ const attrs = {};
23
+ const pattern = /([\w:.-]+)\s*=\s*("([^"]*)"|'([^']*)')/gu;
24
+ let match;
25
+ while ((match = pattern.exec(body)) !== null) {
26
+ attrs[match[1]] = decodeEntities(match[3] ?? match[4] ?? '');
27
+ }
28
+ return attrs;
29
+ }
30
+ /**
31
+ * Parses the subset of XML that scanner exports actually use.
32
+ *
33
+ * **Deliberately narrow, and it throws rather than guesses.** Burp and Nessus
34
+ * both export machine-generated XML with a fixed shape: elements, attributes,
35
+ * text and CDATA. This handles exactly that, plus comments, the XML
36
+ * declaration, a DOCTYPE, self-closing tags and the five named entities with
37
+ * numeric character references.
38
+ *
39
+ * It does **not** handle namespaces, entity definitions or mixed-content
40
+ * ordering, and it has no opinion about schemas. Anything structurally
41
+ * unexpected — an unclosed element, a mismatched end tag, two root elements —
42
+ * is an error, because a parser that guesses at broken input produces findings
43
+ * that are quietly wrong, and a wrong finding is worse than a failed import.
44
+ *
45
+ * Hand-written rather than taken from a library because `@secureport/core` ships
46
+ * with zero runtime dependencies: it is imported by the hosted API and by third
47
+ * parties on equal terms, and a domain model that drags an XML parser in with it
48
+ * is a supply-chain decision made on everyone's behalf.
49
+ *
50
+ * @param source - The XML document.
51
+ * @returns The root element.
52
+ * @throws SyntaxError If the document is not well-formed, or has no root.
53
+ */
54
+ export function parseXml(source) {
55
+ const stack = [];
56
+ let root;
57
+ let i = 0;
58
+ while (i < source.length) {
59
+ const lt = source.indexOf('<', i);
60
+ if (lt === -1)
61
+ break;
62
+ // Text before this tag belongs to the element currently open.
63
+ if (lt > i && stack.length > 0) {
64
+ stack[stack.length - 1].text += decodeEntities(source.slice(i, lt));
65
+ }
66
+ if (source.startsWith('<!--', lt)) {
67
+ const end = source.indexOf('-->', lt);
68
+ if (end === -1)
69
+ throw new SyntaxError('unterminated comment');
70
+ i = end + 3;
71
+ continue;
72
+ }
73
+ if (source.startsWith('<![CDATA[', lt)) {
74
+ const end = source.indexOf(']]>', lt);
75
+ if (end === -1)
76
+ throw new SyntaxError('unterminated CDATA section');
77
+ // CDATA is literal: no entity decoding, which is the whole point of it.
78
+ if (stack.length > 0)
79
+ stack[stack.length - 1].text += source.slice(lt + 9, end);
80
+ i = end + 3;
81
+ continue;
82
+ }
83
+ if (source.startsWith('<?', lt) || source.startsWith('<!', lt)) {
84
+ const end = source.indexOf('>', lt);
85
+ if (end === -1)
86
+ throw new SyntaxError('unterminated declaration');
87
+ i = end + 1;
88
+ continue;
89
+ }
90
+ const gt = source.indexOf('>', lt);
91
+ if (gt === -1)
92
+ throw new SyntaxError('unterminated tag');
93
+ const raw = source.slice(lt + 1, gt);
94
+ if (raw.startsWith('/')) {
95
+ const name = raw.slice(1).trim();
96
+ const open = stack.pop();
97
+ if (open === undefined)
98
+ throw new SyntaxError(`unexpected closing tag </${name}>`);
99
+ if (open.name !== name) {
100
+ throw new SyntaxError(`closing tag </${name}> does not match <${open.name}>`);
101
+ }
102
+ i = gt + 1;
103
+ continue;
104
+ }
105
+ const selfClosing = raw.endsWith('/');
106
+ const body = selfClosing ? raw.slice(0, -1) : raw;
107
+ const nameEnd = body.search(/[\s/]/u);
108
+ const name = (nameEnd === -1 ? body : body.slice(0, nameEnd)).trim();
109
+ if (name === '')
110
+ throw new SyntaxError('tag with no name');
111
+ const node = {
112
+ name,
113
+ attrs: parseAttrs(nameEnd === -1 ? '' : body.slice(nameEnd)),
114
+ children: [],
115
+ text: '',
116
+ };
117
+ if (stack.length > 0)
118
+ stack[stack.length - 1].children.push(node);
119
+ else if (root === undefined)
120
+ root = node;
121
+ else
122
+ throw new SyntaxError('more than one root element');
123
+ if (!selfClosing)
124
+ stack.push(node);
125
+ i = gt + 1;
126
+ }
127
+ if (stack.length > 0)
128
+ throw new SyntaxError(`unclosed element <${stack[stack.length - 1].name}>`);
129
+ if (root === undefined)
130
+ throw new SyntaxError('no root element');
131
+ const finish = (node) => ({
132
+ name: node.name,
133
+ attrs: node.attrs,
134
+ children: node.children.map(finish),
135
+ text: node.text.trim(),
136
+ });
137
+ return finish(root);
138
+ }
139
+ /** Every descendant with this name, at any depth. */
140
+ export function findAll(node, name) {
141
+ const found = [];
142
+ const walk = (current) => {
143
+ if (current.name === name)
144
+ found.push(current);
145
+ for (const child of current.children)
146
+ walk(child);
147
+ };
148
+ walk(node);
149
+ return found;
150
+ }
151
+ /** The text of the first direct child with this name, if it has any. */
152
+ export function childText(node, name) {
153
+ const child = node.children.find((c) => c.name === name);
154
+ const text = child?.text.trim();
155
+ return text === undefined || text === '' ? undefined : text;
156
+ }
157
+ //# sourceMappingURL=xml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml.js","sourceRoot":"","sources":["../../src/import/xml.ts"],"names":[],"mappings":"AAqBA,MAAM,QAAQ,GAAqC,MAAM,CAAC,MAAM,CAAC;IAC/D,GAAG,EAAE,GAAG;IACR,EAAE,EAAE,GAAG;IACP,EAAE,EAAE,GAAG;IACP,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;CACV,CAAC,CAAC;AAEH,sEAAsE;AACtE,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;QACxE,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,GACR,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7F,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,QAAQ;gBAC3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EAAE,IAAY;IACjD,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,CAAC,OAAgB,EAAE,EAAE;QAChC,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,OAAO,KAAK,CAAC;AACf,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS,CAAC,IAAa,EAAE,IAAY;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { Finding } from '../finding.js';
2
+ import type { ImportOptions } from './nuclei.js';
3
+ /**
4
+ * Turns a ZAP JSON report into {@link Finding}s.
5
+ *
6
+ * **One finding per instance, not per alert.** ZAP groups every occurrence of a
7
+ * weakness under a single alert with an `instances` array, so an alert is a
8
+ * class and an instance is a detection. Flattening is what lets two URLs
9
+ * affected by the same rule become two issues, and lets one of them be fixed
10
+ * without closing the other.
11
+ *
12
+ * An alert with no instances still produces one finding, against the site — a
13
+ * detection with no location is still a detection.
14
+ *
15
+ * Severity comes from ZAP's `riskcode`; see `ZAP_RISK` below for why nothing
16
+ * here is ever `critical`.
17
+ *
18
+ * @param json - The contents of a ZAP JSON report.
19
+ * @param options - Ownership, and the injected clock and id source.
20
+ * @returns One finding per instance, in report order.
21
+ * @throws SyntaxError If the report is not valid JSON. Unlike Nuclei's JSONL,
22
+ * where one bad line costs one record, a ZAP report is a single document: if it
23
+ * will not parse there is nothing to salvage and silence would be a lie.
24
+ */
25
+ export declare function importZap(json: string, options: ImportOptions): Finding[];
26
+ //# sourceMappingURL=zap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zap.d.ts","sourceRoot":"","sources":["../../src/import/zap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoEjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,EAAE,CAmEzE"}