@vltpkg/query 0.0.0-3 → 0.0.0-30
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/README.md +39 -82
- package/dist/esm/attribute.d.ts +1 -1
- package/dist/esm/attribute.d.ts.map +1 -1
- package/dist/esm/attribute.js +8 -13
- package/dist/esm/attribute.js.map +1 -1
- package/dist/esm/combinator.d.ts.map +1 -1
- package/dist/esm/combinator.js +5 -2
- package/dist/esm/combinator.js.map +1 -1
- package/dist/esm/id.d.ts.map +1 -1
- package/dist/esm/id.js +23 -7
- package/dist/esm/id.js.map +1 -1
- package/dist/esm/index.d.ts +40 -7
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +303 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/parser.d.ts +15 -0
- package/dist/esm/parser.d.ts.map +1 -0
- package/dist/esm/parser.js +93 -0
- package/dist/esm/parser.js.map +1 -0
- package/dist/esm/pseudo/abandoned.d.ts +7 -0
- package/dist/esm/pseudo/abandoned.d.ts.map +1 -0
- package/dist/esm/pseudo/abandoned.js +6 -0
- package/dist/esm/pseudo/abandoned.js.map +1 -0
- package/dist/esm/pseudo/attr.d.ts +2 -1
- package/dist/esm/pseudo/attr.d.ts.map +1 -1
- package/dist/esm/pseudo/attr.js +10 -2
- package/dist/esm/pseudo/attr.js.map +1 -1
- package/dist/esm/pseudo/confused.d.ts +9 -0
- package/dist/esm/pseudo/confused.d.ts.map +1 -0
- package/dist/esm/pseudo/confused.js +19 -0
- package/dist/esm/pseudo/confused.js.map +1 -0
- package/dist/esm/pseudo/cve.d.ts +13 -0
- package/dist/esm/pseudo/cve.d.ts.map +1 -0
- package/dist/esm/pseudo/cve.js +44 -0
- package/dist/esm/pseudo/cve.js.map +1 -0
- package/dist/esm/pseudo/cwe.d.ts +13 -0
- package/dist/esm/pseudo/cwe.d.ts.map +1 -0
- package/dist/esm/pseudo/cwe.js +43 -0
- package/dist/esm/pseudo/cwe.js.map +1 -0
- package/dist/esm/pseudo/debug.d.ts +7 -0
- package/dist/esm/pseudo/debug.d.ts.map +1 -0
- package/dist/esm/pseudo/debug.js +6 -0
- package/dist/esm/pseudo/debug.js.map +1 -0
- package/dist/esm/pseudo/deprecated.d.ts +7 -0
- package/dist/esm/pseudo/deprecated.d.ts.map +1 -0
- package/dist/esm/pseudo/deprecated.js +6 -0
- package/dist/esm/pseudo/deprecated.js.map +1 -0
- package/dist/esm/pseudo/dev.d.ts +6 -0
- package/dist/esm/pseudo/dev.d.ts.map +1 -0
- package/dist/esm/pseudo/dev.js +15 -0
- package/dist/esm/pseudo/dev.js.map +1 -0
- package/dist/esm/pseudo/dynamic.d.ts +7 -0
- package/dist/esm/pseudo/dynamic.d.ts.map +1 -0
- package/dist/esm/pseudo/dynamic.js +6 -0
- package/dist/esm/pseudo/dynamic.js.map +1 -0
- package/dist/esm/pseudo/empty.d.ts +7 -0
- package/dist/esm/pseudo/empty.d.ts.map +1 -0
- package/dist/esm/pseudo/empty.js +14 -0
- package/dist/esm/pseudo/empty.js.map +1 -0
- package/dist/esm/pseudo/entropic.d.ts +7 -0
- package/dist/esm/pseudo/entropic.d.ts.map +1 -0
- package/dist/esm/pseudo/entropic.js +6 -0
- package/dist/esm/pseudo/entropic.js.map +1 -0
- package/dist/esm/pseudo/env.d.ts +7 -0
- package/dist/esm/pseudo/env.d.ts.map +1 -0
- package/dist/esm/pseudo/env.js +6 -0
- package/dist/esm/pseudo/env.js.map +1 -0
- package/dist/esm/pseudo/eval.d.ts +7 -0
- package/dist/esm/pseudo/eval.d.ts.map +1 -0
- package/dist/esm/pseudo/eval.js +6 -0
- package/dist/esm/pseudo/eval.js.map +1 -0
- package/dist/esm/pseudo/fs.d.ts +7 -0
- package/dist/esm/pseudo/fs.d.ts.map +1 -0
- package/dist/esm/pseudo/fs.js +6 -0
- package/dist/esm/pseudo/fs.js.map +1 -0
- package/dist/esm/pseudo/helpers.d.ts +25 -1
- package/dist/esm/pseudo/helpers.d.ts.map +1 -1
- package/dist/esm/pseudo/helpers.js +53 -0
- package/dist/esm/pseudo/helpers.js.map +1 -1
- package/dist/esm/pseudo/host.d.ts +20 -0
- package/dist/esm/pseudo/host.d.ts.map +1 -0
- package/dist/esm/pseudo/host.js +80 -0
- package/dist/esm/pseudo/host.js.map +1 -0
- package/dist/esm/pseudo/license.d.ts +13 -0
- package/dist/esm/pseudo/license.d.ts.map +1 -0
- package/dist/esm/pseudo/license.js +58 -0
- package/dist/esm/pseudo/license.js.map +1 -0
- package/dist/esm/pseudo/link.d.ts +9 -0
- package/dist/esm/pseudo/link.d.ts.map +1 -0
- package/dist/esm/pseudo/link.js +25 -0
- package/dist/esm/pseudo/link.js.map +1 -0
- package/dist/esm/pseudo/malware.d.ts +24 -0
- package/dist/esm/pseudo/malware.d.ts.map +1 -0
- package/dist/esm/pseudo/malware.js +187 -0
- package/dist/esm/pseudo/malware.js.map +1 -0
- package/dist/esm/pseudo/minified.d.ts +7 -0
- package/dist/esm/pseudo/minified.d.ts.map +1 -0
- package/dist/esm/pseudo/minified.js +6 -0
- package/dist/esm/pseudo/minified.js.map +1 -0
- package/dist/esm/pseudo/missing.d.ts +8 -0
- package/dist/esm/pseudo/missing.d.ts.map +1 -0
- package/dist/esm/pseudo/missing.js +15 -0
- package/dist/esm/pseudo/missing.js.map +1 -0
- package/dist/esm/pseudo/native.d.ts +7 -0
- package/dist/esm/pseudo/native.d.ts.map +1 -0
- package/dist/esm/pseudo/native.js +6 -0
- package/dist/esm/pseudo/native.js.map +1 -0
- package/dist/esm/pseudo/network.d.ts +7 -0
- package/dist/esm/pseudo/network.d.ts.map +1 -0
- package/dist/esm/pseudo/network.js +6 -0
- package/dist/esm/pseudo/network.js.map +1 -0
- package/dist/esm/pseudo/obfuscated.d.ts +7 -0
- package/dist/esm/pseudo/obfuscated.d.ts.map +1 -0
- package/dist/esm/pseudo/obfuscated.js +6 -0
- package/dist/esm/pseudo/obfuscated.js.map +1 -0
- package/dist/esm/pseudo/optional.d.ts +6 -0
- package/dist/esm/pseudo/optional.d.ts.map +1 -0
- package/dist/esm/pseudo/optional.js +15 -0
- package/dist/esm/pseudo/optional.js.map +1 -0
- package/dist/esm/pseudo/outdated.d.ts +4 -4
- package/dist/esm/pseudo/outdated.d.ts.map +1 -1
- package/dist/esm/pseudo/outdated.js +44 -33
- package/dist/esm/pseudo/outdated.js.map +1 -1
- package/dist/esm/pseudo/overridden.d.ts +8 -0
- package/dist/esm/pseudo/overridden.d.ts.map +1 -0
- package/dist/esm/pseudo/overridden.js +17 -0
- package/dist/esm/pseudo/overridden.js.map +1 -0
- package/dist/esm/pseudo/path.d.ts +19 -0
- package/dist/esm/pseudo/path.d.ts.map +1 -0
- package/dist/esm/pseudo/path.js +113 -0
- package/dist/esm/pseudo/path.js.map +1 -0
- package/dist/esm/pseudo/peer.d.ts +6 -0
- package/dist/esm/pseudo/peer.d.ts.map +1 -0
- package/dist/esm/pseudo/peer.js +15 -0
- package/dist/esm/pseudo/peer.js.map +1 -0
- package/dist/esm/pseudo/prerelease.d.ts +18 -0
- package/dist/esm/pseudo/prerelease.d.ts.map +1 -0
- package/dist/esm/pseudo/prerelease.js +41 -0
- package/dist/esm/pseudo/prerelease.js.map +1 -0
- package/dist/esm/pseudo/private.d.ts +7 -0
- package/dist/esm/pseudo/private.d.ts.map +1 -0
- package/dist/esm/pseudo/private.js +16 -0
- package/dist/esm/pseudo/private.js.map +1 -0
- package/dist/esm/pseudo/prod.d.ts +6 -0
- package/dist/esm/pseudo/prod.d.ts.map +1 -0
- package/dist/esm/pseudo/prod.js +15 -0
- package/dist/esm/pseudo/prod.js.map +1 -0
- package/dist/esm/pseudo/published.d.ts +40 -0
- package/dist/esm/pseudo/published.d.ts.map +1 -0
- package/dist/esm/pseudo/published.js +158 -0
- package/dist/esm/pseudo/published.js.map +1 -0
- package/dist/esm/pseudo/root.d.ts +7 -0
- package/dist/esm/pseudo/root.d.ts.map +1 -0
- package/dist/esm/pseudo/root.js +18 -0
- package/dist/esm/pseudo/root.js.map +1 -0
- package/dist/esm/pseudo/scanned.d.ts +9 -0
- package/dist/esm/pseudo/scanned.d.ts.map +1 -0
- package/dist/esm/pseudo/scanned.js +17 -0
- package/dist/esm/pseudo/scanned.js.map +1 -0
- package/dist/esm/pseudo/score.d.ts +16 -0
- package/dist/esm/pseudo/score.d.ts.map +1 -0
- package/dist/esm/pseudo/score.js +119 -0
- package/dist/esm/pseudo/score.js.map +1 -0
- package/dist/esm/pseudo/scripts.d.ts +7 -0
- package/dist/esm/pseudo/scripts.d.ts.map +1 -0
- package/dist/esm/pseudo/scripts.js +6 -0
- package/dist/esm/pseudo/scripts.js.map +1 -0
- package/dist/esm/pseudo/semver.d.ts +2 -1
- package/dist/esm/pseudo/semver.d.ts.map +1 -1
- package/dist/esm/pseudo/semver.js +11 -24
- package/dist/esm/pseudo/semver.js.map +1 -1
- package/dist/esm/pseudo/severity.d.ts +15 -0
- package/dist/esm/pseudo/severity.d.ts.map +1 -0
- package/dist/esm/pseudo/severity.js +160 -0
- package/dist/esm/pseudo/severity.js.map +1 -0
- package/dist/esm/pseudo/shell.d.ts +7 -0
- package/dist/esm/pseudo/shell.d.ts.map +1 -0
- package/dist/esm/pseudo/shell.js +6 -0
- package/dist/esm/pseudo/shell.js.map +1 -0
- package/dist/esm/pseudo/shrinkwrap.d.ts +7 -0
- package/dist/esm/pseudo/shrinkwrap.d.ts.map +1 -0
- package/dist/esm/pseudo/shrinkwrap.js +6 -0
- package/dist/esm/pseudo/shrinkwrap.js.map +1 -0
- package/dist/esm/pseudo/spec.d.ts +17 -0
- package/dist/esm/pseudo/spec.d.ts.map +1 -0
- package/dist/esm/pseudo/spec.js +102 -0
- package/dist/esm/pseudo/spec.js.map +1 -0
- package/dist/esm/pseudo/squat.d.ts +15 -0
- package/dist/esm/pseudo/squat.d.ts.map +1 -0
- package/dist/esm/pseudo/squat.js +161 -0
- package/dist/esm/pseudo/squat.js.map +1 -0
- package/dist/esm/pseudo/suspicious.d.ts +7 -0
- package/dist/esm/pseudo/suspicious.d.ts.map +1 -0
- package/dist/esm/pseudo/suspicious.js +6 -0
- package/dist/esm/pseudo/suspicious.js.map +1 -0
- package/dist/esm/pseudo/tracker.d.ts +7 -0
- package/dist/esm/pseudo/tracker.d.ts.map +1 -0
- package/dist/esm/pseudo/tracker.js +6 -0
- package/dist/esm/pseudo/tracker.js.map +1 -0
- package/dist/esm/pseudo/trivial.d.ts +7 -0
- package/dist/esm/pseudo/trivial.d.ts.map +1 -0
- package/dist/esm/pseudo/trivial.js +6 -0
- package/dist/esm/pseudo/trivial.js.map +1 -0
- package/dist/esm/pseudo/type.d.ts +8 -0
- package/dist/esm/pseudo/type.d.ts.map +1 -0
- package/dist/esm/pseudo/type.js +22 -0
- package/dist/esm/pseudo/type.js.map +1 -0
- package/dist/esm/pseudo/undesirable.d.ts +7 -0
- package/dist/esm/pseudo/undesirable.d.ts.map +1 -0
- package/dist/esm/pseudo/undesirable.js +6 -0
- package/dist/esm/pseudo/undesirable.js.map +1 -0
- package/dist/esm/pseudo/unknown.d.ts +7 -0
- package/dist/esm/pseudo/unknown.d.ts.map +1 -0
- package/dist/esm/pseudo/unknown.js +6 -0
- package/dist/esm/pseudo/unknown.js.map +1 -0
- package/dist/esm/pseudo/unmaintained.d.ts +7 -0
- package/dist/esm/pseudo/unmaintained.d.ts.map +1 -0
- package/dist/esm/pseudo/unmaintained.js +6 -0
- package/dist/esm/pseudo/unmaintained.js.map +1 -0
- package/dist/esm/pseudo/unpopular.d.ts +7 -0
- package/dist/esm/pseudo/unpopular.d.ts.map +1 -0
- package/dist/esm/pseudo/unpopular.js +6 -0
- package/dist/esm/pseudo/unpopular.js.map +1 -0
- package/dist/esm/pseudo/unstable.d.ts +7 -0
- package/dist/esm/pseudo/unstable.d.ts.map +1 -0
- package/dist/esm/pseudo/unstable.js +6 -0
- package/dist/esm/pseudo/unstable.js.map +1 -0
- package/dist/esm/pseudo/workspace.d.ts +6 -0
- package/dist/esm/pseudo/workspace.d.ts.map +1 -0
- package/dist/esm/pseudo/workspace.js +20 -0
- package/dist/esm/pseudo/workspace.js.map +1 -0
- package/dist/esm/pseudo.d.ts.map +1 -1
- package/dist/esm/pseudo.js +151 -109
- package/dist/esm/pseudo.js.map +1 -1
- package/dist/esm/types.d.ts +98 -26
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +1 -106
- package/dist/esm/types.js.map +1 -1
- package/package.json +20 -15
- package/dist/esm/class.d.ts +0 -6
- package/dist/esm/class.d.ts.map +0 -1
- package/dist/esm/class.js +0 -128
- package/dist/esm/class.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrC,CAAC;AAC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3B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,IAAY,EACZ,IAAY,EACZ,EAAE;IACF,OAAO,KAAK,EAAE,KAAkB,EAAE,EAAE;QAClC,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAElC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAC7B,CAAA;YACD,IAAI,OAAO,EAAE,CAAC;gBACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\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 an edge and its outgoing node from the results.\n */\nexport const removeEdge = (state: ParserState, edge: EdgeLike) => {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n}\n\n/**\n * Removes any edges that have no destination node from the results.\n */\nexport const removeDanglingEdges = (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n}\n\n/**\n * Removes any nodes that have no incoming edges from the results.\n */\nexport const removeUnlinkedNodes = (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesIn.size === 0) {\n state.partial.nodes.delete(node)\n }\n }\n}\n\n/**\n * Removes quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\n\n/**\n * Asserts that the security archive is present.\n */\nexport const assertSecurityArchive: (\n state: ParserState,\n name: string,\n) => asserts state is ParserState & {\n securityArchive: NonNullable<ParserState['securityArchive']>\n} = (state, name) => {\n if (!state.securityArchive) {\n throw error(\n `Missing security archive while trying to parse the :${name} selector`,\n { found: state },\n )\n }\n}\n\n/**\n * Clears all nodes and edges from the results.\n */\nexport const clear = (state: ParserState): ParserState => {\n state.partial.nodes.clear()\n state.partial.edges.clear()\n return state\n}\n\n/**\n * Reusable security selector alert filter.\n */\nexport const createSecuritySelectorFilter = (\n name: string,\n type: string,\n) => {\n return async (state: ParserState) => {\n assertSecurityArchive(state, name)\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert => alert.type === type,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
import type { PostcssNode } from '@vltpkg/dss-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Parses the internal parameters of the :host() pseudo selector.
|
|
5
|
+
* Returns the context key that should be used to look up the host context function.
|
|
6
|
+
*/
|
|
7
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => string;
|
|
8
|
+
/**
|
|
9
|
+
* :host Pseudo-Selector, switches the current graph context to a new
|
|
10
|
+
* set of graphs loaded from a specific host context.
|
|
11
|
+
*
|
|
12
|
+
* This selector accepts a single parameter that specifies which host context
|
|
13
|
+
* to use. The host context must be defined in the hostContexts map provided
|
|
14
|
+
* to the Query constructor.
|
|
15
|
+
*
|
|
16
|
+
* Example:
|
|
17
|
+
* - :host(local) - Switches to graphs loaded from the local context
|
|
18
|
+
*/
|
|
19
|
+
export declare const hostContext: (state: ParserState) => Promise<ParserState>;
|
|
20
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/pseudo/host.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH,eAAO,MAAM,cAAc,UAAW,WAAW,EAAE,KAAG,MAsBrD,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,UAAiB,WAAW,yBA2DnD,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
3
|
+
import { removeQuotes } from "./helpers.js";
|
|
4
|
+
/**
|
|
5
|
+
* Parses the internal parameters of the :host() pseudo selector.
|
|
6
|
+
* Returns the context key that should be used to look up the host context function.
|
|
7
|
+
*/
|
|
8
|
+
export const parseInternals = (nodes) => {
|
|
9
|
+
let contextKey = '';
|
|
10
|
+
if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
11
|
+
contextKey = removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
|
|
12
|
+
.value);
|
|
13
|
+
}
|
|
14
|
+
else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
15
|
+
const tagNode = asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]);
|
|
16
|
+
contextKey = tagNode.value;
|
|
17
|
+
}
|
|
18
|
+
if (!contextKey) {
|
|
19
|
+
throw error('Expected a context key parameter for :host selector');
|
|
20
|
+
}
|
|
21
|
+
return contextKey;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* :host Pseudo-Selector, switches the current graph context to a new
|
|
25
|
+
* set of graphs loaded from a specific host context.
|
|
26
|
+
*
|
|
27
|
+
* This selector accepts a single parameter that specifies which host context
|
|
28
|
+
* to use. The host context must be defined in the hostContexts map provided
|
|
29
|
+
* to the Query constructor.
|
|
30
|
+
*
|
|
31
|
+
* Example:
|
|
32
|
+
* - :host(local) - Switches to graphs loaded from the local context
|
|
33
|
+
*/
|
|
34
|
+
export const hostContext = async (state) => {
|
|
35
|
+
if (!state.hostContexts) {
|
|
36
|
+
throw error('No host contexts available for :host selector');
|
|
37
|
+
}
|
|
38
|
+
let contextKey;
|
|
39
|
+
try {
|
|
40
|
+
contextKey = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw error('Failed to parse :host selector', {
|
|
44
|
+
cause: err,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const contextFunction = state.hostContexts.get(contextKey);
|
|
48
|
+
if (!contextFunction) {
|
|
49
|
+
throw error(`Unknown host context: ${contextKey}`, {
|
|
50
|
+
validOptions: Array.from(state.hostContexts.keys()),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Get the graphs from the host context function
|
|
54
|
+
const { initialEdges, initialNodes, edges, nodes, securityArchive, } = await contextFunction();
|
|
55
|
+
// Clear current nodes and edges
|
|
56
|
+
state.securityArchive = securityArchive;
|
|
57
|
+
state.initial.nodes.clear();
|
|
58
|
+
state.initial.edges.clear();
|
|
59
|
+
state.partial.nodes.clear();
|
|
60
|
+
state.partial.edges.clear();
|
|
61
|
+
state.importers.clear();
|
|
62
|
+
// Reset the initial state
|
|
63
|
+
for (const node of initialNodes) {
|
|
64
|
+
state.initial.nodes.add(node);
|
|
65
|
+
}
|
|
66
|
+
for (const edge of initialEdges) {
|
|
67
|
+
state.initial.edges.add(edge);
|
|
68
|
+
}
|
|
69
|
+
// Populate with nodes and edges from all returned graphs
|
|
70
|
+
for (const node of nodes) {
|
|
71
|
+
state.partial.nodes.add(node);
|
|
72
|
+
// use the current selected nodes by the context function as importers
|
|
73
|
+
state.importers.add(node);
|
|
74
|
+
}
|
|
75
|
+
for (const edge of edges) {
|
|
76
|
+
state.partial.edges.add(edge);
|
|
77
|
+
}
|
|
78
|
+
return state;
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../src/pseudo/host.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,oBAAoB,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAI3C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAU,EAAE;IAC7D,IAAI,UAAU,GAAG,EAAE,CAAA;IAEnB,IAAI,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,UAAU,GAAG,YAAY,CACvB,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACvD,KAAK,CACT,CAAA;IACH,CAAC;SAAM,IACL,SAAS,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACvD,CAAC;QACD,MAAM,OAAO,GAAG,SAAS,CACvB,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CA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AA;IAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;IAEvB,0BAA0B;IAC1B,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,yDAAyD;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC7B,sEAAsE;QACtE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,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 '@vltpkg/dss-parser'\nimport { removeQuotes } from './helpers.ts'\nimport type { ParserState } from '../types.ts'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\n\n/**\n * Parses the internal parameters of the :host() pseudo selector.\n * Returns the context key that should be used to look up the host context function.\n */\nexport const parseInternals = (nodes: PostcssNode[]): string => {\n let contextKey = ''\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n contextKey = removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n const tagNode = asTagNode(\n asPostcssNodeWithChildren(nodes[0]).nodes[0],\n )\n contextKey = tagNode.value\n }\n\n if (!contextKey) {\n throw error('Expected a context key parameter for :host selector')\n }\n\n return contextKey\n}\n\n/**\n * :host Pseudo-Selector, switches the current graph context to a new\n * set of graphs loaded from a specific host context.\n *\n * This selector accepts a single parameter that specifies which host context\n * to use. The host context must be defined in the hostContexts map provided\n * to the Query constructor.\n *\n * Example:\n * - :host(local) - Switches to graphs loaded from the local context\n */\nexport const hostContext = async (state: ParserState) => {\n if (!state.hostContexts) {\n throw error('No host contexts available for :host selector')\n }\n\n let contextKey: string\n try {\n contextKey = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :host selector', {\n cause: err,\n })\n }\n\n const contextFunction = state.hostContexts.get(contextKey)\n if (!contextFunction) {\n throw error(`Unknown host context: ${contextKey}`, {\n validOptions: Array.from(state.hostContexts.keys()),\n })\n }\n\n // Get the graphs from the host context function\n const {\n initialEdges,\n initialNodes,\n edges,\n nodes,\n securityArchive,\n } = await contextFunction()\n\n // Clear current nodes and edges\n state.securityArchive = securityArchive\n state.initial.nodes.clear()\n state.initial.edges.clear()\n state.partial.nodes.clear()\n state.partial.edges.clear()\n state.importers.clear()\n\n // Reset the initial state\n for (const node of initialNodes) {\n state.initial.nodes.add(node)\n }\n for (const edge of initialEdges) {\n state.initial.edges.add(edge)\n }\n\n // Populate with nodes and edges from all returned graphs\n for (const node of nodes) {\n state.partial.nodes.add(node)\n // use the current selected nodes by the context function as importers\n state.importers.add(node)\n }\n for (const edge of edges) {\n state.partial.edges.add(edge)\n }\n\n return state\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
import type { PostcssNode } from '@vltpkg/dss-parser';
|
|
3
|
+
export type LicenseKinds = 'unlicensed' | 'misc' | 'restricted' | 'ambiguous' | 'copyleft' | 'unknown' | 'none' | 'exception' | undefined;
|
|
4
|
+
export type LicenseAlertTypes = 'explicitlyUnlicensedItem' | 'miscLicenseIssues' | 'nonpermissiveLicense' | 'ambiguousClassifier' | 'copyleftLicense' | 'unidentifiedLicense' | 'noLicenseFound' | 'licenseException' | undefined;
|
|
5
|
+
export declare const isLicenseKind: (value?: string) => value is LicenseKinds;
|
|
6
|
+
export declare const asLicenseKind: (value?: string) => LicenseKinds;
|
|
7
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
8
|
+
kind: LicenseKinds;
|
|
9
|
+
};
|
|
10
|
+
export declare const license: (state: ParserState) => Promise<ParserState & {
|
|
11
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=license.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/pseudo/license.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,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;;EA2B/C,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
3
|
+
import { assertSecurityArchive, 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
|
+
assertSecurityArchive(state, 'license');
|
|
39
|
+
let internals;
|
|
40
|
+
try {
|
|
41
|
+
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
throw error('Failed to parse :license selector', { cause: err });
|
|
45
|
+
}
|
|
46
|
+
const { kind } = internals;
|
|
47
|
+
const alertName = kindsMap.get(kind);
|
|
48
|
+
for (const node of state.partial.nodes) {
|
|
49
|
+
const report = state.securityArchive.get(node.id);
|
|
50
|
+
const exclude = !report?.alerts.some(alert => alert.type === alertName);
|
|
51
|
+
if (exclude) {
|
|
52
|
+
removeNode(state, node);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
removeDanglingEdges(state);
|
|
56
|
+
return state;
|
|
57
|
+
};
|
|
58
|
+
//# 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,oBAAoB,CAAA;AAC3B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AA0BrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAkC;IACxD,CAAC,YAAY,EAAE,0BAA0B,CAAC;IAC1C,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAC7B,CAAC,YAAY,EAAE,sBAAsB,CAAC;IACtC,CAAC,WAAW,EAAE,qBAAqB,CAAC;IACpC,CAAC,UAAU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} from '@vltpkg/dss-parser'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\nimport type { ParserState } from '../types.ts'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\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 assertSecurityArchive(state, 'license')\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,9 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* :link Pseudo-Selector, matches only nodes that are file links.
|
|
4
|
+
*
|
|
5
|
+
* It filters out any node that is not of type 'file' or nodes of 'file'
|
|
6
|
+
* type that ends with 'tar.gz' since these are local tarballs.
|
|
7
|
+
*/
|
|
8
|
+
export declare const link: (state: ParserState) => Promise<ParserState>;
|
|
9
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/pseudo/link.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;;;GAKG;AACH,eAAO,MAAM,IAAI,UAAiB,WAAW,yBAmB5C,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { splitDepID } from '@vltpkg/dep-id/browser';
|
|
2
|
+
import { removeNode } from "./helpers.js";
|
|
3
|
+
/**
|
|
4
|
+
* :link Pseudo-Selector, matches only nodes that are file links.
|
|
5
|
+
*
|
|
6
|
+
* It filters out any node that is not of type 'file' or nodes of 'file'
|
|
7
|
+
* type that ends with 'tar.gz' since these are local tarballs.
|
|
8
|
+
*/
|
|
9
|
+
export const link = async (state) => {
|
|
10
|
+
for (const node of state.partial.nodes) {
|
|
11
|
+
const [type, path] = splitDepID(node.id);
|
|
12
|
+
if (type !== 'file' || path.endsWith('tar.gz') || path === '.') {
|
|
13
|
+
removeNode(state, node);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
for (const edge of state.partial.edges) {
|
|
17
|
+
if (!edge.spec.file ||
|
|
18
|
+
edge.spec.file.endsWith('tar.gz') ||
|
|
19
|
+
edge.spec.file === '.') {
|
|
20
|
+
state.partial.edges.delete(edge);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/pseudo/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC/C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACxC,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAC/D,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IACE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,EACtB,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { splitDepID } from '@vltpkg/dep-id/browser'\nimport type { ParserState } from '../types.ts'\nimport { removeNode } from './helpers.ts'\n\n/**\n * :link Pseudo-Selector, matches only nodes that are file links.\n *\n * It filters out any node that is not of type 'file' or nodes of 'file'\n * type that ends with 'tar.gz' since these are local tarballs.\n */\nexport const link = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n const [type, path] = splitDepID(node.id)\n if (type !== 'file' || path.endsWith('tar.gz') || path === '.') {\n removeNode(state, node)\n }\n }\n\n for (const edge of state.partial.edges) {\n if (\n !edge.spec.file ||\n edge.spec.file.endsWith('tar.gz') ||\n edge.spec.file === '.'\n ) {\n state.partial.edges.delete(edge)\n }\n }\n\n return state\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
import type { PostcssNode } from '@vltpkg/dss-parser';
|
|
3
|
+
export type MalwareKinds = '0' | '1' | '2' | '3' | 'critical' | 'high' | 'medium' | 'low' | undefined;
|
|
4
|
+
export type MalwareAlertTypes = 'malware' | 'gptMalware' | 'gptSecurity' | 'gptAnomaly' | undefined;
|
|
5
|
+
export type MalwareComparator = '>' | '<' | '>=' | '<=' | undefined;
|
|
6
|
+
export declare const isMalwareKind: (value?: string) => value is MalwareKinds;
|
|
7
|
+
export declare const asMalwareKind: (value?: string) => MalwareKinds;
|
|
8
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
9
|
+
kind: MalwareKinds;
|
|
10
|
+
comparator: MalwareComparator;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* :malware Pseudo-Selector, matches nodes with malware alerts.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* - :malware - matches malware with severity >= medium (critical, high, medium but not low)
|
|
17
|
+
* - :malware(critical) - matches specific malware kind
|
|
18
|
+
* - :malware(>1) - matches malware with severity greater than 1
|
|
19
|
+
* - :malware(">=medium") - matches malware with severity >= medium
|
|
20
|
+
*/
|
|
21
|
+
export declare const malware: (state: ParserState) => Promise<ParserState & {
|
|
22
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=malware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"malware.d.ts","sourceRoot":"","sources":["../../../src/pseudo/malware.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,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;AAEb,MAAM,MAAM,iBAAiB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAA;AA2BnE,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,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAA;CAyDrD,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,UAAiB,WAAW;;EA0G/C,CAAA"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
3
|
+
import { assertSecurityArchive, 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
|
+
// Map numerical values to their respective kinds for comparison operations
|
|
15
|
+
const kindLevelMap = new Map([
|
|
16
|
+
['critical', 0],
|
|
17
|
+
['high', 1],
|
|
18
|
+
['medium', 2],
|
|
19
|
+
['low', 3],
|
|
20
|
+
['0', 0],
|
|
21
|
+
['1', 1],
|
|
22
|
+
['2', 2],
|
|
23
|
+
['3', 3],
|
|
24
|
+
]);
|
|
25
|
+
const kinds = new Set(kindsMap.keys());
|
|
26
|
+
export const isMalwareKind = (value) => kinds.has(value);
|
|
27
|
+
export const asMalwareKind = (value) => {
|
|
28
|
+
if (!isMalwareKind(value)) {
|
|
29
|
+
throw error('Expected a valid malware kind', {
|
|
30
|
+
found: value,
|
|
31
|
+
validOptions: Array.from(kinds),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
36
|
+
export const parseInternals = (nodes) => {
|
|
37
|
+
// Handle case where no parameters are provided (parameterless :malware)
|
|
38
|
+
if (!nodes[0]) {
|
|
39
|
+
return { kind: undefined, comparator: undefined };
|
|
40
|
+
}
|
|
41
|
+
const selectorNode = asPostcssNodeWithChildren(nodes[0]);
|
|
42
|
+
if (!selectorNode.nodes[0]) {
|
|
43
|
+
return { kind: undefined, comparator: undefined };
|
|
44
|
+
}
|
|
45
|
+
let kindValue = '';
|
|
46
|
+
let comparator = undefined;
|
|
47
|
+
let kind;
|
|
48
|
+
// Parse the parameter (kind with optional comparator)
|
|
49
|
+
if (isStringNode(selectorNode.nodes[0])) {
|
|
50
|
+
kindValue = removeQuotes(asStringNode(selectorNode.nodes[0]).value);
|
|
51
|
+
}
|
|
52
|
+
else if (isTagNode(selectorNode.nodes[0])) {
|
|
53
|
+
kindValue = asTagNode(selectorNode.nodes[0]).value;
|
|
54
|
+
}
|
|
55
|
+
// Extract comparator if present
|
|
56
|
+
if (kindValue.startsWith('>=')) {
|
|
57
|
+
comparator = '>=';
|
|
58
|
+
kindValue = kindValue.substring(2);
|
|
59
|
+
}
|
|
60
|
+
else if (kindValue.startsWith('<=')) {
|
|
61
|
+
comparator = '<=';
|
|
62
|
+
kindValue = kindValue.substring(2);
|
|
63
|
+
}
|
|
64
|
+
else if (kindValue.startsWith('>')) {
|
|
65
|
+
comparator = '>';
|
|
66
|
+
kindValue = kindValue.substring(1);
|
|
67
|
+
}
|
|
68
|
+
else if (kindValue.startsWith('<')) {
|
|
69
|
+
comparator = '<';
|
|
70
|
+
kindValue = kindValue.substring(1);
|
|
71
|
+
}
|
|
72
|
+
// Validate the kind without comparator
|
|
73
|
+
if (!comparator) {
|
|
74
|
+
kind = asMalwareKind(kindValue);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// For comparisons, just make sure it's a valid numeric value or a valid kind
|
|
78
|
+
if (isMalwareKind(kindValue)) {
|
|
79
|
+
kind = kindValue;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw error('Expected a valid malware kind or number between 0-3', {
|
|
83
|
+
found: kindValue,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { kind, comparator };
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* :malware Pseudo-Selector, matches nodes with malware alerts.
|
|
91
|
+
*
|
|
92
|
+
* Usage:
|
|
93
|
+
* - :malware - matches malware with severity >= medium (critical, high, medium but not low)
|
|
94
|
+
* - :malware(critical) - matches specific malware kind
|
|
95
|
+
* - :malware(>1) - matches malware with severity greater than 1
|
|
96
|
+
* - :malware(">=medium") - matches malware with severity >= medium
|
|
97
|
+
*/
|
|
98
|
+
export const malware = async (state) => {
|
|
99
|
+
assertSecurityArchive(state, 'malware');
|
|
100
|
+
let internals;
|
|
101
|
+
try {
|
|
102
|
+
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
throw error('Failed to parse :malware selector', { cause: err });
|
|
106
|
+
}
|
|
107
|
+
const { kind, comparator } = internals;
|
|
108
|
+
const alertName = comparator ? undefined : kindsMap.get(kind);
|
|
109
|
+
for (const node of state.partial.nodes) {
|
|
110
|
+
const report = state.securityArchive.get(node.id);
|
|
111
|
+
// Always exclude nodes that don't have security data or alerts
|
|
112
|
+
if (!report?.alerts || report.alerts.length === 0) {
|
|
113
|
+
removeNode(state, node);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (const node of state.partial.nodes) {
|
|
117
|
+
const report = state.securityArchive.get(node.id);
|
|
118
|
+
let exclude = true;
|
|
119
|
+
if (report) {
|
|
120
|
+
if (kind === undefined && comparator === undefined) {
|
|
121
|
+
// Parameterless :malware - match malware alerts with severity >= medium (exclude low/gptAnomaly)
|
|
122
|
+
exclude = !report.alerts.some(alert => alert.type === 'malware' ||
|
|
123
|
+
alert.type === 'gptMalware' ||
|
|
124
|
+
alert.type === 'gptSecurity');
|
|
125
|
+
}
|
|
126
|
+
else if (comparator) {
|
|
127
|
+
// retrieve the value to compare against
|
|
128
|
+
const kindLevel = kindLevelMap.get(kind);
|
|
129
|
+
// the kindLevel value has already been validated at this point
|
|
130
|
+
// and thus can never return an undefined/falsy value but ts doesn't
|
|
131
|
+
// know about that, so we have the extra check here
|
|
132
|
+
/* c8 ignore next - impossible */
|
|
133
|
+
if (kindLevel == null)
|
|
134
|
+
break;
|
|
135
|
+
// Check each alert to find any that match our comparison criteria
|
|
136
|
+
for (const alert of report.alerts) {
|
|
137
|
+
// Get the numerical value of the alert type
|
|
138
|
+
const alertType = alert.type;
|
|
139
|
+
// retrieve a key to the current alert level to be compared against
|
|
140
|
+
const currentAlertLevelKey = [...kindsMap.entries()].find(([_, alertValue]) => alertValue === alertType)?.[0];
|
|
141
|
+
// perform the comparison based on the user-provided kindLevel
|
|
142
|
+
if (currentAlertLevelKey) {
|
|
143
|
+
const currentAlertLevel = kindLevelMap.get(currentAlertLevelKey);
|
|
144
|
+
/* c8 ignore next - impossible but ts doesn't know */
|
|
145
|
+
if (currentAlertLevel == null)
|
|
146
|
+
continue;
|
|
147
|
+
switch (comparator) {
|
|
148
|
+
case '>':
|
|
149
|
+
if (currentAlertLevel > kindLevel) {
|
|
150
|
+
exclude = false;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case '<':
|
|
154
|
+
if (currentAlertLevel < kindLevel) {
|
|
155
|
+
exclude = false;
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case '>=':
|
|
159
|
+
if (currentAlertLevel >= kindLevel) {
|
|
160
|
+
exclude = false;
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case '<=':
|
|
164
|
+
if (currentAlertLevel <= kindLevel) {
|
|
165
|
+
exclude = false;
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
// If we've found a match, no need to check other alerts
|
|
170
|
+
if (!exclude)
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// Original exact match behavior
|
|
177
|
+
exclude = !report.alerts.some(alert => alert.type === alertName);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (exclude) {
|
|
181
|
+
removeNode(state, node);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
removeDanglingEdges(state);
|
|
185
|
+
return state;
|
|
186
|
+
};
|
|
187
|
+
//# sourceM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CACD,MAAK;4BACP,KAAK,IAAI;gCACP,IAAI,iBAAiB,IAAI,SAAS,EAAE,CAAC;oCACnC,OAAO,GAAG,KAAK,CAAA;gCACjB,CAAC;gCACD,MAAK;wBACT,CAAC;wBAED,wDAAwD;wBACxD,IAAI,CAAC,OAAO;4BAAE,MAAK;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,gCAAgC;gBAChC,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC3B,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAClC,CAAA;YACH,CAAC;QACH,CAAC;QAED,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 '@vltpkg/dss-parser'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\nimport type { ParserState } from '../types.ts'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\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\nexport type MalwareComparator = '>' | '<' | '>=' | '<=' | 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])\n\n// Map numerical values to their respective kinds for comparison operations\nconst kindLevelMap = new Map<MalwareKinds, number>([\n ['critical', 0],\n ['high', 1],\n ['medium', 2],\n ['low', 3],\n ['0', 0],\n ['1', 1],\n ['2', 2],\n ['3', 3],\n])\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; comparator: MalwareComparator } => {\n // Handle case where no parameters are provided (parameterless :malware)\n if (!nodes[0]) {\n return { kind: undefined, comparator: undefined }\n }\n\n const selectorNode = asPostcssNodeWithChildren(nodes[0])\n if (!selectorNode.nodes[0]) {\n return { kind: undefined, comparator: undefined }\n }\n\n let kindValue = ''\n let comparator: MalwareComparator = undefined\n let kind: MalwareKinds\n\n // Parse the parameter (kind with optional comparator)\n if (isStringNode(selectorNode.nodes[0])) {\n kindValue = removeQuotes(\n asStringNode(selectorNode.nodes[0]).value,\n )\n } else if (isTagNode(selectorNode.nodes[0])) {\n kindValue = asTagNode(selectorNode.nodes[0]).value\n }\n\n // Extract comparator if present\n if (kindValue.startsWith('>=')) {\n comparator = '>='\n kindValue = kindValue.substring(2)\n } else if (kindValue.startsWith('<=')) {\n comparator = '<='\n kindValue = kindValue.substring(2)\n } else if (kindValue.startsWith('>')) {\n comparator = '>'\n kindValue = kindValue.substring(1)\n } else if (kindValue.startsWith('<')) {\n comparator = '<'\n kindValue = kindValue.substring(1)\n }\n\n // Validate the kind without comparator\n if (!comparator) {\n kind = asMalwareKind(kindValue)\n } else {\n // For comparisons, just make sure it's a valid numeric value or a valid kind\n if (isMalwareKind(kindValue)) {\n kind = kindValue\n } else {\n throw error(\n 'Expected a valid malware kind or number between 0-3',\n {\n found: kindValue,\n },\n )\n }\n }\n\n return { kind, comparator }\n}\n\n/**\n * :malware Pseudo-Selector, matches nodes with malware alerts.\n *\n * Usage:\n * - :malware - matches malware with severity >= medium (critical, high, medium but not low)\n * - :malware(critical) - matches specific malware kind\n * - :malware(>1) - matches malware with severity greater than 1\n * - :malware(\">=medium\") - matches malware with severity >= medium\n */\nexport const malware = async (state: ParserState) => {\n assertSecurityArchive(state, 'malware')\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, comparator } = internals\n const alertName = comparator ? undefined : kindsMap.get(kind)\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n // Always exclude nodes that don't have security data or alerts\n if (!report?.alerts || report.alerts.length === 0) {\n removeNode(state, node)\n }\n }\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n let exclude = true\n\n if (report) {\n if (kind === undefined && comparator === undefined) {\n // Parameterless :malware - match malware alerts with severity >= medium (exclude low/gptAnomaly)\n exclude = !report.alerts.some(\n alert =>\n alert.type === 'malware' ||\n alert.type === 'gptMalware' ||\n alert.type === 'gptSecurity',\n )\n } else if (comparator) {\n // retrieve the value to compare against\n const kindLevel = kindLevelMap.get(kind)\n // the kindLevel value has already been validated at this point\n // and thus can never return an undefined/falsy value but ts doesn't\n // know about that, so we have the extra check here\n /* c8 ignore next - impossible */\n if (kindLevel == null) break\n\n // Check each alert to find any that match our comparison criteria\n for (const alert of report.alerts) {\n // Get the numerical value of the alert type\n const alertType = alert.type\n\n // retrieve a key to the current alert level to be compared against\n const currentAlertLevelKey = [...kindsMap.entries()].find(\n ([_, alertValue]) => alertValue === alertType,\n )?.[0]\n\n // perform the comparison based on the user-provided kindLevel\n if (currentAlertLevelKey) {\n const currentAlertLevel = kindLevelMap.get(\n currentAlertLevelKey,\n )\n /* c8 ignore next - impossible but ts doesn't know */\n if (currentAlertLevel == null) continue\n\n switch (comparator) {\n case '>':\n if (currentAlertLevel > kindLevel) {\n exclude = false\n }\n break\n case '<':\n if (currentAlertLevel < kindLevel) {\n exclude = false\n }\n break\n case '>=':\n if (currentAlertLevel >= kindLevel) {\n exclude = false\n }\n break\n case '<=':\n if (currentAlertLevel <= kindLevel) {\n exclude = false\n }\n break\n }\n\n // If we've found a match, no need to check other alerts\n if (!exclude) break\n }\n }\n } else {\n // Original exact match behavior\n exclude = !report.alerts.some(\n alert => alert.type === alertName,\n )\n }\n }\n\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out any node that does not have a **minifiedFile** report alert.
|
|
3
|
+
*/
|
|
4
|
+
export declare const minified: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
7
|
+
//# 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;;EAGpB,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,8 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* :missing Pseudo-Selector, matches only edges that are not linked to any node.
|
|
4
|
+
* It filters out any edges that have a 'to' property, keeping only dangling edges
|
|
5
|
+
* and clears all nodes from the result.
|
|
6
|
+
*/
|
|
7
|
+
export declare const missing: (state: ParserState) => Promise<ParserState>;
|
|
8
|
+
//# sourceMappingURL=missing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing.d.ts","sourceRoot":"","sources":["../../../src/pseudo/missing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,eAAO,MAAM,OAAO,UAAiB,WAAW,yBAQ/C,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* :missing Pseudo-Selector, matches only edges that are not linked to any node.
|
|
3
|
+
* It filters out any edges that have a 'to' property, keeping only dangling edges
|
|
4
|
+
* and clears all nodes from the result.
|
|
5
|
+
*/
|
|
6
|
+
export const missing = async (state) => {
|
|
7
|
+
for (const edge of state.partial.edges) {
|
|
8
|
+
if (edge.to) {
|
|
9
|
+
state.partial.edges.delete(edge);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
state.partial.nodes.clear();
|
|
13
|
+
return state;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=missing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing.js","sourceRoot":"","sources":["../../../src/pseudo/missing.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAClD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { ParserState } from '../types.ts'\n\n/**\n * :missing Pseudo-Selector, matches only edges that are not linked to any node.\n * It filters out any edges that have a 'to' property, keeping only dangling edges\n * and clears all nodes from the result.\n */\nexport const missing = async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n state.partial.nodes.clear()\n return state\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
7
|
+
//# 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;;EAGxB,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,7 @@
|
|
|
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
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
7
|
+
//# 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;;EAGnB,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
|