@vltpkg/query 1.0.0-rc.32 → 1.0.0-rc.34
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.
- package/dist/index.js +10 -6
- package/dist/parser.js +2 -1
- package/dist/pseudo/hostname.js +3 -1
- package/dist/pseudo/malware.d.ts +3 -16
- package/dist/pseudo/malware.js +11 -171
- package/dist/pseudo/scripts.js +1 -1
- package/dist/pseudo/vuln.d.ts +22 -0
- package/dist/pseudo/vuln.js +220 -0
- package/dist/pseudo.js +3 -3
- package/dist/types.d.ts +3 -2
- package/package.json +19 -10
- package/skills/dss-query/REFERENCE.md +123 -0
- package/skills/dss-query/SKILL.md +190 -0
- package/skills/dss-query/evals/README.md +79 -0
- package/skills/dss-query/evals/evals.json +89 -0
- package/skills/dss-query/evals/grade.mjs +480 -0
- package/src/attribute.ts +186 -0
- package/src/combinator.ts +132 -0
- package/src/id.ts +46 -0
- package/src/index.ts +620 -0
- package/src/parser.ts +122 -0
- package/src/pseudo/abandoned.ts +9 -0
- package/src/pseudo/attr.ts +92 -0
- package/src/pseudo/built.ts +19 -0
- package/src/pseudo/confused.ts +29 -0
- package/src/pseudo/cve.ts +93 -0
- package/src/pseudo/cwe.ts +97 -0
- package/src/pseudo/debug.ts +9 -0
- package/src/pseudo/deprecated.ts +9 -0
- package/src/pseudo/dev.ts +18 -0
- package/src/pseudo/diff.ts +90 -0
- package/src/pseudo/dist.ts +144 -0
- package/src/pseudo/dynamic.ts +9 -0
- package/src/pseudo/empty.ts +15 -0
- package/src/pseudo/entropic.ts +9 -0
- package/src/pseudo/env.ts +6 -0
- package/src/pseudo/eval.ts +9 -0
- package/src/pseudo/fs.ts +9 -0
- package/src/pseudo/helpers.ts +106 -0
- package/src/pseudo/host.ts +111 -0
- package/src/pseudo/hostname.ts +156 -0
- package/src/pseudo/license.ts +134 -0
- package/src/pseudo/link.ts +30 -0
- package/src/pseudo/malware.ts +41 -0
- package/src/pseudo/minified.ts +9 -0
- package/src/pseudo/missing.ts +16 -0
- package/src/pseudo/native.ts +9 -0
- package/src/pseudo/network.ts +9 -0
- package/src/pseudo/obfuscated.ts +9 -0
- package/src/pseudo/optional.ts +18 -0
- package/src/pseudo/outdated.ts +305 -0
- package/src/pseudo/overridden.ts +20 -0
- package/src/pseudo/path.ts +146 -0
- package/src/pseudo/peer.ts +18 -0
- package/src/pseudo/prerelease.ts +47 -0
- package/src/pseudo/private.ts +19 -0
- package/src/pseudo/prod.ts +18 -0
- package/src/pseudo/published.ts +248 -0
- package/src/pseudo/registry.ts +29 -0
- package/src/pseudo/root.ts +19 -0
- package/src/pseudo/scanned.ts +20 -0
- package/src/pseudo/score.ts +186 -0
- package/src/pseudo/scripts.ts +54 -0
- package/src/pseudo/semver.ts +320 -0
- package/src/pseudo/severity.ts +231 -0
- package/src/pseudo/shell.ts +9 -0
- package/src/pseudo/shrinkwrap.ts +9 -0
- package/src/pseudo/spec.ts +131 -0
- package/src/pseudo/squat.ts +225 -0
- package/src/pseudo/suspicious.ts +9 -0
- package/src/pseudo/tracker.ts +9 -0
- package/src/pseudo/trivial.ts +9 -0
- package/src/pseudo/type.ts +26 -0
- package/src/pseudo/undesirable.ts +9 -0
- package/src/pseudo/unknown.ts +9 -0
- package/src/pseudo/unmaintained.ts +9 -0
- package/src/pseudo/unpopular.ts +9 -0
- package/src/pseudo/unstable.ts +9 -0
- package/src/pseudo/vuln.ts +273 -0
- package/src/pseudo/workspace.ts +22 -0
- package/src/pseudo.ts +413 -0
- package/src/types.ts +165 -0
- package/tap-snapshots/test/attribute.ts.test.cjs +304 -0
- package/tap-snapshots/test/combinator.ts.test.cjs +333 -0
- package/tap-snapshots/test/id.ts.test.cjs +118 -0
- package/tap-snapshots/test/parser.ts.test.cjs +344 -0
- package/tap-snapshots/test/pseudo/abandoned.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/attr.ts.test.cjs +161 -0
- package/tap-snapshots/test/pseudo/built.ts.test.cjs +70 -0
- package/tap-snapshots/test/pseudo/confused.ts.test.cjs +32 -0
- package/tap-snapshots/test/pseudo/cve.ts.test.cjs +49 -0
- package/tap-snapshots/test/pseudo/cwe.ts.test.cjs +49 -0
- package/tap-snapshots/test/pseudo/debug.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/deprecated.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/dist.ts.test.cjs +30 -0
- package/tap-snapshots/test/pseudo/dynamic.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/empty.ts.test.cjs +50 -0
- package/tap-snapshots/test/pseudo/entropic.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/env.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/eval.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/fs.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/helpers.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/hostname.ts.test.cjs +148 -0
- package/tap-snapshots/test/pseudo/license.ts.test.cjs +41 -0
- package/tap-snapshots/test/pseudo/link.ts.test.cjs +36 -0
- package/tap-snapshots/test/pseudo/malware.ts.test.cjs +22 -0
- package/tap-snapshots/test/pseudo/minified.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/missing.ts.test.cjs +30 -0
- package/tap-snapshots/test/pseudo/native.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/network.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/obfuscated.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/outdated.ts.test.cjs +130 -0
- package/tap-snapshots/test/pseudo/overridden.ts.test.cjs +75 -0
- package/tap-snapshots/test/pseudo/prerelease.ts.test.cjs +101 -0
- package/tap-snapshots/test/pseudo/private.ts.test.cjs +38 -0
- package/tap-snapshots/test/pseudo/published.ts.test.cjs +171 -0
- package/tap-snapshots/test/pseudo/registry.ts.test.cjs +68 -0
- package/tap-snapshots/test/pseudo/root.ts.test.cjs +24 -0
- package/tap-snapshots/test/pseudo/scanned.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/score.ts.test.cjs +239 -0
- package/tap-snapshots/test/pseudo/scripts.ts.test.cjs +61 -0
- package/tap-snapshots/test/pseudo/semver.ts.test.cjs +575 -0
- package/tap-snapshots/test/pseudo/severity.ts.test.cjs +95 -0
- package/tap-snapshots/test/pseudo/shell.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/shrinkwrap.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/spec.ts.test.cjs +148 -0
- package/tap-snapshots/test/pseudo/squat.ts.test.cjs +129 -0
- package/tap-snapshots/test/pseudo/suspicious.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/tracker.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/trivial.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/type.ts.test.cjs +51 -0
- package/tap-snapshots/test/pseudo/undesirable.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/unknown.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/unmaintained.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/unpopular.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/unstable.ts.test.cjs +18 -0
- package/tap-snapshots/test/pseudo/vuln.ts.test.cjs +208 -0
- package/tap-snapshots/test/pseudo/vulnerable.ts.test.cjs +20 -0
- package/tap-snapshots/test/pseudo/workspace.ts.test.cjs +19 -0
- package/tap-snapshots/test/pseudo.ts.test.cjs +1247 -0
- package/test/attribute.ts +266 -0
- package/test/combinator.ts +168 -0
- package/test/fixtures/graph.ts +999 -0
- package/test/fixtures/selector.ts +103 -0
- package/test/fixtures/types.ts +7 -0
- package/test/id.ts +102 -0
- package/test/index.ts +1000 -0
- package/test/parser.ts +117 -0
- package/test/pseudo/abandoned.ts +98 -0
- package/test/pseudo/attr.ts +298 -0
- package/test/pseudo/built.ts +214 -0
- package/test/pseudo/confused.ts +160 -0
- package/test/pseudo/cve.ts +249 -0
- package/test/pseudo/cwe.ts +255 -0
- package/test/pseudo/debug.ts +98 -0
- package/test/pseudo/deprecated.ts +98 -0
- package/test/pseudo/dev.ts +61 -0
- package/test/pseudo/diff.ts +417 -0
- package/test/pseudo/dist.ts +215 -0
- package/test/pseudo/dynamic.ts +98 -0
- package/test/pseudo/empty.ts +108 -0
- package/test/pseudo/entropic.ts +101 -0
- package/test/pseudo/env.ts +98 -0
- package/test/pseudo/eval.ts +98 -0
- package/test/pseudo/fs.ts +98 -0
- package/test/pseudo/helpers.ts +370 -0
- package/test/pseudo/host-context.ts +276 -0
- package/test/pseudo/hostname.ts +314 -0
- package/test/pseudo/license.ts +265 -0
- package/test/pseudo/link.ts +94 -0
- package/test/pseudo/malware.ts +184 -0
- package/test/pseudo/minified.ts +98 -0
- package/test/pseudo/missing.ts +111 -0
- package/test/pseudo/native.ts +98 -0
- package/test/pseudo/network.ts +98 -0
- package/test/pseudo/obfuscated.ts +98 -0
- package/test/pseudo/optional.ts +73 -0
- package/test/pseudo/outdated.ts +331 -0
- package/test/pseudo/overridden.ts +317 -0
- package/test/pseudo/path.ts +680 -0
- package/test/pseudo/peer.ts +101 -0
- package/test/pseudo/prerelease.ts +279 -0
- package/test/pseudo/private.ts +108 -0
- package/test/pseudo/prod.ts +61 -0
- package/test/pseudo/published.ts +557 -0
- package/test/pseudo/registry.ts +122 -0
- package/test/pseudo/root.ts +66 -0
- package/test/pseudo/scanned.ts +78 -0
- package/test/pseudo/score.ts +591 -0
- package/test/pseudo/scripts.ts +294 -0
- package/test/pseudo/semver.ts +822 -0
- package/test/pseudo/severity.ts +310 -0
- package/test/pseudo/shell.ts +98 -0
- package/test/pseudo/shrinkwrap.ts +98 -0
- package/test/pseudo/spec.ts +525 -0
- package/test/pseudo/squat.ts +565 -0
- package/test/pseudo/suspicious.ts +98 -0
- package/test/pseudo/tracker.ts +98 -0
- package/test/pseudo/trivial.ts +98 -0
- package/test/pseudo/type.ts +105 -0
- package/test/pseudo/undesirable.ts +98 -0
- package/test/pseudo/unknown.ts +98 -0
- package/test/pseudo/unmaintained.ts +98 -0
- package/test/pseudo/unpopular.ts +98 -0
- package/test/pseudo/unstable.ts +98 -0
- package/test/pseudo/vuln.ts +625 -0
- package/test/pseudo/vulnerable.ts +137 -0
- package/test/pseudo/workspace.ts +111 -0
- package/test/pseudo.ts +558 -0
- package/tsconfig.json +3 -0
- package/tsconfig.publish.json +19 -0
- package/tsconfig.publish.tsbuildinfo +1 -0
- package/typedoc.mjs +2 -0
- package/dist/pseudo/vulnerable.d.ts +0 -8
- package/dist/pseudo/vulnerable.js +0 -17
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import t from 'tap'
|
|
2
|
+
import { joinDepIDTuple } from '@vltpkg/dep-id'
|
|
3
|
+
import { asSecurityArchiveLike } from '@vltpkg/security-archive'
|
|
4
|
+
import { getSimpleGraph } from '../fixtures/graph.ts'
|
|
5
|
+
import type { ParserState } from '../../src/types.ts'
|
|
6
|
+
import { parse } from '../../src/parser.ts'
|
|
7
|
+
import { dynamic } from '../../src/pseudo/dynamic.ts'
|
|
8
|
+
|
|
9
|
+
t.test('selects packages with a dynamicRequire alert', async t => {
|
|
10
|
+
const getState = (query: string, graph = getSimpleGraph()) => {
|
|
11
|
+
const ast = parse(query)
|
|
12
|
+
const current = ast.first.first
|
|
13
|
+
const state: ParserState = {
|
|
14
|
+
comment: '',
|
|
15
|
+
current,
|
|
16
|
+
initial: {
|
|
17
|
+
edges: new Set(graph.edges.values()),
|
|
18
|
+
nodes: new Set(graph.nodes.values()),
|
|
19
|
+
},
|
|
20
|
+
partial: {
|
|
21
|
+
edges: new Set(graph.edges.values()),
|
|
22
|
+
nodes: new Set(graph.nodes.values()),
|
|
23
|
+
},
|
|
24
|
+
collect: {
|
|
25
|
+
edges: new Set(),
|
|
26
|
+
nodes: new Set(),
|
|
27
|
+
},
|
|
28
|
+
cancellable: async () => {},
|
|
29
|
+
walk: async i => i,
|
|
30
|
+
securityArchive: asSecurityArchiveLike(
|
|
31
|
+
new Map([
|
|
32
|
+
[
|
|
33
|
+
joinDepIDTuple(['registry', '', 'e@1.0.0']),
|
|
34
|
+
{ alerts: [{ type: 'dynamicRequire' }] },
|
|
35
|
+
],
|
|
36
|
+
]),
|
|
37
|
+
),
|
|
38
|
+
importers: new Set(graph.importers),
|
|
39
|
+
retries: 0,
|
|
40
|
+
signal: new AbortController().signal,
|
|
41
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
42
|
+
}
|
|
43
|
+
return state
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await t.test(
|
|
47
|
+
'filter out any node that does not have the alert',
|
|
48
|
+
async t => {
|
|
49
|
+
const res = await dynamic(getState(':dynamic'))
|
|
50
|
+
t.strictSame(
|
|
51
|
+
[...res.partial.nodes].map(n => n.name),
|
|
52
|
+
['e'],
|
|
53
|
+
'should select only dynamic packages',
|
|
54
|
+
)
|
|
55
|
+
t.matchSnapshot({
|
|
56
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
57
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
t.test('missing security archive', async t => {
|
|
64
|
+
const getState = (query: string) => {
|
|
65
|
+
const ast = parse(query)
|
|
66
|
+
const current = ast.first.first
|
|
67
|
+
const state: ParserState = {
|
|
68
|
+
comment: '',
|
|
69
|
+
current,
|
|
70
|
+
initial: {
|
|
71
|
+
edges: new Set(),
|
|
72
|
+
nodes: new Set(),
|
|
73
|
+
},
|
|
74
|
+
partial: {
|
|
75
|
+
edges: new Set(),
|
|
76
|
+
nodes: new Set(),
|
|
77
|
+
},
|
|
78
|
+
collect: {
|
|
79
|
+
edges: new Set(),
|
|
80
|
+
nodes: new Set(),
|
|
81
|
+
},
|
|
82
|
+
cancellable: async () => {},
|
|
83
|
+
walk: async i => i,
|
|
84
|
+
securityArchive: undefined,
|
|
85
|
+
importers: new Set(),
|
|
86
|
+
retries: 0,
|
|
87
|
+
signal: new AbortController().signal,
|
|
88
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
89
|
+
}
|
|
90
|
+
return state
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await t.rejects(
|
|
94
|
+
dynamic(getState(':dynamic')),
|
|
95
|
+
{ message: /Missing security archive/ },
|
|
96
|
+
'should throw an error',
|
|
97
|
+
)
|
|
98
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import t from 'tap'
|
|
2
|
+
import type { ParserState } from '../../src/types.ts'
|
|
3
|
+
import { parse } from '../../src/parser.ts'
|
|
4
|
+
import { empty } from '../../src/pseudo/empty.ts'
|
|
5
|
+
import {
|
|
6
|
+
getSimpleGraph,
|
|
7
|
+
getSingleWorkspaceGraph,
|
|
8
|
+
getCycleGraph,
|
|
9
|
+
} from '../fixtures/graph.ts'
|
|
10
|
+
|
|
11
|
+
t.test('selects packages with no dependencies', async t => {
|
|
12
|
+
const getState = (query: string, graph = getSimpleGraph()) => {
|
|
13
|
+
const ast = parse(query)
|
|
14
|
+
const current = ast.first.first
|
|
15
|
+
const state: ParserState = {
|
|
16
|
+
comment: '',
|
|
17
|
+
current,
|
|
18
|
+
initial: {
|
|
19
|
+
edges: new Set(graph.edges.values()),
|
|
20
|
+
nodes: new Set(graph.nodes.values()),
|
|
21
|
+
},
|
|
22
|
+
partial: {
|
|
23
|
+
edges: new Set(graph.edges.values()),
|
|
24
|
+
nodes: new Set(graph.nodes.values()),
|
|
25
|
+
},
|
|
26
|
+
collect: {
|
|
27
|
+
edges: new Set(),
|
|
28
|
+
nodes: new Set(),
|
|
29
|
+
},
|
|
30
|
+
cancellable: async () => {},
|
|
31
|
+
walk: async i => i,
|
|
32
|
+
retries: 0,
|
|
33
|
+
securityArchive: undefined,
|
|
34
|
+
importers: new Set(graph.importers),
|
|
35
|
+
signal: new AbortController().signal,
|
|
36
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
37
|
+
}
|
|
38
|
+
return state
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await t.test(
|
|
42
|
+
'selects nodes with no outgoing edges in simple graph',
|
|
43
|
+
async t => {
|
|
44
|
+
// Based on the getSimpleGraph fixture, packages a, c, e, f and @x/y have no dependencies
|
|
45
|
+
const res = await empty(getState(':empty'))
|
|
46
|
+
t.strictSame(
|
|
47
|
+
[...res.partial.nodes].map(n => n.name).sort(),
|
|
48
|
+
['a', 'c', 'e', 'f', '@x/y'].sort(),
|
|
49
|
+
'should select only packages with no dependencies',
|
|
50
|
+
)
|
|
51
|
+
t.matchSnapshot({
|
|
52
|
+
nodes: [...res.partial.nodes].map(n => n.name).sort(),
|
|
53
|
+
edges: [...res.partial.edges].map(e => e.name).sort(),
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
await t.test(
|
|
59
|
+
'selects nodes with no outgoing edges in workspace graph',
|
|
60
|
+
async t => {
|
|
61
|
+
// In getSingleWorkspaceGraph, both 'ws' (root) and 'w' (workspace) have no dependencies
|
|
62
|
+
const wsGraph = getSingleWorkspaceGraph()
|
|
63
|
+
const res = await empty(getState(':empty', wsGraph))
|
|
64
|
+
t.strictSame(
|
|
65
|
+
[...res.partial.nodes].map(n => n.name).sort(),
|
|
66
|
+
['ws', 'w'].sort(),
|
|
67
|
+
'should select all nodes in workspace graph as none have dependencies',
|
|
68
|
+
)
|
|
69
|
+
t.matchSnapshot({
|
|
70
|
+
nodes: [...res.partial.nodes].map(n => n.name).sort(),
|
|
71
|
+
edges: [...res.partial.edges].map(e => e.name).sort(),
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
await t.test('returns no nodes in cycle graph', async t => {
|
|
77
|
+
// In getCycleGraph, all nodes have dependencies (cycle)
|
|
78
|
+
const cycleGraph = getCycleGraph()
|
|
79
|
+
const res = await empty(getState(':empty', cycleGraph))
|
|
80
|
+
t.strictSame(
|
|
81
|
+
[...res.partial.nodes].map(n => n.name),
|
|
82
|
+
[],
|
|
83
|
+
'should not select any packages in a cycle graph as all have dependencies',
|
|
84
|
+
)
|
|
85
|
+
t.matchSnapshot({
|
|
86
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
87
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
await t.test('handles an empty partial state', async t => {
|
|
92
|
+
// Create a state with empty partial nodes
|
|
93
|
+
const state = getState(':empty')
|
|
94
|
+
state.partial.nodes.clear()
|
|
95
|
+
state.partial.edges.clear()
|
|
96
|
+
|
|
97
|
+
const res = await empty(state)
|
|
98
|
+
t.strictSame(
|
|
99
|
+
[...res.partial.nodes].map(n => n.name),
|
|
100
|
+
[],
|
|
101
|
+
'should return empty array when starting with empty partial state',
|
|
102
|
+
)
|
|
103
|
+
t.matchSnapshot({
|
|
104
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
105
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import t from 'tap'
|
|
2
|
+
import { joinDepIDTuple } from '@vltpkg/dep-id'
|
|
3
|
+
import { asSecurityArchiveLike } from '@vltpkg/security-archive'
|
|
4
|
+
import { getSimpleGraph } from '../fixtures/graph.ts'
|
|
5
|
+
import type { ParserState } from '../../src/types.ts'
|
|
6
|
+
import { parse } from '../../src/parser.ts'
|
|
7
|
+
import { entropic } from '../../src/pseudo/entropic.ts'
|
|
8
|
+
|
|
9
|
+
t.test(
|
|
10
|
+
'selects packages with a highEntropyStrings alert',
|
|
11
|
+
async t => {
|
|
12
|
+
const getState = (query: string, graph = getSimpleGraph()) => {
|
|
13
|
+
const ast = parse(query)
|
|
14
|
+
const current = ast.first.first
|
|
15
|
+
const state: ParserState = {
|
|
16
|
+
comment: '',
|
|
17
|
+
current,
|
|
18
|
+
initial: {
|
|
19
|
+
edges: new Set(graph.edges.values()),
|
|
20
|
+
nodes: new Set(graph.nodes.values()),
|
|
21
|
+
},
|
|
22
|
+
partial: {
|
|
23
|
+
edges: new Set(graph.edges.values()),
|
|
24
|
+
nodes: new Set(graph.nodes.values()),
|
|
25
|
+
},
|
|
26
|
+
collect: {
|
|
27
|
+
edges: new Set(),
|
|
28
|
+
nodes: new Set(),
|
|
29
|
+
},
|
|
30
|
+
cancellable: async () => {},
|
|
31
|
+
walk: async i => i,
|
|
32
|
+
securityArchive: asSecurityArchiveLike(
|
|
33
|
+
new Map([
|
|
34
|
+
[
|
|
35
|
+
joinDepIDTuple(['registry', '', 'e@1.0.0']),
|
|
36
|
+
{ alerts: [{ type: 'highEntropyStrings' }] },
|
|
37
|
+
],
|
|
38
|
+
]),
|
|
39
|
+
),
|
|
40
|
+
importers: new Set(graph.importers),
|
|
41
|
+
retries: 0,
|
|
42
|
+
signal: new AbortController().signal,
|
|
43
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
44
|
+
}
|
|
45
|
+
return state
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
await t.test(
|
|
49
|
+
'filter out any node that does not have the alert',
|
|
50
|
+
async t => {
|
|
51
|
+
const res = await entropic(getState(':entropic'))
|
|
52
|
+
t.strictSame(
|
|
53
|
+
[...res.partial.nodes].map(n => n.name),
|
|
54
|
+
['e'],
|
|
55
|
+
'should select only entropic packages',
|
|
56
|
+
)
|
|
57
|
+
t.matchSnapshot({
|
|
58
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
59
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
)
|
|
63
|
+
},
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
t.test('missing security archive', async t => {
|
|
67
|
+
const getState = (query: string) => {
|
|
68
|
+
const ast = parse(query)
|
|
69
|
+
const current = ast.first.first
|
|
70
|
+
const state: ParserState = {
|
|
71
|
+
comment: '',
|
|
72
|
+
current,
|
|
73
|
+
initial: {
|
|
74
|
+
edges: new Set(),
|
|
75
|
+
nodes: new Set(),
|
|
76
|
+
},
|
|
77
|
+
partial: {
|
|
78
|
+
edges: new Set(),
|
|
79
|
+
nodes: new Set(),
|
|
80
|
+
},
|
|
81
|
+
collect: {
|
|
82
|
+
edges: new Set(),
|
|
83
|
+
nodes: new Set(),
|
|
84
|
+
},
|
|
85
|
+
cancellable: async () => {},
|
|
86
|
+
walk: async i => i,
|
|
87
|
+
securityArchive: undefined,
|
|
88
|
+
importers: new Set(),
|
|
89
|
+
retries: 0,
|
|
90
|
+
signal: new AbortController().signal,
|
|
91
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
92
|
+
}
|
|
93
|
+
return state
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await t.rejects(
|
|
97
|
+
entropic(getState(':entropic')),
|
|
98
|
+
{ message: /Missing security archive/ },
|
|
99
|
+
'should throw an error',
|
|
100
|
+
)
|
|
101
|
+
})
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import t from 'tap'
|
|
2
|
+
import { joinDepIDTuple } from '@vltpkg/dep-id'
|
|
3
|
+
import { asSecurityArchiveLike } from '@vltpkg/security-archive'
|
|
4
|
+
import { getSimpleGraph } from '../fixtures/graph.ts'
|
|
5
|
+
import type { ParserState } from '../../src/types.ts'
|
|
6
|
+
import { parse } from '../../src/parser.ts'
|
|
7
|
+
import { env } from '../../src/pseudo/env.ts'
|
|
8
|
+
|
|
9
|
+
t.test('selects packages with a envVars alert', async t => {
|
|
10
|
+
const getState = (query: string, graph = getSimpleGraph()) => {
|
|
11
|
+
const ast = parse(query)
|
|
12
|
+
const current = ast.first.first
|
|
13
|
+
const state: ParserState = {
|
|
14
|
+
comment: '',
|
|
15
|
+
current,
|
|
16
|
+
initial: {
|
|
17
|
+
edges: new Set(graph.edges.values()),
|
|
18
|
+
nodes: new Set(graph.nodes.values()),
|
|
19
|
+
},
|
|
20
|
+
partial: {
|
|
21
|
+
edges: new Set(graph.edges.values()),
|
|
22
|
+
nodes: new Set(graph.nodes.values()),
|
|
23
|
+
},
|
|
24
|
+
collect: {
|
|
25
|
+
edges: new Set(),
|
|
26
|
+
nodes: new Set(),
|
|
27
|
+
},
|
|
28
|
+
cancellable: async () => {},
|
|
29
|
+
walk: async i => i,
|
|
30
|
+
retries: 0,
|
|
31
|
+
securityArchive: asSecurityArchiveLike(
|
|
32
|
+
new Map([
|
|
33
|
+
[
|
|
34
|
+
joinDepIDTuple(['registry', '', 'e@1.0.0']),
|
|
35
|
+
{ alerts: [{ type: 'envVars' }] },
|
|
36
|
+
],
|
|
37
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
importers: new Set(graph.importers),
|
|
40
|
+
signal: new AbortController().signal,
|
|
41
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
42
|
+
}
|
|
43
|
+
return state
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await t.test(
|
|
47
|
+
'filter out any node that does not have the alert',
|
|
48
|
+
async t => {
|
|
49
|
+
const res = await env(getState(':env'))
|
|
50
|
+
t.strictSame(
|
|
51
|
+
[...res.partial.nodes].map(n => n.name),
|
|
52
|
+
['e'],
|
|
53
|
+
'should select only env packages',
|
|
54
|
+
)
|
|
55
|
+
t.matchSnapshot({
|
|
56
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
57
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
t.test('missing security archive', async t => {
|
|
64
|
+
const getState = (query: string) => {
|
|
65
|
+
const ast = parse(query)
|
|
66
|
+
const current = ast.first.first
|
|
67
|
+
const state: ParserState = {
|
|
68
|
+
comment: '',
|
|
69
|
+
current,
|
|
70
|
+
initial: {
|
|
71
|
+
edges: new Set(),
|
|
72
|
+
nodes: new Set(),
|
|
73
|
+
},
|
|
74
|
+
partial: {
|
|
75
|
+
edges: new Set(),
|
|
76
|
+
nodes: new Set(),
|
|
77
|
+
},
|
|
78
|
+
collect: {
|
|
79
|
+
edges: new Set(),
|
|
80
|
+
nodes: new Set(),
|
|
81
|
+
},
|
|
82
|
+
cancellable: async () => {},
|
|
83
|
+
walk: async i => i,
|
|
84
|
+
retries: 0,
|
|
85
|
+
securityArchive: undefined,
|
|
86
|
+
importers: new Set(),
|
|
87
|
+
signal: new AbortController().signal,
|
|
88
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
89
|
+
}
|
|
90
|
+
return state
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await t.rejects(
|
|
94
|
+
env(getState(':env')),
|
|
95
|
+
{ message: /Missing security archive/ },
|
|
96
|
+
'should throw an error',
|
|
97
|
+
)
|
|
98
|
+
})
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import t from 'tap'
|
|
2
|
+
import { joinDepIDTuple } from '@vltpkg/dep-id'
|
|
3
|
+
import { asSecurityArchiveLike } from '@vltpkg/security-archive'
|
|
4
|
+
import { getSimpleGraph } from '../fixtures/graph.ts'
|
|
5
|
+
import type { ParserState } from '../../src/types.ts'
|
|
6
|
+
import { parse } from '../../src/parser.ts'
|
|
7
|
+
import { evalParser } from '../../src/pseudo/eval.ts'
|
|
8
|
+
|
|
9
|
+
t.test('selects packages with an eval alert', async t => {
|
|
10
|
+
const getState = (query: string, graph = getSimpleGraph()) => {
|
|
11
|
+
const ast = parse(query)
|
|
12
|
+
const current = ast.first.first
|
|
13
|
+
const state: ParserState = {
|
|
14
|
+
comment: '',
|
|
15
|
+
current,
|
|
16
|
+
initial: {
|
|
17
|
+
edges: new Set(graph.edges.values()),
|
|
18
|
+
nodes: new Set(graph.nodes.values()),
|
|
19
|
+
},
|
|
20
|
+
partial: {
|
|
21
|
+
edges: new Set(graph.edges.values()),
|
|
22
|
+
nodes: new Set(graph.nodes.values()),
|
|
23
|
+
},
|
|
24
|
+
collect: {
|
|
25
|
+
edges: new Set(),
|
|
26
|
+
nodes: new Set(),
|
|
27
|
+
},
|
|
28
|
+
cancellable: async () => {},
|
|
29
|
+
walk: async i => i,
|
|
30
|
+
retries: 0,
|
|
31
|
+
securityArchive: asSecurityArchiveLike(
|
|
32
|
+
new Map([
|
|
33
|
+
[
|
|
34
|
+
joinDepIDTuple(['registry', '', 'e@1.0.0']),
|
|
35
|
+
{ alerts: [{ type: 'usesEval' }] },
|
|
36
|
+
],
|
|
37
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
importers: new Set(graph.importers),
|
|
40
|
+
signal: new AbortController().signal,
|
|
41
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
42
|
+
}
|
|
43
|
+
return state
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await t.test(
|
|
47
|
+
'filter out any node that does not have the alert',
|
|
48
|
+
async t => {
|
|
49
|
+
const res = await evalParser(getState(':eval'))
|
|
50
|
+
t.strictSame(
|
|
51
|
+
[...res.partial.nodes].map(n => n.name),
|
|
52
|
+
['e'],
|
|
53
|
+
'should select only eval packages',
|
|
54
|
+
)
|
|
55
|
+
t.matchSnapshot({
|
|
56
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
57
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
t.test('missing security archive', async t => {
|
|
64
|
+
const getState = (query: string) => {
|
|
65
|
+
const ast = parse(query)
|
|
66
|
+
const current = ast.first.first
|
|
67
|
+
const state: ParserState = {
|
|
68
|
+
comment: '',
|
|
69
|
+
current,
|
|
70
|
+
initial: {
|
|
71
|
+
edges: new Set(),
|
|
72
|
+
nodes: new Set(),
|
|
73
|
+
},
|
|
74
|
+
partial: {
|
|
75
|
+
edges: new Set(),
|
|
76
|
+
nodes: new Set(),
|
|
77
|
+
},
|
|
78
|
+
collect: {
|
|
79
|
+
edges: new Set(),
|
|
80
|
+
nodes: new Set(),
|
|
81
|
+
},
|
|
82
|
+
cancellable: async () => {},
|
|
83
|
+
walk: async i => i,
|
|
84
|
+
retries: 0,
|
|
85
|
+
securityArchive: undefined,
|
|
86
|
+
importers: new Set(),
|
|
87
|
+
signal: new AbortController().signal,
|
|
88
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
89
|
+
}
|
|
90
|
+
return state
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await t.rejects(
|
|
94
|
+
evalParser(getState(':eval')),
|
|
95
|
+
{ message: /Missing security archive/ },
|
|
96
|
+
'should throw an error',
|
|
97
|
+
)
|
|
98
|
+
})
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import t from 'tap'
|
|
2
|
+
import { joinDepIDTuple } from '@vltpkg/dep-id'
|
|
3
|
+
import { asSecurityArchiveLike } from '@vltpkg/security-archive'
|
|
4
|
+
import { getSimpleGraph } from '../fixtures/graph.ts'
|
|
5
|
+
import type { ParserState } from '../../src/types.ts'
|
|
6
|
+
import { parse } from '../../src/parser.ts'
|
|
7
|
+
import { fs } from '../../src/pseudo/fs.ts'
|
|
8
|
+
|
|
9
|
+
t.test('selects packages with a filesystemAccess alert', async t => {
|
|
10
|
+
const getState = (query: string, graph = getSimpleGraph()) => {
|
|
11
|
+
const ast = parse(query)
|
|
12
|
+
const current = ast.first.first
|
|
13
|
+
const state: ParserState = {
|
|
14
|
+
comment: '',
|
|
15
|
+
current,
|
|
16
|
+
initial: {
|
|
17
|
+
edges: new Set(graph.edges.values()),
|
|
18
|
+
nodes: new Set(graph.nodes.values()),
|
|
19
|
+
},
|
|
20
|
+
partial: {
|
|
21
|
+
edges: new Set(graph.edges.values()),
|
|
22
|
+
nodes: new Set(graph.nodes.values()),
|
|
23
|
+
},
|
|
24
|
+
collect: {
|
|
25
|
+
edges: new Set(),
|
|
26
|
+
nodes: new Set(),
|
|
27
|
+
},
|
|
28
|
+
cancellable: async () => {},
|
|
29
|
+
walk: async i => i,
|
|
30
|
+
retries: 0,
|
|
31
|
+
securityArchive: asSecurityArchiveLike(
|
|
32
|
+
new Map([
|
|
33
|
+
[
|
|
34
|
+
joinDepIDTuple(['registry', '', 'e@1.0.0']),
|
|
35
|
+
{ alerts: [{ type: 'filesystemAccess' }] },
|
|
36
|
+
],
|
|
37
|
+
]),
|
|
38
|
+
),
|
|
39
|
+
importers: new Set(graph.importers),
|
|
40
|
+
signal: new AbortController().signal,
|
|
41
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
42
|
+
}
|
|
43
|
+
return state
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await t.test(
|
|
47
|
+
'filter out any node that does not have the alert',
|
|
48
|
+
async t => {
|
|
49
|
+
const res = await fs(getState(':fs'))
|
|
50
|
+
t.strictSame(
|
|
51
|
+
[...res.partial.nodes].map(n => n.name),
|
|
52
|
+
['e'],
|
|
53
|
+
'should select only fs packages',
|
|
54
|
+
)
|
|
55
|
+
t.matchSnapshot({
|
|
56
|
+
nodes: [...res.partial.nodes].map(n => n.name),
|
|
57
|
+
edges: [...res.partial.edges].map(e => e.name),
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
t.test('missing security archive', async t => {
|
|
64
|
+
const getState = (query: string) => {
|
|
65
|
+
const ast = parse(query)
|
|
66
|
+
const current = ast.first.first
|
|
67
|
+
const state: ParserState = {
|
|
68
|
+
comment: '',
|
|
69
|
+
current,
|
|
70
|
+
initial: {
|
|
71
|
+
edges: new Set(),
|
|
72
|
+
nodes: new Set(),
|
|
73
|
+
},
|
|
74
|
+
partial: {
|
|
75
|
+
edges: new Set(),
|
|
76
|
+
nodes: new Set(),
|
|
77
|
+
},
|
|
78
|
+
collect: {
|
|
79
|
+
edges: new Set(),
|
|
80
|
+
nodes: new Set(),
|
|
81
|
+
},
|
|
82
|
+
cancellable: async () => {},
|
|
83
|
+
walk: async i => i,
|
|
84
|
+
retries: 0,
|
|
85
|
+
securityArchive: undefined,
|
|
86
|
+
importers: new Set(),
|
|
87
|
+
signal: new AbortController().signal,
|
|
88
|
+
specificity: { idCounter: 0, commonCounter: 0 },
|
|
89
|
+
}
|
|
90
|
+
return state
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await t.rejects(
|
|
94
|
+
fs(getState(':fs')),
|
|
95
|
+
{ message: /Missing security archive/ },
|
|
96
|
+
'should throw an error',
|
|
97
|
+
)
|
|
98
|
+
})
|