@vltpkg/query 0.0.0-0.1730239248325 → 0.0.0-10

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 (218) hide show
  1. package/README.md +12 -70
  2. package/dist/esm/attribute.d.ts +1 -1
  3. package/dist/esm/attribute.d.ts.map +1 -1
  4. package/dist/esm/attribute.js +14 -5
  5. package/dist/esm/attribute.js.map +1 -1
  6. package/dist/esm/combinator.d.ts +1 -1
  7. package/dist/esm/combinator.d.ts.map +1 -1
  8. package/dist/esm/combinator.js +6 -2
  9. package/dist/esm/combinator.js.map +1 -1
  10. package/dist/esm/id.d.ts +1 -1
  11. package/dist/esm/id.d.ts.map +1 -1
  12. package/dist/esm/id.js +21 -7
  13. package/dist/esm/id.js.map +1 -1
  14. package/dist/esm/index.d.ts +22 -4
  15. package/dist/esm/index.d.ts.map +1 -1
  16. package/dist/esm/index.js +250 -17
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/parser.d.ts +15 -0
  19. package/dist/esm/parser.d.ts.map +1 -0
  20. package/dist/esm/parser.js +92 -0
  21. package/dist/esm/parser.js.map +1 -0
  22. package/dist/esm/pseudo/abandoned.d.ts +7 -0
  23. package/dist/esm/pseudo/abandoned.d.ts.map +1 -0
  24. package/dist/esm/pseudo/abandoned.js +6 -0
  25. package/dist/esm/pseudo/abandoned.js.map +1 -0
  26. package/dist/esm/pseudo/attr.d.ts +18 -0
  27. package/dist/esm/pseudo/attr.d.ts.map +1 -0
  28. package/dist/esm/pseudo/attr.js +58 -0
  29. package/dist/esm/pseudo/attr.js.map +1 -0
  30. package/dist/esm/pseudo/confused.d.ts +7 -0
  31. package/dist/esm/pseudo/confused.d.ts.map +1 -0
  32. package/dist/esm/pseudo/confused.js +6 -0
  33. package/dist/esm/pseudo/confused.js.map +1 -0
  34. package/dist/esm/pseudo/cve.d.ts +12 -0
  35. package/dist/esm/pseudo/cve.d.ts.map +1 -0
  36. package/dist/esm/pseudo/cve.js +44 -0
  37. package/dist/esm/pseudo/cve.js.map +1 -0
  38. package/dist/esm/pseudo/cwe.d.ts +12 -0
  39. package/dist/esm/pseudo/cwe.d.ts.map +1 -0
  40. package/dist/esm/pseudo/cwe.js +43 -0
  41. package/dist/esm/pseudo/cwe.js.map +1 -0
  42. package/dist/esm/pseudo/debug.d.ts +7 -0
  43. package/dist/esm/pseudo/debug.d.ts.map +1 -0
  44. package/dist/esm/pseudo/debug.js +6 -0
  45. package/dist/esm/pseudo/debug.js.map +1 -0
  46. package/dist/esm/pseudo/deprecated.d.ts +7 -0
  47. package/dist/esm/pseudo/deprecated.d.ts.map +1 -0
  48. package/dist/esm/pseudo/deprecated.js +6 -0
  49. package/dist/esm/pseudo/deprecated.js.map +1 -0
  50. package/dist/esm/pseudo/dev.d.ts +6 -0
  51. package/dist/esm/pseudo/dev.d.ts.map +1 -0
  52. package/dist/esm/pseudo/dev.js +15 -0
  53. package/dist/esm/pseudo/dev.js.map +1 -0
  54. package/dist/esm/pseudo/dynamic.d.ts +7 -0
  55. package/dist/esm/pseudo/dynamic.d.ts.map +1 -0
  56. package/dist/esm/pseudo/dynamic.js +6 -0
  57. package/dist/esm/pseudo/dynamic.js.map +1 -0
  58. package/dist/esm/pseudo/empty.d.ts +7 -0
  59. package/dist/esm/pseudo/empty.d.ts.map +1 -0
  60. package/dist/esm/pseudo/empty.js +14 -0
  61. package/dist/esm/pseudo/empty.js.map +1 -0
  62. package/dist/esm/pseudo/entropic.d.ts +7 -0
  63. package/dist/esm/pseudo/entropic.d.ts.map +1 -0
  64. package/dist/esm/pseudo/entropic.js +6 -0
  65. package/dist/esm/pseudo/entropic.js.map +1 -0
  66. package/dist/esm/pseudo/env.d.ts +7 -0
  67. package/dist/esm/pseudo/env.d.ts.map +1 -0
  68. package/dist/esm/pseudo/env.js +6 -0
  69. package/dist/esm/pseudo/env.js.map +1 -0
  70. package/dist/esm/pseudo/eval.d.ts +7 -0
  71. package/dist/esm/pseudo/eval.d.ts.map +1 -0
  72. package/dist/esm/pseudo/eval.js +6 -0
  73. package/dist/esm/pseudo/eval.js.map +1 -0
  74. package/dist/esm/pseudo/fs.d.ts +7 -0
  75. package/dist/esm/pseudo/fs.d.ts.map +1 -0
  76. package/dist/esm/pseudo/fs.js +6 -0
  77. package/dist/esm/pseudo/fs.js.map +1 -0
  78. package/dist/esm/pseudo/helpers.d.ts +35 -0
  79. package/dist/esm/pseudo/helpers.d.ts.map +1 -0
  80. package/dist/esm/pseudo/helpers.js +69 -0
  81. package/dist/esm/pseudo/helpers.js.map +1 -0
  82. package/dist/esm/pseudo/license.d.ts +12 -0
  83. package/dist/esm/pseudo/license.d.ts.map +1 -0
  84. package/dist/esm/pseudo/license.js +58 -0
  85. package/dist/esm/pseudo/license.js.map +1 -0
  86. package/dist/esm/pseudo/link.d.ts +9 -0
  87. package/dist/esm/pseudo/link.d.ts.map +1 -0
  88. package/dist/esm/pseudo/link.js +25 -0
  89. package/dist/esm/pseudo/link.js.map +1 -0
  90. package/dist/esm/pseudo/malware.d.ts +14 -0
  91. package/dist/esm/pseudo/malware.d.ts.map +1 -0
  92. package/dist/esm/pseudo/malware.js +165 -0
  93. package/dist/esm/pseudo/malware.js.map +1 -0
  94. package/dist/esm/pseudo/minified.d.ts +7 -0
  95. package/dist/esm/pseudo/minified.d.ts.map +1 -0
  96. package/dist/esm/pseudo/minified.js +6 -0
  97. package/dist/esm/pseudo/minified.js.map +1 -0
  98. package/dist/esm/pseudo/missing.d.ts +8 -0
  99. package/dist/esm/pseudo/missing.d.ts.map +1 -0
  100. package/dist/esm/pseudo/missing.js +15 -0
  101. package/dist/esm/pseudo/missing.js.map +1 -0
  102. package/dist/esm/pseudo/native.d.ts +7 -0
  103. package/dist/esm/pseudo/native.d.ts.map +1 -0
  104. package/dist/esm/pseudo/native.js +6 -0
  105. package/dist/esm/pseudo/native.js.map +1 -0
  106. package/dist/esm/pseudo/network.d.ts +7 -0
  107. package/dist/esm/pseudo/network.d.ts.map +1 -0
  108. package/dist/esm/pseudo/network.js +6 -0
  109. package/dist/esm/pseudo/network.js.map +1 -0
  110. package/dist/esm/pseudo/obfuscated.d.ts +7 -0
  111. package/dist/esm/pseudo/obfuscated.d.ts.map +1 -0
  112. package/dist/esm/pseudo/obfuscated.js +6 -0
  113. package/dist/esm/pseudo/obfuscated.js.map +1 -0
  114. package/dist/esm/pseudo/optional.d.ts +6 -0
  115. package/dist/esm/pseudo/optional.d.ts.map +1 -0
  116. package/dist/esm/pseudo/optional.js +15 -0
  117. package/dist/esm/pseudo/optional.js.map +1 -0
  118. package/dist/esm/pseudo/outdated.d.ts +54 -0
  119. package/dist/esm/pseudo/outdated.d.ts.map +1 -0
  120. package/dist/esm/pseudo/outdated.js +212 -0
  121. package/dist/esm/pseudo/outdated.js.map +1 -0
  122. package/dist/esm/pseudo/peer.d.ts +6 -0
  123. package/dist/esm/pseudo/peer.d.ts.map +1 -0
  124. package/dist/esm/pseudo/peer.js +15 -0
  125. package/dist/esm/pseudo/peer.js.map +1 -0
  126. package/dist/esm/pseudo/private.d.ts +7 -0
  127. package/dist/esm/pseudo/private.d.ts.map +1 -0
  128. package/dist/esm/pseudo/private.js +16 -0
  129. package/dist/esm/pseudo/private.js.map +1 -0
  130. package/dist/esm/pseudo/prod.d.ts +6 -0
  131. package/dist/esm/pseudo/prod.d.ts.map +1 -0
  132. package/dist/esm/pseudo/prod.js +15 -0
  133. package/dist/esm/pseudo/prod.js.map +1 -0
  134. package/dist/esm/pseudo/published.d.ts +40 -0
  135. package/dist/esm/pseudo/published.d.ts.map +1 -0
  136. package/dist/esm/pseudo/published.js +159 -0
  137. package/dist/esm/pseudo/published.js.map +1 -0
  138. package/dist/esm/pseudo/scanned.d.ts +9 -0
  139. package/dist/esm/pseudo/scanned.d.ts.map +1 -0
  140. package/dist/esm/pseudo/scanned.js +17 -0
  141. package/dist/esm/pseudo/scanned.js.map +1 -0
  142. package/dist/esm/pseudo/score.d.ts +15 -0
  143. package/dist/esm/pseudo/score.d.ts.map +1 -0
  144. package/dist/esm/pseudo/score.js +119 -0
  145. package/dist/esm/pseudo/score.js.map +1 -0
  146. package/dist/esm/pseudo/scripts.d.ts +7 -0
  147. package/dist/esm/pseudo/scripts.d.ts.map +1 -0
  148. package/dist/esm/pseudo/scripts.js +6 -0
  149. package/dist/esm/pseudo/scripts.js.map +1 -0
  150. package/dist/esm/pseudo/semver.d.ts +16 -0
  151. package/dist/esm/pseudo/semver.d.ts.map +1 -0
  152. package/dist/esm/pseudo/semver.js +166 -0
  153. package/dist/esm/pseudo/semver.js.map +1 -0
  154. package/dist/esm/pseudo/severity.d.ts +14 -0
  155. package/dist/esm/pseudo/severity.d.ts.map +1 -0
  156. package/dist/esm/pseudo/severity.js +160 -0
  157. package/dist/esm/pseudo/severity.js.map +1 -0
  158. package/dist/esm/pseudo/shell.d.ts +7 -0
  159. package/dist/esm/pseudo/shell.d.ts.map +1 -0
  160. package/dist/esm/pseudo/shell.js +6 -0
  161. package/dist/esm/pseudo/shell.js.map +1 -0
  162. package/dist/esm/pseudo/shrinkwrap.d.ts +7 -0
  163. package/dist/esm/pseudo/shrinkwrap.d.ts.map +1 -0
  164. package/dist/esm/pseudo/shrinkwrap.js +6 -0
  165. package/dist/esm/pseudo/shrinkwrap.js.map +1 -0
  166. package/dist/esm/pseudo/squat.d.ts +14 -0
  167. package/dist/esm/pseudo/squat.d.ts.map +1 -0
  168. package/dist/esm/pseudo/squat.js +161 -0
  169. package/dist/esm/pseudo/squat.js.map +1 -0
  170. package/dist/esm/pseudo/suspicious.d.ts +7 -0
  171. package/dist/esm/pseudo/suspicious.d.ts.map +1 -0
  172. package/dist/esm/pseudo/suspicious.js +6 -0
  173. package/dist/esm/pseudo/suspicious.js.map +1 -0
  174. package/dist/esm/pseudo/tracker.d.ts +7 -0
  175. package/dist/esm/pseudo/tracker.d.ts.map +1 -0
  176. package/dist/esm/pseudo/tracker.js +6 -0
  177. package/dist/esm/pseudo/tracker.js.map +1 -0
  178. package/dist/esm/pseudo/trivial.d.ts +7 -0
  179. package/dist/esm/pseudo/trivial.d.ts.map +1 -0
  180. package/dist/esm/pseudo/trivial.js +6 -0
  181. package/dist/esm/pseudo/trivial.js.map +1 -0
  182. package/dist/esm/pseudo/undesirable.d.ts +7 -0
  183. package/dist/esm/pseudo/undesirable.d.ts.map +1 -0
  184. package/dist/esm/pseudo/undesirable.js +6 -0
  185. package/dist/esm/pseudo/undesirable.js.map +1 -0
  186. package/dist/esm/pseudo/unknown.d.ts +7 -0
  187. package/dist/esm/pseudo/unknown.d.ts.map +1 -0
  188. package/dist/esm/pseudo/unknown.js +6 -0
  189. package/dist/esm/pseudo/unknown.js.map +1 -0
  190. package/dist/esm/pseudo/unmaintained.d.ts +7 -0
  191. package/dist/esm/pseudo/unmaintained.d.ts.map +1 -0
  192. package/dist/esm/pseudo/unmaintained.js +6 -0
  193. package/dist/esm/pseudo/unmaintained.js.map +1 -0
  194. package/dist/esm/pseudo/unpopular.d.ts +7 -0
  195. package/dist/esm/pseudo/unpopular.d.ts.map +1 -0
  196. package/dist/esm/pseudo/unpopular.js +6 -0
  197. package/dist/esm/pseudo/unpopular.js.map +1 -0
  198. package/dist/esm/pseudo/unstable.d.ts +7 -0
  199. package/dist/esm/pseudo/unstable.d.ts.map +1 -0
  200. package/dist/esm/pseudo/unstable.js +6 -0
  201. package/dist/esm/pseudo/unstable.js.map +1 -0
  202. package/dist/esm/pseudo/workspace.d.ts +6 -0
  203. package/dist/esm/pseudo/workspace.d.ts.map +1 -0
  204. package/dist/esm/pseudo/workspace.js +15 -0
  205. package/dist/esm/pseudo/workspace.js.map +1 -0
  206. package/dist/esm/pseudo.d.ts +1 -8
  207. package/dist/esm/pseudo.d.ts.map +1 -1
  208. package/dist/esm/pseudo.js +115 -122
  209. package/dist/esm/pseudo.js.map +1 -1
  210. package/dist/esm/types.d.ts +85 -8
  211. package/dist/esm/types.d.ts.map +1 -1
  212. package/dist/esm/types.js +29 -16
  213. package/dist/esm/types.js.map +1 -1
  214. package/package.json +28 -19
  215. package/dist/esm/class.d.ts +0 -6
  216. package/dist/esm/class.d.ts.map +0 -1
  217. package/dist/esm/class.js +0 -127
  218. package/dist/esm/class.js.map +0 -1
@@ -0,0 +1,58 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asAttributeNode, asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, } from "../types.js";
3
+ import { attributeSelectorsMap, filterAttributes, } from "../attribute.js";
4
+ import { removeQuotes } from "./helpers.js";
5
+ /**
6
+ * Parses the internal / nested selectors of a `:attr` selector.
7
+ */
8
+ export const parseInternals = (nodes) => {
9
+ // the last part is the attribute selector
10
+ const attributeSelector = asAttributeNode(asPostcssNodeWithChildren(nodes.pop()).nodes[0]);
11
+ // all preppending selectors are naming nested properties
12
+ const properties = [];
13
+ for (const selector of nodes) {
14
+ const selectorNode = asPostcssNodeWithChildren(selector).nodes[0];
15
+ // Handle both quoted string and tag nodes
16
+ if (isStringNode(selectorNode)) {
17
+ properties.push(removeQuotes(asStringNode(selectorNode).value));
18
+ }
19
+ else {
20
+ properties.push(asTagNode(selectorNode).value);
21
+ }
22
+ }
23
+ // include the attribute selector as the last part of the property lookup
24
+ properties.push(attributeSelector.attribute);
25
+ return {
26
+ attribute: attributeSelector.attribute,
27
+ insensitive: attributeSelector.insensitive || false,
28
+ operator: attributeSelector.operator,
29
+ value: attributeSelector.value,
30
+ properties,
31
+ };
32
+ };
33
+ /**
34
+ * :attr Pseudo-Selector, allows for retrieving nodes based on nested
35
+ * properties of the `package.json` metadata.
36
+ */
37
+ export const attr = async (state) => {
38
+ // Parses and retrieves the values for the nested selectors
39
+ let internals;
40
+ try {
41
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
42
+ }
43
+ catch (err) {
44
+ throw error('Failed to parse :attr selector', {
45
+ cause: err,
46
+ });
47
+ }
48
+ // reuses the attribute selector logic to filter the nodes
49
+ const comparator = internals.operator ?
50
+ attributeSelectorsMap.get(internals.operator)
51
+ : undefined;
52
+ const value = internals.value || '';
53
+ const propertyName = internals.attribute;
54
+ const insensitive = internals.insensitive;
55
+ const prefixProperties = internals.properties;
56
+ return filterAttributes(state, comparator, value, propertyName, insensitive, prefixProperties);
57
+ };
58
+ //# sourceMappingURL=attr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attr.js","sourceRoot":"","sources":["../../../src/pseudo/attr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAU3C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACL,EAAE;IACjB,0CAA0C;IAC1C,MAAM,iBAAiB,GAAG,eAAe,CACvC,yBAAyB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAChD,CAAA;IACD,yDAAyD;IACzD,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACjE,0CAA0C;QAC1C,IAAI,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/B,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;QACjE,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IACD,yEAAyE;IACzE,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAE5C,OAAO;QACL,SAAS,EAAE,iBAAiB,CAAC,SAAS;QACtC,WAAW,EAAE,iBAAiB,CAAC,WAAW,IAAI,KAAK;QACnD,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;QACpC,KAAK,EAAE,iBAAiB,CAAC,KAAK;QAC9B,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC/C,2DAA2D;IAC3D,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,cAAc,CACxB,yBAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAC/C,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,CAAC,gCAAgC,EAAE;YAC5C,KAAK,EAAE,GAAG;SACX,CAAC,CAAA;IACJ,CAAC;IAED,0DAA0D;IAC1D,MAAM,UAAU,GACd,SAAS,CAAC,QAAQ,CAAC,CAAC;QAClB,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC;QAC/C,CAAC,CAAC,SAAS,CAAA;IACb,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,EAAE,CAAA;IACnC,MAAM,YAAY,GAAG,SAAS,CAAC,SAAS,CAAA;IACxC,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAA;IACzC,MAAM,gBAAgB,GAAG,SAAS,CAAC,UAAU,CAAA;IAC7C,OAAO,gBAAgB,CACrB,KAAK,EACL,UAAU,EACV,KAAK,EACL,YAAY,EACZ,WAAW,EACX,gBAAgB,CACjB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {\n asAttributeNode,\n asPostcssNodeWithChildren,\n asStringNode,\n asTagNode,\n isStringNode,\n} from '../types.ts'\nimport type { ParserState, PostcssNode } from '../types.ts'\nimport {\n attributeSelectorsMap,\n filterAttributes,\n} from '../attribute.ts'\nimport { removeQuotes } from './helpers.ts'\n\nexport type AttrInternals = {\n attribute: string\n insensitive: boolean\n operator?: string\n value?: string\n properties: string[]\n}\n\n/**\n * Parses the internal / nested selectors of a `:attr` selector.\n */\nexport const parseInternals = (\n nodes: PostcssNode[],\n): AttrInternals => {\n // the last part is the attribute selector\n const attributeSelector = asAttributeNode(\n asPostcssNodeWithChildren(nodes.pop()).nodes[0],\n )\n // all preppending selectors are naming nested properties\n const properties: string[] = []\n for (const selector of nodes) {\n const selectorNode = asPostcssNodeWithChildren(selector).nodes[0]\n // Handle both quoted string and tag nodes\n if (isStringNode(selectorNode)) {\n properties.push(removeQuotes(asStringNode(selectorNode).value))\n } else {\n properties.push(asTagNode(selectorNode).value)\n }\n }\n // include the attribute selector as the last part of the property lookup\n properties.push(attributeSelector.attribute)\n\n return {\n attribute: attributeSelector.attribute,\n insensitive: attributeSelector.insensitive || false,\n operator: attributeSelector.operator,\n value: attributeSelector.value,\n properties,\n }\n}\n\n/**\n * :attr Pseudo-Selector, allows for retrieving nodes based on nested\n * properties of the `package.json` metadata.\n */\nexport const attr = async (state: ParserState) => {\n // Parses and retrieves the values for the nested selectors\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :attr selector', {\n cause: err,\n })\n }\n\n // reuses the attribute selector logic to filter the nodes\n const comparator =\n internals.operator ?\n attributeSelectorsMap.get(internals.operator)\n : undefined\n const value = internals.value || ''\n const propertyName = internals.attribute\n const insensitive = internals.insensitive\n const prefixProperties = internals.properties\n return filterAttributes(\n state,\n comparator,\n value,\n propertyName,\n insensitive,\n prefixProperties,\n )\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **manifestConfusion** report alert.
3
+ */
4
+ export declare const confused: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=confused.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confused.d.ts","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ;;EAGpB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **manifestConfusion** report alert.
4
+ */
5
+ export const confused = createSecuritySelectorFilter('confused', 'manifestConfusion');
6
+ //# sourceMappingURL=confused.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confused.js","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,4BAA4B,CAClD,UAAU,EACV,mBAAmB,CACpB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **manifestConfusion** report alert.\n */\nexport const confused = createSecuritySelectorFilter(\n 'confused',\n 'manifestConfusion',\n)\n"]}
@@ -0,0 +1,12 @@
1
+ import type { ParserState, PostcssNode } from '../types.ts';
2
+ export type CveInternals = {
3
+ cveId: string;
4
+ };
5
+ export declare const parseInternals: (nodes: PostcssNode[]) => CveInternals;
6
+ /**
7
+ * Filters out any node that does not have a CVE alert with the specified CVE ID.
8
+ */
9
+ export declare const cve: (state: ParserState) => Promise<ParserState & {
10
+ securityArchive: NonNullable<ParserState["securityArchive"]>;
11
+ }>;
12
+ //# sourceMappingURL=cve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cve.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB,YAuBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW;;EA4B3C,CAAA"}
@@ -0,0 +1,44 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
3
+ import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
4
+ export const parseInternals = (nodes) => {
5
+ let cveId = '';
6
+ if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
7
+ cveId = removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
8
+ .value);
9
+ }
10
+ else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
11
+ cveId = asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value;
12
+ }
13
+ if (!cveId) {
14
+ throw error('Expected a CVE ID', {
15
+ found: asPostcssNodeWithChildren(nodes[0]).nodes[0],
16
+ });
17
+ }
18
+ return { cveId };
19
+ };
20
+ /**
21
+ * Filters out any node that does not have a CVE alert with the specified CVE ID.
22
+ */
23
+ export const cve = async (state) => {
24
+ assertSecurityArchive(state, 'cve');
25
+ let internals;
26
+ try {
27
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
28
+ }
29
+ catch (err) {
30
+ throw error('Failed to parse :cve selector', { cause: err });
31
+ }
32
+ const { cveId } = internals;
33
+ for (const node of state.partial.nodes) {
34
+ const report = state.securityArchive.get(node.id);
35
+ const exclude = !report?.alerts.some(alert => alert.props?.cveId?.trim().toLowerCase() ===
36
+ cveId.trim().toLowerCase());
37
+ if (exclude) {
38
+ removeNode(state, node);
39
+ }
40
+ }
41
+ removeDanglingEdges(state);
42
+ return state;
43
+ };
44
+ //# sourceMappingURL=cve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cve.js","sourceRoot":"","sources":["../../../src/pseudo/cve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAMrB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACN,EAAE;IAChB,IAAI,KAAK,GAAG,EAAE,CAAA;IAEd,IAAI,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,KAAK,GAAG,YAAY,CAClB,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACvD,KAAK,CACT,CAAA;IACH,CAAC;SAAM,IACL,SAAS,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACvD,CAAC;QACD,KAAK,GAAG,SAAS,CACf,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAC7C,CAAC,KAAK,CAAA;IACT,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC,mBAAmB,EAAE;YAC/B,KAAK,EAAE,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SACpD,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC9C,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAEnC,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,cAAc,CACxB,yBAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAC/C,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAA;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CACN,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE;YACxC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAC7B,CAAA;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAE1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {\n asPostcssNodeWithChildren,\n asStringNode,\n asTagNode,\n isStringNode,\n isTagNode,\n} from '../types.ts'\nimport type { ParserState, PostcssNode } from '../types.ts'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type CveInternals = {\n cveId: string\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): CveInternals => {\n let cveId = ''\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n cveId = removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n cveId = asTagNode(\n asPostcssNodeWithChildren(nodes[0]).nodes[0],\n ).value\n }\n\n if (!cveId) {\n throw error('Expected a CVE ID', {\n found: asPostcssNodeWithChildren(nodes[0]).nodes[0],\n })\n }\n\n return { cveId }\n}\n\n/**\n * Filters out any node that does not have a CVE alert with the specified CVE ID.\n */\nexport const cve = async (state: ParserState) => {\n assertSecurityArchive(state, 'cve')\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :cve selector', { cause: err })\n }\n\n const { cveId } = internals\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert =>\n alert.props?.cveId?.trim().toLowerCase() ===\n cveId.trim().toLowerCase(),\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { ParserState, PostcssNode } from '../types.ts';
2
+ export type CweInternals = {
3
+ cweId: string;
4
+ };
5
+ export declare const parseInternals: (nodes: PostcssNode[]) => CweInternals;
6
+ /**
7
+ * Filters out any node that does not have a CWE alert with the specified CWE ID.
8
+ */
9
+ export declare const cwe: (state: ParserState) => Promise<ParserState & {
10
+ securityArchive: NonNullable<ParserState["securityArchive"]>;
11
+ }>;
12
+ //# sourceMappingURL=cwe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cwe.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cwe.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB,YAuBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW;;EA6B3C,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
3
+ import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
4
+ export const parseInternals = (nodes) => {
5
+ let cweId = '';
6
+ if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
7
+ cweId = removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
8
+ .value);
9
+ }
10
+ else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
11
+ cweId = asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value;
12
+ }
13
+ if (!cweId) {
14
+ throw error('Expected a CWE ID', {
15
+ found: asPostcssNodeWithChildren(nodes[0]).nodes[0],
16
+ });
17
+ }
18
+ return { cweId };
19
+ };
20
+ /**
21
+ * Filters out any node that does not have a CWE alert with the specified CWE ID.
22
+ */
23
+ export const cwe = async (state) => {
24
+ assertSecurityArchive(state, 'cwe');
25
+ let internals;
26
+ try {
27
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
28
+ }
29
+ catch (err) {
30
+ throw error('Failed to parse :cwe selector', { cause: err });
31
+ }
32
+ const { cweId } = internals;
33
+ for (const node of state.partial.nodes) {
34
+ const report = state.securityArchive.get(node.id);
35
+ const exclude = !report?.alerts.some(alert => alert.props?.cwes?.some(cwe => cwe.id.trim().toLowerCase() === cweId.trim().toLowerCase()));
36
+ if (exclude) {
37
+ removeNode(state, node);
38
+ }
39
+ }
40
+ removeDanglingEdges(state);
41
+ return state;
42
+ };
43
+ //# sourceMappingURL=cwe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cwe.js","sourceRoot":"","sources":["../../../src/pseudo/cwe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAMrB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACN,EAAE;IAChB,IAAI,KAAK,GAAG,EAAE,CAAA;IAEd,IAAI,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,KAAK,GAAG,YAAY,CAClB,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACvD,KAAK,CACT,CAAA;IACH,CAAC;SAAM,IACL,SAAS,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACvD,CAAC;QACD,KAAK,GAAG,SAAS,CACf,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAC7C,CAAC,KAAK,CAAA;IACT,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,CAAC,mBAAmB,EAAE;YAC/B,KAAK,EAAE,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SACpD,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC9C,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAEnC,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,cAAc,CACxB,yBAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAC/C,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,CAAC,+BAA+B,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAA;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAC3C,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CACrB,GAAG,CAAC,EAAE,CACJ,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAC7D,CACF,CAAA;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAE1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {\n asPostcssNodeWithChildren,\n asStringNode,\n asTagNode,\n isStringNode,\n isTagNode,\n} from '../types.ts'\nimport type { ParserState, PostcssNode } from '../types.ts'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type CweInternals = {\n cweId: string\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): CweInternals => {\n let cweId = ''\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n cweId = removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n cweId = asTagNode(\n asPostcssNodeWithChildren(nodes[0]).nodes[0],\n ).value\n }\n\n if (!cweId) {\n throw error('Expected a CWE ID', {\n found: asPostcssNodeWithChildren(nodes[0]).nodes[0],\n })\n }\n\n return { cweId }\n}\n\n/**\n * Filters out any node that does not have a CWE alert with the specified CWE ID.\n */\nexport const cwe = async (state: ParserState) => {\n assertSecurityArchive(state, 'cwe')\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :cwe selector', { cause: err })\n }\n\n const { cweId } = internals\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(alert =>\n alert.props?.cwes?.some(\n cwe =>\n cwe.id.trim().toLowerCase() === cweId.trim().toLowerCase(),\n ),\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **debugAccess** report alert.
3
+ */
4
+ export declare const debug: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/pseudo/debug.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,KAAK;;EAGjB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **debugAccess** report alert.
4
+ */
5
+ export const debug = createSecuritySelectorFilter('debug', 'debugAccess');
6
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/pseudo/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,4BAA4B,CAC/C,OAAO,EACP,aAAa,CACd,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **debugAccess** report alert.\n */\nexport const debug = createSecuritySelectorFilter(\n 'debug',\n 'debugAccess',\n)\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **deprecated** report alert.
3
+ */
4
+ export declare const deprecated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=deprecated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/deprecated.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;EAGtB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **deprecated** report alert.
4
+ */
5
+ export const deprecated = createSecuritySelectorFilter('deprecated', 'deprecated');
6
+ //# sourceMappingURL=deprecated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../../src/pseudo/deprecated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,4BAA4B,CACpD,YAAY,EACZ,YAAY,CACb,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **deprecated** report alert.\n */\nexport const deprecated = createSecuritySelectorFilter(\n 'deprecated',\n 'deprecated',\n)\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ParserState } from '../types.ts';
2
+ /**
3
+ * :dev Pseudo-Selector will only match devDependencies.
4
+ */
5
+ export declare const dev: (state: ParserState) => Promise<ParserState>;
6
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/pseudo/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;GAEG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW,yBAW3C,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { removeEdge, removeUnlinkedNodes } from "./helpers.js";
2
+ /**
3
+ * :dev Pseudo-Selector will only match devDependencies.
4
+ */
5
+ export const dev = async (state) => {
6
+ // filter edges that don't have type 'dev'
7
+ for (const edge of state.partial.edges) {
8
+ if (edge.type !== 'dev') {
9
+ removeEdge(state, edge);
10
+ }
11
+ }
12
+ removeUnlinkedNodes(state);
13
+ return state;
14
+ };
15
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/pseudo/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC9C,0CAA0C;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAE1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { ParserState } from '../types.ts'\nimport { removeEdge, removeUnlinkedNodes } from './helpers.ts'\n\n/**\n * :dev Pseudo-Selector will only match devDependencies.\n */\nexport const dev = async (state: ParserState) => {\n // filter edges that don't have type 'dev'\n for (const edge of state.partial.edges) {\n if (edge.type !== 'dev') {\n removeEdge(state, edge)\n }\n }\n\n removeUnlinkedNodes(state)\n\n return state\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **dynamicRequire** report alert.
3
+ */
4
+ export declare const dynamic: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=dynamic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../src/pseudo/dynamic.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO;;EAGnB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **dynamicRequire** report alert.
4
+ */
5
+ export const dynamic = createSecuritySelectorFilter('dynamic', 'dynamicRequire');
6
+ //# sourceMappingURL=dynamic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic.js","sourceRoot":"","sources":["../../../src/pseudo/dynamic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CACjD,SAAS,EACT,gBAAgB,CACjB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **dynamicRequire** report alert.\n */\nexport const dynamic = createSecuritySelectorFilter(\n 'dynamic',\n 'dynamicRequire',\n)\n"]}
@@ -0,0 +1,7 @@
1
+ import type { ParserState } from '../types.ts';
2
+ /**
3
+ * :empty Pseudo-Selector, matches only nodes that have no children.
4
+ * It filters out any node that has edges out, i.e., has dependencies.
5
+ */
6
+ export declare const empty: (state: ParserState) => Promise<ParserState>;
7
+ //# sourceMappingURL=empty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../../src/pseudo/empty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;GAGG;AACH,eAAO,MAAM,KAAK,UAAiB,WAAW,yBAO7C,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { removeNode } from "./helpers.js";
2
+ /**
3
+ * :empty Pseudo-Selector, matches only nodes that have no children.
4
+ * It filters out any node that has edges out, i.e., has dependencies.
5
+ */
6
+ export const empty = async (state) => {
7
+ for (const node of state.partial.nodes) {
8
+ if (node.edgesOut.size > 0) {
9
+ removeNode(state, node);
10
+ }
11
+ }
12
+ return state;
13
+ };
14
+ //# sourceMappingURL=empty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty.js","sourceRoot":"","sources":["../../../src/pseudo/empty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC3B,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { ParserState } from '../types.ts'\nimport { removeNode } from './helpers.ts'\n\n/**\n * :empty Pseudo-Selector, matches only nodes that have no children.\n * It filters out any node that has edges out, i.e., has dependencies.\n */\nexport const empty = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesOut.size > 0) {\n removeNode(state, node)\n }\n }\n return state\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **highEntropyStrings** report alert.
3
+ */
4
+ export declare const entropic: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=entropic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entropic.d.ts","sourceRoot":"","sources":["../../../src/pseudo/entropic.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ;;EAGpB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **highEntropyStrings** report alert.
4
+ */
5
+ export const entropic = createSecuritySelectorFilter('entropic', 'highEntropyStrings');
6
+ //# sourceMappingURL=entropic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entropic.js","sourceRoot":"","sources":["../../../src/pseudo/entropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,4BAA4B,CAClD,UAAU,EACV,oBAAoB,CACrB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **highEntropyStrings** report alert.\n */\nexport const entropic = createSecuritySelectorFilter(\n 'entropic',\n 'highEntropyStrings',\n)\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **envVars** report alert.
3
+ */
4
+ export declare const env: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/pseudo/env.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,GAAG;;EAAiD,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **envVars** report alert.
4
+ */
5
+ export const env = createSecuritySelectorFilter('env', 'envVars');
6
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/pseudo/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **envVars** report alert.\n */\nexport const env = createSecuritySelectorFilter('env', 'envVars')\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **usesEval** report alert.
3
+ */
4
+ export declare const evalParser: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../../src/pseudo/eval.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;EAGtB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **usesEval** report alert.
4
+ */
5
+ export const evalParser = createSecuritySelectorFilter('eval', 'usesEval');
6
+ //# sourceMappingURL=eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval.js","sourceRoot":"","sources":["../../../src/pseudo/eval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,4BAA4B,CACpD,MAAM,EACN,UAAU,CACX,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **usesEval** report alert.\n */\nexport const evalParser = createSecuritySelectorFilter(\n 'eval',\n 'usesEval',\n)\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Filters out any node that does not have a **filesystemAccess** report alert.
3
+ */
4
+ export declare const fs: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
5
+ securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
6
+ }>;
7
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/pseudo/fs.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,EAAE;;EAGd,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **filesystemAccess** report alert.
4
+ */
5
+ export const fs = createSecuritySelectorFilter('fs', 'filesystemAccess');
6
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/pseudo/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,4BAA4B,CAC5C,IAAI,EACJ,kBAAkB,CACnB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **filesystemAccess** report alert.\n */\nexport const fs = createSecuritySelectorFilter(\n 'fs',\n 'filesystemAccess',\n)\n"]}
@@ -0,0 +1,35 @@
1
+ import type { EdgeLike, NodeLike } from '@vltpkg/graph';
2
+ import type { ParserState } from '../types.js';
3
+ /**
4
+ * Removes a node and its incoming edges from the results.
5
+ */
6
+ export declare const removeNode: (state: ParserState, node: NodeLike) => void;
7
+ /**
8
+ * Removes an edge and its outgoing node from the results.
9
+ */
10
+ export declare const removeEdge: (state: ParserState, edge: EdgeLike) => void;
11
+ /**
12
+ * Removes any edges that have no destination node from the results.
13
+ */
14
+ export declare const removeDanglingEdges: (state: ParserState) => void;
15
+ /**
16
+ * Removes any nodes that have no incoming edges from the results.
17
+ */
18
+ export declare const removeUnlinkedNodes: (state: ParserState) => void;
19
+ /**
20
+ * Removes quotes from a string value.
21
+ */
22
+ export declare const removeQuotes: (value: string) => string;
23
+ /**
24
+ * Asserts that the security archive is present.
25
+ */
26
+ export declare const assertSecurityArchive: (state: ParserState, name: string) => asserts state is ParserState & {
27
+ securityArchive: NonNullable<ParserState['securityArchive']>;
28
+ };
29
+ /**
30
+ * Reusable security selector alert filter.
31
+ */
32
+ export declare const createSecuritySelectorFilter: (name: string, type: string) => (state: ParserState) => Promise<ParserState & {
33
+ securityArchive: NonNullable<ParserState["securityArchive"]>;
34
+ }>;
35
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,WACR,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAClC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,KAAK,IAAI,WAAW,GAAG;IAClC,eAAe,EAAE,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;CAQ7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,SACjC,MAAM,QACN,MAAM,aAES,WAAW;qBAjBf,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;EAkC7D,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ /**
3
+ * Removes a node and its incoming edges from the results.
4
+ */
5
+ export const removeNode = (state, node) => {
6
+ for (const edge of node.edgesIn) {
7
+ state.partial.edges.delete(edge);
8
+ }
9
+ state.partial.nodes.delete(node);
10
+ };
11
+ /**
12
+ * Removes an edge and its outgoing node from the results.
13
+ */
14
+ export const removeEdge = (state, edge) => {
15
+ state.partial.edges.delete(edge);
16
+ if (edge.to) {
17
+ state.partial.nodes.delete(edge.to);
18
+ }
19
+ };
20
+ /**
21
+ * Removes any edges that have no destination node from the results.
22
+ */
23
+ export const removeDanglingEdges = (state) => {
24
+ for (const edge of state.partial.edges) {
25
+ if (!edge.to) {
26
+ state.partial.edges.delete(edge);
27
+ }
28
+ }
29
+ };
30
+ /**
31
+ * Removes any nodes that have no incoming edges from the results.
32
+ */
33
+ export const removeUnlinkedNodes = (state) => {
34
+ for (const node of state.partial.nodes) {
35
+ if (node.edgesIn.size === 0) {
36
+ state.partial.nodes.delete(node);
37
+ }
38
+ }
39
+ };
40
+ /**
41
+ * Removes quotes from a string value.
42
+ */
43
+ export const removeQuotes = (value) => value.replace(/^"(.*?)"$/, '$1');
44
+ /**
45
+ * Asserts that the security archive is present.
46
+ */
47
+ export const assertSecurityArchive = (state, name) => {
48
+ if (!state.securityArchive) {
49
+ throw error(`Missing security archive while trying to parse the :${name} selector`, { found: state });
50
+ }
51
+ };
52
+ /**
53
+ * Reusable security selector alert filter.
54
+ */
55
+ export const createSecuritySelectorFilter = (name, type) => {
56
+ return async (state) => {
57
+ assertSecurityArchive(state, name);
58
+ for (const node of state.partial.nodes) {
59
+ const report = state.securityArchive.get(node.id);
60
+ const exclude = !report?.alerts.some(alert => alert.type === type);
61
+ if (exclude) {
62
+ removeNode(state, node);
63
+ }
64
+ }
65
+ removeDanglingEdges(state);
66
+ return state;
67
+ };
68
+ };
69
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAkB,EAAE,EAAE;IACxD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAkB,EAAE,EAAE;IACxD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC5B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAC5C,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAK9B,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAClB,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC3B,MAAM,KAAK,CACT,uDAAuD,IAAI,WAAW,EACtE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,IAAY,EACZ,IAAY,EACZ,EAAE;IACF,OAAO,KAAK,EAAE,KAAkB,EAAE,EAAE;QAClC,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAElC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAC7B,CAAA;YACD,IAAI,OAAO,EAAE,CAAC;gBACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { ParserState } from '../types.js'\nimport { error } from '@vltpkg/error-cause'\n\n/**\n * Removes a node and its incoming edges from the results.\n */\nexport const removeNode = (state: ParserState, node: NodeLike) => {\n for (const edge of node.edgesIn) {\n state.partial.edges.delete(edge)\n }\n state.partial.nodes.delete(node)\n}\n\n/**\n * Removes an edge and its outgoing node from the results.\n */\nexport const removeEdge = (state: ParserState, edge: EdgeLike) => {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n}\n\n/**\n * Removes any edges that have no destination node from the results.\n */\nexport const removeDanglingEdges = (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n}\n\n/**\n * Removes any nodes that have no incoming edges from the results.\n */\nexport const removeUnlinkedNodes = (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesIn.size === 0) {\n state.partial.nodes.delete(node)\n }\n }\n}\n\n/**\n * Removes quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\n\n/**\n * Asserts that the security archive is present.\n */\nexport const assertSecurityArchive: (\n state: ParserState,\n name: string,\n) => asserts state is ParserState & {\n securityArchive: NonNullable<ParserState['securityArchive']>\n} = (state, name) => {\n if (!state.securityArchive) {\n throw error(\n `Missing security archive while trying to parse the :${name} selector`,\n { found: state },\n )\n }\n}\n\n/**\n * Reusable security selector alert filter.\n */\nexport const createSecuritySelectorFilter = (\n name: string,\n type: string,\n) => {\n return async (state: ParserState) => {\n assertSecurityArchive(state, name)\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert => alert.type === type,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n }\n}\n"]}