@vltpkg/query 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/package.json +10 -12
  2. package/skills/dss-query/REFERENCE.md +0 -125
  3. package/skills/dss-query/SKILL.md +0 -190
  4. package/skills/dss-query/evals/README.md +0 -81
  5. package/skills/dss-query/evals/evals.json +0 -89
  6. package/skills/dss-query/evals/grade.mjs +0 -481
  7. package/src/attribute.ts +0 -190
  8. package/src/combinator.ts +0 -135
  9. package/src/error.ts +0 -78
  10. package/src/id.ts +0 -46
  11. package/src/index.ts +0 -670
  12. package/src/parser.ts +0 -122
  13. package/src/pseudo/abandoned.ts +0 -9
  14. package/src/pseudo/attr.ts +0 -92
  15. package/src/pseudo/built.ts +0 -19
  16. package/src/pseudo/confused.ts +0 -29
  17. package/src/pseudo/cve.ts +0 -93
  18. package/src/pseudo/cwe.ts +0 -97
  19. package/src/pseudo/debug.ts +0 -9
  20. package/src/pseudo/deprecated.ts +0 -9
  21. package/src/pseudo/dev.ts +0 -18
  22. package/src/pseudo/diff.ts +0 -90
  23. package/src/pseudo/dist.ts +0 -148
  24. package/src/pseudo/dynamic.ts +0 -9
  25. package/src/pseudo/empty.ts +0 -15
  26. package/src/pseudo/entropic.ts +0 -9
  27. package/src/pseudo/env.ts +0 -6
  28. package/src/pseudo/eval.ts +0 -9
  29. package/src/pseudo/fs.ts +0 -9
  30. package/src/pseudo/helpers.ts +0 -106
  31. package/src/pseudo/host.ts +0 -111
  32. package/src/pseudo/hostname.ts +0 -156
  33. package/src/pseudo/license.ts +0 -134
  34. package/src/pseudo/link.ts +0 -30
  35. package/src/pseudo/malware.ts +0 -41
  36. package/src/pseudo/minified.ts +0 -9
  37. package/src/pseudo/missing.ts +0 -16
  38. package/src/pseudo/native.ts +0 -9
  39. package/src/pseudo/network.ts +0 -9
  40. package/src/pseudo/obfuscated.ts +0 -9
  41. package/src/pseudo/optional.ts +0 -18
  42. package/src/pseudo/outdated.ts +0 -345
  43. package/src/pseudo/overridden.ts +0 -20
  44. package/src/pseudo/path.ts +0 -146
  45. package/src/pseudo/peer.ts +0 -18
  46. package/src/pseudo/prerelease.ts +0 -47
  47. package/src/pseudo/private.ts +0 -19
  48. package/src/pseudo/prod.ts +0 -18
  49. package/src/pseudo/published.ts +0 -250
  50. package/src/pseudo/registry.ts +0 -29
  51. package/src/pseudo/root.ts +0 -19
  52. package/src/pseudo/scanned.ts +0 -20
  53. package/src/pseudo/score.ts +0 -186
  54. package/src/pseudo/scripts.ts +0 -61
  55. package/src/pseudo/semver.ts +0 -320
  56. package/src/pseudo/severity.ts +0 -231
  57. package/src/pseudo/shell.ts +0 -9
  58. package/src/pseudo/shrinkwrap.ts +0 -9
  59. package/src/pseudo/skill.ts +0 -59
  60. package/src/pseudo/skills.ts +0 -29
  61. package/src/pseudo/spec.ts +0 -131
  62. package/src/pseudo/squat.ts +0 -225
  63. package/src/pseudo/suspicious.ts +0 -9
  64. package/src/pseudo/tracker.ts +0 -9
  65. package/src/pseudo/trivial.ts +0 -9
  66. package/src/pseudo/type.ts +0 -26
  67. package/src/pseudo/undesirable.ts +0 -9
  68. package/src/pseudo/unknown.ts +0 -9
  69. package/src/pseudo/unmaintained.ts +0 -9
  70. package/src/pseudo/unpopular.ts +0 -9
  71. package/src/pseudo/unstable.ts +0 -9
  72. package/src/pseudo/vuln.ts +0 -273
  73. package/src/pseudo/workspace.ts +0 -22
  74. package/src/pseudo.ts +0 -440
  75. package/src/types.ts +0 -206
  76. package/tap-snapshots/test/attribute.ts.test.cjs +0 -304
  77. package/tap-snapshots/test/combinator.ts.test.cjs +0 -333
  78. package/tap-snapshots/test/id.ts.test.cjs +0 -118
  79. package/tap-snapshots/test/parser.ts.test.cjs +0 -344
  80. package/tap-snapshots/test/pseudo/abandoned.ts.test.cjs +0 -18
  81. package/tap-snapshots/test/pseudo/attr.ts.test.cjs +0 -161
  82. package/tap-snapshots/test/pseudo/built.ts.test.cjs +0 -70
  83. package/tap-snapshots/test/pseudo/confused.ts.test.cjs +0 -32
  84. package/tap-snapshots/test/pseudo/cve.ts.test.cjs +0 -49
  85. package/tap-snapshots/test/pseudo/cwe.ts.test.cjs +0 -49
  86. package/tap-snapshots/test/pseudo/debug.ts.test.cjs +0 -18
  87. package/tap-snapshots/test/pseudo/deprecated.ts.test.cjs +0 -18
  88. package/tap-snapshots/test/pseudo/dist.ts.test.cjs +0 -30
  89. package/tap-snapshots/test/pseudo/dynamic.ts.test.cjs +0 -18
  90. package/tap-snapshots/test/pseudo/empty.ts.test.cjs +0 -50
  91. package/tap-snapshots/test/pseudo/entropic.ts.test.cjs +0 -18
  92. package/tap-snapshots/test/pseudo/env.ts.test.cjs +0 -18
  93. package/tap-snapshots/test/pseudo/eval.ts.test.cjs +0 -18
  94. package/tap-snapshots/test/pseudo/fs.ts.test.cjs +0 -18
  95. package/tap-snapshots/test/pseudo/helpers.ts.test.cjs +0 -18
  96. package/tap-snapshots/test/pseudo/hostname.ts.test.cjs +0 -148
  97. package/tap-snapshots/test/pseudo/license.ts.test.cjs +0 -41
  98. package/tap-snapshots/test/pseudo/link.ts.test.cjs +0 -36
  99. package/tap-snapshots/test/pseudo/malware.ts.test.cjs +0 -22
  100. package/tap-snapshots/test/pseudo/minified.ts.test.cjs +0 -18
  101. package/tap-snapshots/test/pseudo/missing.ts.test.cjs +0 -30
  102. package/tap-snapshots/test/pseudo/native.ts.test.cjs +0 -18
  103. package/tap-snapshots/test/pseudo/network.ts.test.cjs +0 -18
  104. package/tap-snapshots/test/pseudo/obfuscated.ts.test.cjs +0 -18
  105. package/tap-snapshots/test/pseudo/outdated.ts.test.cjs +0 -132
  106. package/tap-snapshots/test/pseudo/overridden.ts.test.cjs +0 -75
  107. package/tap-snapshots/test/pseudo/prerelease.ts.test.cjs +0 -101
  108. package/tap-snapshots/test/pseudo/private.ts.test.cjs +0 -38
  109. package/tap-snapshots/test/pseudo/published.ts.test.cjs +0 -171
  110. package/tap-snapshots/test/pseudo/registry.ts.test.cjs +0 -68
  111. package/tap-snapshots/test/pseudo/root.ts.test.cjs +0 -24
  112. package/tap-snapshots/test/pseudo/scanned.ts.test.cjs +0 -18
  113. package/tap-snapshots/test/pseudo/score.ts.test.cjs +0 -239
  114. package/tap-snapshots/test/pseudo/scripts.ts.test.cjs +0 -62
  115. package/tap-snapshots/test/pseudo/semver.ts.test.cjs +0 -575
  116. package/tap-snapshots/test/pseudo/severity.ts.test.cjs +0 -122
  117. package/tap-snapshots/test/pseudo/shell.ts.test.cjs +0 -18
  118. package/tap-snapshots/test/pseudo/shrinkwrap.ts.test.cjs +0 -18
  119. package/tap-snapshots/test/pseudo/skills.ts.test.cjs +0 -19
  120. package/tap-snapshots/test/pseudo/spec.ts.test.cjs +0 -148
  121. package/tap-snapshots/test/pseudo/squat.ts.test.cjs +0 -129
  122. package/tap-snapshots/test/pseudo/suspicious.ts.test.cjs +0 -18
  123. package/tap-snapshots/test/pseudo/tracker.ts.test.cjs +0 -18
  124. package/tap-snapshots/test/pseudo/trivial.ts.test.cjs +0 -18
  125. package/tap-snapshots/test/pseudo/type.ts.test.cjs +0 -51
  126. package/tap-snapshots/test/pseudo/undesirable.ts.test.cjs +0 -18
  127. package/tap-snapshots/test/pseudo/unknown.ts.test.cjs +0 -18
  128. package/tap-snapshots/test/pseudo/unmaintained.ts.test.cjs +0 -18
  129. package/tap-snapshots/test/pseudo/unpopular.ts.test.cjs +0 -18
  130. package/tap-snapshots/test/pseudo/unstable.ts.test.cjs +0 -18
  131. package/tap-snapshots/test/pseudo/vuln.ts.test.cjs +0 -208
  132. package/tap-snapshots/test/pseudo/vulnerable.ts.test.cjs +0 -20
  133. package/tap-snapshots/test/pseudo/workspace.ts.test.cjs +0 -19
  134. package/tap-snapshots/test/pseudo.ts.test.cjs +0 -1247
  135. package/test/attribute.ts +0 -273
  136. package/test/combinator.ts +0 -175
  137. package/test/error.ts +0 -60
  138. package/test/fixtures/graph.ts +0 -999
  139. package/test/fixtures/selector.ts +0 -103
  140. package/test/fixtures/types.ts +0 -7
  141. package/test/id.ts +0 -102
  142. package/test/index.ts +0 -1148
  143. package/test/parser.ts +0 -117
  144. package/test/pseudo/abandoned.ts +0 -98
  145. package/test/pseudo/attr.ts +0 -298
  146. package/test/pseudo/built.ts +0 -214
  147. package/test/pseudo/confused.ts +0 -160
  148. package/test/pseudo/cve.ts +0 -249
  149. package/test/pseudo/cwe.ts +0 -255
  150. package/test/pseudo/debug.ts +0 -98
  151. package/test/pseudo/deprecated.ts +0 -98
  152. package/test/pseudo/dev.ts +0 -61
  153. package/test/pseudo/diff.ts +0 -417
  154. package/test/pseudo/dist.ts +0 -215
  155. package/test/pseudo/dynamic.ts +0 -98
  156. package/test/pseudo/empty.ts +0 -108
  157. package/test/pseudo/entropic.ts +0 -101
  158. package/test/pseudo/env.ts +0 -98
  159. package/test/pseudo/eval.ts +0 -98
  160. package/test/pseudo/fs.ts +0 -98
  161. package/test/pseudo/helpers.ts +0 -370
  162. package/test/pseudo/host-context.ts +0 -276
  163. package/test/pseudo/hostname.ts +0 -314
  164. package/test/pseudo/license.ts +0 -265
  165. package/test/pseudo/link.ts +0 -94
  166. package/test/pseudo/malware.ts +0 -184
  167. package/test/pseudo/minified.ts +0 -98
  168. package/test/pseudo/missing.ts +0 -111
  169. package/test/pseudo/native.ts +0 -98
  170. package/test/pseudo/network.ts +0 -98
  171. package/test/pseudo/obfuscated.ts +0 -98
  172. package/test/pseudo/optional.ts +0 -73
  173. package/test/pseudo/outdated.ts +0 -461
  174. package/test/pseudo/overridden.ts +0 -317
  175. package/test/pseudo/path.ts +0 -680
  176. package/test/pseudo/peer.ts +0 -101
  177. package/test/pseudo/prerelease.ts +0 -279
  178. package/test/pseudo/private.ts +0 -108
  179. package/test/pseudo/prod.ts +0 -61
  180. package/test/pseudo/published.ts +0 -557
  181. package/test/pseudo/registry.ts +0 -122
  182. package/test/pseudo/root.ts +0 -66
  183. package/test/pseudo/scanned.ts +0 -144
  184. package/test/pseudo/score.ts +0 -591
  185. package/test/pseudo/scripts.ts +0 -324
  186. package/test/pseudo/semver.ts +0 -822
  187. package/test/pseudo/severity.ts +0 -342
  188. package/test/pseudo/shell.ts +0 -98
  189. package/test/pseudo/shrinkwrap.ts +0 -98
  190. package/test/pseudo/skill.ts +0 -189
  191. package/test/pseudo/skills.ts +0 -90
  192. package/test/pseudo/spec.ts +0 -525
  193. package/test/pseudo/squat.ts +0 -565
  194. package/test/pseudo/suspicious.ts +0 -98
  195. package/test/pseudo/tracker.ts +0 -98
  196. package/test/pseudo/trivial.ts +0 -98
  197. package/test/pseudo/type.ts +0 -105
  198. package/test/pseudo/undesirable.ts +0 -98
  199. package/test/pseudo/unknown.ts +0 -98
  200. package/test/pseudo/unmaintained.ts +0 -98
  201. package/test/pseudo/unpopular.ts +0 -98
  202. package/test/pseudo/unstable.ts +0 -98
  203. package/test/pseudo/vuln.ts +0 -625
  204. package/test/pseudo/vulnerable.ts +0 -137
  205. package/test/pseudo/workspace.ts +0 -111
  206. package/test/pseudo.ts +0 -584
  207. package/tsconfig.json +0 -3
  208. package/tsconfig.publish.json +0 -19
  209. package/tsconfig.publish.tsbuildinfo +0 -1
  210. package/typedoc.mjs +0 -2
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **telemetry** report alert.
5
- */
6
- export const tracker = createSecuritySelectorFilter(
7
- 'tracker',
8
- 'telemetry',
9
- )
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **trivialPackage** report alert.
5
- */
6
- export const trivial = createSecuritySelectorFilter(
7
- 'trivial',
8
- 'trivialPackage',
9
- )
@@ -1,26 +0,0 @@
1
- import { splitDepID } from '@vltpkg/dep-id/browser'
2
- import {
3
- asPostcssNodeWithChildren,
4
- asTagNode,
5
- } from '@vltpkg/dss-parser'
6
- import { removeDanglingEdges, removeNode } from './helpers.ts'
7
- import type { ParserState } from '../types.ts'
8
-
9
- /**
10
- * :type(str) Pseudo-Element will match only nodes that are of
11
- * the same type as the value used. The type is determined by the
12
- * first part of the dependency ID.
13
- */
14
- export const type = async (state: ParserState) => {
15
- const type = asPostcssNodeWithChildren(state.current)
16
- const selector = asPostcssNodeWithChildren(type.nodes[0])
17
- const name = asTagNode(selector.nodes[0]).value
18
- for (const node of state.partial.nodes) {
19
- const nodeType = splitDepID(node.id)[0]
20
- if (nodeType !== name) {
21
- removeNode(state, node)
22
- }
23
- }
24
- removeDanglingEdges(state)
25
- return state
26
- }
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **troll** report alert.
5
- */
6
- export const undesirable = createSecuritySelectorFilter(
7
- 'undesirable',
8
- 'troll',
9
- )
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **newAuthor** report alert.
5
- */
6
- export const unknown = createSecuritySelectorFilter(
7
- 'unknown',
8
- 'newAuthor',
9
- )
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **unmaintained** report alert.
5
- */
6
- export const unmaintained = createSecuritySelectorFilter(
7
- 'unmaintained',
8
- 'unmaintained',
9
- )
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **unpopularPackage** report alert.
5
- */
6
- export const unpopular = createSecuritySelectorFilter(
7
- 'unpopular',
8
- 'unpopularPackage',
9
- )
@@ -1,9 +0,0 @@
1
- import { createSecuritySelectorFilter } from './helpers.ts'
2
-
3
- /**
4
- * Filters out any node that does not have a **unstableOwnership** report alert.
5
- */
6
- export const unstable = createSecuritySelectorFilter(
7
- 'unstable',
8
- 'unstableOwnership',
9
- )
@@ -1,273 +0,0 @@
1
- import { error } from '@vltpkg/error-cause'
2
- import {
3
- asPostcssNodeWithChildren,
4
- asStringNode,
5
- asTagNode,
6
- isStringNode,
7
- isTagNode,
8
- } from '@vltpkg/dss-parser'
9
- import {
10
- assertSecurityArchive,
11
- removeDanglingEdges,
12
- removeNode,
13
- removeQuotes,
14
- } from './helpers.ts'
15
- import type { ParserState } from '../types.ts'
16
- import type { PostcssNode } from '@vltpkg/dss-parser'
17
-
18
- export type VulnKinds =
19
- | '0'
20
- | '1'
21
- | '2'
22
- | '3'
23
- | 'critical'
24
- | 'high'
25
- | 'medium'
26
- | 'low'
27
- | undefined
28
-
29
- export type VulnComparator = '>' | '<' | '>=' | '<=' | undefined
30
-
31
- // Valid vulnerability kind names
32
- const kinds = new Set<string | undefined>([
33
- 'critical',
34
- 'high',
35
- 'medium',
36
- 'low',
37
- '0',
38
- '1',
39
- '2',
40
- '3',
41
- ])
42
-
43
- // Map numerical values to their respective kinds for comparison operations
44
- const kindLevelMap = new Map<VulnKinds, number>([
45
- ['critical', 0],
46
- ['high', 1],
47
- ['medium', 2],
48
- ['low', 3],
49
- ['0', 0],
50
- ['1', 1],
51
- ['2', 2],
52
- ['3', 3],
53
- ])
54
-
55
- // Maps alert types to their severity level for comparison operations.
56
- // gptSecurity maps to medium (2), gptAnomaly maps to low (3).
57
- const alertLevelMap = new Map<string, number>([
58
- ['criticalCVE', 0],
59
- ['cve', 1],
60
- ['potentialVulnerability', 2],
61
- ['gptSecurity', 2],
62
- ['mildCVE', 3],
63
- ['gptAnomaly', 3],
64
- ])
65
-
66
- // Maps alert.severity strings to numeric levels for cveId-bearing alerts
67
- // whose type may not be in alertLevelMap.
68
- const severityLevelMap = new Map<string, number>([
69
- ['critical', 0],
70
- ['high', 1],
71
- ['medium', 2],
72
- ['low', 3],
73
- ])
74
-
75
- /**
76
- * Returns the severity level for an alert, considering both its type
77
- * (via alertLevelMap) and its cveId + severity fields. Alerts with a
78
- * cveId are treated as vulnerability alerts even if their type is not
79
- * in the closed set.
80
- */
81
- const getAlertLevel = (alert: {
82
- type: string
83
- severity?: string
84
- props?: { cveId?: string }
85
- }): number | undefined => {
86
- const level = alertLevelMap.get(alert.type)
87
- if (level != null) return level
88
- // Fall back to severity field for alerts carrying a CVE id
89
- if (alert.props?.cveId && alert.severity) {
90
- return severityLevelMap.get(alert.severity)
91
- }
92
- return undefined
93
- }
94
-
95
- export const isVulnKind = (value?: string): value is VulnKinds =>
96
- kinds.has(value)
97
-
98
- export const asVulnKind = (value?: string): VulnKinds => {
99
- if (!isVulnKind(value)) {
100
- throw error('Expected a valid vuln kind', {
101
- found: value,
102
- validOptions: Array.from(kinds),
103
- })
104
- }
105
- return value
106
- }
107
-
108
- export const parseInternals = (
109
- nodes: PostcssNode[],
110
- ): { kind: VulnKinds; comparator: VulnComparator } => {
111
- // Handle case where no parameters are provided (parameterless :vuln)
112
- if (!nodes[0]) {
113
- return { kind: undefined, comparator: undefined }
114
- }
115
-
116
- const selectorNode = asPostcssNodeWithChildren(nodes[0])
117
- if (!selectorNode.nodes[0]) {
118
- return { kind: undefined, comparator: undefined }
119
- }
120
-
121
- let kindValue = ''
122
- let comparator: VulnComparator = undefined
123
- let kind: VulnKinds
124
-
125
- // Parse the parameter (kind with optional comparator)
126
- if (isStringNode(selectorNode.nodes[0])) {
127
- kindValue = removeQuotes(
128
- asStringNode(selectorNode.nodes[0]).value,
129
- )
130
- } else if (isTagNode(selectorNode.nodes[0])) {
131
- kindValue = asTagNode(selectorNode.nodes[0]).value
132
- }
133
-
134
- // Extract comparator if present
135
- if (kindValue.startsWith('>=')) {
136
- comparator = '>='
137
- kindValue = kindValue.substring(2)
138
- } else if (kindValue.startsWith('<=')) {
139
- comparator = '<='
140
- kindValue = kindValue.substring(2)
141
- } else if (kindValue.startsWith('>')) {
142
- comparator = '>'
143
- kindValue = kindValue.substring(1)
144
- } else if (kindValue.startsWith('<')) {
145
- comparator = '<'
146
- kindValue = kindValue.substring(1)
147
- }
148
-
149
- // Validate the kind without comparator
150
- if (!comparator) {
151
- kind = asVulnKind(kindValue)
152
- } else {
153
- // For comparisons, just make sure it's a valid numeric value or a valid kind
154
- if (isVulnKind(kindValue)) {
155
- kind = kindValue
156
- } else {
157
- throw error(
158
- 'Expected a valid vuln kind or number between 0-3',
159
- {
160
- found: kindValue,
161
- },
162
- )
163
- }
164
- }
165
-
166
- return { kind, comparator }
167
- }
168
-
169
- /**
170
- * :vuln / :vulnerable Pseudo-Selector, matches nodes with vulnerability alerts.
171
- *
172
- * Usage:
173
- * - :vuln - matches vulnerabilities with severity >= medium (critical, high, medium but not low)
174
- * - :vuln(critical) - matches specific vulnerability kind
175
- * - :vuln(>1) - matches vulnerabilities with severity greater than 1
176
- * - :vuln(">=medium") - matches vulnerabilities with severity >= medium
177
- */
178
- export const vuln = async (state: ParserState) => {
179
- assertSecurityArchive(state, 'vuln')
180
-
181
- let internals
182
- try {
183
- internals = parseInternals(
184
- asPostcssNodeWithChildren(state.current).nodes,
185
- )
186
- } catch (err) {
187
- throw error('Failed to parse :vuln selector', { cause: err })
188
- }
189
-
190
- const { kind, comparator } = internals
191
-
192
- for (const node of state.partial.nodes) {
193
- const report = state.securityArchive.get(node.id)
194
- // Always exclude nodes that don't have security data or alerts
195
- if (!report?.alerts || report.alerts.length === 0) {
196
- removeNode(state, node)
197
- }
198
- }
199
-
200
- for (const node of state.partial.nodes) {
201
- const report = state.securityArchive.get(node.id)
202
- let exclude = true
203
-
204
- if (report) {
205
- if (kind === undefined && comparator === undefined) {
206
- // Parameterless :vuln - match vuln alerts with severity >= medium
207
- // Includes: criticalCVE, cve, potentialVulnerability, gptSecurity,
208
- // and any alert carrying a cveId prop
209
- // Excludes: mildCVE, gptAnomaly (low severity)
210
- exclude = !report.alerts.some(alert => {
211
- const level = getAlertLevel(alert)
212
- return level != null && level <= 2
213
- })
214
- } else if (comparator) {
215
- // retrieve the value to compare against
216
- const kindLevel = kindLevelMap.get(kind)
217
- // the kindLevel value has already been validated at this point
218
- // and thus can never return an undefined/falsy value but ts doesn't
219
- // know about that, so we have the extra check here
220
- /* c8 ignore next - impossible */
221
- if (kindLevel == null) break
222
-
223
- // Check each alert to find any that match our comparison criteria
224
- for (const alert of report.alerts) {
225
- const currentAlertLevel = getAlertLevel(alert)
226
- if (currentAlertLevel == null) continue
227
-
228
- switch (comparator) {
229
- case '>':
230
- if (currentAlertLevel > kindLevel) {
231
- exclude = false
232
- }
233
- break
234
- case '<':
235
- if (currentAlertLevel < kindLevel) {
236
- exclude = false
237
- }
238
- break
239
- case '>=':
240
- if (currentAlertLevel >= kindLevel) {
241
- exclude = false
242
- }
243
- break
244
- case '<=':
245
- if (currentAlertLevel <= kindLevel) {
246
- exclude = false
247
- }
248
- break
249
- }
250
-
251
- // If we've found a match, no need to check other alerts
252
- if (!exclude) break
253
- }
254
- } else {
255
- // Exact match behavior — also matches gptSecurity/gptAnomaly
256
- // at the same level as their mapped kind, and cveId-bearing alerts
257
- const targetLevel = kindLevelMap.get(kind)
258
- exclude = !report.alerts.some(alert => {
259
- const level = getAlertLevel(alert)
260
- return level != null && level === targetLevel
261
- })
262
- }
263
- }
264
-
265
- if (exclude) {
266
- removeNode(state, node)
267
- }
268
- }
269
-
270
- removeDanglingEdges(state)
271
-
272
- return state
273
- }
@@ -1,22 +0,0 @@
1
- import type { ParserState } from '../types.ts'
2
- import { removeNode } from './helpers.ts'
3
-
4
- /**
5
- * :workspace Pseudo-Selector will only match workspace dependencies.
6
- */
7
- export const workspace = async (state: ParserState) => {
8
- // Filter out the root node and any nodes that are not marked as workspaces
9
- for (const node of state.partial.nodes) {
10
- if (!node.importer || node.mainImporter) {
11
- removeNode(state, node)
12
- }
13
- }
14
-
15
- // Clears up any edges that are not pointing to workspace nodes
16
- for (const edge of state.partial.edges) {
17
- if (edge.to?.importer && !edge.to.mainImporter) continue
18
- state.partial.edges.delete(edge)
19
- }
20
-
21
- return state
22
- }