Skip to content

refactor(deps): replace mkdirp, uuid, tmp with node builtins#779

Merged
parker-snyk merged 5 commits intomainfrom
CN-1003-replace-deps-with-node-builtins
Apr 10, 2026
Merged

refactor(deps): replace mkdirp, uuid, tmp with node builtins#779
parker-snyk merged 5 commits intomainfrom
CN-1003-replace-deps-with-node-builtins

Conversation

@parker-snyk
Copy link
Copy Markdown
Contributor

@parker-snyk parker-snyk commented Apr 6, 2026

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

What does this PR do?

Removes mkdirp, uuid, and tmp from dependencies and uses native Node built-ins (fs, crypto, os) instead. Since the minimum supported Node version is 20.19, we can safely use features like fs.mkdirSync(..., { recursive: true }) and crypto.randomUUID().

Where should the reviewer start?

lib/analyzer/image-inspector.ts and lib/image-save-path.ts have the main functional changes. test/system/docker.spec.ts has a minor test fix to clean up temporary mock tarballs properly.

How should this be manually tested?

npm run test:system and npm run test:unit.

Any background context you want to provide?

This was prompted by a desire to trim down the dependency tree. Moving off of tmp also forced us to be explicit about test cleanup, avoiding silent file leaks in /tmp during the test suite.

What are the relevant tickets?

CN-1003

Screenshots

N/A

Additional questions

None

@parker-snyk parker-snyk marked this pull request as ready for review April 6, 2026 18:39
@parker-snyk parker-snyk requested a review from a team as a code owner April 6, 2026 18:39
@parker-snyk parker-snyk requested a review from jcambier April 6, 2026 18:39
- Replace fs.rmdirSync with fs.rmSync({ recursive, force }) in system
  tests to handle non-empty temp dirs left by getImageArchive creating
  subdirs before a failed pull
- Extend .snyk ignore expiry for SNYK-JS-TAR-15307072/15416075/15456201
  (transitive via snyk-nodejs-lockfile-parser > @yarnpkg/core > tar)
  from 2026-04-03 to 2026-07-06
@parker-snyk parker-snyk force-pushed the CN-1003-replace-deps-with-node-builtins branch from 596995d to 69c1073 Compare April 6, 2026 19:36
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot

This comment has been minimized.

@parker-snyk parker-snyk requested a review from jcambier April 10, 2026 12:49
@parker-snyk parker-snyk merged commit bdeddc7 into main Apr 10, 2026
16 checks passed
@parker-snyk parker-snyk deleted the CN-1003-replace-deps-with-node-builtins branch April 10, 2026 13:18
@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

ReferenceError in tests 🟠 [major]

The variable crypto is used at line 175 to generate a random UUID, but it has not been imported into the file. Unlike process, the crypto module is not a global in Node.js and requires an explicit import * as crypto from 'crypto' or import { randomUUID } from 'crypto'. This will cause the test suite to crash with a ReferenceError: crypto is not defined.

`snyk-docker-plugin-test-${crypto.randomUUID()}.tar`,
Resource Leak in Tests 🟠 [major]

In the tests starting at line 154 and 186, customPath is created as a temporary directory using fs.mkdtempSync, but the cleanup via fs.rmSync is placed at the end of the it block. If any expect() assertion fails earlier in the test, the cleanup line will be skipped, leading to persistent temporary directories left on the host system. This contradicts the PR goal of avoiding silent file leaks. These paths should be cleaned up in a try...finally block or handled via the afterEach hook.

fs.rmSync(customPath, { recursive: true, force: true });
📚 Repository Context Analyzed

This review considered 15 relevant code sections from 8 files (average relevance: 0.69)

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