Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mkdirp@^0.5.1 due to CVE warnings, use native recursive fs.mkdir #768

Closed
wants to merge 3 commits into from

Conversation

ericanderson
Copy link
Contributor

@ericanderson ericanderson commented Feb 1, 2022

Summary

mkdirp was triggering github security warnings. Upgrading version will resolve that.

Details

Github security warnings. The ones where you are the owner of a project and you visit the project's home page and get a giant warning from GitHub telling you there are CVE's in libraries within your repo.

I don't know for sure if metro was or was not vulnerable. I for sure know this wouldn't affect someone's production code. What I do know is that humans build tolerance and blindness to things over time. Having a security warning linger on a repo/project is a long term risk to other, real security vulnerabilities being seen and fixed.

This version bump fixes the issue because it is the recommended version to resolve the CVE.

The code delta is to deal with the vulnerable library having a major semver change and thus the code needed to be adapted.

Test plan

yarn test

@facebook-github-bot
Copy link
Contributor

Hi @ericanderson!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 2, 2022
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 2, 2022
Copy link

@philIip philIip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ericanderson for working on this! in the diff summary, can you give some examples of the security warnings and why this version bump and implementation change fixes them? thanks!

packages/metro-memory-fs/src/index.js Outdated Show resolved Hide resolved
@ericanderson
Copy link
Contributor Author

ericanderson commented Feb 3, 2022

@philIip Github security warnings. The ones where you are the owner of a project and you visit the project's home page and get a giant warning from GitHub telling you there are CVE's in libraries within your repo.

I don't know for sure if metro was or was not vulnerable. I'm sure this wouldn't affect someone's production code. What I do know is that humans build tolerance and blindness to things over time. Having a security warning linger on a repo/project is a long term risk to other, real security vulnerabilities being seen and fixed.

This version bump fixes the issue because it is the recommended version to resolve the CVE.

The code delta is to deal with the vulnerable library having a major semver change and thus the code needed to be adapted.

@facebook-github-bot
Copy link
Contributor

@philIip has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ericanderson
Copy link
Contributor Author

As an aside which shouldn't block this change, it seems like maintaining metro-memory-fs is an unnecessary use of resources. This package is only used for tests (at least within this repo).

The memfs library seems complete and well maintained. It is what webpack switched to after abandoning its own memory-fs (top right corner see deprecation notice).

@facebook-github-bot
Copy link
Contributor

@rh389 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@robhogan
Copy link
Contributor

robhogan commented Feb 9, 2022

Hi @ericanderson - thanks for working on this. Unfortunately, it's proving problematic to merge internally due to the way we manage direct dependencies across the containing workspace (upshot being we'd have to update mkdirp in a lot of other places in order to merge this). Sorry that has an effect on a perfectly good PR.

To be honest, I'm thinking it'd be simpler to eliminate mkdirp from metro entirely - we support node >= 12 so the native recursive option is available to us and should be all we need. If you're interested in pivoting this PR in that direction it'd be very welcome, completely understand if not - apologies again for the wasted time.

@ericanderson
Copy link
Contributor Author

@rh389 fair enough, will pivot as I'd prefer to get these warnings out of my repos.

Copy link
Contributor

@robhogan robhogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could just tidy up the async call with the fs promises API, otherwise perfect (and thanks again)

Edit: Ah, also looks like we'll need to beef up the implementation of recursive in metro-memory-fs a bit

Comment on lines 90 to 91
const mkdirPromised = util.promisify(fs.mkdir);
return mkdirPromised(dirName, {recursive: true}).then(() => undefined);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const mkdirPromised = util.promisify(fs.mkdir);
return mkdirPromised(dirName, {recursive: true}).then(() => undefined);
return fsPromises.mkdir(dirName, {recursive: true});

@@ -86,9 +87,8 @@ function saveAsAssets(
}

function createDir(dirName: string): Promise<empty> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function createDir(dirName: string): Promise<empty> {
function createDir(dirName: string): Promise<void> {

Comment on lines 22 to 23
const fs = require('fs');
const util = require('util');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const fs = require('fs');
const util = require('util');
const fsPromises = require('fs').promises;

@facebook-github-bot
Copy link
Contributor

@rh389 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@robhogan robhogan changed the title Upgrade to mkdirp 1.0.4 for security warnings Remove mkdirp@^0.5.1 (due to CVE warnings) in favour of native recursive fs.mkdir Feb 9, 2022
@facebook-github-bot
Copy link
Contributor

@rh389 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@robhogan robhogan changed the title Remove mkdirp@^0.5.1 (due to CVE warnings) in favour of native recursive fs.mkdir Remove mkdirp@^0.5.1 due to CVE warnings, use native recursive fs.mkdir Feb 9, 2022
@ericanderson
Copy link
Contributor Author

Thanks for the help getting it through @rh389. Sorry about the false start earlier. I was in and out of meetings and pushed before running tests.

@robhogan
Copy link
Contributor

Not at all - I was just keen to get it pulled in before the end of my day yesterday. It's waiting for internal review now but everything's green so I'd expect it to be in the next fortnightly release, this PR will auto-close when it lands. Thanks again for the contribution (and patience!)

nevilm-lt pushed a commit to nevilm-lt/metro that referenced this pull request Mar 14, 2022
…mkdir` (facebook#768)

Summary:
**Summary**

mkdirp was triggering github security warnings.

**Details**

Github security warnings. The ones where you are the owner of a project and you visit the project's home page and get a giant warning from GitHub telling you there are CVE's in libraries within your repo.

I don't know for sure if metro was or was not vunerable. I for sure know this wouldn't affect someone's production code. What I do know is that humans build tolerance and blindness to things over time. Having a security warning linger on a repo/project is a long term risk to other, real security vulnerabilities being seen and fixed.

**Test plan**

`yarn test`

Pull Request resolved: facebook#768

Reviewed By: GijsWeterings

Differential Revision: D33986388

Pulled By: rh389

fbshipit-source-id: c1d3ebc3b4ed0c9bd8d3348cfc052ccd6a5cc4a5
nevilm-lt pushed a commit to nevilm-lt/metro that referenced this pull request Apr 21, 2022
…mkdir` (facebook#768)

Summary:
**Summary**

mkdirp was triggering github security warnings.

**Details**

Github security warnings. The ones where you are the owner of a project and you visit the project's home page and get a giant warning from GitHub telling you there are CVE's in libraries within your repo.

I don't know for sure if metro was or was not vunerable. I for sure know this wouldn't affect someone's production code. What I do know is that humans build tolerance and blindness to things over time. Having a security warning linger on a repo/project is a long term risk to other, real security vulnerabilities being seen and fixed.

**Test plan**

`yarn test`

Pull Request resolved: facebook#768

Reviewed By: GijsWeterings

Differential Revision: D33986388

Pulled By: rh389

fbshipit-source-id: c1d3ebc3b4ed0c9bd8d3348cfc052ccd6a5cc4a5
nevilm-lt pushed a commit to nevilm-lt/metro that referenced this pull request Apr 22, 2022
…mkdir` (facebook#768)

Summary:
**Summary**

mkdirp was triggering github security warnings.

**Details**

Github security warnings. The ones where you are the owner of a project and you visit the project's home page and get a giant warning from GitHub telling you there are CVE's in libraries within your repo.

I don't know for sure if metro was or was not vunerable. I for sure know this wouldn't affect someone's production code. What I do know is that humans build tolerance and blindness to things over time. Having a security warning linger on a repo/project is a long term risk to other, real security vulnerabilities being seen and fixed.

**Test plan**

`yarn test`

Pull Request resolved: facebook#768

Reviewed By: GijsWeterings

Differential Revision: D33986388

Pulled By: rh389

fbshipit-source-id: c1d3ebc3b4ed0c9bd8d3348cfc052ccd6a5cc4a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants