@vltpkg/query 0.0.0-7 → 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 +6 -0
- 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 +4 -4
- 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 +3 -1
- package/dist/esm/pseudo/cve.d.ts.map +1 -1
- package/dist/esm/pseudo/cve.js +2 -5
- package/dist/esm/pseudo/cve.js.map +1 -1
- package/dist/esm/pseudo/cwe.d.ts +3 -1
- package/dist/esm/pseudo/cwe.d.ts.map +1 -1
- package/dist/esm/pseudo/cwe.js +2 -5
- package/dist/esm/pseudo/cwe.js.map +1 -1
- 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 +3 -1
- package/dist/esm/pseudo/license.d.ts.map +1 -1
- package/dist/esm/pseudo/license.js +2 -5
- package/dist/esm/pseudo/license.js.map +1 -1
- package/dist/esm/pseudo/malware.d.ts +3 -1
- package/dist/esm/pseudo/malware.d.ts.map +1 -1
- package/dist/esm/pseudo/malware.js +2 -5
- package/dist/esm/pseudo/malware.js.map +1 -1
- 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 +3 -1
- package/dist/esm/pseudo/severity.d.ts.map +1 -1
- package/dist/esm/pseudo/severity.js +2 -5
- package/dist/esm/pseudo/severity.js.map +1 -1
- 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 +3 -1
- package/dist/esm/pseudo/squat.d.ts.map +1 -1
- package/dist/esm/pseudo/squat.js +2 -5
- package/dist/esm/pseudo/squat.js.map +1 -1
- 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 +5 -1
- package/dist/esm/pseudo.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -228,6 +228,12 @@ security data needs to be fetched prior to a `Query` instantiation.
|
|
|
228
228
|
- `:obfuscated` Matches packages that use obfuscated files,
|
|
229
229
|
intentionally packed to hide their behavior. This could be a sign of
|
|
230
230
|
malware.
|
|
231
|
+
- `:scanned` Ensures that security report data is available for all
|
|
232
|
+
packages in the current graph. This selector is useful for
|
|
233
|
+
validating that security data has been properly loaded before
|
|
234
|
+
running other security-related selectors. Make sure to prefix your
|
|
235
|
+
queries with `:scanned` to make sure all currently known package
|
|
236
|
+
alerts were checked.
|
|
231
237
|
- `:scripts` Matches packages that have scripts that are run when the
|
|
232
238
|
package is installed. The majority of malware in npm is hidden in
|
|
233
239
|
install scripts.
|
package/dist/esm/attribute.js
CHANGED
|
@@ -128,7 +128,9 @@ export const attribute = async (state) => {
|
|
|
128
128
|
if (state.loose) {
|
|
129
129
|
return state;
|
|
130
130
|
}
|
|
131
|
-
throw
|
|
131
|
+
throw error(`Unsupported attribute operator: ${curr.operator}`, {
|
|
132
|
+
found: state.current,
|
|
133
|
+
});
|
|
132
134
|
}
|
|
133
135
|
const value = curr.value || '';
|
|
134
136
|
const propertyName = curr.attribute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../src/attribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAK5C,+EAA+E;AAC/E,wDAAwD;AACxD,gEAAgE;AAChE,MAAM,iBAAiB,GAAG,CAAC,CAAY,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAc,EACd,UAAoB,EACpB,SAAiB,EACK,EAAE;IACxB,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,OAAM;IAE1B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAY,CAAC,IAAI,CAAC,QAAqB,CAAC,CAAC,CAAA;IACjE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAa,CAAA;IAClC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,4CAA4C;YAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,KAAK,CAAC,yCAAyC,EAAE;oBACrD,KAAK,EAAE,UAAU;iBAClB,CAAC,CAAA;YACJ,CAAC;YACD,oBAAoB;YAEpB,wDAAwD;YACxD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,KAAK,MAAM,CAAC,IAAI,I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,CAAC;IAChD,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;CACpC,CAAA;AACD,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAC1C,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CACnC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,KAAkB,EACI,EAAE;IACxB,MAAM,KAAK,CAAC,WAAW,EAAE,CAAA;IAEzB,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;IACnE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,IAAI,KAAK,CACb,mCAAmC,IAAI,CAAC,QAAQ,EAAE,CACnD,CAAA;IACH,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;IAC9B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAA;IACtC,OAAO,gBAAgB,CACrB,KAAK,EACL,UAAU,EACV,KAAK,EACL,YAAY,EACZ,WAAW,CACZ,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { NodeLike } from '@vltpkg/graph'\nimport type { JSONField, Manifest } from '@vltpkg/types'\nimport { asAttributeNode } from './types.ts'\nimport type { ParserState } from './types.ts'\n\nexport type ComparatorFn = (attr: string, value?: string) => boolean\n\n// JSONField has a mapped type constituent that would coerce to [object Object]\n// when stringified, which is what we want in this case.\n// eslint-disable-next-line @typescript-eslint/no-base-to-string\nconst jsonFieldToString = (v: JSONField) => String(v)\n\n/**\n * Retrieve the {@link Manifest} values found at the given `properties`\n * location for a given {@link Node}.\n */\nexport const getManifestPropertyValues = (\n node: NodeLike,\n properties: string[],\n attribute: string,\n): string[] | undefined => {\n if (!node.manifest) return\n\n const traverse = new Set<JSONField>([node.manifest as JSONField])\n const props = new Set<JSONField>()\n for (const key of properties) {\n for (const prop of traverse) {\n /* c8 ignore start - should be impossible */\n if (!prop) {\n throw error('failed to find nested property in :attr', {\n found: properties,\n })\n }\n /* c8 ignore stop */\n\n // expand the result list to include nested array values\n if (Array.isArray(prop)) {\n for (const p of prop) {\n traverse.add(p)\n }\n continue\n }\n\n // guard for inspecting keys of objects next\n if (\n typeof prop === 'string' ||\n typeof prop === 'number' ||\n typeof prop === 'boolean'\n ) {\n continue\n }\n\n // assign next value when found\n if (key in prop) {\n const nextValue = prop[key]\n if (nextValue) {\n if (key === attribute) {\n props.add(nextValue)\n } else {\n traverse.delete(prop)\n traverse.add(nextValue)\n }\n }\n }\n }\n }\n // if no value was found after trying a given key\n // then there's nothing to be collected\n if (!props.size) return\n\n // expand the result to include array values\n const collect = new Set<string>()\n for (const prop of props) {\n if (Array.isArray(prop)) {\n for (const p of prop) {\n collect.add(p ? jsonFieldToString(p) : '')\n }\n } else {\n collect.add(jsonFieldToString(prop))\n }\n }\n\n return [...collect]\n}\n\n// decorator style of function that will filter `ParserState` results\n// based on a provided `comparator` function\nexport const filterAttributes = (\n state: ParserState,\n comparator: ComparatorFn | undefined,\n value: string,\n propertyName: string,\n insensitive: boolean,\n prefixProperties: string[] = [],\n): ParserState => {\n const check = (attr: JSONField) =>\n comparator?.(\n insensitive ?\n jsonFieldToString(attr).toLowerCase()\n : jsonFieldToString(attr),\n insensitive ? value.toLowerCase() : value,\n )\n const deleteNode = (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 for (const node of state.partial.nodes) {\n const prefixes =\n prefixProperties.length ? prefixProperties : [propertyName]\n const attrs = getManifestPropertyValues(\n node,\n prefixes,\n propertyName,\n )\n\n // if no attribute value was found, that means the attribute won't match\n if (!attrs?.length) {\n deleteNode(node)\n continue\n }\n\n // if the node attribute value won't match, then remove the node\n if (comparator && !attrs.some(check)) {\n deleteNode(node)\n }\n }\n\n for (const edge of state.partial.edges) {\n // edge.name is a special case in order\n // to be able to match missing nodes by name\n if (propertyName === 'name' && check(edge.name)) {\n continue\n }\n // remove any remaining dangling edge\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n return state\n}\n\n// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors\nconst attributeSelectors: Record<string, ComparatorFn> = {\n '=': (attr: string, value = '') => attr === value,\n '^=': (attr: string, value = '') => attr.startsWith(value),\n '$=': (attr: string, value = '') => attr.endsWith(value),\n '~=': (attr: string, value = '') =>\n new Set<string>(attr.match(/\\w+/g)).has(value),\n '*=': (attr: string, value = '') => attr.includes(value),\n '|=': (attr: string, value = '') =>\n attr === value || attr.startsWith(`${value}-`),\n undefined: (attr: string) => !!attr,\n}\nexport const attributeSelectorsMap = new Map<string, ComparatorFn>(\n Object.entries(attributeSelectors),\n)\n\n/**\n * Parse attributes selectors, e.g: `[name]`, `[name=value]`, etc\n */\nexport const attribute = async (\n state: ParserState,\n): Promise<ParserState> => {\n await state.cancellable()\n\n const curr = asAttributeNode(state.current)\n const operatorFn = attributeSelectorsMap.get(String(curr.operator))\n if (!operatorFn) {\n if (state.loose) {\n return state\n }\n\n throw new Error(\n `Unsupported attribute operator: ${curr.operator}`,\n )\n }\n\n const value = curr.value || ''\n const propertyName = curr.attribute\n const insensitive = !!curr.insensitive\n return filterAttributes(\n state,\n operatorFn,\n value,\n propertyName,\n insensitive,\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"attribute.js","sourceRoot":"","sources":["../../src/attribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AA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GAAG,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;IACnE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,CAAC,mCAAmC,IAAI,CAAC,QAAQ,EAAE,EAAE;YAC9D,KAAK,EAAE,KAAK,CAAC,OAAO;SACrB,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;IAC9B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAA;IACnC,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAA;IACtC,OAAO,gBAAgB,CACrB,KAAK,EACL,UAAU,EACV,KAAK,EACL,YAAY,EACZ,WAAW,CACZ,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { NodeLike } from '@vltpkg/graph'\nimport type { JSONField, Manifest } from '@vltpkg/types'\nimport { asAttributeNode } from './types.ts'\nimport type { ParserState } from './types.ts'\n\nexport type ComparatorFn = (attr: string, value?: string) => boolean\n\n// JSONField has a mapped type constituent that would coerce to [object Object]\n// when stringified, which is what we want in this case.\n// eslint-disable-next-line @typescript-eslint/no-base-to-string\nconst jsonFieldToString = (v: JSONField) => String(v)\n\n/**\n * Retrieve the {@link Manifest} values found at the given `properties`\n * location for a given {@link Node}.\n */\nexport const getManifestPropertyValues = (\n node: NodeLike,\n properties: string[],\n attribute: string,\n): string[] | undefined => {\n if (!node.manifest) return\n\n const traverse = new Set<JSONField>([node.manifest as JSONField])\n const props = new Set<JSONField>()\n for (const key of properties) {\n for (const prop of traverse) {\n /* c8 ignore start - should be impossible */\n if (!prop) {\n throw error('failed to find nested property in :attr', {\n found: properties,\n })\n }\n /* c8 ignore stop */\n\n // expand the result list to include nested array values\n if (Array.isArray(prop)) {\n for (const p of prop) {\n traverse.add(p)\n }\n continue\n }\n\n // guard for inspecting keys of objects next\n if (\n typeof prop === 'string' ||\n typeof prop === 'number' ||\n typeof prop === 'boolean'\n ) {\n continue\n }\n\n // assign next value when found\n if (key in prop) {\n const nextValue = prop[key]\n if (nextValue) {\n if (key === attribute) {\n props.add(nextValue)\n } else {\n traverse.delete(prop)\n traverse.add(nextValue)\n }\n }\n }\n }\n }\n // if no value was found after trying a given key\n // then there's nothing to be collected\n if (!props.size) return\n\n // expand the result to include array values\n const collect = new Set<string>()\n for (const prop of props) {\n if (Array.isArray(prop)) {\n for (const p of prop) {\n collect.add(p ? jsonFieldToString(p) : '')\n }\n } else {\n collect.add(jsonFieldToString(prop))\n }\n }\n\n return [...collect]\n}\n\n// decorator style of function that will filter `ParserState` results\n// based on a provided `comparator` function\nexport const filterAttributes = (\n state: ParserState,\n comparator: ComparatorFn | undefined,\n value: string,\n propertyName: string,\n insensitive: boolean,\n prefixProperties: string[] = [],\n): ParserState => {\n const check = (attr: JSONField) =>\n comparator?.(\n insensitive ?\n jsonFieldToString(attr).toLowerCase()\n : jsonFieldToString(attr),\n insensitive ? value.toLowerCase() : value,\n )\n const deleteNode = (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 for (const node of state.partial.nodes) {\n const prefixes =\n prefixProperties.length ? prefixProperties : [propertyName]\n const attrs = getManifestPropertyValues(\n node,\n prefixes,\n propertyName,\n )\n\n // if no attribute value was found, that means the attribute won't match\n if (!attrs?.length) {\n deleteNode(node)\n continue\n }\n\n // if the node attribute value won't match, then remove the node\n if (comparator && !attrs.some(check)) {\n deleteNode(node)\n }\n }\n\n for (const edge of state.partial.edges) {\n // edge.name is a special case in order\n // to be able to match missing nodes by name\n if (propertyName === 'name' && check(edge.name)) {\n continue\n }\n // remove any remaining dangling edge\n if (!edge.to) {\n state.partial.edges.delete(edge)\n }\n }\n return state\n}\n\n// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors\nconst attributeSelectors: Record<string, ComparatorFn> = {\n '=': (attr: string, value = '') => attr === value,\n '^=': (attr: string, value = '') => attr.startsWith(value),\n '$=': (attr: string, value = '') => attr.endsWith(value),\n '~=': (attr: string, value = '') =>\n new Set<string>(attr.match(/\\w+/g)).has(value),\n '*=': (attr: string, value = '') => attr.includes(value),\n '|=': (attr: string, value = '') =>\n attr === value || attr.startsWith(`${value}-`),\n undefined: (attr: string) => !!attr,\n}\nexport const attributeSelectorsMap = new Map<string, ComparatorFn>(\n Object.entries(attributeSelectors),\n)\n\n/**\n * Parse attributes selectors, e.g: `[name]`, `[name=value]`, etc\n */\nexport const attribute = async (\n state: ParserState,\n): Promise<ParserState> => {\n await state.cancellable()\n\n const curr = asAttributeNode(state.current)\n const operatorFn = attributeSelectorsMap.get(String(curr.operator))\n if (!operatorFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported attribute operator: ${curr.operator}`, {\n found: state.current,\n })\n }\n\n const value = curr.value || ''\n const propertyName = curr.attribute\n const insensitive = !!curr.insensitive\n return filterAttributes(\n state,\n operatorFn,\n value,\n propertyName,\n insensitive,\n )\n}\n"]}
|
package/dist/esm/class.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/class.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/class.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,YAAY,CAAA;AAoHvD;;GAEG;AACH,eAAO,MAAM,OAAO,UAAiB,WAAW,yBAe/C,CAAA"}
|
package/dist/esm/class.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
1
2
|
import { asClassNode } from "./types.js";
|
|
2
3
|
const classSelectors = {
|
|
3
4
|
prod: async (state) => {
|
|
@@ -121,7 +122,9 @@ export const classFn = async (state) => {
|
|
|
121
122
|
if (state.loose) {
|
|
122
123
|
return state;
|
|
123
124
|
}
|
|
124
|
-
throw
|
|
125
|
+
throw error(`Unsupported class: ${state.current.value}`, {
|
|
126
|
+
found: state.current,
|
|
127
|
+
});
|
|
125
128
|
}
|
|
126
129
|
return comparatorFn(state);
|
|
127
130
|
};
|
package/dist/esm/class.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGxC,MAAM,cAAc,GAA6B;IAC/C,IAAI,EAAE,KAAK,EAAE,KAAkB,EAAE,EAAE;QACjC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC1C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACvB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBAChC,SAAQ;YACV,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACtC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;gBAC5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,QAAQ,CAAC,MAAM,CAAC,IAAI,C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CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { asClassNode } from './types.ts'\nimport type { ParserFn, ParserState } from './types.ts'\n\nconst classSelectors: Record<string, ParserFn> = {\n prod: async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.type !== 'prod' || edge.from.dev) {\n state.partial.edges.delete(edge)\n }\n }\n for (const node of state.partial.nodes) {\n if (!node.edgesIn.size) {\n state.partial.nodes.delete(node)\n continue\n }\n const iterator = new Set(node.edgesIn)\n for (const edge of iterator) {\n if (!state.partial.edges.has(edge)) {\n iterator.delete(edge)\n }\n }\n if (!iterator.size) {\n state.partial.nodes.delete(node)\n }\n }\n return state\n },\n dev: async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.type !== 'dev' && !edge.from.dev) {\n state.partial.edges.delete(edge)\n }\n }\n for (const node of state.partial.nodes) {\n if (!node.edgesIn.size) {\n state.partial.nodes.delete(node)\n continue\n }\n const iterator = new Set(node.edgesIn)\n for (const edge of iterator) {\n if (!state.partial.edges.has(edge)) {\n iterator.delete(edge)\n }\n }\n if (!iterator.size) {\n state.partial.nodes.delete(node)\n }\n }\n return state\n },\n optional: async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.type !== 'optional' && !edge.from.optional) {\n state.partial.edges.delete(edge)\n }\n }\n for (const node of state.partial.nodes) {\n if (!node.edgesIn.size) {\n state.partial.nodes.delete(node)\n continue\n }\n const iterator = new Set(node.edgesIn)\n for (const edge of iterator) {\n if (!state.partial.edges.has(edge)) {\n iterator.delete(edge)\n }\n }\n if (!iterator.size) {\n state.partial.nodes.delete(node)\n }\n }\n return state\n },\n peer: async (state: ParserState) => {\n for (const edge of state.partial.edges) {\n if (edge.type !== 'peer') {\n state.partial.edges.delete(edge)\n }\n }\n for (const node of state.partial.nodes) {\n if (!node.edgesIn.size) {\n state.partial.nodes.delete(node)\n continue\n }\n for (const e of node.edgesIn) {\n if (!state.partial.edges.has(e)) {\n state.partial.nodes.delete(node)\n }\n }\n }\n return state\n },\n workspace: async (state: ParserState) => {\n for (const node of state.partial.nodes) {\n if (!node.importer || node.mainImporter) {\n state.partial.nodes.delete(node)\n }\n }\n for (const edge of state.partial.edges) {\n // workspaces can't be missing\n if (!edge.to) {\n state.partial.edges.delete(edge)\n // keep only edges that are linking to preivously kept nodes\n } else if (!state.partial.nodes.has(edge.to)) {\n state.partial.edges.delete(edge)\n }\n }\n return state\n },\n // TBD: all things bundled\n // bundled: () => false,\n}\n\nconst classSelectorsMap = new Map<string, ParserFn>(\n Object.entries(classSelectors),\n)\n\n/**\n * Parse classes, e.g: `.prod`, `.dev`, `.optional`, etc\n */\nexport const classFn = async (state: ParserState) => {\n await state.cancellable()\n\n const curr = asClassNode(state.current)\n const comparatorFn = curr.value && classSelectorsMap.get(curr.value)\n if (!comparatorFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported class: ${state.current.value}`, {\n found: state.current,\n })\n }\n return comparatorFn(state)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combinator.d.ts","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"combinator.d.ts","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,YAAY,CAAA;AA8GvD;;GAEG;AACH,eAAO,MAAM,UAAU,UAAiB,WAAW,yBAgBlD,CAAA"}
|
package/dist/esm/combinator.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { asCombinatorNode } from "./types.js";
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
3
|
/**
|
|
3
4
|
* Returns a new set of nodes, containing all direct dependencies
|
|
4
5
|
* of the current list of nodes used.
|
|
@@ -102,7 +103,9 @@ export const combinator = async (state) => {
|
|
|
102
103
|
if (state.loose) {
|
|
103
104
|
return state;
|
|
104
105
|
}
|
|
105
|
-
throw
|
|
106
|
+
throw error(`Unsupported combinator: ${state.current.value}`, {
|
|
107
|
+
found: state.current,
|
|
108
|
+
});
|
|
106
109
|
}
|
|
107
110
|
return parserFn(state);
|
|
108
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"combinator.js","sourceRoot":"","sources":["../../src/combinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,eAAe,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE;IACnD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAC3B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IAE3B,qDAAqD;IACrD,uDAAuD;IACvD,kBAAkB;IAClB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBAC7B,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;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AAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE;YAC5D,KAAK,EAAE,KAAK,CAAC,OAAO;SACrB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import type { EdgeLike, NodeLike } from '@vltpkg/graph'\nimport { asCombinatorNode } from './types.ts'\nimport type { ParserState, ParserFn } from './types.ts'\nimport { error } from '@vltpkg/error-cause'\n\n/**\n * Returns a new set of nodes, containing all direct dependencies\n * of the current list of nodes used.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator\n */\nconst childCombinator = async (state: ParserState) => {\n const traverse = new Set(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // visit direct children of the current list of nodes\n // collecting refs to these children and the edges that\n // connected them.\n for (const node of traverse) {\n for (const edge of node.edgesOut.values()) {\n if (edge.to) {\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n }\n\n return state\n}\n\n/**\n * Returns a new set of nodes, containing nodes that are also children\n * of all parent nodes to the current list of nodes used.\n *\n * Note: The subsequent-sibling comparator has a behavior that is\n * somehow approximative of that of its css counterpart, given that\n * in the context of dependency graphs the order of appearance is\n * not necessarily controlled by the end user. The approach for\n * this comparator is to match all siblings of a node.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Subsequent-sibling_combinator\n */\nconst subsequentSiblingCombinator = async (state: ParserState) => {\n const traverse = new Set(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // visits direct parents of the current list of node and then\n // visit their children, collecting refs to all children and edges\n // that are not in the original list of nodes.\n for (const node of traverse) {\n for (const edge of node.edgesIn) {\n const parents: IterableIterator<EdgeLike> =\n edge.from.edgesOut.values()\n for (const edge of parents) {\n if (edge.to && edge.to !== node) {\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n }\n }\n\n return state\n}\n\n/**\n * Returns a new set of nodes containing all nodes that are descendents\n * to items in the current list of nodes.\n *\n * ref: https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator\n */\nconst descendentCombinator = async (state: ParserState) => {\n // spaces between tags selectors are a noop\n if (state.prev?.type === 'tag' || state.next?.type === 'tag') {\n return state\n }\n\n const traverse = new Set<NodeLike>(state.partial.nodes)\n state.partial.edges.clear()\n state.partial.nodes.clear()\n\n // breadth-first traversal of the graph, starting from the current\n // list of nodes, collecting all nodes and edges along the way\n for (const node of traverse) {\n const children = new Set<NodeLike>()\n for (const edge of node.edgesOut.values()) {\n if (edge.to) {\n children.add(edge.to)\n state.partial.edges.add(edge)\n state.partial.nodes.add(edge.to)\n }\n }\n for (const child of children) {\n traverse.add(child)\n }\n }\n\n return state\n}\n\nconst combinatorSelectors = {\n '>': childCombinator,\n '~': subsequentSiblingCombinator,\n ' ': descendentCombinator,\n}\n\nconst combinatorSelectorsMap = new Map<string, ParserFn>(\n Object.entries(combinatorSelectors),\n)\n\n/**\n * Parse css-style combinators, e.g: `>`, `~` and ` `\n */\nexport const combinator = async (state: ParserState) => {\n await state.cancellable()\n\n const curr = asCombinatorNode(state.current)\n const parserFn =\n curr.value && combinatorSelectorsMap.get(curr.value)\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw error(`Unsupported combinator: ${state.current.value}`, {\n found: state.current,\n })\n }\n return parserFn(state)\n}\n"]}
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,SAAS,EAAY,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAYnE,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAiC1B,eAAO,MAAM,IAAI,UACR,WAAW,KACjB,OAAO,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,SAAS,EAAY,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAYnE,OAAO,KAAK,EAEV,WAAW,EAEX,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAiC1B,eAAO,MAAM,IAAI,UACR,WAAW,KACjB,OAAO,CAAC,WAAW,CAsDrB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,SAAS,CAAA;IAChB,WAAW,EAAE,WAAW,CAAA;IACxB,eAAe,EAAE,mBAAmB,GAAG,SAAS,CAAA;CACjD,CAAA;AAsCD,qBAAa,KAAK;;IAMhB;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;gBASvC,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,EAAE,YAAY;IAOjE;;OAEG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC;CA6C1B"}
|
package/dist/esm/index.js
CHANGED
|
@@ -41,7 +41,9 @@ export const walk = async (state) => {
|
|
|
41
41
|
if (state.loose) {
|
|
42
42
|
return state;
|
|
43
43
|
}
|
|
44
|
-
throw
|
|
44
|
+
throw error(`Missing parser for query node: ${state.current.type}`, {
|
|
45
|
+
found: state.current,
|
|
46
|
+
});
|
|
45
47
|
}
|
|
46
48
|
state = await parserFn(state);
|
|
47
49
|
// pseudo selectors handle their own sub selectors
|
|
@@ -93,6 +95,7 @@ const securitySelectors = new Set([
|
|
|
93
95
|
':native',
|
|
94
96
|
':network',
|
|
95
97
|
':obfuscated',
|
|
98
|
+
':scanned',
|
|
96
99
|
':scripts',
|
|
97
100
|
':sev',
|
|
98
101
|
':severity',
|
|
@@ -136,9 +139,6 @@ export class Query {
|
|
|
136
139
|
* Search the graph for nodes and edges that match the given query.
|
|
137
140
|
*/
|
|
138
141
|
async search(query, signal) {
|
|
139
|
-
if (typeof query !== 'string') {
|
|
140
|
-
throw new TypeError('Query search argument needs to be a string');
|
|
141
|
-
}
|
|
142
142
|
if (!query)
|
|
143
143
|
return { edges: [], nodes: [] };
|
|
144
144
|
const cachedResult = this.#cache.get(query);
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C,OAAO,qBAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,cAAc,GACf,MAAM,YAAY,CAAA;AAQnB,cAAc,YAAY,CAAA;AAE1B,MAAM,MAAM,GAAG,KAAK,EAAE,KAAkB,EAAE,EAAE,CAAC,KAAK,C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AK,EAAE,IAAI,GAAG,EAAY;aAC3B;YACD,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;YACzB,MAAM;YACN,eAAe,EAAE,IAAI,CAAC,gBAAgB;YACtC,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,IAAI;SACL,CAAC,CAAA;QAEF,MAAM,GAAG,GAAkB;YACzB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;SACjC,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,CAAA;IACZ,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, GraphLike, NodeLike } from '@vltpkg/graph'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\nimport type { SecurityArchiveLike } from '@vltpkg/security-archive'\nimport postcssSelectorParser from 'postcss-selector-parser'\nimport { attribute } from './attribute.ts'\nimport { classFn } from './class.ts'\nimport { combinator } from './combinator.ts'\nimport { id } from './id.ts'\nimport { pseudo } from './pseudo.ts'\nimport {\n isPostcssNodeWithChildren,\n asPostcssNodeWithChildren,\n isSelectorNode,\n} from './types.ts'\nimport type {\n PostcssNodeWithChildren,\n ParserState,\n ParserFn,\n QueryResponse,\n} from './types.ts'\n\nexport * from './types.ts'\n\nconst noopFn = async (state: ParserState) => state\n\nconst selectors = {\n attribute,\n class: classFn,\n combinator,\n comment: noopFn,\n id,\n nesting: noopFn,\n pseudo,\n root: noopFn,\n selector: async (state: ParserState) => {\n state.partial.nodes = new Set(state.initial.nodes)\n state.partial.edges = new Set(state.initial.edges)\n return state\n },\n string: async (state: ParserState) => {\n throw error('Unsupported selector', { found: state.current })\n },\n tag: async (state: ParserState) => {\n if (state.current.value !== '{' && state.current.value !== '}') {\n throw error('Unsupported selector', { found: state.current })\n }\n return state\n },\n universal: noopFn,\n}\nconst selectorsMap = new Map<string, ParserFn>(\n Object.entries(selectors),\n)\n\nexport const walk = async (\n state: ParserState,\n): Promise<ParserState> => {\n await state.cancellable()\n\n const parserFn = selectorsMap.get(state.current.type)\n\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw new Error(\n `Missing parser for query node: ${state.current.type}`,\n )\n }\n state = await parserFn(state)\n\n // pseudo selectors handle their own sub selectors\n if (\n isPostcssNodeWithChildren(state.current) &&\n state.current.type !== 'pseudo'\n ) {\n const node: PostcssNodeWithChildren = asPostcssNodeWithChildren(\n state.current,\n )\n\n if (node.nodes.length) {\n for (let i = 0; i < node.nodes.length; i++) {\n const current = node.nodes[i]\n /* c8 ignore next -- impossible but TS doesn't know that */\n if (!current) continue\n\n const childState: ParserState = {\n ...state,\n current,\n next: node.nodes[i + 1],\n prev: node.nodes[i - 1],\n }\n state = await walk(childState)\n }\n }\n\n if (isSelectorNode(node)) {\n for (const edge of state.partial.edges) {\n state.collect.edges.add(edge)\n }\n for (const node of state.partial.nodes) {\n state.collect.nodes.add(node)\n }\n }\n }\n return state\n}\n\nexport type QueryOptions = {\n graph: GraphLike\n specOptions: SpecOptions\n securityArchive: SecurityArchiveLike | undefined\n}\n\n// A list of known security selectors that rely on\n// data from the security-archive in order to work\nconst securitySelectors = new Set([\n ':abandoned',\n ':confused',\n ':cve',\n ':debug',\n ':deprecated',\n ':dynamic',\n ':entropic',\n ':env',\n ':eval',\n ':fs',\n ':license',\n ':malware',\n ':minified',\n ':native',\n ':network',\n ':obfuscated',\n ':scripts',\n ':sev',\n ':severity',\n ':shell',\n ':shrinkwrap',\n ':squat',\n ':suspicious',\n ':tracker',\n ':trivial',\n ':undesirable',\n ':unknown',\n ':unmaintained',\n ':unpopular',\n ':unstable',\n])\n\nexport class Query {\n #cache: Map<string, QueryResponse>\n #graph: GraphLike\n #specOptions: SpecOptions\n #securityArchive: SecurityArchiveLike | undefined\n\n /**\n * Helper method to determine if a given query string is using any of\n * the known security selectors. This is useful so that operations can\n * skip hydrating the security archive if it's not needed.\n */\n static hasSecuritySelectors(query: string): boolean {\n for (const selector of securitySelectors) {\n if (query.includes(selector)) {\n return true\n }\n }\n return false\n }\n\n constructor({ graph, specOptions, securityArchive }: QueryOptions) {\n this.#cache = new Map()\n this.#graph = graph\n this.#specOptions = specOptions\n this.#securityArchive = securityArchive\n }\n\n /**\n * Search the graph for nodes and edges that match the given query.\n */\n async search(\n query: string,\n signal?: AbortSignal,\n ): Promise<QueryResponse> {\n if (typeof query !== 'string') {\n throw new TypeError(\n 'Query search argument needs to be a string',\n )\n }\n\n if (!query) return { edges: [], nodes: [] }\n\n const cachedResult = this.#cache.get(query)\n if (cachedResult) {\n return cachedResult\n }\n\n const nodes = new Set<NodeLike>(\n Array.from(this.#graph.nodes.values()),\n )\n const edges = new Set<EdgeLike>(Array.from(this.#graph.edges))\n\n // builds initial state and walks over it,\n // retrieving the collected result\n const { collect } = await walk({\n cancellable: async () => {\n await new Promise(resolve => {\n setTimeout(resolve, 0)\n })\n signal?.throwIfAborted()\n },\n current: postcssSelectorParser().astSync(query),\n initial: {\n nodes: new Set(nodes),\n edges: new Set(edges),\n },\n collect: {\n nodes: new Set<NodeLike>(),\n edges: new Set<EdgeLike>(),\n },\n partial: { nodes, edges },\n signal,\n securityArchive: this.#securityArchive,\n specOptions: this.#specOptions,\n walk,\n })\n\n const res: QueryResponse = {\n edges: Array.from(collect.edges),\n nodes: Array.from(collect.nodes),\n }\n this.#cache.set(query, res)\n return res\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C,OAAO,qBAAqB,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACp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CAAC;YACD,OAAO,EAAE,qBAAqB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;YAC/C,OAAO,EAAE;gBACP,KAAK,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC;gBACrB,KAAK,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC;aACtB;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,IAAI,GAAG,EAAY;gBAC1B,KAAK,EAAE,IAAI,GAAG,EAAY;aAC3B;YACD,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;YACzB,MAAM;YACN,eAAe,EAAE,IAAI,CAAC,gBAAgB;YACtC,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,IAAI;SACL,CAAC,CAAA;QAEF,MAAM,GAAG,GAAkB;YACzB,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;YAChC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;SACjC,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,CAAA;IACZ,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { EdgeLike, GraphLike, NodeLike } from '@vltpkg/graph'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\nimport type { SecurityArchiveLike } from '@vltpkg/security-archive'\nimport postcssSelectorParser from 'postcss-selector-parser'\nimport { attribute } from './attribute.ts'\nimport { classFn } from './class.ts'\nimport { combinator } from './combinator.ts'\nimport { id } from './id.ts'\nimport { pseudo } from './pseudo.ts'\nimport {\n isPostcssNodeWithChildren,\n asPostcssNodeWithChildren,\n isSelectorNode,\n} from './types.ts'\nimport type {\n PostcssNodeWithChildren,\n ParserState,\n ParserFn,\n QueryResponse,\n} from './types.ts'\n\nexport * from './types.ts'\n\nconst noopFn = async (state: ParserState) => state\n\nconst selectors = {\n attribute,\n class: classFn,\n combinator,\n comment: noopFn,\n id,\n nesting: noopFn,\n pseudo,\n root: noopFn,\n selector: async (state: ParserState) => {\n state.partial.nodes = new Set(state.initial.nodes)\n state.partial.edges = new Set(state.initial.edges)\n return state\n },\n string: async (state: ParserState) => {\n throw error('Unsupported selector', { found: state.current })\n },\n tag: async (state: ParserState) => {\n if (state.current.value !== '{' && state.current.value !== '}') {\n throw error('Unsupported selector', { found: state.current })\n }\n return state\n },\n universal: noopFn,\n}\nconst selectorsMap = new Map<string, ParserFn>(\n Object.entries(selectors),\n)\n\nexport const walk = async (\n state: ParserState,\n): Promise<ParserState> => {\n await state.cancellable()\n\n const parserFn = selectorsMap.get(state.current.type)\n\n if (!parserFn) {\n if (state.loose) {\n return state\n }\n\n throw error(\n `Missing parser for query node: ${state.current.type}`,\n {\n found: state.current,\n },\n )\n }\n state = await parserFn(state)\n\n // pseudo selectors handle their own sub selectors\n if (\n isPostcssNodeWithChildren(state.current) &&\n state.current.type !== 'pseudo'\n ) {\n const node: PostcssNodeWithChildren = asPostcssNodeWithChildren(\n state.current,\n )\n\n if (node.nodes.length) {\n for (let i = 0; i < node.nodes.length; i++) {\n const current = node.nodes[i]\n /* c8 ignore next -- impossible but TS doesn't know that */\n if (!current) continue\n\n const childState: ParserState = {\n ...state,\n current,\n next: node.nodes[i + 1],\n prev: node.nodes[i - 1],\n }\n state = await walk(childState)\n }\n }\n\n if (isSelectorNode(node)) {\n for (const edge of state.partial.edges) {\n state.collect.edges.add(edge)\n }\n for (const node of state.partial.nodes) {\n state.collect.nodes.add(node)\n }\n }\n }\n return state\n}\n\nexport type QueryOptions = {\n graph: GraphLike\n specOptions: SpecOptions\n securityArchive: SecurityArchiveLike | undefined\n}\n\n// A list of known security selectors that rely on\n// data from the security-archive in order to work\nconst securitySelectors = new Set([\n ':abandoned',\n ':confused',\n ':cve',\n ':debug',\n ':deprecated',\n ':dynamic',\n ':entropic',\n ':env',\n ':eval',\n ':fs',\n ':license',\n ':malware',\n ':minified',\n ':native',\n ':network',\n ':obfuscated',\n ':scanned',\n ':scripts',\n ':sev',\n ':severity',\n ':shell',\n ':shrinkwrap',\n ':squat',\n ':suspicious',\n ':tracker',\n ':trivial',\n ':undesirable',\n ':unknown',\n ':unmaintained',\n ':unpopular',\n ':unstable',\n])\n\nexport class Query {\n #cache: Map<string, QueryResponse>\n #graph: GraphLike\n #specOptions: SpecOptions\n #securityArchive: SecurityArchiveLike | undefined\n\n /**\n * Helper method to determine if a given query string is using any of\n * the known security selectors. This is useful so that operations can\n * skip hydrating the security archive if it's not needed.\n */\n static hasSecuritySelectors(query: string): boolean {\n for (const selector of securitySelectors) {\n if (query.includes(selector)) {\n return true\n }\n }\n return false\n }\n\n constructor({ graph, specOptions, securityArchive }: QueryOptions) {\n this.#cache = new Map()\n this.#graph = graph\n this.#specOptions = specOptions\n this.#securityArchive = securityArchive\n }\n\n /**\n * Search the graph for nodes and edges that match the given query.\n */\n async search(\n query: string,\n signal?: AbortSignal,\n ): Promise<QueryResponse> {\n if (!query) return { edges: [], nodes: [] }\n\n const cachedResult = this.#cache.get(query)\n if (cachedResult) {\n return cachedResult\n }\n\n const nodes = new Set<NodeLike>(\n Array.from(this.#graph.nodes.values()),\n )\n const edges = new Set<EdgeLike>(Array.from(this.#graph.edges))\n\n // builds initial state and walks over it,\n // retrieving the collected result\n const { collect } = await walk({\n cancellable: async () => {\n await new Promise(resolve => {\n setTimeout(resolve, 0)\n })\n signal?.throwIfAborted()\n },\n current: postcssSelectorParser().astSync(query),\n initial: {\n nodes: new Set(nodes),\n edges: new Set(edges),\n },\n collect: {\n nodes: new Set<NodeLike>(),\n edges: new Set<EdgeLike>(),\n },\n partial: { nodes, edges },\n signal,\n securityArchive: this.#securityArchive,\n specOptions: this.#specOptions,\n walk,\n })\n\n const res: QueryResponse = {\n edges: Array.from(collect.edges),\n nodes: Array.from(collect.nodes),\n }\n this.#cache.set(query, res)\n return res\n }\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **missingAuthor** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const abandoned: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const abandoned: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=abandoned.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abandoned.d.ts","sourceRoot":"","sources":["../../../src/pseudo/abandoned.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"abandoned.d.ts","sourceRoot":"","sources":["../../../src/pseudo/abandoned.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,SAAS;;EAGrB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **manifestConfusion** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const confused: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const confused: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=confused.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confused.d.ts","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"confused.d.ts","sourceRoot":"","sources":["../../../src/pseudo/confused.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,QAAQ;;EAGpB,CAAA"}
|
package/dist/esm/pseudo/cve.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ export declare const parseInternals: (nodes: PostcssNode[]) => CveInternals;
|
|
|
6
6
|
/**
|
|
7
7
|
* Filters out any node that does not have a CVE alert with the specified CVE ID.
|
|
8
8
|
*/
|
|
9
|
-
export declare const cve: (state: ParserState) => Promise<ParserState
|
|
9
|
+
export declare const cve: (state: ParserState) => Promise<ParserState & {
|
|
10
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
11
|
+
}>;
|
|
10
12
|
//# sourceMappingURL=cve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cve.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"cve.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,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,6 +1,6 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
2
|
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
|
|
3
|
-
import { removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
3
|
+
import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
4
4
|
export const parseInternals = (nodes) => {
|
|
5
5
|
let cveId = '';
|
|
6
6
|
if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
@@ -21,10 +21,7 @@ export const parseInternals = (nodes) => {
|
|
|
21
21
|
* Filters out any node that does not have a CVE alert with the specified CVE ID.
|
|
22
22
|
*/
|
|
23
23
|
export const cve = async (state) => {
|
|
24
|
-
|
|
25
|
-
throw new Error('Missing security archive while trying to parse ' +
|
|
26
|
-
'the :cve security selector');
|
|
27
|
-
}
|
|
24
|
+
assertSecurityArchive(state, 'cve');
|
|
28
25
|
let internals;
|
|
29
26
|
try {
|
|
30
27
|
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
@@ -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,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAMrB,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,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACvD,CAAC;QACD,KAAK,GAAG,SAAS,CACf,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,K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AE,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 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
|
@@ -6,5 +6,7 @@ export declare const parseInternals: (nodes: PostcssNode[]) => CweInternals;
|
|
|
6
6
|
/**
|
|
7
7
|
* Filters out any node that does not have a CWE alert with the specified CWE ID.
|
|
8
8
|
*/
|
|
9
|
-
export declare const cwe: (state: ParserState) => Promise<ParserState
|
|
9
|
+
export declare const cwe: (state: ParserState) => Promise<ParserState & {
|
|
10
|
+
securityArchive: NonNullable<ParserState["securityArchive"]>;
|
|
11
|
+
}>;
|
|
10
12
|
//# sourceMappingURL=cwe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cwe.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cwe.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"cwe.d.ts","sourceRoot":"","sources":["../../../src/pseudo/cwe.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ3D,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,6 +1,6 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
2
|
import { asPostcssNodeWithChildren, asStringNode, asTagNode, isStringNode, isTagNode, } from "../types.js";
|
|
3
|
-
import { removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
3
|
+
import { assertSecurityArchive, removeDanglingEdges, removeNode, removeQuotes, } from "./helpers.js";
|
|
4
4
|
export const parseInternals = (nodes) => {
|
|
5
5
|
let cweId = '';
|
|
6
6
|
if (isStringNode(asPostcssNodeWithChildren(nodes[0]).nodes[0])) {
|
|
@@ -21,10 +21,7 @@ export const parseInternals = (nodes) => {
|
|
|
21
21
|
* Filters out any node that does not have a CWE alert with the specified CWE ID.
|
|
22
22
|
*/
|
|
23
23
|
export const cwe = async (state) => {
|
|
24
|
-
|
|
25
|
-
throw new Error('Missing security archive while trying to parse ' +
|
|
26
|
-
'the :cwe security selector');
|
|
27
|
-
}
|
|
24
|
+
assertSecurityArchive(state, 'cwe');
|
|
28
25
|
let internals;
|
|
29
26
|
try {
|
|
30
27
|
internals = parseInternals(asPostcssNodeWithChildren(state.current).nodes);
|
|
@@ -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,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,YAAY,GACb,MAAM,cAAc,CAAA;AAMrB,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,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EACvD,CAAC;QACD,KAAK,GAAG,SAAS,CACf,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAC7C,CAA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AE,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 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"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **debugAccess** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const debug: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const debug: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/pseudo/debug.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/pseudo/debug.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 **deprecated** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const deprecated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const deprecated: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=deprecated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/deprecated.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../../src/pseudo/deprecated.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU;;EAGtB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Filters out any node that does not have a **dynamicRequire** report alert.
|
|
3
3
|
*/
|
|
4
|
-
export declare const dynamic: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState
|
|
4
|
+
export declare const dynamic: (state: import("../types.ts").ParserState) => Promise<import("../types.ts").ParserState & {
|
|
5
|
+
securityArchive: NonNullable<import("../types.ts").ParserState["securityArchive"]>;
|
|
6
|
+
}>;
|
|
5
7
|
//# sourceMappingURL=dynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../src/pseudo/dynamic.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../src/pseudo/dynamic.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 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"}
|