@vltpkg/query 0.0.0-0.1730724342581 → 0.0.0-11
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 +8 -74
- package/dist/esm/attribute.d.ts +2 -2
- package/dist/esm/attribute.d.ts.map +1 -1
- package/dist/esm/attribute.js +14 -5
- package/dist/esm/attribute.js.map +1 -1
- package/dist/esm/combinator.d.ts +1 -1
- package/dist/esm/combinator.d.ts.map +1 -1
- package/dist/esm/combinator.js +6 -2
- package/dist/esm/combinator.js.map +1 -1
- package/dist/esm/id.d.ts +1 -1
- package/dist/esm/id.d.ts.map +1 -1
- package/dist/esm/id.js +21 -7
- package/dist/esm/id.js.map +1 -1
- package/dist/esm/index.d.ts +23 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +250 -17
- 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 +92 -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 +18 -0
- package/dist/esm/pseudo/attr.d.ts.map +1 -0
- package/dist/esm/pseudo/attr.js +58 -0
- package/dist/esm/pseudo/attr.js.map +1 -0
- 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 +12 -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 +12 -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 +35 -0
- package/dist/esm/pseudo/helpers.d.ts.map +1 -0
- package/dist/esm/pseudo/helpers.js +69 -0
- package/dist/esm/pseudo/helpers.js.map +1 -0
- package/dist/esm/pseudo/license.d.ts +12 -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 +14 -0
- package/dist/esm/pseudo/malware.d.ts.map +1 -0
- package/dist/esm/pseudo/malware.js +165 -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 +54 -0
- package/dist/esm/pseudo/outdated.d.ts.map +1 -0
- package/dist/esm/pseudo/outdated.js +212 -0
- package/dist/esm/pseudo/outdated.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/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 +159 -0
- package/dist/esm/pseudo/published.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 +15 -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 +16 -0
- package/dist/esm/pseudo/semver.d.ts.map +1 -0
- package/dist/esm/pseudo/semver.js +166 -0
- package/dist/esm/pseudo/semver.js.map +1 -0
- package/dist/esm/pseudo/severity.d.ts +14 -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/squat.d.ts +14 -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/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 +15 -0
- package/dist/esm/pseudo/workspace.js.map +1 -0
- package/dist/esm/pseudo.d.ts +1 -8
- package/dist/esm/pseudo.d.ts.map +1 -1
- package/dist/esm/pseudo.js +115 -122
- package/dist/esm/pseudo.js.map +1 -1
- package/dist/esm/types.d.ts +83 -6
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +25 -13
- package/dist/esm/types.js.map +1 -1
- package/package.json +29 -19
- package/dist/esm/class.d.ts +0 -6
- package/dist/esm/class.d.ts.map +0 -1
- package/dist/esm/class.js +0 -127
- package/dist/esm/class.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAE,IAAc,EAAE,EAAE;IAC/D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,KAAK,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AAC,KAAK,CAAC,eAAe,EAAE,CAAC;QAC3B,MAAM,KAAK,CACT,uDAAuD,IAAI,WAAW,EACtE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,IAAY,EACZ,IAAY,EACZ,EAAE;IACF,OAAO,KAAK,EAAE,KAAkB,EAAE,EAAE;QAClC,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAElC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAC7B,CAAA;YACD,IAAI,OAAO,EAAE,CAAC;gBACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport type { ParserState } from '../types.js'\nimport { error } from '@vltpkg/error-cause'\n\n/**\n * Removes a node and its incoming edges from the results.\n */\nexport const removeNode = (state: ParserState, node: NodeLike) => {\n for (const edge of node.edgesIn) {\n state.partial.edges.delete(edge)\n }\n state.partial.nodes.delete(node)\n}\n\n/**\n * Removes an edge and its outgoing node from the results.\n */\nexport const removeEdge = (state: ParserState, edge: EdgeLike) => {\n state.partial.edges.delete(edge)\n if (edge.to) {\n state.partial.nodes.delete(edge.to)\n }\n}\n\n/**\n * Removes any edges that have no destination node from the results.\n */\nexport const removeDanglingEdges = (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n}\n\n/**\n * Removes any nodes that have no incoming edges from the results.\n */\nexport const removeUnlinkedNodes = (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesIn.size === 0) {\n state.partial.nodes.delete(node)\n }\n }\n}\n\n/**\n * Removes quotes from a string value.\n */\nexport const removeQuotes = (value: string) =>\n value.replace(/^\"(.*?)\"$/, '$1')\n\n/**\n * Asserts that the security archive is present.\n */\nexport const assertSecurityArchive: (\n state: ParserState,\n name: string,\n) => asserts state is ParserState & {\n securityArchive: NonNullable<ParserState['securityArchive']>\n} = (state, name) => {\n if (!state.securityArchive) {\n throw error(\n `Missing security archive while trying to parse the :${name} selector`,\n { found: state },\n )\n }\n}\n\n/**\n * Reusable security selector alert filter.\n */\nexport const createSecuritySelectorFilter = (\n name: string,\n type: string,\n) => {\n return async (state: ParserState) => {\n assertSecurityArchive(state, name)\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert => alert.type === type,\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ParserState, PostcssNode } from '../types.ts';
|
|
2
|
+
export type LicenseKinds = 'unlicensed' | 'misc' | 'restricted' | 'ambiguous' | 'copyleft' | 'unknown' | 'none' | 'exception' | undefined;
|
|
3
|
+
export type LicenseAlertTypes = 'explicitlyUnlicensedItem' | 'miscLicenseIssues' | 'nonpermissiveLicense' | 'ambiguousClassifier' | 'copyleftLicense' | 'unidentifiedLicense' | 'noLicenseFound' | 'licenseException' | undefined;
|
|
4
|
+
export declare const isLicenseKind: (value?: string) => value is LicenseKinds;
|
|
5
|
+
export declare const asLicenseKind: (value?: string) => LicenseKinds;
|
|
6
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
7
|
+
kind: LicenseKinds;
|
|
8
|
+
};
|
|
9
|
+
export declare const license: (state: ParserState) => Promise<ParserState & {
|
|
10
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=license.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/pseudo/license.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,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 "../types.js";
|
|
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,aAAa,CAAA;AAEpB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAwBrB,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,EAAE,iBAAiB,CAAC;IAC/B,CAAC,SAAS,EAAE,qBAAqB,CAAC;IAClC,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAC1B,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACjC,CAAC,SAAS,EAAE,SAAS,CAAC;CACvB,CAAC,CAAA;AACF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAc,EACS,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAqB,CAAC,CAAA;AAE5D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAgB,EAAE;IAC5D,IAAI,C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AAM,KAAK,CAAC,mCAAmC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAClE,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAA;IAC1B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACpC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAClC,CAAA;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAE1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {\n asPostcssNodeWithChildren,\n asStringNode,\n asTagNode,\n isStringNode,\n isTagNode,\n} from '../types.ts'\nimport type { ParserState, PostcssNode } from '../types.ts'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type LicenseKinds =\n | 'unlicensed'\n | 'misc'\n | 'restricted'\n | 'ambiguous'\n | 'copyleft'\n | 'unknown'\n | 'none'\n | 'exception'\n | undefined\n\nexport type LicenseAlertTypes =\n | 'explicitlyUnlicensedItem'\n | 'miscLicenseIssues'\n | 'nonpermissiveLicense'\n | 'ambiguousClassifier'\n | 'copyleftLicense'\n | 'unidentifiedLicense'\n | 'noLicenseFound'\n | 'licenseException'\n | undefined\n\nconst kindsMap = new Map<LicenseKinds, LicenseAlertTypes>([\n ['unlicensed', 'explicitlyUnlicensedItem'],\n ['misc', 'miscLicenseIssues'],\n ['restricted', 'nonpermissiveLicense'],\n ['ambiguous', 'ambiguousClassifier'],\n ['copyleft', 'copyleftLicense'],\n ['unknown', 'unidentifiedLicense'],\n ['none', 'noLicenseFound'],\n ['exception', 'licenseException'],\n [undefined, undefined],\n])\nconst kinds = new Set(kindsMap.keys())\n\nexport const isLicenseKind = (\n value?: string,\n): value is LicenseKinds => kinds.has(value as LicenseKinds)\n\nexport const asLicenseKind = (value?: string): LicenseKinds => {\n if (!isLicenseKind(value)) {\n throw error('Expected a valid license kind', {\n found: value,\n validOptions: Array.from(kinds),\n })\n }\n return value\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): { kind: LicenseKinds } => {\n let kind: LicenseKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asLicenseKind(\n removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n ),\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n kind = asLicenseKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\n}\n\nexport const license = async (state: ParserState) => {\n 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,14 @@
|
|
|
1
|
+
import type { ParserState, PostcssNode } from '../types.ts';
|
|
2
|
+
export type MalwareKinds = '0' | '1' | '2' | '3' | 'critical' | 'high' | 'medium' | 'low' | undefined;
|
|
3
|
+
export type MalwareAlertTypes = 'malware' | 'gptMalware' | 'gptSecurity' | 'gptAnomaly' | undefined;
|
|
4
|
+
export type MalwareComparator = '>' | '<' | '>=' | '<=' | undefined;
|
|
5
|
+
export declare const isMalwareKind: (value?: string) => value is MalwareKinds;
|
|
6
|
+
export declare const asMalwareKind: (value?: string) => MalwareKinds;
|
|
7
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
8
|
+
kind: MalwareKinds;
|
|
9
|
+
comparator: MalwareComparator;
|
|
10
|
+
};
|
|
11
|
+
export declare const malware: (state: ParserState) => Promise<ParserState & {
|
|
12
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=malware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"malware.d.ts","sourceRoot":"","sources":["../../../src/pseudo/malware.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,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;CAoDrD,CAAA;AAED,eAAO,MAAM,OAAO,UAAiB,WAAW;;EAkG/C,CAAA"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
|
|
3
|
+
import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
4
|
+
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
|
+
let kindValue = '';
|
|
38
|
+
let comparator = undefined;
|
|
39
|
+
let kind;
|
|
40
|
+
// Parse the parameter (kind with optional comparator)
|
|
41
|
+
if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
42
|
+
kindValue = removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
|
|
43
|
+
.value);
|
|
44
|
+
}
|
|
45
|
+
else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
46
|
+
kindValue = asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value;
|
|
47
|
+
}
|
|
48
|
+
// Extract comparator if present
|
|
49
|
+
if (kindValue.startsWith('>=')) {
|
|
50
|
+
comparator = '>=';
|
|
51
|
+
kindValue = kindValue.substring(2);
|
|
52
|
+
}
|
|
53
|
+
else if (kindValue.startsWith('<=')) {
|
|
54
|
+
comparator = '<=';
|
|
55
|
+
kindValue = kindValue.substring(2);
|
|
56
|
+
}
|
|
57
|
+
else if (kindValue.startsWith('>')) {
|
|
58
|
+
comparator = '>';
|
|
59
|
+
kindValue = kindValue.substring(1);
|
|
60
|
+
}
|
|
61
|
+
else if (kindValue.startsWith('<')) {
|
|
62
|
+
comparator = '<';
|
|
63
|
+
kindValue = kindValue.substring(1);
|
|
64
|
+
}
|
|
65
|
+
// Validate the kind without comparator
|
|
66
|
+
if (!comparator) {
|
|
67
|
+
kind = asMalwareKind(kindValue);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// For comparisons, just make sure it's a valid numeric value or a valid kind
|
|
71
|
+
if (isMalwareKind(kindValue)) {
|
|
72
|
+
kind = kindValue;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw error('Expected a valid malware kind or number between 0-3', {
|
|
76
|
+
found: kindValue,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { kind, comparator };
|
|
81
|
+
};
|
|
82
|
+
export const malware = async (state) => {
|
|
83
|
+
assertSecurityArchive(state, 'malware');
|
|
84
|
+
let internals;
|
|
85
|
+
try {
|
|
86
|
+
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
throw error('Failed to parse :malware selector', { cause: err });
|
|
90
|
+
}
|
|
91
|
+
const { kind, comparator } = internals;
|
|
92
|
+
const alertName = comparator ? undefined : kindsMap.get(kind);
|
|
93
|
+
for (const node of state.partial.nodes) {
|
|
94
|
+
const report = state.securityArchive.get(node.id);
|
|
95
|
+
// Always exclude nodes that don't have security data or alerts
|
|
96
|
+
if (!report?.alerts || report.alerts.length === 0) {
|
|
97
|
+
removeNode(state, node);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
for (const node of state.partial.nodes) {
|
|
101
|
+
const report = state.securityArchive.get(node.id);
|
|
102
|
+
let exclude = true;
|
|
103
|
+
if (report) {
|
|
104
|
+
if (comparator) {
|
|
105
|
+
// retrieve the value to compare against
|
|
106
|
+
const kindLevel = kindLevelMap.get(kind);
|
|
107
|
+
// the kindLevel value has already been validated at this point
|
|
108
|
+
// and thus can never return an undefined/falsy value but ts doesn't
|
|
109
|
+
// know about that, so we have the extra check here
|
|
110
|
+
/* c8 ignore next - impossible */
|
|
111
|
+
if (!kindLevel)
|
|
112
|
+
break;
|
|
113
|
+
// Check each alert to find any that match our comparison criteria
|
|
114
|
+
for (const alert of report.alerts) {
|
|
115
|
+
// Get the numerical value of the alert type
|
|
116
|
+
const alertType = alert.type;
|
|
117
|
+
// retrieve a key to the current alert level to be compared against
|
|
118
|
+
const currentAlertLevelKey = [...kindsMap.entries()].find(([_, alertValue]) => alertValue === alertType)?.[0];
|
|
119
|
+
// perform the comparison based on the user-provided kindLevel
|
|
120
|
+
if (currentAlertLevelKey) {
|
|
121
|
+
const currentAlertLevel = kindLevelMap.get(currentAlertLevelKey);
|
|
122
|
+
/* c8 ignore next - impossible but ts doesn't know */
|
|
123
|
+
if (currentAlertLevel == null)
|
|
124
|
+
continue;
|
|
125
|
+
switch (comparator) {
|
|
126
|
+
case '>':
|
|
127
|
+
if (currentAlertLevel > kindLevel) {
|
|
128
|
+
exclude = false;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case '<':
|
|
132
|
+
if (currentAlertLevel < kindLevel) {
|
|
133
|
+
exclude = false;
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
case '>=':
|
|
137
|
+
if (currentAlertLevel >= kindLevel) {
|
|
138
|
+
exclude = false;
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
case '<=':
|
|
142
|
+
if (currentAlertLevel <= kindLevel) {
|
|
143
|
+
exclude = false;
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
// If we've found a match, no need to check other alerts
|
|
148
|
+
if (!exclude)
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// Original exact match behavior
|
|
155
|
+
exclude = !report.alerts.some(alert => alert.type === alertName);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (exclude) {
|
|
159
|
+
removeNode(state, node);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
removeDanglingEdges(state);
|
|
163
|
+
return state;
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=malware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"malware.js","sourceRoot":"","sources":["../../../src/pseudo/malware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,qBAAqB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AAQ;wBAEvC,QAAQ,UAAU,EAAE,CAAC;4BACnB,KAAK,GAAG;gCACN,IAAI,iBAAiB,GAAG,SAAS,EAAE,CAAC;oCAClC,OAAO,GAAG,KAAK,CAAA;gCACjB,CAAC;gCACD,MAAK;4BACP,KAAK,GAAG;gCACN,IAAI,iBAAiB,GAAG,SAAS,EAAE,CAAC;oCAClC,OAAO,GAAG,KAAK,CAAA;gCACjB,CAAC;gCACD,MAAK;4BACP,KAAK,IAAI;gCACP,IAAI,iBAAiB,IAAI,SAAS,EAAE,CAAC;oCACnC,OAAO,GAAG,KAAK,CAAA;gCACjB,CAAC;gCACD,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 '../types.ts'\nimport type { ParserState, PostcssNode } from '../types.ts'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n removeQuotes,\n} from './helpers.ts'\n\nexport type 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 let kindValue = ''\n let comparator: MalwareComparator = undefined\n let kind: MalwareKinds\n\n // Parse the parameter (kind with optional comparator)\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kindValue = removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n kindValue = asTagNode(\n asPostcssNodeWithChildren(nodes[0]).nodes[0],\n ).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\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 (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) 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/pseudo/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CACjD,SAAS,EACT,eAAe,CAChB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **networkAccess** report alert.\n */\nexport const network = createSecuritySelectorFilter(\n 'network',\n 'networkAccess',\n)\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out any node that does not have an **obfuscatedFile** report alert.
|
|
3
|
+
*/
|
|
4
|
+
export declare const obfuscated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=obfuscated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obfuscated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/obfuscated.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;EAGtB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createSecuritySelectorFilter } from "./helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* Filters out any node that does not have an **obfuscatedFile** report alert.
|
|
4
|
+
*/
|
|
5
|
+
export const obfuscated = createSecuritySelectorFilter('obfuscated', 'obfuscatedFile');
|
|
6
|
+
//# sourceMappingURL=obfuscated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obfuscated.js","sourceRoot":"","sources":["../../../src/pseudo/obfuscated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,4BAA4B,CACpD,YAAY,EACZ,gBAAgB,CACjB,CAAA","sourcesContent":["import { createSecuritySelectorFilter } from './helpers.ts'\n\n/**\n * Filters out any node that does not have an **obfuscatedFile** report alert.\n */\nexport const obfuscated = createSecuritySelectorFilter(\n 'obfuscated',\n 'obfuscatedFile',\n)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../../src/pseudo/optional.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;GAEG;AACH,eAAO,MAAM,QAAQ,UAAiB,WAAW,yBAWhD,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { removeEdge, removeUnlinkedNodes } from "./helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* :optional Pseudo-Selector will only match optional dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export const optional = async (state) => {
|
|
6
|
+
// filter edges that aren't marked as optional
|
|
7
|
+
for (const edge of state.partial.edges) {
|
|
8
|
+
if (!edge.optional) {
|
|
9
|
+
removeEdge(state, edge);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
removeUnlinkedNodes(state);
|
|
13
|
+
return state;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=optional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../src/pseudo/optional.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACnD,8CAA8C;IAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAE1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { ParserState } from '../types.ts'\nimport { removeEdge, removeUnlinkedNodes } from './helpers.ts'\n\n/**\n * :optional Pseudo-Selector will only match optional dependencies.\n */\nexport const optional = async (state: ParserState) => {\n // filter edges that aren't marked as optional\n for (const edge of state.partial.edges) {\n if (!edge.optional) {\n removeEdge(state, edge)\n }\n }\n\n removeUnlinkedNodes(state)\n\n return state\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { NodeLike } from '@vltpkg/graph';
|
|
2
|
+
import type { SpecOptions } from '@vltpkg/spec/browser';
|
|
3
|
+
import type { ParserState, PostcssNode } from '../types.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The possible values accepted by the :outdated() pseudo selector.
|
|
6
|
+
*/
|
|
7
|
+
export type OutdatedKinds = 'any' | 'major' | 'minor' | 'patch' | 'in-range' | 'out-of-range';
|
|
8
|
+
/**
|
|
9
|
+
* Result of the internal parsing of the :outdated() pseudo selector.
|
|
10
|
+
*/
|
|
11
|
+
export type OutdatedInternals = {
|
|
12
|
+
kind: OutdatedKinds;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Extracts a semver type from a version string.
|
|
16
|
+
*/
|
|
17
|
+
export type SemverTypeExtraction = (version: string) => number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a string is a valid {@link OutdatedKinds}.
|
|
20
|
+
*/
|
|
21
|
+
export declare const isOutdatedKind: (value: string) => value is OutdatedKinds;
|
|
22
|
+
/**
|
|
23
|
+
* Asserts that a string is a valid {@link OutdatedKinds}.
|
|
24
|
+
*/
|
|
25
|
+
export declare const asOutdatedKind: (value: string) => OutdatedKinds;
|
|
26
|
+
/**
|
|
27
|
+
* Fetches the available versions of a package from the npm registry.
|
|
28
|
+
*/
|
|
29
|
+
export declare const retrieveRemoteVersions: (node: NodeLike, specOptions: SpecOptions, signal?: AbortSignal) => Promise<string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves what kind of check the :outdated selector should perform.
|
|
32
|
+
*/
|
|
33
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => OutdatedInternals;
|
|
34
|
+
/**
|
|
35
|
+
* Filter nodes by queueing up for removal those that are not outdated.
|
|
36
|
+
*/
|
|
37
|
+
export declare const queueNode: (state: ParserState, node: NodeLike, kind: OutdatedKinds) => Promise<NodeLike | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Filters out nodes that are not outdated.
|
|
40
|
+
*
|
|
41
|
+
* The :outdated() pseudo selector supports one `type` argument,
|
|
42
|
+
* possible values are the following:
|
|
43
|
+
*
|
|
44
|
+
* - `any`: Selects all nodes that have a greater version available.
|
|
45
|
+
* - `major`: Selects all nodes that have a greater major version available.
|
|
46
|
+
* - `minor`: Selects all nodes that have a greater minor version available.
|
|
47
|
+
* - `patch`: Selects all nodes that have a greater patch version available.
|
|
48
|
+
* - `in-range`: Selects all nodes that have a parent node with a spec definition
|
|
49
|
+
* that satisfies one of the available remote versions.
|
|
50
|
+
* - `out-of-range`: Selects all nodes that have a parent node with a spec definition
|
|
51
|
+
* that does not satisfy any of the available remote versions.
|
|
52
|
+
*/
|
|
53
|
+
export declare const outdated: (state: ParserState) => Promise<ParserState>;
|
|
54
|
+
//# sourceMappingURL=outdated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outdated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/outdated.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAiBvD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG3D;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,cAAc,CAAA;AAElB;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,aAAa,CAAA;CACpB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,MAAM,KACZ,MAAM,GAAG,SAAS,CAAA;AAWvB;;GAEG;AACH,eAAO,MAAM,cAAc,UAClB,MAAM,KACZ,KAAK,IAAI,aAAkD,CAAA;AAE9D;;GAEG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,aAQ9C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,SAC3B,QAAQ,eACD,WAAW,WACf,WAAW,KACnB,OAAO,CAAC,MAAM,EAAE,CA6BlB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB,iBAmBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,UACb,WAAW,QACZ,QAAQ,QACR,aAAa,KAClB,OAAO,CAAC,QAAQ,GAAG,SAAS,CAsG9B,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,UAAiB,WAAW,yBA4ChD,CAAA"}
|