Skip to content

chore(deps): drop lodash runtime dependency#95

Merged
kurok merged 3 commits into
masterfrom
chore/drop-lodash
Jun 17, 2026
Merged

chore(deps): drop lodash runtime dependency#95
kurok merged 3 commits into
masterfrom
chore/drop-lodash

Conversation

@kurok

@kurok kurok commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

Removes lodash from the runtime dependency tree, replacing every src/ call site with native JavaScript. lodash moves to devDependencies (the test suite still uses it). Runtime dependencies are now @aws-sdk/credential-providers, aws4, and long-timeout.

This addresses the npm/Socket "module-replacements" advisory flagging lodash as replaceable with native APIs, and continues the dependency-reduction direction of v2.0.1.

Replacements

Was Now
_.cloneDeep (×3) structuredClone (global, Node ≥ 18)
_.noop (×6) a single module-level const noop = () => {}
_.intersection(_.functionsIn(logger), [...]).length >= 5 [...].every(m => typeof logger?.[m] === 'function')
_.omit + _.cloneDeep + _.defaultsDeep (VaultApiClient ctor) shallow copy + delete requestOptions + structuredClone + explicit apiVersion default
_.mapValues (×2) Object.fromEntries(Object.entries(...).map(...))
_.zipObject + _.mapValues (VaultNodeConfig) one Object.fromEntries(vaultPaths.map(...))
_.isPlainObject 5-line prototype check
_.merge small recursive deepMerge helper

Compatibility

Public interfaces and runtime behavior are unchanged. The only internal nuance: a disabled logger (logger: false) now returns the client's own noop instead of lodash's _.noop; the no-op contract is identical. One unit test that asserted identity against _.noop was updated to assert the behavioral contract.

structuredClone is safe at every clone site: the requestOptions object (which may hold a live undici dispatcher) is excluded before the clone and re-attached by reference, exactly as before; all other cloned data is plain config / secret JSON.

Tests

  • eslint src/ — clean
  • npm run test:unit — 138 passing, including the nested deepMerge path and the updated __setupLogger tests

Version/CHANGELOG intentionally untouched — to be handled in the release PR.

Replace every lodash call site in src/ with native JavaScript:

- _.cloneDeep              -> structuredClone
- _.noop                   -> a shared module-level noop
- _.intersection/functionsIn logger check -> Array#every + typeof
- _.omit/cloneDeep/defaultsDeep (VaultApiClient) -> shallow copy +
  delete + structuredClone + explicit apiVersion default
- _.mapValues / _.zipObject -> Object.fromEntries
- _.isPlainObject          -> prototype check
- _.merge                  -> a small recursive deepMerge helper

lodash moves to devDependencies (still used by the test suite). Public
interfaces and runtime behavior are unchanged; runtime dependencies are
now @aws-sdk/credential-providers, aws4, and long-timeout.

Signed-off-by: Yuriy R <22548029+kurok@users.noreply.github.com>
@kurok kurok requested a review from wRLSS as a code owner June 17, 2026 09:06
Comment thread src/VaultNodeConfig.js Fixed
kurok added 2 commits June 17, 2026 10:10
Skip `__proto__`, `constructor`, and `prototype` keys when merging, so a
crafted source object can't pollute Object.prototype. Matches the
protection lodash.merge already provided. Addresses the CodeQL
"prototype-polluting function" finding on PR #95.

Signed-off-by: Yuriy R <22548029+kurok@users.noreply.github.com>
Replace the Set-based prototype-pollution guard with explicit
`key === '__proto__' || key === 'constructor' || key === 'prototype'`
comparisons. The Set.has() guard was not recognized as a sanitizer by
CodeQL's js/prototype-pollution-utility query, so alert #1 stayed open;
the explicit comparison is the pattern CodeQL recognizes. Behavior is
identical.

Signed-off-by: Yuriy R <22548029+kurok@users.noreply.github.com>
@kurok kurok merged commit 1fbec78 into master Jun 17, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants