@vltpkg/query 0.0.0-6 → 0.0.0-8
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 +47 -3
- package/dist/esm/attribute.js +3 -1
- package/dist/esm/attribute.js.map +1 -1
- package/dist/esm/class.d.ts.map +1 -1
- package/dist/esm/class.js +4 -1
- package/dist/esm/class.js.map +1 -1
- package/dist/esm/combinator.d.ts.map +1 -1
- package/dist/esm/combinator.js +4 -1
- package/dist/esm/combinator.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +11 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pseudo/abandoned.d.ts +3 -1
- package/dist/esm/pseudo/abandoned.d.ts.map +1 -1
- package/dist/esm/pseudo/confused.d.ts +3 -1
- package/dist/esm/pseudo/confused.d.ts.map +1 -1
- 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 +3 -1
- package/dist/esm/pseudo/debug.d.ts.map +1 -1
- package/dist/esm/pseudo/deprecated.d.ts +3 -1
- package/dist/esm/pseudo/deprecated.d.ts.map +1 -1
- package/dist/esm/pseudo/dynamic.d.ts +3 -1
- package/dist/esm/pseudo/dynamic.d.ts.map +1 -1
- package/dist/esm/pseudo/entropic.d.ts +3 -1
- package/dist/esm/pseudo/entropic.d.ts.map +1 -1
- package/dist/esm/pseudo/env.d.ts +3 -1
- package/dist/esm/pseudo/env.d.ts.map +1 -1
- package/dist/esm/pseudo/eval.d.ts +3 -1
- package/dist/esm/pseudo/eval.d.ts.map +1 -1
- package/dist/esm/pseudo/fs.d.ts +3 -1
- package/dist/esm/pseudo/fs.d.ts.map +1 -1
- package/dist/esm/pseudo/helpers.d.ts +9 -1
- package/dist/esm/pseudo/helpers.d.ts.map +1 -1
- package/dist/esm/pseudo/helpers.js +10 -3
- package/dist/esm/pseudo/helpers.js.map +1 -1
- 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/malware.d.ts +12 -0
- package/dist/esm/pseudo/malware.d.ts.map +1 -0
- package/dist/esm/pseudo/malware.js +57 -0
- package/dist/esm/pseudo/malware.js.map +1 -0
- package/dist/esm/pseudo/minified.d.ts +3 -1
- package/dist/esm/pseudo/minified.d.ts.map +1 -1
- package/dist/esm/pseudo/native.d.ts +3 -1
- package/dist/esm/pseudo/native.d.ts.map +1 -1
- package/dist/esm/pseudo/network.d.ts +3 -1
- package/dist/esm/pseudo/network.d.ts.map +1 -1
- package/dist/esm/pseudo/obfuscated.d.ts +3 -1
- package/dist/esm/pseudo/obfuscated.d.ts.map +1 -1
- package/dist/esm/pseudo/scanned.d.ts +7 -0
- package/dist/esm/pseudo/scanned.d.ts.map +1 -0
- package/dist/esm/pseudo/scanned.js +12 -0
- package/dist/esm/pseudo/scanned.js.map +1 -0
- package/dist/esm/pseudo/scripts.d.ts +3 -1
- package/dist/esm/pseudo/scripts.d.ts.map +1 -1
- package/dist/esm/pseudo/severity.d.ts +12 -0
- package/dist/esm/pseudo/severity.d.ts.map +1 -0
- package/dist/esm/pseudo/severity.js +57 -0
- package/dist/esm/pseudo/severity.js.map +1 -0
- package/dist/esm/pseudo/shell.d.ts +3 -1
- package/dist/esm/pseudo/shell.d.ts.map +1 -1
- package/dist/esm/pseudo/shrinkwrap.d.ts +3 -1
- package/dist/esm/pseudo/shrinkwrap.d.ts.map +1 -1
- package/dist/esm/pseudo/squat.d.ts +12 -0
- package/dist/esm/pseudo/squat.d.ts.map +1 -0
- package/dist/esm/pseudo/squat.js +54 -0
- package/dist/esm/pseudo/squat.js.map +1 -0
- package/dist/esm/pseudo/suspicious.d.ts +3 -1
- package/dist/esm/pseudo/suspicious.d.ts.map +1 -1
- package/dist/esm/pseudo/tracker.d.ts +3 -1
- package/dist/esm/pseudo/tracker.d.ts.map +1 -1
- package/dist/esm/pseudo/trivial.d.ts +3 -1
- package/dist/esm/pseudo/trivial.d.ts.map +1 -1
- package/dist/esm/pseudo/undesirable.d.ts +3 -1
- package/dist/esm/pseudo/undesirable.d.ts.map +1 -1
- package/dist/esm/pseudo/unknown.d.ts +3 -1
- package/dist/esm/pseudo/unknown.d.ts.map +1 -1
- package/dist/esm/pseudo/unmaintained.d.ts +3 -1
- package/dist/esm/pseudo/unmaintained.d.ts.map +1 -1
- package/dist/esm/pseudo/unpopular.d.ts +3 -1
- package/dist/esm/pseudo/unpopular.d.ts.map +1 -1
- package/dist/esm/pseudo/unstable.d.ts +3 -1
- package/dist/esm/pseudo/unstable.d.ts.map +1 -1
- package/dist/esm/pseudo.d.ts.map +1 -1
- package/dist/esm/pseudo.js +18 -1
- package/dist/esm/pseudo.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **highEntropyStrings** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const entropic: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const entropic: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=entropic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entropic.d.ts","sourceRoot":"","sources":["../../../src/pseudo/entropic.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"entropic.d.ts","sourceRoot":"","sources":["../../../src/pseudo/entropic.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ;;EAGpB,CAAA"}
|
package/dist/esm/pseudo/env.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **envVars** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const env: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const env: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/pseudo/env.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/pseudo/env.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,GAAG;;EAAiD,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **usesEval** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const evalParser: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const evalParser: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=eval.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../../src/pseudo/eval.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"eval.d.ts","sourceRoot":"","sources":["../../../src/pseudo/eval.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;EAGtB,CAAA"}
|
package/dist/esm/pseudo/fs.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **filesystemAccess** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const fs: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const fs: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/pseudo/fs.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/pseudo/fs.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,EAAE;;EAGd,CAAA"}
|
|
@@ -12,8 +12,16 @@ export declare const removeDanglingEdges: (state: ParserState) => void;
|
|
|
12
12
|
* Removes quotes from a string value.
|
|
13
13
|
*/
|
|
14
14
|
export declare const removeQuotes: (value: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Asserts that the security archive is present.
|
|
17
|
+
*/
|
|
18
|
+
export declare const assertSecurityArchive: (state: ParserState, name: string) => asserts state is ParserState & {
|
|
19
|
+
securityArchive: NonNullable<ParserState['securityArchive']>;
|
|
20
|
+
};
|
|
15
21
|
/**
|
|
16
22
|
* Reusable security selector alert filter.
|
|
17
23
|
*/
|
|
18
|
-
export declare const createSecuritySelectorFilter: (name: string, type: string) => (state: ParserState) => Promise<ParserState
|
|
24
|
+
export declare const createSecuritySelectorFilter: (name: string, type: string) => (state: ParserState) => Promise<ParserState & {
|
|
25
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
26
|
+
}>;
|
|
19
27
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/pseudo/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;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,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,4BAA4B,SACjC,MAAM,QACN,MAAM,aAES,WAAW;qBAjBf,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;EAkC7D,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
1
2
|
/**
|
|
2
3
|
* Removes a node and its incoming edges from the results.
|
|
3
4
|
*/
|
|
@@ -21,14 +22,20 @@ export const removeDanglingEdges = (state) => {
|
|
|
21
22
|
* Removes quotes from a string value.
|
|
22
23
|
*/
|
|
23
24
|
export const removeQuotes = (value) => value.replace(/^"(.*?)"$/, '$1');
|
|
25
|
+
/**
|
|
26
|
+
* Asserts that the security archive is present.
|
|
27
|
+
*/
|
|
28
|
+
export const assertSecurityArchive = (state, name) => {
|
|
29
|
+
if (!state.securityArchive) {
|
|
30
|
+
throw error(`Missing security archive while trying to parse the :${name} selector`, { found: state });
|
|
31
|
+
}
|
|
32
|
+
};
|
|
24
33
|
/**
|
|
25
34
|
* Reusable security selector alert filter.
|
|
26
35
|
*/
|
|
27
36
|
export const createSecuritySelectorFilter = (name, type) => {
|
|
28
37
|
return async (state) => {
|
|
29
|
-
|
|
30
|
-
throw new Error(`Missing security archive while trying to parse the :${name} security selector`);
|
|
31
|
-
}
|
|
38
|
+
assertSecurityArchive(state, name);
|
|
32
39
|
for (const node of state.partial.nodes) {
|
|
33
40
|
const report = state.securityArchive.get(node.id);
|
|
34
41
|
const exclude = !report?.alerts.some(alert => alert.type === type);
|
|
@@ -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":"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,CAAC,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O,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 { 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 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 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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AAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAClD,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAEvC,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,cAAc,CACxB,yBAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAC/C,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,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,12 @@
|
|
|
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 declare const isMalwareKind: (value?: string) => value is MalwareKinds;
|
|
5
|
+
export declare const asMalwareKind: (value?: string) => MalwareKinds;
|
|
6
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
7
|
+
kind: MalwareKinds;
|
|
8
|
+
};
|
|
9
|
+
export declare const malware: (state: ParserState) => Promise<ParserState & {
|
|
10
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
11
|
+
}>;
|
|
12
|
+
//# 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;AAcb,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,57 @@
|
|
|
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
|
+
const kinds = new Set(kindsMap.keys());
|
|
15
|
+
export const isMalwareKind = (value) => kinds.has(value);
|
|
16
|
+
export const asMalwareKind = (value) => {
|
|
17
|
+
if (!isMalwareKind(value)) {
|
|
18
|
+
throw error('Expected a valid malware kind', {
|
|
19
|
+
found: value,
|
|
20
|
+
validOptions: Array.from(kinds),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
export const parseInternals = (nodes) => {
|
|
26
|
+
let kind;
|
|
27
|
+
if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
28
|
+
kind = asMalwareKind(removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
|
|
29
|
+
.value));
|
|
30
|
+
}
|
|
31
|
+
else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
32
|
+
kind = asMalwareKind(asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value);
|
|
33
|
+
}
|
|
34
|
+
return { kind };
|
|
35
|
+
};
|
|
36
|
+
export const malware = async (state) => {
|
|
37
|
+
assertSecurityArchive(state, 'malware');
|
|
38
|
+
let internals;
|
|
39
|
+
try {
|
|
40
|
+
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw error('Failed to parse :malware selector', { cause: err });
|
|
44
|
+
}
|
|
45
|
+
const { kind } = internals;
|
|
46
|
+
const alertName = kindsMap.get(kind);
|
|
47
|
+
for (const node of state.partial.nodes) {
|
|
48
|
+
const report = state.securityArchive.get(node.id);
|
|
49
|
+
const exclude = !report?.alerts.some(alert => alert.type === alertName);
|
|
50
|
+
if (exclude) {
|
|
51
|
+
removeNode(state, node);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
removeDanglingEdges(state);
|
|
55
|
+
return state;
|
|
56
|
+
};
|
|
57
|
+
//# 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,EACrB,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAoBrB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAkC;IACxD,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,MAAM,EAAE,YAAY,CAAC;IACtB,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,KAAK,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,YAAY,CAAC;IACnB,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB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ACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAClD,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAEvC,IAAI,SAAS,CAAA;IACb,IAAI,CAAC;QACH,SAAS,GAAG,cAAc,CACxB,yBAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAC/C,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,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 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\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])\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 } => {\n let kind: MalwareKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asMalwareKind(\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 = asMalwareKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\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 } = 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"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **minifiedFile** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const minified: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const minified: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=minified.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minified.d.ts","sourceRoot":"","sources":["../../../src/pseudo/minified.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"minified.d.ts","sourceRoot":"","sources":["../../../src/pseudo/minified.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ;;EAGpB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **hasNativeCode** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const nativeParser: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const nativeParser: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/pseudo/native.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/pseudo/native.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,YAAY;;EAGxB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **networkAccess** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const network: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const network: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/pseudo/network.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/pseudo/network.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO;;EAGnB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have an **obfuscatedFile** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const obfuscated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const obfuscated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=obfuscated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obfuscated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/obfuscated.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
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,7 @@
|
|
|
1
|
+
import type { ParserState } from '../types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Ensures that security report data is available for all packages in the current graph.
|
|
4
|
+
* Throws an error if security data is not available.
|
|
5
|
+
*/
|
|
6
|
+
export declare const scanned: (state: ParserState) => Promise<ParserState>;
|
|
7
|
+
//# sourceMappingURL=scanned.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanned.d.ts","sourceRoot":"","sources":["../../../src/pseudo/scanned.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,OAAO,UAAiB,WAAW,yBAK/C,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
/**
|
|
3
|
+
* Ensures that security report data is available for all packages in the current graph.
|
|
4
|
+
* Throws an error if security data is not available.
|
|
5
|
+
*/
|
|
6
|
+
export const scanned = async (state) => {
|
|
7
|
+
if (!state.securityArchive?.ok) {
|
|
8
|
+
throw error('Security report data missing');
|
|
9
|
+
}
|
|
10
|
+
return state;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=scanned.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanned.js","sourceRoot":"","sources":["../../../src/pseudo/scanned.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IAClD,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,EAAE,CAAC;QAC/B,MAAM,KAAK,CAAC,8BAA8B,CAAC,CAAA;IAC7C,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { ParserState } from '../types.ts'\n\n/**\n * Ensures that security report data is available for all packages in the current graph.\n * Throws an error if security data is not available.\n */\nexport const scanned = async (state: ParserState) => {\n if (!state.securityArchive?.ok) {\n throw error('Security report data missing')\n }\n return state\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have an **installScripts** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const scripts: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const scripts: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/pseudo/scripts.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/pseudo/scripts.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO;;EAGnB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ParserState, PostcssNode } from '../types.ts';
|
|
2
|
+
export type SeverityKinds = '0' | '1' | '2' | '3' | 'critical' | 'high' | 'medium' | 'low' | undefined;
|
|
3
|
+
export type SeverityAlertTypes = 'criticalCVE' | 'cve' | 'potentialVulnerability' | 'mildCVE' | undefined;
|
|
4
|
+
export declare const isSeverityKind: (value?: string) => value is SeverityKinds;
|
|
5
|
+
export declare const asSeverityKind: (value?: string) => SeverityKinds;
|
|
6
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
7
|
+
kind: SeverityKinds;
|
|
8
|
+
};
|
|
9
|
+
export declare const severity: (state: ParserState) => Promise<ParserState & {
|
|
10
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=severity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../../../src/pseudo/severity.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,MAAM,MAAM,aAAa,GACrB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,UAAU,GACV,MAAM,GACN,QAAQ,GACR,KAAK,GACL,SAAS,CAAA;AAEb,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,KAAK,GACL,wBAAwB,GACxB,SAAS,GACT,SAAS,CAAA;AAcb,eAAO,MAAM,cAAc,WACjB,MAAM,KACb,KAAK,IAAI,aAAkD,CAAA;AAE9D,eAAO,MAAM,cAAc,WAAY,MAAM,KAAG,aAQ/C,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB;IAAE,IAAI,EAAE,aAAa,CAAA;CAmBvB,CAAA;AAED,eAAO,MAAM,QAAQ,UAAiB,WAAW;;EA2BhD,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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', 'criticalCVE'],
|
|
6
|
+
['high', 'cve'],
|
|
7
|
+
['medium', 'potentialVulnerability'],
|
|
8
|
+
['low', 'mildCVE'],
|
|
9
|
+
['0', 'criticalCVE'],
|
|
10
|
+
['1', 'cve'],
|
|
11
|
+
['2', 'potentialVulnerability'],
|
|
12
|
+
['3', 'mildCVE'],
|
|
13
|
+
]);
|
|
14
|
+
const kinds = new Set(kindsMap.keys());
|
|
15
|
+
export const isSeverityKind = (value) => kinds.has(value);
|
|
16
|
+
export const asSeverityKind = (value) => {
|
|
17
|
+
if (!isSeverityKind(value)) {
|
|
18
|
+
throw error('Expected a valid severity kind', {
|
|
19
|
+
found: value,
|
|
20
|
+
validOptions: Array.from(kinds),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
export const parseInternals = (nodes) => {
|
|
26
|
+
let kind;
|
|
27
|
+
if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
28
|
+
kind = asSeverityKind(removeQuotes(asStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])
|
|
29
|
+
.value));
|
|
30
|
+
}
|
|
31
|
+
else if (isTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
32
|
+
kind = asSeverityKind(asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value);
|
|
33
|
+
}
|
|
34
|
+
return { kind };
|
|
35
|
+
};
|
|
36
|
+
export const severity = async (state) => {
|
|
37
|
+
assertSecurityArchive(state, 'severity');
|
|
38
|
+
let internals;
|
|
39
|
+
try {
|
|
40
|
+
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw error('Failed to parse :severity selector', { cause: err });
|
|
44
|
+
}
|
|
45
|
+
const { kind } = internals;
|
|
46
|
+
const alertName = kindsMap.get(kind);
|
|
47
|
+
for (const node of state.partial.nodes) {
|
|
48
|
+
const report = state.securityArchive.get(node.id);
|
|
49
|
+
const exclude = !report?.alerts.some(alert => alert.type === alertName);
|
|
50
|
+
if (exclude) {
|
|
51
|
+
removeNode(state, node);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
removeDanglingEdges(state);
|
|
55
|
+
return state;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=severity.js.map
|
|
@@ -0,0 +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M,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 SeverityKinds =\n | '0'\n | '1'\n | '2'\n | '3'\n | 'critical'\n | 'high'\n | 'medium'\n | 'low'\n | undefined\n\nexport type SeverityAlertTypes =\n | 'criticalCVE'\n | 'cve'\n | 'potentialVulnerability'\n | 'mildCVE'\n | undefined\n\nconst kindsMap = new Map<SeverityKinds, SeverityAlertTypes>([\n ['critical', 'criticalCVE'],\n ['high', 'cve'],\n ['medium', 'potentialVulnerability'],\n ['low', 'mildCVE'],\n ['0', 'criticalCVE'],\n ['1', 'cve'],\n ['2', 'potentialVulnerability'],\n ['3', 'mildCVE'],\n])\nconst kinds = new Set(kindsMap.keys())\n\nexport const isSeverityKind = (\n value?: string,\n): value is SeverityKinds => kinds.has(value as SeverityKinds)\n\nexport const asSeverityKind = (value?: string): SeverityKinds => {\n if (!isSeverityKind(value)) {\n throw error('Expected a valid severity kind', {\n found: value,\n validOptions: Array.from(kinds),\n })\n }\n return value\n}\n\nexport const parseInternals = (\n nodes: PostcssNode[],\n): { kind: SeverityKinds } => {\n let kind: SeverityKinds\n\n if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {\n kind = asSeverityKind(\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 = asSeverityKind(\n asTagNode(asPostcssNodeWithChildren(nodes[0]).nodes[0]).value,\n )\n }\n\n return { kind }\n}\n\nexport const severity = async (state: ParserState) => {\n assertSecurityArchive(state, 'severity')\n\n let internals\n try {\n internals = parseInternals(\n asPostcssNodeWithChildren(state.current).nodes,\n )\n } catch (err) {\n throw error('Failed to parse :severity 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"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **shellAccess** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const shell: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const shell: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/pseudo/shell.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/pseudo/shell.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,KAAK;;EAGjB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **shrinkwrap** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const shrinkwrap: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const shrinkwrap: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=shrinkwrap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shrinkwrap.d.ts","sourceRoot":"","sources":["../../../src/pseudo/shrinkwrap.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"shrinkwrap.d.ts","sourceRoot":"","sources":["../../../src/pseudo/shrinkwrap.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;EAGtB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ParserState, PostcssNode } from '../types.ts';
|
|
2
|
+
export type SquatKinds = '0' | '2' | 'critical' | 'medium' | undefined;
|
|
3
|
+
export type SquatAlertTypes = 'didYouMean' | 'gptDidYouMean' | undefined;
|
|
4
|
+
export declare const isSquatKind: (value?: string) => value is SquatKinds;
|
|
5
|
+
export declare const asSquatKind: (value?: string) => SquatKinds;
|
|
6
|
+
export declare const parseInternals: (nodes: PostcssNode[]) => {
|
|
7
|
+
kind: SquatKinds;
|
|
8
|
+
};
|
|
9
|
+
export declare const squat: (state: ParserState) => Promise<ParserState & {
|
|
10
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=squat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"squat.d.ts","sourceRoot":"","sources":["../../../src/pseudo/squat.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEtE,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,eAAe,GACf,SAAS,CAAA;AAWb,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,KAAK,IAAI,UACtB,CAAA;AAEhC,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,UAQ5C,CAAA;AAED,eAAO,MAAM,cAAc,UAClB,WAAW,EAAE,KACnB;IAAE,IAAI,EAAE,UAAU,CAAA;CAmBpB,CAAA;AAED,eAAO,MAAM,KAAK,UAAiB,WAAW;;EA2B7C,CAAA"}
|