Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lavamoat-tofu

Package Overview
Dependencies
Maintainers
6
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lavamoat-tofu - npm Package Compare versions

Comparing version 7.1.0 to 7.2.0

23

CHANGELOG.md
# Changelog
## [7.2.0](https://github.com/LavaMoat/LavaMoat/compare/lavamoat-tofu-v7.1.0...lavamoat-tofu-v7.2.0) (2024-02-07)
### Features
* **tofu:** add ESM support ([be9594c](https://github.com/LavaMoat/LavaMoat/commit/be9594c0916fa773e2a9d7db0dae7cc92e16cd3e))
### Bug Fixes
* **deps:** update dependency type-fest to v4.10.0 ([9f2cf3c](https://github.com/LavaMoat/LavaMoat/commit/9f2cf3cb3e00fc5184268bedb6967ffc8d29d066))
* **deps:** update dependency type-fest to v4.10.1 ([36567e7](https://github.com/LavaMoat/LavaMoat/commit/36567e7f54efab0efd2021b9f82b5e4e4c77fe4d))
* **deps:** update dependency type-fest to v4.10.2 ([1580ed9](https://github.com/LavaMoat/LavaMoat/commit/1580ed967085ae277384fcee3eac32ab9930adcd))
* **deps:** update dependency type-fest to v4.9.0 ([70e9ffd](https://github.com/LavaMoat/LavaMoat/commit/70e9ffdf740a7d79cee9d583a55188e4ab02617d))
* **tofu:** fix type errors ([fe75965](https://github.com/LavaMoat/LavaMoat/commit/fe7596576265bc931fc2387bf7e352339f8d630b))
### Dependencies
* The following workspace dependencies were updated
* peerDependencies
* lavamoat-core bumped from ^15.0.0 to ^15.1.2
## [7.1.0](https://github.com/LavaMoat/LavaMoat/compare/lavamoat-tofu-v7.0.0...lavamoat-tofu-v7.1.0) (2024-01-18)

@@ -4,0 +27,0 @@

12

package.json
{
"name": "lavamoat-tofu",
"version": "7.1.0",
"version": "7.2.0",
"description": "This is the TOFU (trust-on-first-use) static analysis tool used by LavaMoat to automatically generate useable config",

@@ -29,10 +29,10 @@ "repository": {

"peerDependencies": {
"lavamoat-core": "^15.0.0"
"lavamoat-core": "^15.1.2"
},
"dependencies": {
"@babel/parser": "7.23.6",
"@babel/traverse": "7.23.7",
"@babel/types": "7.23.6",
"@babel/parser": "7.23.9",
"@babel/traverse": "7.23.9",
"@babel/types": "7.23.9",
"@types/babel__traverse": "7.20.5",
"type-fest": "4.7.1"
"type-fest": "4.10.2"
},

@@ -39,0 +39,0 @@ "devDependencies": {

@@ -6,13 +6,22 @@ 'use strict'

const nonReferenceIdentifiers = [
/**
* Types which are not references to globals
*/
const nonReferenceIdentifiers = new Set([
'ArrayPatten',
'BreakStatement',
'CatchClause',
'ClassMethod',
'ContinueStatement',
'ExportDefaultSpecifier',
'ExportSpecifier',
'FunctionDeclaration',
'FunctionExpression',
'ClassMethod',
'ImportDefaultSpecifier',
'ImportNamespaceSpecifier',
'ImportSpecifier',
'LabeledStatement',
'BreakStatement',
'ContinueStatement',
'CatchClause',
'ArrayPatten',
'MetaProperty',
'RestElement',
]
])

@@ -22,7 +31,8 @@ module.exports = { findGlobals }

/**
* @typedef {import('@babel/traverse').NodePath<import('@babel/types').Identifier|import('@babel/types').ThisExpression>} IdentifierOrThisExpressionNodePath
* @typedef {import('@babel/traverse').NodePath<
* import('@babel/types').Identifier | import('@babel/types').ThisExpression
* >} IdentifierOrThisExpressionNodePath
*/
/**
*
* @param {import('@babel/types').Node} ast

@@ -39,5 +49,6 @@ * @returns {Map<string, IdentifierOrThisExpressionNodePath[]>}

const parentType = path.parent.type
if (nonReferenceIdentifiers.includes(parentType)) {
if (nonReferenceIdentifiers.has(parentType)) {
return
}
if (parentType === 'VariableDeclarator' && path.parent.id === path.node) {

@@ -93,3 +104,2 @@ return

/**
*
* @param {IdentifierOrThisExpressionNodePath} path

@@ -96,0 +106,0 @@ * @param {string} [name]

@@ -5,3 +5,3 @@ const { parse } = require('@babel/parser')

inspectGlobals,
inspectImports,
inspectRequires,
inspectEsmImports,

@@ -19,3 +19,5 @@ inspectDynamicRequires,

inspectGlobals,
inspectImports,
/** @deprecated - Use {@link inspectRequires} */
inspectImports: inspectRequires,
inspectRequires,
inspectEsmImports,

@@ -22,0 +24,0 @@ inspectDynamicRequires,

@@ -19,3 +19,3 @@ const { parse } = require('@babel/parser')

inspectGlobals,
inspectImports,
inspectRequires,
inspectEsmImports,

@@ -34,4 +34,3 @@ inspectDynamicRequires,

/**
*
* @param {import('../../core/src/generatePolicy').AST|string} source
* @param {import('../../core/src/generatePolicy').AST | string} source
* @param {InspectGlobalsOpts} options

@@ -64,3 +63,2 @@ * @returns

/**
*
* @param {string} name

@@ -118,5 +116,5 @@ * @param {import('./findGlobals').IdentifierOrThisExpressionNodePath[]} paths

/**
*
* @param {string} variableName
* @param {import('@babel/types').Identifier|import('@babel/types').ThisExpression} identifierNode
* @param {import('@babel/types').Identifier
* | import('@babel/types').ThisExpression} identifierNode
* @param {import('./inspectPrimordialAssignments').MemberLikeExpression[]} parents

@@ -159,3 +157,2 @@ * @returns

/**
*
* @param {string} identifierPath

@@ -183,56 +180,51 @@ * @param {import('../../core/src/schema').GlobalPolicyValue} identifierUse

/**
* This finds all modules `import`ed into the AST, as well as any re-exported
* modules.
*
* @param {import('../../core/src/generatePolicy').AST} ast
* @returns {{esmImports: string[]}}
* @param {import('@babel/types').Node} ast
* @param {string[]} [packagesToInspect] - List of module IDs to look for; if
* omitted, will inspect all imports
* @returns {string[]} - List of imported identifiers
*/
function inspectEsmImports(ast) {
/** @type {string[]} */
const esmImports = []
function inspectEsmImports(ast, packagesToInspect) {
const pkgsToInspect = new Set(packagesToInspect)
/** @type {Set<string>} */
const esmImports = new Set()
/**
* @param {import('@babel/traverse').NodePath<
* | import('@babel/types').ImportDeclaration
* | import('@babel/types').ExportNamedDeclaration
* >} path
*/
const handleNodePath = (path) => {
const importSource = path.node.source?.value
if (
importSource &&
((pkgsToInspect.size && pkgsToInspect.has(importSource)) ||
!pkgsToInspect.size)
) {
esmImports.add(importSource)
}
}
traverse(ast, {
ImportDeclaration: (path) => {
const { node } = path
const { specifiers, source } = node
// not sure if this is ever not a StringLiteral, but just in case
if (source.type !== 'StringLiteral') {
return
}
const importSource = source.value
specifiers.forEach((spec) => {
switch (spec.type) {
case 'ImportDefaultSpecifier': {
const importName = importSource
esmImports.push(importName)
return
}
case 'ImportNamespaceSpecifier': {
const importName = importSource
esmImports.push(importName)
return
}
case 'ImportSpecifier': {
// @ts-ignore - FIXME needs logic changes for type safety
const importName = `${importSource}.${spec.imported.name}`
esmImports.push(importName)
return
}
default: {
throw new Error(
`inspectEsmImports - unknown import specifier type "${
/** @type {import('@babel/types').Node} */ (spec).type
}"`
)
}
}
})
ExportNamedDeclaration: (path) => {
handleNodePath(path)
},
ImportDeclaration: handleNodePath,
})
return { esmImports }
return [...esmImports]
}
/**
* @typedef {import('@babel/traverse').NodePath<import('@babel/types').CallExpression>} RequireCallResult
* @typedef {import('@babel/traverse').NodePath<
* import('@babel/types').CallExpression
* >} RequireCallResult
*/
/**
*
* @param {import('@babel/types').Node} ast

@@ -265,3 +257,2 @@ * @returns {RequireCallResult[]}

/**
*
* @param {import('@babel/types').Node} ast

@@ -292,8 +283,11 @@ * @returns {RequireCallResult[]}

/**
* This finds all modules `required`ed into the AST, as well as any re-exported
* modules.
*
* @param {import('@babel/types').Node} ast
* @param {string[]} packagesToInspect
* @param {boolean} deep
* @param {string[]} [packagesToInspect]
* @param {boolean} [deep]
* @returns {{ cjsImports: string[] }}
*/
function inspectImports(ast, packagesToInspect, deep = true) {
function inspectRequires(ast, packagesToInspect, deep = true) {
/** @type {string[][]} */

@@ -376,10 +370,14 @@ const cjsImports = []

/**
* @typedef {{node: import('@babel/types').PatternLike|import('@babel/types').AssignmentPattern['left'], keyPath: string[]}} Declaration
* @typedef {{
* node:
* | import('@babel/types').PatternLike
* | import('@babel/types').AssignmentPattern['left']
* keyPath: string[]
* }} Declaration
*/
/**
*
* @param {import('@babel/types').LVal|import('@babel/types').Expression} node
* @param {import('@babel/types').LVal | import('@babel/types').Expression} node
* @param {string[]} keyPath
* @returns {Declaration[]}}
* @returns {Declaration[]} }
*/

@@ -405,3 +403,2 @@ function inspectPatternElementForDeclarations(node, keyPath = []) {

/**
*
* @param {import('@babel/types').ObjectPattern} node

@@ -441,3 +438,2 @@ * @param {string[]} keyPath

/**
*
* @param {import('@babel/types').ArrayPattern} node

@@ -473,3 +469,2 @@ * @param {string[]} keyPath

/**
*
* @param {import('@babel/types').Node | import('@babel/types').PatternLike} child

@@ -497,3 +492,2 @@ * @returns

/**
*
* @param {import('@babel/types').ObjectPattern} node

@@ -535,3 +529,2 @@ * @returns

/**
*
* @param {import('@babel/types').ArrayPattern} node

@@ -538,0 +531,0 @@ * @returns {string[][]}

@@ -20,10 +20,11 @@ module.exports = {

* @typedef MemberExpressionNesting
* @property {import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression[]} memberExpressions
* @property {import("./inspectPrimordialAssignments").MemberLikeExpression} parentOfMembershipChain
* @property {import("./inspectPrimordialAssignments").MemberLikeExpression|import("@babel/types").LVal} topmostMember
* @property {import('./inspectPrimordialAssignments').NonComputedMemberLikeExpression[]} memberExpressions
* @property {import('./inspectPrimordialAssignments').MemberLikeExpression} parentOfMembershipChain
* @property {import('./inspectPrimordialAssignments').MemberLikeExpression
* | import('@babel/types').LVal} topmostMember
*/
/**
* @param {import("@babel/types").Node} identifierNode
* @param {import("@babel/types").Node[]} parents
* @param {import('@babel/types').Node} identifierNode
* @param {import('@babel/types').Node[]} parents
* @returns

@@ -36,3 +37,3 @@ */

const memberExpressions = getTailmostMatchingChain(
/** @type {import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression[]} */ (
/** @type {import('./inspectPrimordialAssignments').NonComputedMemberLikeExpression[]} */ (
parentsOnly

@@ -57,4 +58,3 @@ ),

/**
*
* @param {import("./inspectPrimordialAssignments").MemberLikeExpression[]} memberExpressions
* @param {import('./inspectPrimordialAssignments').MemberLikeExpression[]} memberExpressions
* @returns {string[]}

@@ -70,4 +70,3 @@ */

/**
*
* @param {import("@babel/types").Node} node
* @param {import('@babel/types').Node} node
* @returns {string}

@@ -90,4 +89,3 @@ */

/**
*
* @param {import("@babel/types").Node} node
* @param {import('@babel/types').Node} node
* @returns {node is import("./inspectPrimordialAssignments").MemberLikeExpression}

@@ -102,4 +100,3 @@ */

/**
*
* @param {import("./inspectPrimordialAssignments").MemberLikeExpression} node
* @param {import('./inspectPrimordialAssignments').MemberLikeExpression} node
* @returns {node is import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression}

@@ -112,5 +109,4 @@ */

/**
*
* @param {import("@babel/types").LVal} identifierNode
* @param {import("@babel/types").Node[]} parents
* @param {import('@babel/types').LVal} identifierNode
* @param {import('@babel/types').Node[]} parents
* @returns {boolean}

@@ -120,3 +116,3 @@ */

const parentExpression =
/** @type {import("@babel/types").UnaryExpression} */ (
/** @type {import('@babel/types').UnaryExpression} */ (
parents[parents.length - 2]

@@ -145,3 +141,4 @@ )

/**
* if array contains 'x' and 'x.y' just keep 'x'
* If array contains 'x' and 'x.y' just keep 'x'
*
* @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} globalsConfig

@@ -175,3 +172,4 @@ * @returns

/**
* if array contains 'x' and 'x.y' just keep 'x'
* If array contains 'x' and 'x.y' just keep 'x'
*
* @param {string[]} keyPathStrings

@@ -207,3 +205,4 @@ * @returns {string[]}

/**
* add variable to results, if not already set
* Add variable to results, if not already set
*
* @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} globalsConfig

@@ -222,2 +221,3 @@ * @param {string} identifierPath

* Merge two global policy configs (as `Map`s) together
*
* @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} configA

@@ -248,3 +248,3 @@ * @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} configB

* @param {Map<PropertyKey, V>} map
* @returns {{[k: string]: V}}if array contains 'x' and 'x.y' just keep 'x'
* @returns {{ [k: string]: V }} If array contains 'x' and 'x.y' just keep 'x'
*/

@@ -256,8 +256,9 @@ function mapToObj(map) {

/**
* Returns an array of a `NodePath`'s parent nodes (to the root)
*
* @param {import('@babel/traverse').NodePath<any>|null} nodePath
* @returns {import("@babel/types").Node[]}
* @param {import('@babel/traverse').NodePath<any> | null} nodePath
* @returns {import('@babel/types').Node[]}
*/
function getParents(nodePath) {
/** @type {import("@babel/types").Node[]} */
/** @type {import('@babel/types').Node[]} */
const parents = []

@@ -276,12 +277,18 @@ let target = nodePath

/**
* Determines if this `Node` is a descendant of a `FunctionDeclaration` or
* `FunctionExpression`.
*
* @param {import('@babel/traverse').NodePath<any>} path
* @param {import('@babel/traverse').NodePath<any>} nodePath
* @returns {boolean}
*/
function isInFunctionDeclaration(path) {
return getParents(path.parentPath).some(
(parent) =>
parent.type === 'FunctionDeclaration' ||
parent.type === 'FunctionExpression'
)
function isInFunctionDeclaration(nodePath) {
let target = nodePath.parentPath
while (target) {
// if function declaration found, short-circuit instead of continuing
if (target.isFunctionDeclaration() || target.isFunctionExpression()) {
return true
}
target = target.parentPath
}
return false
}
const test = require('ava')
const deepEqual = require('deep-equal')
const { parse, inspectEsmImports } = require('../src/index')

@@ -11,5 +10,3 @@

`,
{
esmImports: ['fs'],
}
['fs']
)

@@ -33,54 +30,36 @@

var promise = import("package11");
export * as name3 from "package12";
export { name4 } from "package13";
export { default as name5 } from "package14";
export const foo = "bar";
`,
{
esmImports: [
'package01',
'package02',
'package03.export1',
'package04.export2',
'package05.export3',
'package05.export4',
'package06/path/to/specific/un-exported/file.export5',
'package06/path/to/specific/un-exported/file.export6',
'package07.export7',
'package07.export8',
'package08',
'package09',
'package09',
],
}
[
'package01',
'package02',
'package03',
'package04',
'package05',
'package06/path/to/specific/un-exported/file',
'package07',
'package08',
'package09',
'package10',
'package12',
'package13',
'package14',
]
)
function testInspect(label, opts, fn, expectedResultObj) {
function testInspect(label, opts, fn, expected) {
test(label, (t) => {
const source = fnToCodeBlock(fn)
const ast = parse(source, { sourceType: 'module' })
const result = inspectEsmImports(ast)
const resultSorted = [...Object.entries(result)].sort(sortBy(0))
const expectedSorted = Object.entries(expectedResultObj).sort(sortBy(0))
const actual = inspectEsmImports(ast)
const sortedActual = [...actual].sort()
const sortedExpected = [...expected].sort()
// for debugging
if (!deepEqual(resultSorted, expectedSorted)) {
label, opts, ast, source
console.log(resultSorted)
console.log(expectedSorted)
// eslint-disable-next-line no-debugger
debugger
}
t.deepEqual(resultSorted, expectedSorted)
t.deepEqual(sortedActual, sortedExpected)
})
}
function sortBy(key) {
return (a, b) => {
const vA = a[key]
const vB = b[key]
if (vA === vB) {
return 0
}
return vA > vB ? 1 : -1
}
}
function fnToCodeBlock(fn) {

@@ -87,0 +66,0 @@ const output = typeof fn === 'function' ? `(${fn})()` : `${fn}`

@@ -136,4 +136,4 @@ const test = require('ava')

label, opts
console.log(resultSorted)
console.log(expectedSorted)
t.log(resultSorted)
t.log(expectedSorted)
// eslint-disable-next-line no-debugger

@@ -140,0 +140,0 @@ debugger

export type IdentifierOrThisExpressionNodePath = import('@babel/traverse').NodePath<import('@babel/types').Identifier | import('@babel/types').ThisExpression>;
/**
* @typedef {import('@babel/traverse').NodePath<import('@babel/types').Identifier|import('@babel/types').ThisExpression>} IdentifierOrThisExpressionNodePath
* @typedef {import('@babel/traverse').NodePath<
* import('@babel/types').Identifier | import('@babel/types').ThisExpression
* >} IdentifierOrThisExpressionNodePath
*/
/**
*
* @param {import('@babel/types').Node} ast

@@ -8,0 +9,0 @@ * @returns {Map<string, IdentifierOrThisExpressionNodePath[]>}

import { inspectGlobals } from "./inspectSource";
import { inspectImports } from "./inspectSource";
import { inspectRequires } from "./inspectSource";
import { inspectEsmImports } from "./inspectSource";

@@ -11,3 +11,3 @@ import { inspectDynamicRequires } from "./inspectSource";

import { codeSampleFromAstNode } from "./codeSampleFromAstNode.js";
export { inspectGlobals, inspectImports, inspectEsmImports, inspectDynamicRequires, utils, parse, traverse, inspectPrimordialAssignments, inspectSesCompat, codeSampleFromAstNode };
export { inspectGlobals, inspectRequires as inspectImports, inspectRequires, inspectEsmImports, inspectDynamicRequires, utils, parse, traverse, inspectPrimordialAssignments, inspectSesCompat, codeSampleFromAstNode };
//# sourceMappingURL=index.d.ts.map

@@ -20,4 +20,3 @@ export type InspectGlobalsOpts = {

/**
*
* @param {import('../../core/src/generatePolicy').AST|string} source
* @param {import('../../core/src/generatePolicy').AST | string} source
* @param {InspectGlobalsOpts} options

@@ -28,20 +27,24 @@ * @returns

/**
* This finds all modules `required`ed into the AST, as well as any re-exported
* modules.
*
* @param {import('@babel/types').Node} ast
* @param {string[]} packagesToInspect
* @param {boolean} deep
* @param {string[]} [packagesToInspect]
* @param {boolean} [deep]
* @returns {{ cjsImports: string[] }}
*/
export function inspectImports(ast: import('@babel/types').Node, packagesToInspect: string[], deep?: boolean): {
export function inspectRequires(ast: import('@babel/types').Node, packagesToInspect?: string[] | undefined, deep?: boolean | undefined): {
cjsImports: string[];
};
/**
* This finds all modules `import`ed into the AST, as well as any re-exported
* modules.
*
* @param {import('../../core/src/generatePolicy').AST} ast
* @returns {{esmImports: string[]}}
* @param {import('@babel/types').Node} ast
* @param {string[]} [packagesToInspect] - List of module IDs to look for; if
* omitted, will inspect all imports
* @returns {string[]} - List of imported identifiers
*/
export function inspectEsmImports(ast: import('../../core/src/generatePolicy').AST): {
esmImports: string[];
};
export function inspectEsmImports(ast: import('@babel/types').Node, packagesToInspect?: string[] | undefined): string[];
/**
*
* @param {import('@babel/types').Node} ast

@@ -48,0 +51,0 @@ * @returns {RequireCallResult[]}

export type MemberExpressionNesting = {
memberExpressions: import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression[];
parentOfMembershipChain: import("./inspectPrimordialAssignments").MemberLikeExpression;
topmostMember: import("./inspectPrimordialAssignments").MemberLikeExpression | import("@babel/types").LVal;
memberExpressions: import('./inspectPrimordialAssignments').NonComputedMemberLikeExpression[];
parentOfMembershipChain: import('./inspectPrimordialAssignments').MemberLikeExpression;
topmostMember: import('./inspectPrimordialAssignments').MemberLikeExpression | import('@babel/types').LVal;
};
/**
* @typedef MemberExpressionNesting
* @property {import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression[]} memberExpressions
* @property {import("./inspectPrimordialAssignments").MemberLikeExpression} parentOfMembershipChain
* @property {import("./inspectPrimordialAssignments").MemberLikeExpression|import("@babel/types").LVal} topmostMember
* @property {import('./inspectPrimordialAssignments').NonComputedMemberLikeExpression[]} memberExpressions
* @property {import('./inspectPrimordialAssignments').MemberLikeExpression} parentOfMembershipChain
* @property {import('./inspectPrimordialAssignments').MemberLikeExpression
* | import('@babel/types').LVal} topmostMember
*/
/**
* @param {import("@babel/types").Node} identifierNode
* @param {import("@babel/types").Node[]} parents
* @param {import('@babel/types').Node} identifierNode
* @param {import('@babel/types').Node[]} parents
* @returns
*/
export function getMemberExpressionNesting(identifierNode: import("@babel/types").Node, parents: import("@babel/types").Node[]): {
export function getMemberExpressionNesting(identifierNode: import('@babel/types').Node, parents: import('@babel/types').Node[]): {
memberExpressions: import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression[];

@@ -23,20 +24,17 @@ parentOfMembershipChain: import("@babel/types").Node;

/**
*
* @param {import("./inspectPrimordialAssignments").MemberLikeExpression[]} memberExpressions
* @param {import('./inspectPrimordialAssignments').MemberLikeExpression[]} memberExpressions
* @returns {string[]}
*/
export function getPathFromMemberExpressionChain(memberExpressions: import("./inspectPrimordialAssignments").MemberLikeExpression[]): string[];
export function getPathFromMemberExpressionChain(memberExpressions: import('./inspectPrimordialAssignments').MemberLikeExpression[]): string[];
/**
*
* @param {import("./inspectPrimordialAssignments").MemberLikeExpression} node
* @param {import('./inspectPrimordialAssignments').MemberLikeExpression} node
* @returns {node is import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression}
*/
export function isNonComputedMemberLikeExpression(node: import("./inspectPrimordialAssignments").MemberLikeExpression): node is import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression;
export function isNonComputedMemberLikeExpression(node: import('./inspectPrimordialAssignments').MemberLikeExpression): node is import("./inspectPrimordialAssignments").NonComputedMemberLikeExpression;
/**
*
* @param {import("@babel/types").LVal} identifierNode
* @param {import("@babel/types").Node[]} parents
* @param {import('@babel/types').LVal} identifierNode
* @param {import('@babel/types').Node[]} parents
* @returns {boolean}
*/
export function isUndefinedCheck(identifierNode: import("@babel/types").LVal, parents: import("@babel/types").Node[]): boolean;
export function isUndefinedCheck(identifierNode: import('@babel/types').LVal, parents: import('@babel/types').Node[]): boolean;
/**

@@ -50,3 +48,4 @@ * @template {any} T

/**
* if array contains 'x' and 'x.y' just keep 'x'
* If array contains 'x' and 'x.y' just keep 'x'
*
* @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} globalsConfig

@@ -57,3 +56,4 @@ * @returns

/**
* if array contains 'x' and 'x.y' just keep 'x'
* If array contains 'x' and 'x.y' just keep 'x'
*
* @param {string[]} keyPathStrings

@@ -64,3 +64,4 @@ * @returns {string[]}

/**
* add variable to results, if not already set
* Add variable to results, if not already set
*
* @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} globalsConfig

@@ -73,2 +74,3 @@ * @param {string} identifierPath

* Merge two global policy configs (as `Map`s) together
*
* @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} configA

@@ -88,3 +90,3 @@ * @param {Map<string, import('lavamoat-core').GlobalPolicyValue>} configB

* @param {Map<PropertyKey, V>} map
* @returns {{[k: string]: V}}if array contains 'x' and 'x.y' just keep 'x'
* @returns {{ [k: string]: V }} If array contains 'x' and 'x.y' just keep 'x'
*/

@@ -95,19 +97,21 @@ export function mapToObj<V>(map: Map<PropertyKey, V>): {

/**
* Returns an array of a `NodePath`'s parent nodes (to the root)
*
* @param {import('@babel/traverse').NodePath<any>|null} nodePath
* @returns {import("@babel/types").Node[]}
* @param {import('@babel/traverse').NodePath<any> | null} nodePath
* @returns {import('@babel/types').Node[]}
*/
export function getParents(nodePath: import('@babel/traverse').NodePath<any> | null): import("@babel/types").Node[];
export function getParents(nodePath: import('@babel/traverse').NodePath<any> | null): import('@babel/types').Node[];
/**
* Determines if this `Node` is a descendant of a `FunctionDeclaration` or
* `FunctionExpression`.
*
* @param {import('@babel/traverse').NodePath<any>} path
* @param {import('@babel/traverse').NodePath<any>} nodePath
* @returns {boolean}
*/
export function isInFunctionDeclaration(path: import('@babel/traverse').NodePath<any>): boolean;
export function isInFunctionDeclaration(nodePath: import('@babel/traverse').NodePath<any>): boolean;
/**
*
* @param {import("@babel/types").Node} node
* @param {import('@babel/types').Node} node
* @returns {node is import("./inspectPrimordialAssignments").MemberLikeExpression}
*/
export function isMemberLikeExpression(node: import("@babel/types").Node): node is import("./inspectPrimordialAssignments").MemberLikeExpression;
export function isMemberLikeExpression(node: import('@babel/types').Node): node is import("./inspectPrimordialAssignments").MemberLikeExpression;
//# sourceMappingURL=util.d.ts.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc