chore(deps): drop lodash runtime dependency#95
Merged
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes
lodashfrom the runtime dependency tree, replacing everysrc/call site with native JavaScript.lodashmoves todevDependencies(the test suite still uses it). Runtime dependencies are now@aws-sdk/credential-providers,aws4, andlong-timeout.This addresses the npm/Socket "module-replacements" advisory flagging
lodashas replaceable with native APIs, and continues the dependency-reduction direction of v2.0.1.Replacements
_.cloneDeep(×3)structuredClone(global, Node ≥ 18)_.noop(×6)const noop = () => {}_.intersection(_.functionsIn(logger), [...]).length >= 5[...].every(m => typeof logger?.[m] === 'function')_.omit+_.cloneDeep+_.defaultsDeep(VaultApiClient ctor)delete requestOptions+structuredClone+ explicitapiVersiondefault_.mapValues(×2)Object.fromEntries(Object.entries(...).map(...))_.zipObject+_.mapValues(VaultNodeConfig)Object.fromEntries(vaultPaths.map(...))_.isPlainObject_.mergedeepMergehelperCompatibility
Public interfaces and runtime behavior are unchanged. The only internal nuance: a disabled logger (
logger: false) now returns the client's ownnoopinstead oflodash's_.noop; the no-op contract is identical. One unit test that asserted identity against_.noopwas updated to assert the behavioral contract.structuredCloneis safe at every clone site: therequestOptionsobject (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/— cleannpm run test:unit— 138 passing, including the nesteddeepMergepath and the updated__setupLoggertestsVersion/CHANGELOG intentionally untouched — to be handled in the release PR.