@vltpkg/query 0.0.0-8 → 1.0.0-rc.1
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 +38 -249
- package/dist/esm/attribute.d.ts +1 -1
- package/dist/esm/attribute.d.ts.map +1 -1
- package/dist/esm/attribute.js +5 -12
- package/dist/esm/attribute.js.map +1 -1
- package/dist/esm/combinator.d.ts.map +1 -1
- package/dist/esm/combinator.js +1 -1
- 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 +29 -7
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +247 -21
- 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/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/built.d.ts +8 -0
- package/dist/esm/pseudo/built.d.ts.map +1 -0
- package/dist/esm/pseudo/built.js +16 -0
- package/dist/esm/pseudo/built.js.map +1 -0
- package/dist/esm/pseudo/confused.d.ts +4 -2
- package/dist/esm/pseudo/confused.d.ts.map +1 -1
- package/dist/esm/pseudo/confused.js +15 -2
- package/dist/esm/pseudo/confused.js.map +1 -1
- package/dist/esm/pseudo/cve.d.ts +2 -1
- package/dist/esm/pseudo/cve.d.ts.map +1 -1
- package/dist/esm/pseudo/cve.js +2 -2
- package/dist/esm/pseudo/cve.js.map +1 -1
- package/dist/esm/pseudo/cwe.d.ts +2 -1
- package/dist/esm/pseudo/cwe.d.ts.map +1 -1
- package/dist/esm/pseudo/cwe.js +2 -2
- package/dist/esm/pseudo/cwe.js.map +1 -1
- 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/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/helpers.d.ts +13 -1
- package/dist/esm/pseudo/helpers.d.ts.map +1 -1
- package/dist/esm/pseudo/helpers.js +27 -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 +2 -1
- package/dist/esm/pseudo/license.d.ts.map +1 -1
- package/dist/esm/pseudo/license.js +19 -2
- package/dist/esm/pseudo/license.js.map +1 -1
- 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 +13 -1
- package/dist/esm/pseudo/malware.d.ts.map +1 -1
- package/dist/esm/pseudo/malware.js +140 -10
- package/dist/esm/pseudo/malware.js.map +1 -1
- 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/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 +180 -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 +4 -2
- package/dist/esm/pseudo/scanned.d.ts.map +1 -1
- package/dist/esm/pseudo/scanned.js +10 -5
- package/dist/esm/pseudo/scanned.js.map +1 -1
- 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 +133 -0
- package/dist/esm/pseudo/score.js.map +1 -0
- package/dist/esm/pseudo/scripts.d.ts +7 -4
- package/dist/esm/pseudo/scripts.d.ts.map +1 -1
- package/dist/esm/pseudo/scripts.js +41 -3
- package/dist/esm/pseudo/scripts.js.map +1 -1
- 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 +4 -1
- package/dist/esm/pseudo/severity.d.ts.map +1 -1
- package/dist/esm/pseudo/severity.js +111 -8
- package/dist/esm/pseudo/severity.js.map +1 -1
- 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 +4 -1
- package/dist/esm/pseudo/squat.d.ts.map +1 -1
- package/dist/esm/pseudo/squat.js +127 -9
- package/dist/esm/pseudo/squat.js.map +1 -1
- 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/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 +81 -105
- package/dist/esm/pseudo.js.map +1 -1
- package/dist/esm/types.d.ts +97 -27
- 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 -16
- package/dist/esm/class.d.ts +0 -6
- package/dist/esm/class.d.ts.map +0 -1
- package/dist/esm/class.js +0 -131
- package/dist/esm/class.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attr.js","sourceRoot":"","sources":["../../../src/pseudo/attr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,SAAS,
|
|
1
|
+
{"version":3,"file":"attr.js","sourceRoot":"","sources":["../../../src/pseudo/attr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,YAAY,EACZ,SAAS,EACT,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAY3C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACL,EAAE;IACjB,0CAA0C;IAC1C,MAAM,iBAAiB,GAAG,eAAe,CACvC,yBAAyB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAChD,CAAA;IACD,yDAAyD;IACzD,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACjE,0CAA0C;QAC1C,IAAI,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/B,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;QACjE,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC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ode,\n asPostcssNodeWithChildren,\n asStringNode,\n asTagNode,\n isStringNode,\n} from '@vltpkg/dss-parser'\nimport {\n attributeSelectorsMap,\n filterAttributes,\n} from '../attribute.ts'\nimport { removeQuotes } from './helpers.ts'\nimport type { ParserState } from '../types.ts'\nimport type { PostcssNode } from '@vltpkg/dss-parser'\n\nexport type AttrInternals = {\n attribute: string\n insensitive: boolean\n operator?: string\n value?: string\n properties: string[]\n}\n\n/**\n * Parses the internal / nested selectors of a `:attr` selector.\n */\nexport const parseInternals = (\n nodes: PostcssNode[],\n): AttrInternals => {\n // the last part is the attribute selector\n const attributeSelector = asAttributeNode(\n asPostcssNodeWithChildren(nodes.pop()).nodes[0],\n )\n // all preppending selectors are naming nested properties\n const properties: string[] = []\n for (const selector of nodes) {\n const selectorNode = asPostcssNodeWithChildren(selector).nodes[0]\n // Handle both quoted string and tag nodes\n if (isStringNode(selectorNode)) {\n properties.push(removeQuotes(asStringNode(selectorNode).value))\n } else {\n properties.push(asTagNode(selectorNode).value)\n }\n }\n // include the attribute selector as the last part of the property lookup\n properties.push(attributeSelector.attribute)\n\n return {\n attribute: attributeSelector.attribute,\n insensitive: attributeSelector.insensitive || false,\n operator: attributeSelector.operator,\n value: attributeSelector.value,\n properties,\n }\n}\n\n/**\n * :attr Pseudo-Selector, allows for retrieving nodes based on nested\n * properties of the `package.json` metadata.\n */\nexport const attr = async (state: ParserState) => {\n // Parses and retrieves the values for the nested selectors\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :attr selector', {\n cause: err,\n })\n }\n\n // reuses the attribute selector logic to filter the nodes\n const comparator =\n internals.operator ?\n attributeSelectorsMap.get(internals.operator)\n : undefined\n const value = internals.value || ''\n const propertyName = internals.attribute\n const insensitive = internals.insensitive\n const prefixProperties = internals.properties\n return filterAttributes(\n state,\n comparator,\n value,\n propertyName,\n insensitive,\n prefixProperties,\n )\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* :built Pseudo-Selector will only match packages that have
|
|
4
|
+
* a `buildState` property set to 'built', indicating they have
|
|
5
|
+
* been successfully built during the reify process.
|
|
6
|
+
*/
|
|
7
|
+
export declare const built: (state: ParserState) => Promise<ParserState>;
|
|
8
|
+
//# sourceMappingURL=built.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built.d.ts","sourceRoot":"","sources":["../../../src/pseudo/built.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;;GAIG;AACH,eAAO,MAAM,KAAK,UAAiB,WAAW,yBAU7C,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { removeNode, removeDanglingEdges } from "./helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* :built Pseudo-Selector will only match packages that have
|
|
4
|
+
* a `buildState` property set to 'built', indicating they have
|
|
5
|
+
* been successfully built during the reify process.
|
|
6
|
+
*/
|
|
7
|
+
export const built = async (state) => {
|
|
8
|
+
for (const node of state.partial.nodes) {
|
|
9
|
+
if (node.buildState !== 'built') {
|
|
10
|
+
removeNode(state, node);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
removeDanglingEdges(state);
|
|
14
|
+
return state;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=built.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built.js","sourceRoot":"","sources":["../../../src/pseudo/built.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;YAChC,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 { removeNode, removeDanglingEdges } from './helpers.ts'\n\n/**\n * :built Pseudo-Selector will only match packages that have\n * a `buildState` property set to 'built', indicating they have\n * been successfully built during the reify process.\n */\nexport const built = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.buildState !== 'built') {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { ParserState } from '../types.js';
|
|
1
2
|
/**
|
|
2
3
|
* Filters out any node that does not have a **manifestConfusion** report alert.
|
|
4
|
+
* Also includes any node that has been marked as **confused**.
|
|
3
5
|
*/
|
|
4
|
-
export declare const confused: (state:
|
|
5
|
-
securityArchive: NonNullable<
|
|
6
|
+
export declare const confused: (state: ParserState) => Promise<ParserState & {
|
|
7
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
6
8
|
}>;
|
|
7
9
|
//# sourceMappingURL=confused.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confused.d.ts","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"confused.d.ts","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAO9C;;;GAGG;AACH,eAAO,MAAM,QAAQ,UAAiB,WAAW;;EAiBhD,CAAA"}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { assertSecurityArchive, removeDanglingEdges, removeNode, } from "./helpers.js";
|
|
2
2
|
/**
|
|
3
3
|
* Filters out any node that does not have a **manifestConfusion** report alert.
|
|
4
|
+
* Also includes any node that has been marked as **confused**.
|
|
4
5
|
*/
|
|
5
|
-
export const confused =
|
|
6
|
+
export const confused = async (state) => {
|
|
7
|
+
assertSecurityArchive(state, 'confused');
|
|
8
|
+
for (const node of state.partial.nodes) {
|
|
9
|
+
const report = state.securityArchive.get(node.id);
|
|
10
|
+
const exclude = !node.confused &&
|
|
11
|
+
!report?.alerts.some(alert => alert.type === 'manifestConfusion');
|
|
12
|
+
if (exclude) {
|
|
13
|
+
removeNode(state, node);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
removeDanglingEdges(state);
|
|
17
|
+
return state;
|
|
18
|
+
};
|
|
6
19
|
//# sourceMappingURL=confused.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confused.js","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"confused.js","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,GACX,MAAM,cAAc,CAAA;AAErB;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACnD,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAExC,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,GACX,CAAC,IAAI,CAAC,QAAQ;YACd,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAClB,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAC5C,CAAA;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAC1B,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { ParserState } from '../types.js'\nimport {\n assertSecurityArchive,\n removeDanglingEdges,\n removeNode,\n} from './helpers.ts'\n\n/**\n * Filters out any node that does not have a **manifestConfusion** report alert.\n * Also includes any node that has been marked as **confused**.\n */\nexport const confused = async (state: ParserState) => {\n assertSecurityArchive(state, 'confused')\n\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude =\n !node.confused &&\n !report?.alerts.some(\n alert => alert.type === 'manifestConfusion',\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n return state\n}\n"]}
|
package/dist/esm/pseudo/cve.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cve.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cve.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cve.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,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB,YAuBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW;;EA4B3C,CAAA"}
|
package/dist/esm/pseudo/cve.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from
|
|
2
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
3
3
|
import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
4
4
|
export const parseInternals = (nodes) => {
|
|
5
5
|
let cveId = '';
|
|
@@ -32,7 +32,7 @@ export const cve = async (state) => {
|
|
|
32
32
|
const { cveId } = internals;
|
|
33
33
|
for (const node of state.partial.nodes) {
|
|
34
34
|
const report = state.securityArchive.get(node.id);
|
|
35
|
-
const exclude = !report?.alerts.some(alert => alert.props
|
|
35
|
+
const exclude = !report?.alerts.some(alert => alert.props?.cveId?.trim().toLowerCase() ===
|
|
36
36
|
cveId.trim().toLowerCase());
|
|
37
37
|
if (exclude) {
|
|
38
38
|
removeNode(state, node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cve.js","sourceRoot":"","sources":["../../../src/pseudo/cve.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,
|
|
1
|
+
{"version":3,"file":"cve.js","sourceRoot":"","sources":["../../../src/pseudo/cve.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;AAQrB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACN,EAAE;IAChB,IAAI,KAAK,GAAG,EAAE,CAAA;IAEd,IAAI,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAA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AM,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,CACN,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE;YACxC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAC7B,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 '@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 CveInternals = {\n cveId: string\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): CveInternals => {\n let cveId = ''\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n cveId = removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n cveId = asTagNode(\n asPostcssNodeWithChildren(nodes[0]).nodes[0],\n ).value\n }\n\n if (!cveId) {\n throw error('Expected a CVE ID', {\n found: asPostcssNodeWithChildren(nodes[0]).nodes[0],\n })\n }\n\n return { cveId }\n}\n\n/**\n * Filters out any node that does not have a CVE alert with the specified CVE ID.\n */\nexport const cve = async (state: ParserState) => {\n assertSecurityArchive(state, 'cve')\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :cve selector', { cause: err })\n }\n\n const { cveId } = internals\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(\n alert =>\n alert.props?.cveId?.trim().toLowerCase() ===\n cveId.trim().toLowerCase(),\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
|
package/dist/esm/pseudo/cwe.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cwe.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cwe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cwe.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cwe.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,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB,YAuBF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW;;EA6B3C,CAAA"}
|
package/dist/esm/pseudo/cwe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from
|
|
2
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
3
3
|
import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
4
4
|
export const parseInternals = (nodes) => {
|
|
5
5
|
let cweId = '';
|
|
@@ -32,7 +32,7 @@ export const cwe = async (state) => {
|
|
|
32
32
|
const { cweId } = internals;
|
|
33
33
|
for (const node of state.partial.nodes) {
|
|
34
34
|
const report = state.securityArchive.get(node.id);
|
|
35
|
-
const exclude = !report?.alerts.some(alert => alert.props
|
|
35
|
+
const exclude = !report?.alerts.some(alert => alert.props?.cwes?.some(cwe => cwe.id.trim().toLowerCase() === cweId.trim().toLowerCase()));
|
|
36
36
|
if (exclude) {
|
|
37
37
|
removeNode(state, node);
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cwe.js","sourceRoot":"","sources":["../../../src/pseudo/cwe.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,
|
|
1
|
+
{"version":3,"file":"cwe.js","sourceRoot":"","sources":["../../../src/pseudo/cwe.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;AAQrB,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAoB,EACN,EAAE;IAChB,IAAI,KAAK,GAAG,EAAE,CAAA;IAEd,IAAI,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,KAAK,GAAG,YAAY,CAClB,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACvD,KAAK,CACT,CAAA;IACH,CAAC;SAAM,IACL,SAAS,CAA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AAG,CAAC,EAAE,CACJ,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAC7D,CACF,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 '@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 CweInternals = {\n cweId: string\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): CweInternals => {\n let cweId = ''\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n cweId = removeQuotes(\n asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n .value,\n )\n } else if (\n isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])\n ) {\n cweId = asTagNode(\n asPostcssNodeWithChildren(nodes[0]).nodes[0],\n ).value\n }\n\n if (!cweId) {\n throw error('Expected a CWE ID', {\n found: asPostcssNodeWithChildren(nodes[0]).nodes[0],\n })\n }\n\n return { cweId }\n}\n\n/**\n * Filters out any node that does not have a CWE alert with the specified CWE ID.\n */\nexport const cwe = async (state: ParserState) => {\n assertSecurityArchive(state, 'cwe')\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :cwe selector', { cause: err })\n }\n\n const { cweId } = internals\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n const exclude = !report?.alerts.some(alert =>\n alert.props?.cwes?.some(\n cwe =>\n cwe.id.trim().toLowerCase() === cweId.trim().toLowerCase(),\n ),\n )\n if (exclude) {\n removeNode(state, node)\n }\n }\n\n removeDanglingEdges(state)\n\n return state\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/pseudo/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;GAEG;AACH,eAAO,MAAM,GAAG,UAAiB,WAAW,yBAW3C,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { removeEdge, removeUnlinkedNodes } from "./helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* :dev Pseudo-Selector will only match devDependencies.
|
|
4
|
+
*/
|
|
5
|
+
export const dev = async (state) => {
|
|
6
|
+
// filter edges that don't have type 'dev'
|
|
7
|
+
for (const edge of state.partial.edges) {
|
|
8
|
+
if (edge.type !== 'dev') {
|
|
9
|
+
removeEdge(state, edge);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
removeUnlinkedNodes(state);
|
|
13
|
+
return state;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/pseudo/dev.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAC9C,0CAA0C;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,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 * :dev Pseudo-Selector will only match devDependencies.\n */\nexport const dev = async (state: ParserState) => {\n // filter edges that don't have type 'dev'\n for (const edge of state.partial.edges) {\n if (edge.type !== 'dev') {\n removeEdge(state, edge)\n }\n }\n\n removeUnlinkedNodes(state)\n\n return state\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* :empty Pseudo-Selector, matches only nodes that have no children.
|
|
4
|
+
* It filters out any node that has edges out, i.e., has dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export declare const empty: (state: ParserState) => Promise<ParserState>;
|
|
7
|
+
//# sourceMappingURL=empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../../src/pseudo/empty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;GAGG;AACH,eAAO,MAAM,KAAK,UAAiB,WAAW,yBAO7C,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { removeNode } from "./helpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* :empty Pseudo-Selector, matches only nodes that have no children.
|
|
4
|
+
* It filters out any node that has edges out, i.e., has dependencies.
|
|
5
|
+
*/
|
|
6
|
+
export const empty = async (state) => {
|
|
7
|
+
for (const node of state.partial.nodes) {
|
|
8
|
+
if (node.edgesOut.size > 0) {
|
|
9
|
+
removeNode(state, node);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return state;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=empty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.js","sourceRoot":"","sources":["../../../src/pseudo/empty.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAChD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC3B,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { ParserState } from '../types.ts'\nimport { removeNode } from './helpers.ts'\n\n/**\n * :empty Pseudo-Selector, matches only nodes that have no children.\n * It filters out any node that has edges out, i.e., has dependencies.\n */\nexport const empty = async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (node.edgesOut.size > 0) {\n removeNode(state, node)\n }\n }\n return state\n}\n"]}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import type { NodeLike } from '@vltpkg/
|
|
1
|
+
import type { EdgeLike, NodeLike } from '@vltpkg/types';
|
|
2
2
|
import type { ParserState } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Removes a node and its incoming edges from the results.
|
|
5
5
|
*/
|
|
6
6
|
export declare const removeNode: (state: ParserState, node: NodeLike) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Removes an edge and its outgoing node from the results.
|
|
9
|
+
*/
|
|
10
|
+
export declare const removeEdge: (state: ParserState, edge: EdgeLike) => void;
|
|
7
11
|
/**
|
|
8
12
|
* Removes any edges that have no destination node from the results.
|
|
9
13
|
*/
|
|
10
14
|
export declare const removeDanglingEdges: (state: ParserState) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Removes any nodes that have no incoming edges from the results.
|
|
17
|
+
*/
|
|
18
|
+
export declare const removeUnlinkedNodes: (state: ParserState) => void;
|
|
11
19
|
/**
|
|
12
20
|
* Removes quotes from a string value.
|
|
13
21
|
*/
|
|
@@ -18,6 +26,10 @@ export declare const removeQuotes: (value: string) => string;
|
|
|
18
26
|
export declare const assertSecurityArchive: (state: ParserState, name: string) => asserts state is ParserState & {
|
|
19
27
|
securityArchive: NonNullable<ParserState['securityArchive']>;
|
|
20
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Clears all nodes and edges from the results.
|
|
31
|
+
*/
|
|
32
|
+
export declare const clear: (state: ParserState) => ParserState;
|
|
21
33
|
/**
|
|
22
34
|
* Reusable security selector alert filter.
|
|
23
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,WAAW,QAAQ,QAAQ,SAK5D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAAW,WAAW,SAMrD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,WACR,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAClC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,KAAK,IAAI,WAAW,GAAG;IAClC,eAAe,EAAE,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;CAQ7D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,UAAW,WAAW,KAAG,WAI1C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,4BAA4B,SACjC,MAAM,QACN,MAAM,aAES,WAAW;qBA1Bf,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;EA2C7D,CAAA"}
|
|
@@ -8,6 +8,15 @@ export const removeNode = (state, node) => {
|
|
|
8
8
|
}
|
|
9
9
|
state.partial.nodes.delete(node);
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Removes an edge and its outgoing node from the results.
|
|
13
|
+
*/
|
|
14
|
+
export const removeEdge = (state, edge) => {
|
|
15
|
+
state.partial.edges.delete(edge);
|
|
16
|
+
if (edge.to) {
|
|
17
|
+
state.partial.nodes.delete(edge.to);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
11
20
|
/**
|
|
12
21
|
* Removes any edges that have no destination node from the results.
|
|
13
22
|
*/
|
|
@@ -18,6 +27,16 @@ export const removeDanglingEdges = (state) => {
|
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Removes any nodes that have no incoming edges from the results.
|
|
32
|
+
*/
|
|
33
|
+
export const removeUnlinkedNodes = (state) => {
|
|
34
|
+
for (const node of state.partial.nodes) {
|
|
35
|
+
if (node.edgesIn.size === 0) {
|
|
36
|
+
state.partial.nodes.delete(node);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
21
40
|
/**
|
|
22
41
|
* Removes quotes from a string value.
|
|
23
42
|
*/
|
|
@@ -30,6 +49,14 @@ export const assertSecurityArchive = (state, name) => {
|
|
|
30
49
|
throw error(`Missing security archive while trying to parse the :${name} selector`, { found: state });
|
|
31
50
|
}
|
|
32
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Clears all nodes and edges from the results.
|
|
54
|
+
*/
|
|
55
|
+
export const clear = (state) => {
|
|
56
|
+
state.partial.nodes.clear();
|
|
57
|
+
state.partial.edges.clear();
|
|
58
|
+
return state;
|
|
59
|
+
};
|
|
33
60
|
/**
|
|
34
61
|
* Reusable security selector alert filter.
|
|
35
62
|
*/
|
|
@@ -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;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAkB,EAAE,EAAE;IACxD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;Q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AAE;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,CAC7C,CAAA;QACD,UAAU,GAAG,OAAO,CAAC,KAAK,CAAA;IAC5B,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC,qDAAqD,CAAC,CAAA;IACpE,CAAC;IAED,O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,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"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ParserState
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
import type { PostcssNode } from '@vltpkg/dss-parser';
|
|
2
3
|
export type LicenseKinds = 'unlicensed' | 'misc' | 'restricted' | 'ambiguous' | 'copyleft' | 'unknown' | 'none' | 'exception' | undefined;
|
|
3
4
|
export type LicenseAlertTypes = 'explicitlyUnlicensedItem' | 'miscLicenseIssues' | 'nonpermissiveLicense' | 'ambiguousClassifier' | 'copyleftLicense' | 'unidentifiedLicense' | 'noLicenseFound' | 'licenseException' | undefined;
|
|
4
5
|
export declare const isLicenseKind: (value?: string) => value is LicenseKinds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/pseudo/license.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/pseudo/license.ts"],"names":[],"mappings":"AAeA,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;;EA2C/C,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import {
|
|
2
|
+
import { asError } from '@vltpkg/types';
|
|
3
|
+
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from '@vltpkg/dss-parser';
|
|
3
4
|
import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
4
5
|
const kindsMap = new Map([
|
|
5
6
|
['unlicensed', 'explicitlyUnlicensedItem'],
|
|
@@ -41,7 +42,23 @@ export const license = async (state) => {
|
|
|
41
42
|
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
42
43
|
}
|
|
43
44
|
catch (err) {
|
|
44
|
-
|
|
45
|
+
if (asError(err).message === 'Expected a query node') {
|
|
46
|
+
// No parameters provided - pseudo state form: match ANY license defined (not 'none')
|
|
47
|
+
for (const node of state.partial.nodes) {
|
|
48
|
+
const report = state.securityArchive.get(node.id);
|
|
49
|
+
// Exclude if no report or if it has 'noLicenseFound' alert
|
|
50
|
+
const exclude = !report?.alerts ||
|
|
51
|
+
report.alerts.some(alert => alert.type === 'noLicenseFound');
|
|
52
|
+
if (exclude) {
|
|
53
|
+
removeNode(state, node);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
removeDanglingEdges(state);
|
|
57
|
+
return state;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw error('Failed to parse :license selector', { cause: err });
|
|
61
|
+
}
|
|
45
62
|
}
|
|
46
63
|
const { kind } = internals;
|
|
47
64
|
const alertName = kindsMap.get(kind);
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"license.js","sourceRoot":"","sources":["../../../src/pseudo/license.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,yBAAyB,E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KAAK,gBAAgB,CAAC,CAAA;gBAC9D,IAAI,OAAO,EAAE,CAAC;oBACZ,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBACzB,CAAC;YACH,CAAC;YACD,mBAAmB,CAAC,KAAK,CAAC,CAAA;YAC1B,OAAO,KAAK,CAAA;QACd,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC,mCAAmC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;QAClE,CAAC;IACH,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 { asError } from '@vltpkg/types'\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 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 if (asError(err).message === 'Expected a query node') {\n // No parameters provided - pseudo state form: match ANY license defined (not 'none')\n for (const node of state.partial.nodes) {\n const report = state.securityArchive.get(node.id)\n // Exclude if no report or if it has 'noLicenseFound' alert\n const exclude =\n !report?.alerts ||\n report.alerts.some(alert => alert.type === 'noLicenseFound')\n if (exclude) {\n removeNode(state, node)\n }\n }\n removeDanglingEdges(state)\n return state\n } else {\n throw error('Failed to parse :license selector', { cause: err })\n }\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
|