@vltpkg/query 0.0.0-5 → 0.0.0-7

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 (136) hide show
  1. package/README.md +107 -1
  2. package/dist/esm/index.d.ts +12 -1
  3. package/dist/esm/index.d.ts.map +1 -1
  4. package/dist/esm/index.js +54 -1
  5. package/dist/esm/index.js.map +1 -1
  6. package/dist/esm/pseudo/abandoned.d.ts +5 -0
  7. package/dist/esm/pseudo/abandoned.d.ts.map +1 -0
  8. package/dist/esm/pseudo/abandoned.js +6 -0
  9. package/dist/esm/pseudo/abandoned.js.map +1 -0
  10. package/dist/esm/pseudo/confused.d.ts +5 -0
  11. package/dist/esm/pseudo/confused.d.ts.map +1 -0
  12. package/dist/esm/pseudo/confused.js +6 -0
  13. package/dist/esm/pseudo/confused.js.map +1 -0
  14. package/dist/esm/pseudo/cve.d.ts +10 -0
  15. package/dist/esm/pseudo/cve.d.ts.map +1 -0
  16. package/dist/esm/pseudo/cve.js +47 -0
  17. package/dist/esm/pseudo/cve.js.map +1 -0
  18. package/dist/esm/pseudo/cwe.d.ts +10 -0
  19. package/dist/esm/pseudo/cwe.d.ts.map +1 -0
  20. package/dist/esm/pseudo/cwe.js +46 -0
  21. package/dist/esm/pseudo/cwe.js.map +1 -0
  22. package/dist/esm/pseudo/debug.d.ts +5 -0
  23. package/dist/esm/pseudo/debug.d.ts.map +1 -0
  24. package/dist/esm/pseudo/debug.js +6 -0
  25. package/dist/esm/pseudo/debug.js.map +1 -0
  26. package/dist/esm/pseudo/deprecated.d.ts +5 -0
  27. package/dist/esm/pseudo/deprecated.d.ts.map +1 -0
  28. package/dist/esm/pseudo/deprecated.js +6 -0
  29. package/dist/esm/pseudo/deprecated.js.map +1 -0
  30. package/dist/esm/pseudo/dynamic.d.ts +5 -0
  31. package/dist/esm/pseudo/dynamic.d.ts.map +1 -0
  32. package/dist/esm/pseudo/dynamic.js +6 -0
  33. package/dist/esm/pseudo/dynamic.js.map +1 -0
  34. package/dist/esm/pseudo/entropic.d.ts +5 -0
  35. package/dist/esm/pseudo/entropic.d.ts.map +1 -0
  36. package/dist/esm/pseudo/entropic.js +6 -0
  37. package/dist/esm/pseudo/entropic.js.map +1 -0
  38. package/dist/esm/pseudo/env.d.ts +5 -0
  39. package/dist/esm/pseudo/env.d.ts.map +1 -0
  40. package/dist/esm/pseudo/env.js +6 -0
  41. package/dist/esm/pseudo/env.js.map +1 -0
  42. package/dist/esm/pseudo/eval.d.ts +5 -0
  43. package/dist/esm/pseudo/eval.d.ts.map +1 -0
  44. package/dist/esm/pseudo/eval.js +6 -0
  45. package/dist/esm/pseudo/eval.js.map +1 -0
  46. package/dist/esm/pseudo/fs.d.ts +5 -0
  47. package/dist/esm/pseudo/fs.d.ts.map +1 -0
  48. package/dist/esm/pseudo/fs.js +6 -0
  49. package/dist/esm/pseudo/fs.js.map +1 -0
  50. package/dist/esm/pseudo/helpers.d.ts +4 -0
  51. package/dist/esm/pseudo/helpers.d.ts.map +1 -1
  52. package/dist/esm/pseudo/helpers.js +19 -0
  53. package/dist/esm/pseudo/helpers.js.map +1 -1
  54. package/dist/esm/pseudo/license.d.ts +10 -0
  55. package/dist/esm/pseudo/license.d.ts.map +1 -0
  56. package/dist/esm/pseudo/license.js +61 -0
  57. package/dist/esm/pseudo/license.js.map +1 -0
  58. package/dist/esm/pseudo/malware.d.ts +10 -0
  59. package/dist/esm/pseudo/malware.d.ts.map +1 -0
  60. package/dist/esm/pseudo/malware.js +60 -0
  61. package/dist/esm/pseudo/malware.js.map +1 -0
  62. package/dist/esm/pseudo/minified.d.ts +5 -0
  63. package/dist/esm/pseudo/minified.d.ts.map +1 -0
  64. package/dist/esm/pseudo/minified.js +6 -0
  65. package/dist/esm/pseudo/minified.js.map +1 -0
  66. package/dist/esm/pseudo/native.d.ts +5 -0
  67. package/dist/esm/pseudo/native.d.ts.map +1 -0
  68. package/dist/esm/pseudo/native.js +6 -0
  69. package/dist/esm/pseudo/native.js.map +1 -0
  70. package/dist/esm/pseudo/network.d.ts +5 -0
  71. package/dist/esm/pseudo/network.d.ts.map +1 -0
  72. package/dist/esm/pseudo/network.js +6 -0
  73. package/dist/esm/pseudo/network.js.map +1 -0
  74. package/dist/esm/pseudo/obfuscated.d.ts +5 -0
  75. package/dist/esm/pseudo/obfuscated.d.ts.map +1 -0
  76. package/dist/esm/pseudo/obfuscated.js +6 -0
  77. package/dist/esm/pseudo/obfuscated.js.map +1 -0
  78. package/dist/esm/pseudo/scripts.d.ts +5 -0
  79. package/dist/esm/pseudo/scripts.d.ts.map +1 -0
  80. package/dist/esm/pseudo/scripts.js +6 -0
  81. package/dist/esm/pseudo/scripts.js.map +1 -0
  82. package/dist/esm/pseudo/severity.d.ts +10 -0
  83. package/dist/esm/pseudo/severity.d.ts.map +1 -0
  84. package/dist/esm/pseudo/severity.js +60 -0
  85. package/dist/esm/pseudo/severity.js.map +1 -0
  86. package/dist/esm/pseudo/shell.d.ts +5 -0
  87. package/dist/esm/pseudo/shell.d.ts.map +1 -0
  88. package/dist/esm/pseudo/shell.js +6 -0
  89. package/dist/esm/pseudo/shell.js.map +1 -0
  90. package/dist/esm/pseudo/shrinkwrap.d.ts +5 -0
  91. package/dist/esm/pseudo/shrinkwrap.d.ts.map +1 -0
  92. package/dist/esm/pseudo/shrinkwrap.js +6 -0
  93. package/dist/esm/pseudo/shrinkwrap.js.map +1 -0
  94. package/dist/esm/pseudo/squat.d.ts +10 -0
  95. package/dist/esm/pseudo/squat.d.ts.map +1 -0
  96. package/dist/esm/pseudo/squat.js +57 -0
  97. package/dist/esm/pseudo/squat.js.map +1 -0
  98. package/dist/esm/pseudo/suspicious.d.ts +5 -0
  99. package/dist/esm/pseudo/suspicious.d.ts.map +1 -0
  100. package/dist/esm/pseudo/suspicious.js +6 -0
  101. package/dist/esm/pseudo/suspicious.js.map +1 -0
  102. package/dist/esm/pseudo/tracker.d.ts +5 -0
  103. package/dist/esm/pseudo/tracker.d.ts.map +1 -0
  104. package/dist/esm/pseudo/tracker.js +6 -0
  105. package/dist/esm/pseudo/tracker.js.map +1 -0
  106. package/dist/esm/pseudo/trivial.d.ts +5 -0
  107. package/dist/esm/pseudo/trivial.d.ts.map +1 -0
  108. package/dist/esm/pseudo/trivial.js +6 -0
  109. package/dist/esm/pseudo/trivial.js.map +1 -0
  110. package/dist/esm/pseudo/undesirable.d.ts +5 -0
  111. package/dist/esm/pseudo/undesirable.d.ts.map +1 -0
  112. package/dist/esm/pseudo/undesirable.js +6 -0
  113. package/dist/esm/pseudo/undesirable.js.map +1 -0
  114. package/dist/esm/pseudo/unknown.d.ts +5 -0
  115. package/dist/esm/pseudo/unknown.d.ts.map +1 -0
  116. package/dist/esm/pseudo/unknown.js +6 -0
  117. package/dist/esm/pseudo/unknown.js.map +1 -0
  118. package/dist/esm/pseudo/unmaintained.d.ts +5 -0
  119. package/dist/esm/pseudo/unmaintained.d.ts.map +1 -0
  120. package/dist/esm/pseudo/unmaintained.js +6 -0
  121. package/dist/esm/pseudo/unmaintained.js.map +1 -0
  122. package/dist/esm/pseudo/unpopular.d.ts +5 -0
  123. package/dist/esm/pseudo/unpopular.d.ts.map +1 -0
  124. package/dist/esm/pseudo/unpopular.js +6 -0
  125. package/dist/esm/pseudo/unpopular.js.map +1 -0
  126. package/dist/esm/pseudo/unstable.d.ts +5 -0
  127. package/dist/esm/pseudo/unstable.d.ts.map +1 -0
  128. package/dist/esm/pseudo/unstable.js +6 -0
  129. package/dist/esm/pseudo/unstable.js.map +1 -0
  130. package/dist/esm/pseudo.d.ts.map +1 -1
  131. package/dist/esm/pseudo.js +69 -4
  132. package/dist/esm/pseudo.js.map +1 -1
  133. package/dist/esm/types.d.ts +2 -0
  134. package/dist/esm/types.d.ts.map +1 -1
  135. package/dist/esm/types.js.map +1 -1
  136. package/package.json +8 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/pseudo/fs.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,EAAE,0FAGd,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"]}
@@ -12,4 +12,8 @@ export declare const removeDanglingEdges: (state: ParserState) => void;
12
12
  * Removes quotes from a string value.
13
13
  */
14
14
  export declare const removeQuotes: (value: string) => string;
15
+ /**
16
+ * Reusable security selector alert filter.
17
+ */
18
+ export declare const createSecuritySelectorFilter: (name: string, type: string) => (state: ParserState) => Promise<ParserState>;
15
19
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;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,YAAY,UAAW,MAAM,WACR,CAAA"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;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,YAAY,UAAW,MAAM,WACR,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,4BAA4B,SACjC,MAAM,QACN,MAAM,aAES,WAAW,yBAqBjC,CAAA"}
@@ -21,4 +21,23 @@ export const removeDanglingEdges = (state) => {
21
21
  * Removes quotes from a string value.
22
22
  */
23
23
  export const removeQuotes = (value) => value.replace(/^"(.*?)"$/, '$1');
24
+ /**
25
+ * Reusable security selector alert filter.
26
+ */
27
+ export const createSecuritySelectorFilter = (name, type) => {
28
+ return async (state) => {
29
+ if (!state.securityArchive) {
30
+ throw new Error(`Missing security archive while trying to parse the :${name} security selector`);
31
+ }
32
+ for (const node of state.partial.nodes) {
33
+ const report = state.securityArchive.get(node.id);
34
+ const exclude = !report?.alerts.some(alert => alert.type === type);
35
+ if (exclude) {
36
+ removeNode(state, node);
37
+ }
38
+ }
39
+ removeDanglingEdges(state);
40
+ return state;
41
+ };
42
+ };
24
43
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAGA;;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,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,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAC5C,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA","sourcesContent":["import type { NodeLike } from '@vltpkg/graph'\nimport type { ParserState } from '../types.js'\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 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 quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAGA;;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,CAA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;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { NodeLike } from '@vltpkg/graph'\nimport type { ParserState } from '../types.js'\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 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 quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\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 if (!state.securityArchive) {\n throw new Error(\n `Missing security archive while trying to parse the :${name} security selector`,\n )\n }\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"]}
@@ -0,0 +1,10 @@
1
+ import type { ParserState, PostcssNode } from '../types.ts';
2
+ export type LicenseKinds = 'unlicensed' | 'misc' | 'restricted' | 'ambiguous' | 'copyleft' | 'unknown' | 'none' | 'exception' | undefined;
3
+ export type LicenseAlertTypes = 'explicitlyUnlicensedItem' | 'miscLicenseIssues' | 'nonpermissiveLicense' | 'ambiguousClassifier' | 'copyleftLicense' | 'unidentifiedLicense' | 'noLicenseFound' | 'licenseException' | undefined;
4
+ export declare const isLicenseKind: (value?: string) => value is LicenseKinds;
5
+ export declare const asLicenseKind: (value?: string) => LicenseKinds;
6
+ export declare const parseInternals: (nodes: PostcssNode[]) => {
7
+ kind: LicenseKinds;
8
+ };
9
+ export declare const license: (state: ParserState) => Promise<ParserState>;
10
+ //# sourceMappingURL=license.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/pseudo/license.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO3D,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,MAAM,GACN,YAAY,GACZ,WAAW,GACX,UAAU,GACV,SAAS,GACT,MAAM,GACN,WAAW,GACX,SAAS,CAAA;AAEb,MAAM,MAAM,iBAAiB,GACzB,0BAA0B,GAC1B,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,CAAA;AAeb,eAAO,MAAM,aAAa,WAChB,MAAM,KACb,KAAK,IAAI,YAAgD,CAAA;AAE5D,eAAO,MAAM,aAAa,WAAY,MAAM,KAAG,YAQ9C,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB;IAAE,IAAI,EAAE,YAAY,CAAA;CAmBtB,CAAA;AAED,eAAO,MAAM,OAAO,UAAiB,WAAW,yBAgC/C,CAAA"}
@@ -0,0 +1,61 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
3
+ import { removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
4
+ const kindsMap = new Map([
5
+ ['unlicensed', 'explicitlyUnlicensedItem'],
6
+ ['misc', 'miscLicenseIssues'],
7
+ ['restricted', 'nonpermissiveLicense'],
8
+ ['ambiguous', 'ambiguousClassifier'],
9
+ ['copyleft', 'copyleftLicense'],
10
+ ['unknown', 'unidentifiedLicense'],
11
+ ['none', 'noLicenseFound'],
12
+ ['exception', 'licenseException'],
13
+ [undefined, undefined],
14
+ ]);
15
+ const kinds = new Set(kindsMap.keys());
16
+ export const isLicenseKind = (value) => kinds.has(value);
17
+ export const asLicenseKind = (value) => {
18
+ if (!isLicenseKind(value)) {
19
+ throw error('Expected a valid license kind', {
20
+ found: value,
21
+ validOptions: Array.from(kinds),
22
+ });
23
+ }
24
+ return value;
25
+ };
26
+ export const parseInternals = (nodes) => {
27
+ let kind;
28
+ if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
29
+ kind = asLicenseKind(removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
30
+ .value));
31
+ }
32
+ else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
33
+ kind = asLicenseKind(asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value);
34
+ }
35
+ return { kind };
36
+ };
37
+ export const license = async (state) => {
38
+ if (!state.securityArchive) {
39
+ throw new Error('Missing security archive while trying to parse ' +
40
+ 'the :license security selector');
41
+ }
42
+ let internals;
43
+ try {
44
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
45
+ }
46
+ catch (err) {
47
+ throw error('Failed to parse :license selector', { cause: err });
48
+ }
49
+ const { kind } = internals;
50
+ const alertName = kindsMap.get(kind);
51
+ for (const node of state.partial.nodes) {
52
+ const report = state.securityArchive.get(node.id);
53
+ const exclude = !report?.alerts.some(alert => alert.type === alertName);
54
+ if (exclude) {
55
+ removeNode(state, node);
56
+ }
57
+ }
58
+ removeDanglingEdges(state);
59
+ return state;
60
+ };
61
+ //# sourceMappingURL=license.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license.js","sourceRoot":"","sources":["../../../src/pseudo/license.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,mBAAmB,EACnB,UAAU,EACV,YA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KAAK,CAAC,IAAI,KAAK,SAAS,CAClC,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 removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type LicenseKinds =\n | 'unlicensed'\n | 'misc'\n | 'restricted'\n | 'ambiguous'\n | 'copyleft'\n | 'unknown'\n | 'none'\n | 'exception'\n | undefined\n\nexport type LicenseAlertTypes =\n | 'explicitlyUnlicensedItem'\n | 'miscLicenseIssues'\n | 'nonpermissiveLicense'\n | 'ambiguousClassifier'\n | 'copyleftLicense'\n | 'unidentifiedLicense'\n | 'noLicenseFound'\n | 'licenseException'\n | undefined\n\nconst kindsMap = new Map<LicenseKinds, LicenseAlertTypes>([\n ['unlicensed', 'explicitlyUnlicensedItem'],\n ['misc', 'miscLicenseIssues'],\n ['restricted', 'nonpermissiveLicense'],\n ['ambiguous', 'ambiguousClassifier'],\n ['copyleft', 'copyleftLicense'],\n ['unknown', 'unidentifiedLicense'],\n ['none', 'noLicenseFound'],\n ['exception', 'licenseException'],\n [undefined, undefined],\n])\nconst kinds = new Set(kindsMap.keys())\n\nexport const isLicenseKind = (\n value?: string,\n): value is LicenseKinds => kinds.has(value as LicenseKinds)\n\nexport const asLicenseKind = (value?: string): LicenseKinds => {\n if (!isLicenseKind(value)) {\n throw error('Expected a valid license kind', {\n found: value,\n validOptions: Array.from(kinds),\n })\n }\n return value\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): { kind: LicenseKinds } => {\n let kind: LicenseKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asLicenseKind(\n removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n ),\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n kind = asLicenseKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\n}\n\nexport const license = async (state: ParserState) => {\n if (!state.securityArchive) {\n throw new Error(\n 'Missing security archive while trying to parse ' +\n 'the :license security selector',\n )\n }\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :license selector', { cause: err })\n }\n\n const { kind } = internals\n const alertName = kindsMap.get(kind)\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 === alertName,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { ParserState, PostcssNode } from '../types.ts';
2
+ export type MalwareKinds = '0' | '1' | '2' | '3' | 'critical' | 'high' | 'medium' | 'low' | undefined;
3
+ export type MalwareAlertTypes = 'malware' | 'gptMalware' | 'gptSecurity' | 'gptAnomaly' | undefined;
4
+ export declare const isMalwareKind: (value?: string) => value is MalwareKinds;
5
+ export declare const asMalwareKind: (value?: string) => MalwareKinds;
6
+ export declare const parseInternals: (nodes: PostcssNode[]) => {
7
+ kind: MalwareKinds;
8
+ };
9
+ export declare const malware: (state: ParserState) => Promise<ParserState>;
10
+ //# sourceMappingURL=malware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"malware.d.ts","sourceRoot":"","sources":["../../../src/pseudo/malware.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO3D,MAAM,MAAM,YAAY,GACpB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,UAAU,GACV,MAAM,GACN,QAAQ,GACR,KAAK,GACL,SAAS,CAAA;AAEb,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,SAAS,CAAA;AAcb,eAAO,MAAM,aAAa,WAChB,MAAM,KACb,KAAK,IAAI,YAAgD,CAAA;AAE5D,eAAO,MAAM,aAAa,WAAY,MAAM,KAAG,YAQ9C,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB;IAAE,IAAI,EAAE,YAAY,CAAA;CAmBtB,CAAA;AAED,eAAO,MAAM,OAAO,UAAiB,WAAW,yBAgC/C,CAAA"}
@@ -0,0 +1,60 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
3
+ import { removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
4
+ const kindsMap = new Map([
5
+ ['critical', 'malware'],
6
+ ['high', 'gptMalware'],
7
+ ['medium', 'gptSecurity'],
8
+ ['low', 'gptAnomaly'],
9
+ ['0', 'malware'],
10
+ ['1', 'gptMalware'],
11
+ ['2', 'gptSecurity'],
12
+ ['3', 'gptAnomaly'],
13
+ ]);
14
+ const kinds = new Set(kindsMap.keys());
15
+ export const isMalwareKind = (value) => kinds.has(value);
16
+ export const asMalwareKind = (value) => {
17
+ if (!isMalwareKind(value)) {
18
+ throw error('Expected a valid malware kind', {
19
+ found: value,
20
+ validOptions: Array.from(kinds),
21
+ });
22
+ }
23
+ return value;
24
+ };
25
+ export const parseInternals = (nodes) => {
26
+ let kind;
27
+ if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
28
+ kind = asMalwareKind(removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
29
+ .value));
30
+ }
31
+ else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
32
+ kind = asMalwareKind(asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value);
33
+ }
34
+ return { kind };
35
+ };
36
+ export const malware = async (state) => {
37
+ if (!state.securityArchive) {
38
+ throw new Error('Missing security archive while trying to parse ' +
39
+ 'the :malware security selector');
40
+ }
41
+ let internals;
42
+ try {
43
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
44
+ }
45
+ catch (err) {
46
+ throw error('Failed to parse :malware selector', { cause: err });
47
+ }
48
+ const { kind } = internals;
49
+ const alertName = kindsMap.get(kind);
50
+ for (const node of state.partial.nodes) {
51
+ const report = state.securityArchive.get(node.id);
52
+ const exclude = !report?.alerts.some(alert => alert.type === alertName);
53
+ if (exclude) {
54
+ removeNode(state, node);
55
+ }
56
+ }
57
+ removeDanglingEdges(state);
58
+ return state;
59
+ };
60
+ //# sourceMappingURL=malware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"malware.js","sourceRoot":"","sources":["../../../src/pseudo/malware.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,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAoBrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAkC;IACxD,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,MAAM,EAAE,YAAY,CAAC;IACtB,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,KAAK,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,YAAY,CAAC;IACnB,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,GAAG,EAAE,YAAY,CAAC;CACpB,CAAC,CA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GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAClD,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,iDAAiD;YAC/C,gCAAgC,CACnC,CAAA;IACH,CAAC;IAED,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,mCAAmC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAClE,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAA;IAC1B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACpC,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,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAClC,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 removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type MalwareKinds =\n | '0'\n | '1'\n | '2'\n | '3'\n | 'critical'\n | 'high'\n | 'medium'\n | 'low'\n | undefined\n\nexport type MalwareAlertTypes =\n | 'malware'\n | 'gptMalware'\n | 'gptSecurity'\n | 'gptAnomaly'\n | undefined\n\nconst kindsMap = new Map<MalwareKinds, MalwareAlertTypes>([\n ['critical', 'malware'],\n ['high', 'gptMalware'],\n ['medium', 'gptSecurity'],\n ['low', 'gptAnomaly'],\n ['0', 'malware'],\n ['1', 'gptMalware'],\n ['2', 'gptSecurity'],\n ['3', 'gptAnomaly'],\n])\nconst kinds = new Set(kindsMap.keys())\n\nexport const isMalwareKind = (\n value?: string,\n): value is MalwareKinds => kinds.has(value as MalwareKinds)\n\nexport const asMalwareKind = (value?: string): MalwareKinds => {\n if (!isMalwareKind(value)) {\n throw error('Expected a valid malware kind', {\n found: value,\n validOptions: Array.from(kinds),\n })\n }\n return value\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): { kind: MalwareKinds } => {\n let kind: MalwareKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asMalwareKind(\n removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n ),\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n kind = asMalwareKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\n}\n\nexport const malware = async (state: ParserState) => {\n if (!state.securityArchive) {\n throw new Error(\n 'Missing security archive while trying to parse ' +\n 'the :malware security selector',\n )\n }\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :malware selector', { cause: err })\n }\n\n const { kind } = internals\n const alertName = kindsMap.get(kind)\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 === alertName,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **minifiedFile** report alert.
3
+ */
4
+ export declare const minified: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=minified.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minified.d.ts","sourceRoot":"","sources":["../../../src/pseudo/minified.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ,0FAGpB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **minifiedFile** report alert.
4
+ */
5
+ export const minified = createSecuritySelectorFilter('minified', 'minifiedFile');
6
+ //# sourceMappingURL=minified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minified.js","sourceRoot":"","sources":["../../../src/pseudo/minified.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,4BAA4B,CAClD,UAAU,EACV,cAAc,CACf,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **minifiedFile** report alert.\n */\nexport const minified = createSecuritySelectorFilter(\n 'minified',\n 'minifiedFile',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **hasNativeCode** report alert.
3
+ */
4
+ export declare const nativeParser: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/pseudo/native.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,YAAY,0FAGxB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **hasNativeCode** report alert.
4
+ */
5
+ export const nativeParser = createSecuritySelectorFilter('native', 'hasNativeCode');
6
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.js","sourceRoot":"","sources":["../../../src/pseudo/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,4BAA4B,CACtD,QAAQ,EACR,eAAe,CAChB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **hasNativeCode** report alert.\n */\nexport const nativeParser = createSecuritySelectorFilter(\n 'native',\n 'hasNativeCode',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **networkAccess** report alert.
3
+ */
4
+ export declare const network: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/pseudo/network.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,0FAGnB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **networkAccess** report alert.
4
+ */
5
+ export const network = createSecuritySelectorFilter('network', 'networkAccess');
6
+ //# sourceMappingURL=network.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/pseudo/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CACjD,SAAS,EACT,eAAe,CAChB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **networkAccess** report alert.\n */\nexport const network = createSecuritySelectorFilter(\n 'network',\n 'networkAccess',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have an **obfuscatedFile** report alert.
3
+ */
4
+ export declare const obfuscated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=obfuscated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obfuscated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/obfuscated.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,0FAGtB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have an **obfuscatedFile** report alert.
4
+ */
5
+ export const obfuscated = createSecuritySelectorFilter('obfuscated', 'obfuscatedFile');
6
+ //# sourceMappingURL=obfuscated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obfuscated.js","sourceRoot":"","sources":["../../../src/pseudo/obfuscated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,4BAA4B,CACpD,YAAY,EACZ,gBAAgB,CACjB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have an **obfuscatedFile** report alert.\n */\nexport const obfuscated = createSecuritySelectorFilter(\n 'obfuscated',\n 'obfuscatedFile',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have an **installScripts** report alert.
3
+ */
4
+ export declare const scripts: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=scripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/pseudo/scripts.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,0FAGnB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have an **installScripts** report alert.
4
+ */
5
+ export const scripts = createSecuritySelectorFilter('scripts', 'installScripts');
6
+ //# sourceMappingURL=scripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../../src/pseudo/scripts.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 an **installScripts** report alert.\n */\nexport const scripts = createSecuritySelectorFilter(\n 'scripts',\n 'installScripts',\n)\n"]}
@@ -0,0 +1,10 @@
1
+ import type { ParserState, PostcssNode } from '../types.ts';
2
+ export type SeverityKinds = '0' | '1' | '2' | '3' | 'critical' | 'high' | 'medium' | 'low' | undefined;
3
+ export type SeverityAlertTypes = 'criticalCVE' | 'cve' | 'potentialVulnerability' | 'mildCVE' | undefined;
4
+ export declare const isSeverityKind: (value?: string) => value is SeverityKinds;
5
+ export declare const asSeverityKind: (value?: string) => SeverityKinds;
6
+ export declare const parseInternals: (nodes: PostcssNode[]) => {
7
+ kind: SeverityKinds;
8
+ };
9
+ export declare const severity: (state: ParserState) => Promise<ParserState>;
10
+ //# sourceMappingURL=severity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../../../src/pseudo/severity.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO3D,MAAM,MAAM,aAAa,GACrB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,UAAU,GACV,MAAM,GACN,QAAQ,GACR,KAAK,GACL,SAAS,CAAA;AAEb,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,KAAK,GACL,wBAAwB,GACxB,SAAS,GACT,SAAS,CAAA;AAcb,eAAO,MAAM,cAAc,WACjB,MAAM,KACb,KAAK,IAAI,aAAkD,CAAA;AAE9D,eAAO,MAAM,cAAc,WAAY,MAAM,KAAG,aAQ/C,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB;IAAE,IAAI,EAAE,aAAa,CAAA;CAmBvB,CAAA;AAED,eAAO,MAAM,QAAQ,UAAiB,WAAW,yBAgChD,CAAA"}
@@ -0,0 +1,60 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
3
+ import { removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
4
+ const kindsMap = new Map([
5
+ ['critical', 'criticalCVE'],
6
+ ['high', 'cve'],
7
+ ['medium', 'potentialVulnerability'],
8
+ ['low', 'mildCVE'],
9
+ ['0', 'criticalCVE'],
10
+ ['1', 'cve'],
11
+ ['2', 'potentialVulnerability'],
12
+ ['3', 'mildCVE'],
13
+ ]);
14
+ const kinds = new Set(kindsMap.keys());
15
+ export const isSeverityKind = (value) => kinds.has(value);
16
+ export const asSeverityKind = (value) => {
17
+ if (!isSeverityKind(value)) {
18
+ throw error('Expected a valid severity kind', {
19
+ found: value,
20
+ validOptions: Array.from(kinds),
21
+ });
22
+ }
23
+ return value;
24
+ };
25
+ export const parseInternals = (nodes) => {
26
+ let kind;
27
+ if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
28
+ kind = asSeverityKind(removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
29
+ .value));
30
+ }
31
+ else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
32
+ kind = asSeverityKind(asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value);
33
+ }
34
+ return { kind };
35
+ };
36
+ export const severity = async (state) => {
37
+ if (!state.securityArchive) {
38
+ throw new Error('Missing security archive while trying to parse ' +
39
+ 'the :severity security selector');
40
+ }
41
+ let internals;
42
+ try {
43
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
44
+ }
45
+ catch (err) {
46
+ throw error('Failed to parse :severity selector', { cause: err });
47
+ }
48
+ const { kind } = internals;
49
+ const alertName = kindsMap.get(kind);
50
+ for (const node of state.partial.nodes) {
51
+ const report = state.securityArchive.get(node.id);
52
+ const exclude = !report?.alerts.some(alert => alert.type === alertName);
53
+ if (exclude) {
54
+ removeNode(state, node);
55
+ }
56
+ }
57
+ removeDanglingEdges(state);
58
+ return state;
59
+ };
60
+ //# sourceMappingURL=severity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity.js","sourceRoot":"","sources":["../../../src/pseudo/severity.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,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAoBrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAoC;IAC1D,CAAC,UAAU,EAAE,aAAa,CAAC;IAC3B,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IACpC,CAAC,KAAK,EAAE,SAAS,CAAC;IAClB,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,GAAG,EAAE,KAAK,CAAC;IACZ,CAAC,GAAG,EAAE,wBAAwB,CAAC;IAC/B,CAAC,GAAG,EAAE,SAAS,CAAC;CACjB,CAAC,CAAA;AACF,MA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K,EAAE,KAAkB,EAAE,EAAE;IACnD,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,iDAAiD;YAC/C,iCAAiC,CACpC,CAAA;IACH,CAAC;IAED,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,oCAAoC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACnE,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAA;IAC1B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACpC,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,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAClC,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 removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type SeverityKinds =\n | '0'\n | '1'\n | '2'\n | '3'\n | 'critical'\n | 'high'\n | 'medium'\n | 'low'\n | undefined\n\nexport type SeverityAlertTypes =\n | 'criticalCVE'\n | 'cve'\n | 'potentialVulnerability'\n | 'mildCVE'\n | undefined\n\nconst kindsMap = new Map<SeverityKinds, SeverityAlertTypes>([\n ['critical', 'criticalCVE'],\n ['high', 'cve'],\n ['medium', 'potentialVulnerability'],\n ['low', 'mildCVE'],\n ['0', 'criticalCVE'],\n ['1', 'cve'],\n ['2', 'potentialVulnerability'],\n ['3', 'mildCVE'],\n])\nconst kinds = new Set(kindsMap.keys())\n\nexport const isSeverityKind = (\n value?: string,\n): value is SeverityKinds => kinds.has(value as SeverityKinds)\n\nexport const asSeverityKind = (value?: string): SeverityKinds => {\n if (!isSeverityKind(value)) {\n throw error('Expected a valid severity kind', {\n found: value,\n validOptions: Array.from(kinds),\n })\n }\n return value\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): { kind: SeverityKinds } => {\n let kind: SeverityKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asSeverityKind(\n removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n ),\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n kind = asSeverityKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\n}\n\nexport const severity = async (state: ParserState) => {\n if (!state.securityArchive) {\n throw new Error(\n 'Missing security archive while trying to parse ' +\n 'the :severity security selector',\n )\n }\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :severity selector', { cause: err })\n }\n\n const { kind } = internals\n const alertName = kindsMap.get(kind)\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 === alertName,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **shellAccess** report alert.
3
+ */
4
+ export declare const shell: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/pseudo/shell.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,KAAK,0FAGjB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **shellAccess** report alert.
4
+ */
5
+ export const shell = createSecuritySelectorFilter('shell', 'shellAccess');
6
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../src/pseudo/shell.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 **shellAccess** report alert.\n */\nexport const shell = createSecuritySelectorFilter(\n 'shell',\n 'shellAccess',\n)\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **shrinkwrap** report alert.
3
+ */
4
+ export declare const shrinkwrap: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=shrinkwrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shrinkwrap.d.ts","sourceRoot":"","sources":["../../../src/pseudo/shrinkwrap.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,0FAGtB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { createSecuritySelectorFilter } from "./helpers.js";
2
+ /**
3
+ * Filters out any node that does not have a **shrinkwrap** report alert.
4
+ */
5
+ export const shrinkwrap = createSecuritySelectorFilter('shrinkwrap', 'shrinkwrap');
6
+ //# sourceMappingURL=shrinkwrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shrinkwrap.js","sourceRoot":"","sources":["../../../src/pseudo/shrinkwrap.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 **shrinkwrap** report alert.\n */\nexport const shrinkwrap = createSecuritySelectorFilter(\n 'shrinkwrap',\n 'shrinkwrap',\n)\n"]}
@@ -0,0 +1,10 @@
1
+ import type { ParserState, PostcssNode } from '../types.ts';
2
+ export type SquatKinds = '0' | '2' | 'critical' | 'medium' | undefined;
3
+ export type SquatAlertTypes = 'didYouMean' | 'gptDidYouMean' | undefined;
4
+ export declare const isSquatKind: (value?: string) => value is SquatKinds;
5
+ export declare const asSquatKind: (value?: string) => SquatKinds;
6
+ export declare const parseInternals: (nodes: PostcssNode[]) => {
7
+ kind: SquatKinds;
8
+ };
9
+ export declare const squat: (state: ParserState) => Promise<ParserState>;
10
+ //# sourceMappingURL=squat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"squat.d.ts","sourceRoot":"","sources":["../../../src/pseudo/squat.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO3D,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEtE,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,eAAe,GACf,SAAS,CAAA;AAWb,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,KAAK,IAAI,UACtB,CAAA;AAEhC,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,UAQ5C,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB;IAAE,IAAI,EAAE,UAAU,CAAA;CAmBpB,CAAA;AAED,eAAO,MAAM,KAAK,UAAiB,WAAW,yBAgC7C,CAAA"}
@@ -0,0 +1,57 @@
1
+ import { error } from '@vltpkg/error-cause';
2
+ import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
3
+ import { removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
4
+ const kindsMap = new Map([
5
+ ['critical', 'didYouMean'],
6
+ ['medium', 'gptDidYouMean'],
7
+ ['0', 'didYouMean'],
8
+ ['2', 'gptDidYouMean'],
9
+ [undefined, undefined],
10
+ ]);
11
+ const kinds = new Set(kindsMap.keys());
12
+ export const isSquatKind = (value) => kinds.has(value);
13
+ export const asSquatKind = (value) => {
14
+ if (!isSquatKind(value)) {
15
+ throw error('Expected a valid squat kind', {
16
+ found: value,
17
+ validOptions: Array.from(kinds),
18
+ });
19
+ }
20
+ return value;
21
+ };
22
+ export const parseInternals = (nodes) => {
23
+ let kind;
24
+ if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
25
+ kind = asSquatKind(removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
26
+ .value));
27
+ }
28
+ else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
29
+ kind = asSquatKind(asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value);
30
+ }
31
+ return { kind };
32
+ };
33
+ export const squat = async (state) => {
34
+ if (!state.securityArchive) {
35
+ throw new Error('Missing security archive while trying to parse ' +
36
+ 'the :squat security selector');
37
+ }
38
+ let internals;
39
+ try {
40
+ internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
41
+ }
42
+ catch (err) {
43
+ throw error('Failed to parse :squat selector', { cause: err });
44
+ }
45
+ const { kind } = internals;
46
+ const alertName = kindsMap.get(kind);
47
+ for (const node of state.partial.nodes) {
48
+ const report = state.securityArchive.get(node.id);
49
+ const exclude = !report?.alerts.some(alert => alert.type === alertName);
50
+ if (exclude) {
51
+ removeNode(state, node);
52
+ }
53
+ }
54
+ removeDanglingEdges(state);
55
+ return state;
56
+ };
57
+ //# sourceMappingURL=squat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"squat.js","sourceRoot":"","sources":["../../../src/pseudo/squat.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,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AASrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAA8B;IACpD,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1B,CAAC,QAAQ,EAAE,eAAe,CAAC;IAC3B,CAAC,GAAG,EAAE,YAAY,CAAC;IACnB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,SAAS,EAAE,SAAS,CAAC;CACvB,CAAC,CAAA;AACF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;AAEtC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAuB,EAAE,CACjE,KAAK,CAAC,GAAG,CAAC,KAAmB,CAAC,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAc,EAAE;IACxD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,CAAC,6BAA6B,EAAE;YACzC,KAAK,EAAE,KAAK;YAC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KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAA;IAC1B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACpC,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,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAClC,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 removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type SquatKinds = '0' | '2' | 'critical' | 'medium' | undefined\n\nexport type SquatAlertTypes =\n | 'didYouMean'\n | 'gptDidYouMean'\n | undefined\n\nconst kindsMap = new Map<SquatKinds, SquatAlertTypes>([\n ['critical', 'didYouMean'],\n ['medium', 'gptDidYouMean'],\n ['0', 'didYouMean'],\n ['2', 'gptDidYouMean'],\n [undefined, undefined],\n])\nconst kinds = new Set(kindsMap.keys())\n\nexport const isSquatKind = (value?: string): value is SquatKinds =>\n kinds.has(value as SquatKinds)\n\nexport const asSquatKind = (value?: string): SquatKinds => {\n if (!isSquatKind(value)) {\n throw error('Expected a valid squat kind', {\n found: value,\n validOptions: Array.from(kinds),\n })\n }\n return value\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): { kind: SquatKinds } => {\n let kind: SquatKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asSquatKind(\n removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n ),\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n kind = asSquatKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\n}\n\nexport const squat = async (state: ParserState) => {\n if (!state.securityArchive) {\n throw new Error(\n 'Missing security archive while trying to parse ' +\n 'the :squat security selector',\n )\n }\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :squat selector', { cause: err })\n }\n\n const { kind } = internals\n const alertName = kindsMap.get(kind)\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 === alertName,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Filters out any node that does not have a **suspiciousStarActivity** report alert.
3
+ */
4
+ export declare const suspicious: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState>;
5
+ //# sourceMappingURL=suspicious.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suspicious.d.ts","sourceRoot":"","sources":["../../../src/pseudo/suspicious.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,0FAGtB,CAAA"}