René's URL Explorer Experiment


Title: A more intuitive fs.mkdtemp() · Issue #6142 · nodejs/node · GitHub

Open Graph Title: A more intuitive fs.mkdtemp() · Issue #6142 · nodejs/node

X Title: A more intuitive fs.mkdtemp() · Issue #6142 · nodejs/node

Description: Version: 5.10.1 Platform: Darwin 15.3.0 Subsystem: fs I am happy that the Node team decided to implement fs.mkdtemp() - the security concerns around this behavior make me glad to see it in core. However, the API feels awkward to me becau...

Open Graph Description: Version: 5.10.1 Platform: Darwin 15.3.0 Subsystem: fs I am happy that the Node team decided to implement fs.mkdtemp() - the security concerns around this behavior make me glad to see it in core. Ho...

X Description: Version: 5.10.1 Platform: Darwin 15.3.0 Subsystem: fs I am happy that the Node team decided to implement fs.mkdtemp() - the security concerns around this behavior make me glad to see it in core. Ho...

Opengraph URL: https://github.com/nodejs/node/issues/6142

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"A more intuitive fs.mkdtemp()","articleBody":"\u003c!--\r\nThanks for wanting to report an issue you've found in Node.js. Please fill in\r\nthe template below by replacing the html comments with an appropriate answer.\r\nIf unsure about something, just do as best as you're able.\r\n\r\nversion: `5.10.1`\r\nplatform:  `Darwin 15.3.0`\r\nsubsystem:  `fs`\r\n\r\nIt will be much easier for us to fix the issue if a test case that reproduces\r\nthe problem is provided. Ideally this test case should not have any external\r\ndependencies. We understand that it is not always possible to reduce your code\r\nto a small test case, but we would appreciate to have as\r\nmuch data as possible.\r\n\r\nThank you!\r\n--\u003e\r\n- **Version**: `5.10.1`\r\n- **Platform**: `Darwin 15.3.0`\r\n- **Subsystem**:  `fs`\r\n\r\n\u003c!-- Enter your issue details below this comment. --\u003e\r\n\r\nI am happy that the Node team decided to implement `fs.mkdtemp()` - the security concerns around this behavior make me glad to see it in core.\r\n\r\nHowever, the API feels awkward to me because:\r\n- The randomness it provides is hard coded to 6 characters, which is just enough that it's _probably fine_, but not enough that I don't want to add more.\r\n- Using the `prefix` argument sounds like a good way to add random characters, but doing half the work is strange if you read code that actually does this. Additionally, _if_ I'm going to implement my own name pattern, I don't really want to _also_ have to keep in mind the one Node is using. For example, should I have to re-implement the entire `mkdtemp` just to get valid [UUIDv4](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29) directory names? That is genuinely useful for unit tests and also for being able to easily `mv` the temporary directory to a cache-proof URL on my server without \"renaming\" it ... lest I have to undo the suffix every time or teach my client code about it.\r\n- Using `prefix` as a directory path is messy, What would you expect this code to do?\r\n  \r\n  ``` javascript\r\n  'use strict';\r\n  \r\n  const os = require('os');\r\n  const fs = require('fs');\r\n  \r\n  fs.mkdtemp(os.tmpdir(), (err, dir) =\u003e {\r\n      if (err) {\r\n          throw err;\r\n      }\r\n      console.log('Created directory:', dir);\r\n  });\r\n  ```\r\n  \r\n  If `os.tmpdir()` returns `/tmp` for you, that will actually create a directory at the very root of your filesystem, rather than inside of `/tmp`. And it will end up being named something like `tmp-e0ew3m`. To \"fix\" this you have to use `path.join(os.tmpdir(), '/')`.\r\n\r\nI would like to propose making the API more intuitive and useful for its intended purpose: unique, convenient, secure creation of temporary directories.\r\n1. Have an explicit `cwd` argument, which is internally `path.join()`'d with the name. This is so that the name can be computed in isolation. And to prevent accidentally creating directories out in the open, where they won't actually be cleaned up.\r\n2. Replace `prefix` with (or just add) a `name` option, which is used as-is when provided. Possibly increase the default randomness for the case where one is not provided. This makes it easy to opt-out of the pattern that Node happens to use currently, which is not exposed via any kind of constant (and I don't think that would provide much value, anyway).\r\n\r\nI think these changes are best done as a breaking change, mainly to make the API less surprising. But compatibility could probably be maintained by only enabling these semantics on the options object.\r\n","author":{"url":"https://github.com/sholladay","@type":"Person","name":"sholladay"},"datePublished":"2016-04-11T04:45:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/6142/node/issues/6142"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5e3caaed-7b4f-5c01-b3cd-11abcef9ee52
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9D5E:50919:71E9F6A:9FDD2D2:6A4FD4CD
html-safe-noncec5766c89d505cb09a6bfb448393d5052d759ab421a115f970f2426b64441e0f1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDVFOjUwOTE5OjcxRTlGNkE6OUZERDJEMjo2QTRGRDRDRCIsInZpc2l0b3JfaWQiOiI1MDAzODY2OTE4NTk3MTUzOTk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac9f5b427038051bf186ae63a705b31cabffcddb8d47bddfa390ffe18950dc3f22
hovercard-subject-tagissue:147315098
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/6142/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c225af67eb2f465ed0d173cb34aac976d08ae5b77710e1c47adc9dbdd99b3081/nodejs/node/issues/6142
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c225af67eb2f465ed0d173cb34aac976d08ae5b77710e1c47adc9dbdd99b3081/nodejs/node/issues/6142
og:image:altVersion: 5.10.1 Platform: Darwin 15.3.0 Subsystem: fs I am happy that the Node team decided to implement fs.mkdtemp() - the security concerns around this behavior make me glad to see it in core. Ho...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesholladay
hostnamegithub.com
expected-hostnamegithub.com
None19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release142593e66413bbae27fd485859993597d5a3b104
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/6142#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F6142
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F6142
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/6142
Reloadhttps://github.com/nodejs/node/issues/6142
Reloadhttps://github.com/nodejs/node/issues/6142
Please reload this pagehttps://github.com/nodejs/node/issues/6142
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/6142
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.3k https://github.com/nodejs/node/issues
Pull requests 973 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality 0 https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
A more intuitive fs.mkdtemp()https://github.com/nodejs/node/issues/6142#top
docIssues and PRs related to the documentations.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22doc%22
feature requestIssues that request new features to be added to Node.js.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
fsIssues and PRs related to the fs subsystem / file system.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
https://github.com/sholladay
sholladayhttps://github.com/sholladay
on Apr 11, 2016https://github.com/nodejs/node/issues/6142#issue-147315098
UUIDv4https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29
docIssues and PRs related to the documentations.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22doc%22
feature requestIssues that request new features to be added to Node.js.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22feature%20request%22
fsIssues and PRs related to the fs subsystem / file system.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22fs%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.