Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mejiaj
Copy link
Contributor

@mejiaj mejiaj commented Apr 26, 2023

This PR:

  • Security fixes via overrides
  • Updates dependencies
  • Adds Snyk monitor via CLI

Closes #48.

Dependency updates

Dependency Old 25da089 [04/27/23] b37aee6 [07/12/23]
@uswds/uswds 3.3.0 3.4.1 3.5.0
uswds 2.13.3 2.14.0 -
autoprefixer 10.4.13 10.4.14 -
del 6.0.0 6.1.1 -
glob-parent [⚠️ via overrides] - 6.0.2 -
gulp-replace 1.1.3 1.1.4 -
postcss 8.4.19 8.4.23 8.4.25
sass-embedded 1.56.1 1.62.0 1.63.6
unset-value [⚠️ via overrides] - 2.0.1 -

Note
There is an additional update for del@7, but that only supports ESM.

How to test

Confirm errors

  1. Checkout git checkout develop branch
  2. Run npm i && npm audit
  3. Confirm error message: 6 high severity vulnerabilities
  4. Run npx snyk test
  5. Confirm error message: found 2 issues, 33 vulnerable paths.
  6. Reset branch with git checkout -- .
Confirm fix

  1. Checkout branch git checkout jm-update-dependencies
  2. Run npm i && npm audit
  3. Confirm 0 vulnerabilities
  4. Run snyk test npx snyk test
  5. Confirm 0 vulnerabilities.

Note
I tried testing this on uswds-sandbox with mixed results. Installing via
npm link will show dependency fixes, but gulp scripts won't run (even if Node versions match). Installing via git branch won't show security fixes, but scripts will run.

Test functionality:

  • All gulp tasks should run without errors. Test branch available in Sandbox branch test-compile-60 or use site.
  • There should be zero vulnerabilities in npm audit.

@mejiaj mejiaj marked this pull request as ready for review April 27, 2023 14:06
Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

When running npx snyk test I'm receiving a third failure on develop that persists on this branch.

image

I'm also receiving an error during buildSass on the following fulp tasks

  • compile
  • compileSass
  • updateUswds // runs compile mentioned above

Error: Cannot find module '../../uswds/package.json'

image

If I update the path to package.json I'm able to resolve it

-  const pkg = require(`../../${uswdsPath}/package.json`).version;
+  const pkg = require(`../${uswdsPath}/package.json`).version; 

Curious why I've received this error if you haven't!

Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

@mejiaj This is looking good, but I had trouble removing the vulnerabilities when I installed this branch on uswds-site (notes below). It looks like you ran into a similar issue as described in your PR description. I am not sure if that is an issue with the install method or with the overrides themselves, just wanted to flag it.

  • Successfully completed all steps to confirm vulnerabilities in develop
  • Successfully completed all steps to confirm 0 vulnerabilities and no snyk errors in this branch
  • Confirmed that all gulp tasks work when installed on a local uswds and uswds-compile project
  • Confirmed dependencies are now on their latest version (with the exception of del)
  • Confirmed dependency table in the PR description matches updated dependencies
  • Confirmed this branch removes unset-value and glob-parent snyk errors in uswds-site
    • When I install the jm-update-dependencies branch in uswds-site, via both npm link and installing the remote branch, it shows 6 high severity vulnerabilities and does not resolve glob-parent or unset-value snyk errors. I confirmed that @uswds/compile had the overrides in its package.json.

@mejiaj
Copy link
Contributor Author

mejiaj commented Apr 28, 2023

@mahoneycm

When running npx snyk test I'm receiving a third failure on develop that persists on this branch.

image

This is after removing node_modules and package-lock.json?

How I tested

uswds-compile on  jm-update-dependencies via  v18.15.0 via 💎 v2.7.2 
➜ rm -rf node_modules package-lock.json             
npm %                                                                                                                                                                     

uswds-compile on  jm-update-dependencies [✘] via  v18.15.0 via 💎 v2.7.2 
➜ npm i                                             
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
npm WARN deprecated [email protected]: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies

added 512 packages, and audited 513 packages in 13s

45 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

uswds-compile on  jm-update-dependencies [!1] via  v18.15.0 via 💎 v2.7.2 took 13s 
➜ npx snyk test                                     

Testing /Users/jmejia-a/web/uswds-compile...

Organization:      uswds
Package manager:   npm
Target file:       package-lock.json
Project name:      @uswds/compile
Open source:       no
Project path:      /Users/jmejia-a/web/uswds-compile
Licenses:          enabled

✔ Tested 415 dependencies for known issues, no vulnerable paths found.

Next steps:
- Run `snyk monitor` to be notified about new related vulnerabilities.
- Run `snyk test` as part of your CI/test.

I'm also receiving an error during buildSass on the following fulp tasks

  • compile
  • compileSass
  • updateUswds // runs compile mentioned above

Error: Cannot find module '../../uswds/package.json'

image

If I update the path to package.json I'm able to resolve it

-  const pkg = require(`../../${uswdsPath}/package.json`).version;
+  const pkg = require(`../${uswdsPath}/package.json`).version; 

Curious why I've received this error if you haven't!

You need a test project to run the Compile tasks. I've updated notes to point to uswds/uswds-sandbox at test-compile-60. Thanks for pointing that out.

Pin del to 6.1.1

Co-authored-by: Amy Leadem <[email protected]>
@mejiaj
Copy link
Contributor Author

mejiaj commented Apr 28, 2023

@mejiaj This is looking good, but I had trouble removing the vulnerabilities when I installed this branch on uswds-site (notes below). It looks like you ran into a similar issue as described in your PR description. I am not sure if that is an issue with the install method or with the overrides themselves, just wanted to flag it.

  • Successfully completed all steps to confirm vulnerabilities in develop

  • Successfully completed all steps to confirm 0 vulnerabilities and no snyk errors in this branch

  • Confirmed that all gulp tasks work when installed on a local uswds and uswds-compile project

  • Confirmed dependencies are now on their latest version (with the exception of del)

  • Confirmed dependency table in the PR description matches updated dependencies

  • Confirmed this branch removes unset-value and glob-parent snyk errors in uswds-site

    • When I install the jm-update-dependencies branch in uswds-site, via both npm link and installing the remote branch, it shows 6 high severity vulnerabilities and does not resolve glob-parent or unset-value snyk errors. I confirmed that @uswds/compile had the overrides in its package.json.

@amyleadem I was able to reproduce the last note and not sure why that's happening. It might be an issue with npm audit, but the main focus was handling the issues in this repo.

Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@mejiaj mejiaj requested a review from mahoneycm May 22, 2023 18:26
Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

@mejiaj I was able to run the gulp commands on the test repo linked in the description but I still received the npx snyk test failure after removing node_modules and package-lock.json

Terminal results
uswds-compile on  jm-update-dependencies [!] is 📦 v1.0.0 via  v16.19.0 via 💎 v2.6.10 
❯ rm -rf node_modules package-lock.json

uswds-compile on  jm-update-dependencies [✘!] is 📦 v1.0.0 via  v16.19.0 via 💎 v2.6.10 
❯ npm i        
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
npm WARN deprecated [email protected]: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies

added 513 packages, and audited 514 packages in 23s

46 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

uswds-compile on  jm-update-dependencies [!] is 📦 v1.0.0 via  v16.19.0 via 💎 v2.6.10 took 23s 
❯ npx snyk test

Testing /Users/cmahoney/web/uswds-compile...

Tested 420 dependencies for known issues, found 1 issue, 5 vulnerable paths.


Issues with no direct upgrade or patch:
  ✗ Regular Expression Denial of Service (ReDoS) [High Severity][https://security.snyk.io/vuln/SNYK-JS-ANSIREGEX-1583908] in [email protected]
    introduced by [email protected] > [email protected] > [email protected] > [email protected] > [email protected] > [email protected] and 4 other path(s)
  This issue was fixed in versions: 3.0.1, 4.1.1, 5.0.1, 6.0.1



Organization:      mahoneycm-gsa
Package manager:   npm
Target file:       package-lock.json
Project name:      @uswds/compile
Open source:       no
Project path:      /Users/cmahoney/web/uswds-compile
Licenses:          enabled

@mejiaj mejiaj requested a review from mahoneycm June 14, 2023 14:22
@mejiaj
Copy link
Contributor Author

mejiaj commented Jun 14, 2023

@mahoneycm can you do a clean install and test again?

@mahoneycm
Copy link
Contributor

@mejiaj same issue as before:

image

@mejiaj
Copy link
Contributor Author

mejiaj commented Jun 14, 2023

@mahoneycm thanks for that info! npm ci has a dependency on existing package-lock that it's showing older vulnerabilities.

This command is similar to npm install, except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies.

Source: NPMJS on npm ci.


I wasn't able to reproduce this issue via npm install in both node v16 and v18.

@mejiaj
Copy link
Contributor Author

mejiaj commented Jul 12, 2023

I've updated dependencies and run npm audit fix in b37aee6.

And now we're back to zero vulnerabilities.

# 07/12/23 - After `npm audit fix`.
uswds-compile on jm-update-dependencies [+] via NPM v18.15.0 
→ npm audit fix

changed 2 packages, and audited 513 packages in 478ms

39 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

@mejiaj
Copy link
Contributor Author

mejiaj commented Sep 7, 2023

As of 09/07/23 there are still 0 vulnerabilities. This is ready for review & merge @thisisdano.


Moving additional dep updates to a new issue #71.

@jeremyzilar
Copy link

On a fresh install where @uswds/compile is the only dependency, I am finding that it hangs on caniuse-lite. Then after about 15mins, my computer runs out of memory and crashes. I am on node 16.19.1.
image

@jeremyzilar
Copy link

FWIW -- I downgraded to node 14.21.3 and got it working, I think 😊

@mejiaj
Copy link
Contributor Author

mejiaj commented Nov 8, 2023

@jeremyzilar could you try node 20? That's the latest LTS version.

@mejiaj mejiaj merged commit ea8d76f into develop Nov 9, 2023
@mejiaj mejiaj deleted the jm-update-dependencies branch November 9, 2023 17:17
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.

USWDS-Compile - Bug: gulp vulnerability

4 participants