Giter Site home page Giter Site logo

yarn-audit-fix's Introduction

Yarn audit fix

yarn-audit-fix

CI Maintainability Test Coverage Sonar Known Vulnerabilities Downloads npm (tag)

The missing yarn audit fix

Digest

Problem

  1. yarn audit detects vulnerabilities, but cannot fix them. Authors suggest using Dependabot or Snyk for security patches. Well, it is very inconvenient in some situations, to say the least of it. The discussion: yarn/issues/7075.
  2. yarn audit does not support custom (in-house, internal) registries. Here are the issue & PR which have not yet received the green light.

Solution

Fortunately, there are several workarounds:

  1. Compose npm audit fix with lockfile converter (thanks to Gianfranco P., stackoverflow/60878037). yarn-audit-fix --flow=convert just reproduces these steps with minimal changes. More details: dev.to/yarn-audit-fix-workaround
  2. Fetch yarn/npm audit --json advisories and patch lockfile inners (kudos to G. Kosev, code reference). yarn-audit-fix --flow=patch. Full description: dev.to/yarn-audit-fix-for-yarn-2-berry

Key features

  • Works with Yarn 1 Classic & Yarn v2+ lockfiles (⚠️ experimental)
  • A couple of strategies to fix security issues
  • macOS / Linux / Windows support
  • CLI / JS API
  • TS and flow typings

Getting started

Requirements

Node.js: >=16.0.0

Install

$ yarn add yarn-audit-fix -D

or even better

npm_config_yes=true npx yarn-audit-fix

CLI

$ yarn-audit-fix [--opts]

Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke npm audit fix --package-lock-only
added 14 packages, removed 195 packages and updated 1245 packages in 4.795s
fixed 3 of 26 vulnerabilities in 1370 scanned packages
  23 vulnerabilities required manual review and could not be updated
Updating yarn.lock from package-lock.json...
invoke yarn import
info found npm package-lock.json, converting to yarn.lock
warning synp > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
warning tslint-config-qiwi > [email protected]: tslint-react is deprecated along with TSLint
warning @qiwi/libdefkit > @types/[email protected]: This is a stub types definition. read-pkg provides its own type definitions, so you do not need this installed.
...
success Saved lockfile.
invoke yarn
[1/4] 🔍  Resolving packages...
success Already up-to-date.
Done
Option Description Default with --flow=convert only
--flow Define how yarn.lock is modified. convert — to compose npm audit fix with two-way lockfile conversion (legacy flow). patch — to directly inject audit json data patch
--audit-level Include a vulnerability with a level as defined or higher. Supported values: low, moderate, high, critical low
--cwd Current working dir process.cwd()
--dry-run Get an idea of what audit fix will do
--force Have audit fix install semver-major updates to toplevel dependencies, not just semver-compatible ones false
--help/-h Print help message
--legacy-peer-deps Accept an incorrect (potentially broken) deps resolution
--loglevel Set custom log level
--npm-path Switch to project's local npm version instead of system default. Or provide a custom path. system / local / <custom path> system
--only Set package update scope: dev/prod
--package-lock-only Run audit fix without modifying node_modules. Highly recommended to enable. true
--registry Custom registry url
--silent Disable log output false
--symlink Symlink type for node_modules ref junction for Windows, dir otherwise
--temp Directory for temporary assets <cwd>/node_modules/.cache/yarn-audit-fix
--verbose Switch log level to verbose/debug false

ENV

All mentioned above CLI options can be replaced with the corresponding env variables with leading YAF prefix. For example:

  • YAF_FORCE equals --force
  • YAF_ONLY=prod--only=prod

JS API

yarn-audit-fix is a naive and optimistic workaround, so it exposes all of its inners to give anybody a chance to tweak up and find a better steps combination. Typedoc: https://antongolub.github.io/yarn-audit-fix/modules/

import { run, runSync } from 'yarn-audit-fix'

// NOTE actually it's promisified `run.sync`
await run({
   flow: 'patch',
   verbose: true
})

// `runSync` is an alias for `run.sync`
await runSync({
  flow: 'patch',
  verbose: true
})

Build and run custom flows.

import {
   clear,
   exit,
   patchLockfile,
   yarnInstall
} from 'yarn-audit-fix'

export const flow: TFlow = {
  main: [
    [
      'Patching yarn.lock with audit data...',
      patchLockfile,
      (...args) => {console.log('Smth interesting:', ...args)},
      yarnInstall,
    ],
    ['Done'],
  ],
  fallback: [['Failure!', exit]],
}

await run({}, flow)

Migration notes

^10.0.0

v10 bumps the pkg deps and requires NodeJS v14.

^9.0.0

v9 brings experimental Yarn 2+ lockfiles support, so the previous behaviour (when yaf parsing failure may be used to detect them) has been changed.

^8.0.0

From v8 the library does not contain npm dependency, so the system default is used instead. If necessary you can:

  • Install the required npm version and provide a custom path via CLI / ENV / JS API
  • Use a pinch of npx magic: npm_config_yes=true YAF_NPM_PATH=local npx -p yarn-audit-fix -p npm@8 -c yarn-audit-fix

^7.0.0

Following the deps, converted to ESM. So legacy require API has been dropped since v7.0.0. Use the shiny new import instead or try your luck with esm-hook. CLI works as before.

// const {run} = require('yarn-audit-fix') turns into
import {run} from 'yarn-audit-fix'

^6.0.0

Default fix strategy has been changed to direct lockfile patching with yarn audit --json data. To use the previous legacy flow, pass --flow=convert option to CLI.

^4.0.0

--npm-v7 flag is redundant. From v4.0.0 package's own version of npm is used by default. But you're still able to invoke system default with --npm-path=system or define any custom --npm-path=/another/npm/bin.

Troubleshooting

DoS vulnerability for colors 1.4.x

If you have installed yaf between 7...11 of Jan 2022 and ran it with --flow=convert option, you might see an endless garbage loop in stdout. The problem was caused by the transitive dep: yarn-audit-fix → synp → colors@^1.4.0. Reasons and details: issues/218, snykvuln/2331906.
How to fix? There are 3 ways:

  • Update yarn-audit-fix to >=9.0.5
  • Pin colors version in your lockfile to 1.4.0
  • Reinstall yarn-audit-fix. It looks like npm has already removed the vulnerable versions of colors from the registry, 2022-01-11.

yarn-audit-fix version x.x.x is out of date

npm_config_yes=true npx yarn-audit-fix --audit-level=moderate
Runtime digest
yarn-audit-fix version 4.3.6 is out of date. Install the latest 6.0.0 for better results

npx caches previously loaded packages, so you need one of:

  1. Define version to load: npm [email protected]
  2. Reset npx cache. For Mac/Linux: rm -rf ~/.npm/_npx

yarn-audit-fix command not found

After installation, the package may not be found. This is probably an issue with $PATH finding node_modules/.bin contents or smth like that (npm/issues/957). A bit annoying, but it's easy to handle in several ways.

  • You're able to run the cmd through yarn: yarn yarn-audit-fix.
  • Simply invoke node_modules/.bin/yarn-audit-fix script.

enoent: no such file or directory

In some cases npm audit fix makes node_modules to become inconsistent. This is expected. yarn and npm organize the directory space slightly differently.

npm WARN rm not removing /Users/antongolub/projects/queuefy/node_modules/.cache/yarn-audit-fix/node_modules/npm/node_modules/.bin/node-gyp as it wasn't installed by /Users/antongolub/projects/queuefy/node_modules/.cache/yarn-audit-fix/node_modules/npm/node_modules/node-gyp
npm WARN rm not removing /Users/antongolub/projects/queuefy/node_modules/.cache/yarn-audit-fix/node_modules/npm/node_modules/.bin/uuid as it wasn't installed by /Users/antongolub/projects/queuefy/node_modules/.cache/yarn-audit-fix/node_modules/npm/node_modules/uuid
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /Users/antongolub/projects/queuefy/node_modules/.cache/yarn-audit-fix/node_modules/@qiwi/libdefkit/node_modules/flowgen/lib/cli/index.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/antongolub/projects/queuefy/node_modules/.cache/yarn-audit-fix/node_modules/@qiwi/libdefkit/node_modules/flowgen/lib/cli/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
npm ERR!     /Users/antongolub/.npm/_logs/2020-08-23T07_09_26_924Z-debug.log
{
  status: 254,
  signal: null,
  output: [ null, null, null ]

Let's try this workaround:

  1. Restore the original node_modules state. yarn --force or rm-rf node_modules && yarn.
  2. Apply npx yarn-audit-fix --package-lock-only. The last param should instruct npm not to modify node_modules contents.

--force did not force the update

The problem only concerns repositories with workspaces (monorepos). npm audit fix --force throws 1 status code and suggests running npm audit fix --force. This quite ironic behaviour is exactly what npm (arborist) does now.

$$ yarn-audit-fix --force          
 Preparing temp assets...
 Generating package-lock.json from yarn.lock...
 Applying npm audit fix...
 invoke /home/qwelias/.nvm/versions/node/v12.18.1/lib/node_modules/yarn-audit-fix/node_modules/.bin/npm audit fix --package-lock-only --force --prefix=/home/qwelias/prj/stuff/test-yarn-audit-fix/node_modules/.cache/yarn-audit-fix
 npm WARN using --force Recommended protections disabled.
 npm WARN audit Updating lodash to 4.17.20,which is outside your stated dependency range.
 npm WARN audit Manual fix required in linked project at ./packages/bar for lodash@<=4.17.18.
 npm WARN audit 'cd ./packages/bar' and run 'npm audit' for details.
 npm WARN audit Manual fix required in linked project at ./packages/foo for lodash@<=4.17.18.
 npm WARN audit 'cd ./packages/foo' and run 'npm audit' for details.
 
 up to date, audited 7 packages in 2s
 
 # npm audit report
 
 lodash  <=4.17.18
 Severity: high
 Prototype Pollution - https://npmjs.com/advisories/782
 Prototype Pollution - https://npmjs.com/advisories/1065
 fix available via `npm audit fix --force`
 Will install [email protected], which is outside the stated dependency range
 packages/bar/node_modules/lodash
 packages/foo/node_modules/lodash
 
 1 high severity vulnerability
 
 To address all issues, run:
   npm audit fix --force
 {
   status: 1,
   signal: null,
   output: [ null, null, null ],
   pid: 176019,
   stdout: null,
   stderr: null
 }

So you need, as the message says, to manually change the dependency versions. npm@7 is still in beta, perhaps this logic will be changed later. In some cases npm@6 works better, so if you have such a version installed on your system, you may try:

npx yarn-audit-fix --npm-path=system --flow=convert

You may also try to cast the optimistic flags combo

npx yarn-audit-fix --package-lock-only=false --force --legacy-peer-deps --flow=convert

Unfortunately, even this invocation may return something like:

# npm audit report

hosted-git-info  <3.0.8
Severity: moderate
Regular Expression Deinal of Service - https://npmjs.com/advisories/1677
No fix available
node_modules/normalize-package-data/node_modules/hosted-git-info
  normalize-package-data  2.0.0 - 2.5.0
  Depends on vulnerable versions of hosted-git-info
  node_modules/normalize-package-data
    meow  3.4.0 - 9.0.0
    Depends on vulnerable versions of normalize-package-data
    Depends on vulnerable versions of read-pkg-up

No fix available just means that no fix available. If you still doubt the correctness of the output, you can check it by hand.

npm i --package-lock-only
npm audit fix --package-lock-only --force

Same response for alternative patching flow:

npm_config_yes=true npx yarn-audit-fix --audit-level=moderate --flow=patch
Patching yarn.lock with audit data...
invoke yarn audit --json --level moderate
Can't find patched version that satisfies postcss@^7.0.0 in >=8.2.10
Can't find patched version that satisfies postcss@^7.0.1 in >=8.2.10
Can't find patched version that satisfies postcss@^7.0.27 in >=8.2.10
Can't find patched version that satisfies ws@^7.2.3 in >=6.2.2 <7.0.0 || >=7.4.6
Upgraded deps: <none>
invoke yarn --update-checksums

Not everything can be repaired, alack.

Cannot install package despite being on correct node version

yarn-audit-fix is compatible with any NodeJS version which supports ESM, but the nested packages can define their own engine requirements.

[email protected]: The engine "node" is incompatible with this module. Expected version ">=14.16". Got "14.15.1"

The recommended way is to update the runtime version. As a temporary workaround, you can simply pass --ignore-engines flag.

yarn add yarn-audit-fix -D --ignore-engines

Response Code: 400 (Bad Request)

invoke yarn npm audit --all --json --recursive
➤ YN0035: Bad Request
➤ YN0035:   Response Code: 400 (Bad Request)
➤ YN0035:   Request Method: POST
➤ YN0035:   Request URL: https://registry.yarnpkg.com/-/npm/v1/security/audits/quick

yarnpkg/berry#4117

Contributing

Feel free to open any issues: bugs, feature requests or other questions. You're always welcome to suggest a PR. Just fork this repo, write some code, add some tests and push your changes. Any feedback is appreciated.

License

MIT

yarn-audit-fix's People

Contributors

antongolub avatar coliff avatar dependabot[bot] avatar lars-debitroom avatar qwelias avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yarn-audit-fix's Issues

SyntaxError: Unknown token: { line: 4, col: 2, type: 'INVALID', value: undefined } 4:2 in lockfile

I've deleted the yarn.lock and tried this using bash and cmd with no success. Does this tool only support specific versions of yarn (and the associated lock file)?

D:\WORK\frontend>yarn-audit-fix
Runtime digest

  isMonorepo false
  npmPath D\\WORK\\frontend\\node_modules\\yarn-audit-fix\\node_modules\\.bin\\npm.cmd
  npmVersion 8.1.2
  nodeVersion v14.18.1
  yafVersion 7.1.5
  temp D\\WORK\\frontend\\node_modules\\.cache\\yarn-audit-fix\\04610f6eea2bfb3e8bb3333ee22ac42b
  cwd D\\WORK\\frontend
  flags
    flow patch
    npm-path local


Preparing temp assets...
Patching yarn.lock with audit data...
Failure!
SyntaxError: Unknown token: { line: 4, col: 2, type: 'INVALID', value: undefined } 4:2 in lockfile
    at Parser.unexpected (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:5064:11)
    at Parser.parse (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:5193:14)
    at parse (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:5262:17)
    at Object.module.exports.exports.default (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:4835:96)
    at Object._read (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/lockfile.js:7:21)
    at Module.read (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/lockfile.js:89:44)
    at patchLockfile (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/stages.js:144:25)
    at exec (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/runner.js:30:13)
    at Function.runSync [as sync] (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/runner.js:41:9)
    at file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/cli.js:33:5
internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

SyntaxError: Unknown token: { line: 4, col: 2, type: 'INVALID', value: undefined } 4:2 in lockfile
    at Parser.unexpected (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:5064:11)
    at Parser.parse (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:5193:14)
    at parse (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:5262:17)
    at Object.module.exports.exports.default (D:\WORK\frontend\node_modules\@yarnpkg\lockfile\index.js:4835:96)
    at Object._read (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/lockfile.js:7:21)
    at Module.read (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/lockfile.js:89:44)
    at patchLockfile (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/stages.js:144:25)
    at exec (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/runner.js:30:13)
    at Function.runSync [as sync] (file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/runner.js:41:9)
    at file:///D:/WORK/frontend/node_modules/yarn-audit-fix/target/es6/cli.js:33:5

D:\WORK\frontend>

find-up appears to be an undeclared runtime dependency

$ yarn run yarn-audit-fix
yarn run v1.22.0
$ /Users/olivierlacan/Development/ps/repo/node_modules/.bin/yarn-audit-fix
file:///Users/olivierlacan/Development/ps/repo/node_modules/yarn-audit-fix/target/es6/util.js:4
import { findUpSync, pathExistsSync } from 'find-up';
         ^^^^^^^^^^
SyntaxError: Named export 'findUpSync' not found. The requested module 'find-up' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'find-up';
const { findUpSync, pathExistsSync } = pkg;

    at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:142:20)
    at async Loader.import (internal/modules/esm/loader.js:182:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Not quite familiar with these errors but shouldn't find-up be a runtime dependency?

import { findUpSync, pathExistsSync } from 'find-up'

It's only listed in devDependencies:

"find-up": "^6.0.0",

feat: add --ignore-engines option

https://github.com/antongolub/yarn-audit-fix/pull/165/checks?check_run_id=3294325391

Preparing temp assets...
Patching yarn.lock with audit data...
invoke yarn audit --json --level moderate
Upgraded deps: [email protected]
Installing deps update...
invoke yarn install --update-checksums
[1/4] Resolving packages...
[2/4] Fetching packages...
error @qiwi/[email protected]: The engine "node" is incompatible with this module. Expected version ">=14.8". Got "12.22.4"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Failure!
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 1663,
  stdout: null,
  stderr: null
}

[Bug] Breaks monorepo lerna run command

When installing yarn-audit-fix package under monorepo any lerna run command that is defined in child packages as well will fail with error below.

For example, child package has script named cbuild within package.json. The root package.json has script named cbuild as well that defined as lerna run cbuild. When run yarn cbuild from monorepo root folder the above command hangs with similar error below.

Expected any script related lerna run command runs on all child packages under monorepo.

internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '.../packages/...'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yaml
  • actions/checkout v4
  • actions/setup-node v4
  • paambaati/codeclimate-action v5.0.0
  • actions/checkout v4
  • actions/setup-node v4
  • actions/setup-node v4
  • actions/setup-node v4
  • ubuntu 22.04
  • ubuntu 22.04
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
npm
package.json
  • @types/fs-extra ^11.0.1
  • @types/lodash-es ^4.17.8
  • @types/semver ^7.5.0
  • @types/yarnpkg__lockfile ^1.1.6
  • @yarnpkg/lockfile ^1.1.0
  • chalk ^5.3.0
  • commander ^11.0.0
  • fast-glob ^3.3.1
  • fs-extra ^11.1.1
  • js-yaml ^4.1.0
  • lodash-es ^4.17.21
  • semver ^7.5.4
  • synp ^1.9.10
  • @jest/globals ^29.6.2
  • @types/jest ^29.5.3
  • @types/js-yaml ^4.0.5
  • @types/node ^20.4.8
  • concurrently ^8.2.0
  • cpy-cli ^5.0.0
  • esbuild ^0.20.0
  • esbuild-node-externals ^1.8.0
  • eslint ^8.46.0
  • eslint-config-prettier ^9.0.0
  • eslint-config-qiwi ^2.1.3
  • jest ^29.6.2
  • minimist ^1.2.8
  • mkdirp ^3.0.1
  • npm ^9.8.1
  • prettier ^3.0.1
  • ts-jest ^29.1.1
  • ts-node ^10.9.1
  • typedoc ^0.25.0
  • typescript 5.4.5
  • node >= 16.0.0
packages/foo/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

bug: npm 7.11.0 looks inaccessible

% npx yarn-audit-fix
Need to install the following packages:
  yarn-audit-fix
Ok to proceed? (y) y
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

image

Feature: Output of Yarn should be visible in real-time

Hello!

Yet another feature request :)

I would like to see in real-time the output of Yarn, since currently for projects, that takes long time to be installed, it looks like the tool failed and waits forever to finish.

Some of the output logs:

invoke yarn
// this log ^ line is printed and then after yarn finishes, all of its output is printed as whole

[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.

Done
✨  Done in 112.14s.

As you can see, invoke yarn took 112.14s. which means, for 112 seconds only "invoke yarn" was visible in output and user didn't know anything about further progress

Bug: workspaces configuration is being removed if INT signal was sent in the middle

Hello!

After running yarn-audit-fix, my configuration of Yarn Workspaces from package.json file is removed, if I send INT signal, when yarn-audit-fix is still working.

I believe it's due to creating a copy of package.json (origin.package.json) which overwrites package.json file and removes workspaces configuration.
I believe it would be safer to never overwrite package.json file, since process of fixing audit takes some time and it's very common to interrupt it in the middle of it.

I'm using 1.3.0 version.

Pass additional npm flags

npx yarn-audit-fix --npm.legacy-peer-deps --npm.force
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke /Users/foobar/.npm/_npx/54991/lib/node_modules/yarn-audit-fix/node_modules/.bin/npm audit fix --package-lock-only --prefix /Users/antongolub/projects/js-platform/node_modules/.cache/yarn-audit-fix/0fbe724a7952b7542c6533ff6fbe679a
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @qiwi-private/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"^4.1.2" from [email protected]
npm ERR!   packages/infra
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@"3.9.x || 4.0.x" from [email protected]
npm ERR! node_modules/typedoc
npm ERR!   dev typedoc@"^0.19.2" from [email protected]
npm ERR!   packages/infra
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/foobar/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/foobar/.npm/_logs/2021-03-22T19_33_17_085Z-debug.log
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 55002,
  stdout: null,
  stderr: null
}

Yarn may regenerate whole lockfile

When using --only prod yarn install step may still affect dev deps.
One approach is to use --production, but it doesn't have an alternative for dev deps.

So maybe it would make sense to discard --only support and instead rely on --production as it is supported by both yarn install and npm audit fix. Fixing audit only for dev dependencies looks questionable.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Error: `EINVALIDTAGNAME`

I'm getting the following error, both for npx yarn-audit-fix and installing it to my project and running yarn yarn-audit-fix:

npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name ">=^16.0.0": Tags may not have any characters that encodeURIComponent encodes.

When I check the debug logs, I see:

1978 timing idealTree Completed in 14515ms
1979 timing command:audit Completed in 23151ms
1980 verbose stack Error: Invalid tag name ">=^16.0.0": Tags may not have any characters that encodeURIComponent encodes.
1980 verbose stack     at invalidTagName (~/project/node_modules/npm/node_modules/npm-package-arg/npa.js:94:15)
1980 verbose stack     at fromRegistry (~/project/node_modules/npm/node_modules/npm-package-arg/npa.js:300:13)
1980 verbose stack     at Function.resolve (~/project/node_modules/npm/node_modules/npm-package-arg/npa.js:84:12)
1980 verbose stack     at Arborist.[nodeFromEdge] (~/project/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:943:37)
1980 verbose stack     at async Arborist.[loadPeerSet] (~/project/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1164:23)
1980 verbose stack     at async Arborist.[buildDepStep] (~/project/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:880:11)
1980 verbose stack     at async Arborist.buildIdealTree (~/project/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
1980 verbose stack     at async Arborist.reify (~/project/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:136:5)
1980 verbose stack     at async Audit.audit (~/project/node_modules/npm/lib/audit.js:66:5)
1981 verbose cwd ~/project/node_modules/.cache/yarn-audit-fix/77ed225c58f766d8c86e01106481319e
1982 verbose Darwin 19.5.0
1983 verbose argv "~/.nvm/versions/node/v12.4.0/bin/node" "~/project/node_modules/yarn-audit-fix/node_modules/.bin/npm" "audit" "fix" "--package-lock-only" "--prefix" "~/project/node_modules/.cache/yarn-audit-fix/77ed225c58f766d8c86e01106481319e"
1984 verbose node v12.4.0
1985 verbose npm  v7.14.0
1986 error code EINVALIDTAGNAME
1987 error Invalid tag name ">=^16.0.0": Tags may not have any characters that encodeURIComponent encodes.
1988 verbose exit 1

To debug further, I modifed ~/project/node_modules/npm/node_modules/npm-package-arg/npa.js and added this console.log

  } else {
    if (encodeURIComponent(spec) !== spec) {
      console.log('Invalid Tag Name', res)
      throw invalidTagName(spec)
    }
    res.type = 'tag'
  }

which produced this:

Invalid Tag Name Result {
  type: undefined,
  registry: true,
  where: undefined,
  raw: 'react@>=^16.0.0',
  name: 'react',
  escapedName: 'react',
  scope: undefined,
  rawSpec: '>=^16.0.0',
  saveSpec: null,
  fetchSpec: '>=^16.0.0',
  gitRange: undefined,
  gitCommittish: undefined,
  hosted: undefined
}
Invalid Tag Name Result {
  type: undefined,
  registry: true,
  where: undefined,
  raw: 'react@>=^16.0.0',
  name: 'react',
  escapedName: 'react',
  scope: undefined,
  rawSpec: '>=^16.0.0',
  saveSpec: null,
  fetchSpec: '>=^16.0.0',
  gitRange: undefined,
  gitCommittish: undefined,
  hosted: undefined
}
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name ">=^16.0.0": Tags may not have any characters that encodeURIComponent encodes.

The funny thing is, I can't find that react version referenced anywhere in yarn.lock, so it must be getting created inadvertently in the conversion to package-lock.json, but I added

    fs_extra_1.default.writeFileSync(path_1.join('~/project/', 'package-lock.json'), pgkLockJsonData);

into stages.js and was able to view the temporary package-lock file, and it didn't contain anything like >=^ anywhere in it.

I'd be happy to PR a fix for this, but at this point, I had to give up for time. Any ideas what's going on would be great. Thanks!

Seems to not fix vulnerabilities

Using the package i notice that some fixes seems to not be correctly applied

Here the log:

yarn run v1.22.4
warning ../../../../package.json: No license field
$ yarn-audit-fix --only prod
Runtime digest

  isMonorepo false
  npmPath npm
  npmVersion 7.0.11
  nodeVersion v12.19.1
  yarnAuditFixVersion 3.2.12
  temp /Users/xxxx/Desktop/Repos/xxxx/xxxx/node_modules/.cache/yarn-audit-fix
  cwd /Users/xxxx/Desktop/Repos/xxxxx/xxxx

Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke npm audit fix --package-lock-only --only prod --prefix /Users/xxxxx/Desktop/Repos/xxxxx/xxxx/node_modules/.cache/yarn-audit-fix
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 

up to date, audited 2482 packages in 27s

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

found 0 vulnerabilities

The package says 0 vulnerabilities

but yarn says

❯ yarn audit --groups dependencies --level high
yarn audit v1.22.4
warning ../../../../package.json: No license field
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ high          │ Remote Memory Exposure                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ bl                                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=1.2.3 <2.0.0 || >=2.2.1 <3.0.0 || >=3.0.1 <4.0.0 ||        │
│               │ >=4.0.3                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ archiver                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ archiver > tar-stream > bl                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1555                        │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ high          │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ object-path                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=0.11.5                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ parse-server                                                 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ parse-server > apollo-server-express > apollo-server-core >  │
│               │ graphql-upload > object-path                                 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1573                        │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ high          │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ object-path                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=0.11.5                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ parse-server                                                 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ parse-server > graphql-upload > object-path                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1573                        │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ high          │ Remote Memory Exposure                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ bl                                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=1.2.3 <2.0.0 || >=2.2.1 <3.0.0 || >=3.0.1 <4.0.0 ||        │
│               │ >=4.0.3                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ mongodb                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ mongodb > bl                                                 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1555                        │
└───────────────┴──────────────────────────────────────────────────────────────┘
116 vulnerabilities found - Packages audited: 1024
Severity: 110 Low | 2 Moderate | 4 High

And if i check yarn.lock for example (object-path is not patched)

object-path@^0.11.4:
  version "0.11.4"
  resolved "https://registry.yarnpkg.com/object-path/-/object-path-0.11.4.tgz#370ae752fbf37de3ea70a861c23bba8915691949"
  integrity sha1-NwrnUvvzfePqcKhhwju6iRVpGUk=

i hope logs can help to understand the source issue !

yarn-audit-fix command not found

I installed this using yarn add yarn-audit-fix -D command.

But when I type yarn-audit-fix, Ubuntu gives me that command not found.

Do I have to modify env?

Two vulnerabilities found

There are two security vulnerabilities in dependencies:

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │  Inefficient Regular Expression Complexity in                │
│               │ chalk/ansi-regex                                             │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ ansi-regex                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=5.0.1                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ yarn-audit-fix                                               │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ yarn-audit-fix > npm > npmlog > gauge > strip-ansi >         │
│               │ ansi-regex                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1002401                     │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │  Inefficient Regular Expression Complexity in                │
│               │ chalk/ansi-regex                                             │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ ansi-regex                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=5.0.1                                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ yarn-audit-fix                                               │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ yarn-audit-fix > npm > npmlog > gauge > string-width >       │
│               │ strip-ansi > ansi-regex                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://www.npmjs.com/advisories/1002401                     │
└───────────────┴──────────────────────────────────────────────────────────────┘

yarn-audit-fix version: 7.1.4

feat: use separate scope for npm flags

CLI

Flag Description Default
--npm.* Pass additional flags for npm invocation
--npm.package-lock-only Run audit fix without modifying node_modules. Highly recommended to enable. false
--npm.loglevel Set custom log level
--npm.only Set package updating scope: dev/prod
--npm.force Have audit fix install semver-major updates to toplevel dependencies, not just semver-compatible ones false
--npm.audit-level Include a vulnerability with a level as defined or higher. Supported values: low, moderate, high, critical low
--npm.registry Custom registry url

npx and installed version work differently

antongolub@mbp release-testing % yarn-audit-fix --package-lock-only
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke /usr/local/lib/node_modules/yarn-audit-fix/node_modules/.bin/npm audit fix --package-lock-only --prefix=/Users/antongolub/projects/release-testing/node_modules/.cache/yarn-audit-fix

up to date, audited 1395 packages in 5s

# npm audit report

dot-prop  <4.2.1 || >=5.0.0 <5.1.1
Severity: high
Prototype Pollution - https://npmjs.com/advisories/1213
fix available via `npm audit fix`
node_modules/compare-func/node_modules/dot-prop
  compare-func  <=1.3.2 || 1.3.4
  Depends on vulnerable versions of dot-prop
  node_modules/compare-func

mem  <4.0.0
Denial of Service - https://npmjs.com/advisories/1084
fix available via `npm audit fix`
node_modules/mem
  os-locale  2.0.0 - 3.0.0
  Depends on vulnerable versions of mem
  node_modules/os-locale
    yargs  4.0.0-alpha1 - 12.0.5 || 14.1.0 || 15.0.0 - 15.2.0
    Depends on vulnerable versions of os-locale
    Depends on vulnerable versions of yargs-parser
    node_modules/@iarna/cli/node_modules/yargs
      @iarna/cli  <=1.2.0
      Depends on vulnerable versions of yargs
      node_modules/@iarna/cli
        lock-verify  <=1.1.0 || >=2.2.0
        Depends on vulnerable versions of @iarna/cli
        node_modules/lock-verify

yargs-parser  <=13.1.1 || 14.0.0 - 15.0.0 || 16.0.0 - 18.1.1
Prototype Pollution - https://npmjs.com/advisories/1500
fix available via `npm audit fix`
node_modules/@iarna/cli/node_modules/yargs-parser
  yargs  4.0.0-alpha1 - 12.0.5 || 14.1.0 || 15.0.0 - 15.2.0
  Depends on vulnerable versions of os-locale
  Depends on vulnerable versions of yargs-parser
  node_modules/@iarna/cli/node_modules/yargs
    @iarna/cli  <=1.2.0
    Depends on vulnerable versions of yargs
    node_modules/@iarna/cli
      lock-verify  <=1.1.0 || >=2.2.0
      Depends on vulnerable versions of @iarna/cli
      node_modules/lock-verify

8 vulnerabilities (6 low, 2 high)

To address all issues, run:
  npm audit fix
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 23108,
  stdout: null,
  stderr: null
}
antongolub@mbp release-testing % sudo npm uninstall -g yarn-audit-fix
removed 376 packages in 2.033s
antongolub@mbp release-testing % npx yarn yarn-audit-fix
yarn run v1.22.4
error Command "yarn-audit-fix" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
antongolub@mbp release-testing % yarn add -D -W yarn-audit-fix
yarn add v1.22.4
[1/4] 🔍  Resolving packages...
warning yarn-audit-fix > synp > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 27 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ @npmcli/[email protected]
...
├─ [email protected]
└─ [email protected]
✨  Done in 12.27s.
antongolub@mbp release-testing % yarn-audit-fix --package-lock-only
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke /Users/antongolub/projects/release-testing/node_modules/.bin/npm audit fix --package-lock-only --prefix=/Users/antongolub/projects/release-testing/node_modules/.cache/yarn-audit-fix
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
added 6 packages, removed 250 packages and updated 1425 packages in 6.517s
fixed 55 of 73 vulnerabilities in 1760 scanned packages
  18 vulnerabilities required manual review and could not be updated
Updating yarn.lock from package-lock.json...
invoke yarn --update-checksums
yarn install v1.22.4
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 5.22s.
Done
antongolub@mbp release-testing % 

Regression: EPERM operation not permitted on Windows

It seems the #18 and related issues have regressed.

  isMonorepo false
  npmPath C\\Users\\[snip]\\AppData\\Roaming\\npm-cache\\_npx\\2808\\node_modules\\yarn-audit-fix\\node_modules\\.bin\\npm.cm
  npmVersion 7.12.0
  nodeVersion v12.18.2
  yafVersion 4.3.3
  temp C\\Users\\[snip]\\node_modules\\.cache\\yarn-audit-fix\\ef8927d2f5ca90c9
  cwd C\\Users\\[snip]
  flags
    npm-path local

Preparing temp assets...
Failure!
Error: EPERM: operation not permitted, symlink 'C:\Users\[snip]\node_modules' -> '2f5ca90c9b755890a68ea0d2b\node_modules'
    at Object.symlinkSync (fs.js:1088:3)
    at Object.createSymlinkSync

To reproduce:

$ npx yarn-audit-fix
npx: installed 339 in 11.953s

Errors running on windows in git bash: EPERM operation not permitted, could not find parent dir

I get the following error on running npx yarn-audit-fix on windows in git bash:

npx yarn-audit-fix
Preparing temp assets...
Error: EPERM: operation not permitted, symlink '..\..' -> 'C:\data\src\<my project>\node_modules\.cache\yarn-audit-fix\node_modules'

running the same in a console with administrator privileges results in this error:

npx yarn-audit-fix
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Error: Could not find parent dir!
    at parentPackagePath (C:\data\src\<my project>\node_modules\synp\util\traverse.js:9:11)
    at C:\data\src\<my project>\node_modules\synp\lib\lockfileV1\tree.js:67:30

thanks for any hints to get it running.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string.

$ npx yarn-audit-fix
Runtime digest
Failure!
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type function ([Function])
    at validateString (internal/validators.js:120:11)
    at Object.resolve (path.js:980:7)
    at join (/Users/myuser/node_modules/find-up/index.js:11:14)
    at Function.module.exports.sync (/Users/myuser/myapp/node_modules/find-up/index.js:43:12)
    at Object.getClosestNpm (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/util.js:107:29)
    at Object.getNpm (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/util.js:121:24)
    at printRuntimeDigest (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/stages.js:39:26)
    at Object.exec (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/runner.js:88:13)
    at /Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/runner.js:104:25
    at step (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/runner.js:33:23) {
  code: 'ERR_INVALID_ARG_TYPE'
}
(node:7953) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type function ([Function])
    at validateString (internal/validators.js:120:11)
    at Object.resolve (path.js:980:7)
    at join (/Users/myuser/myapp/node_modules/find-up/index.js:11:14)
    at Function.module.exports.sync (/Users/myuser/myapp/node_modules/find-up/index.js:43:12)
    at Object.getClosestNpm (/Users/myuse/myappr/node_modules/yarn-audit-fix/target/es5/util.js:107:29)
    at Object.getNpm (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/util.js:121:24)
    at printRuntimeDigest (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/stages.js:39:26)
    at Object.exec (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/runner.js:88:13)
    at /Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/runner.js:104:25
    at step (/Users/myuser/myapp/node_modules/yarn-audit-fix/target/es5/runner.js:33:23)
(node:7953) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7953) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I see this with NodeJS v12.21.0 using NPM 7.14.0 and NPM 6.14.13. I see this with yarn-audit-fix versions 5.0.1 and 4.3.6.

I don't see this error with [email protected], but that version doesn't update my yarn.lock with any of the fixes.

My Yarn version is v1.22.10.

Synp fails on attempt to convert undefined or null to object

rc.11 does get past the first part then bombs out here:


found 0 vulnerabilities
npm timing command:audit Completed in 19147ms
npm verb exit [ 0, true ]
npm timing npm Completed in 19956ms
npm info ok
Updating yarn.lock from package-lock.json...
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at flattenPackageLock (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\util\format.js:7:17)
    at buildYarnTree (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\tree.js:22:34)
    at convertNpmV1ToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\index.js:26:22)
    at convertNpmV2ToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV2\index.js:84:12)
    at convertNpmToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\index.js:31:9)
    at Object.npmToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\index.js:17:12)
    at yarnImport (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\target\es5\index.js:114:39)
    at C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\target\es5\index.js:179:21
    at step (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\target\es5\index.js:33:23)

Originally posted by @MattSwartz in #18 (comment)

bug: produced package-lock may be incompatible with npm v7

npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm WARN audit 400 Bad Request - POST https://registry.npmjs.org/-/npm/v1/security/audits/quick - Bad Request
{
  statusCode: 400,
  error: 'Bad Request',
  message: 'Invalid package tree, run  npm install  to rebuild your package-lock.json'
}

--force did not force the update

[email protected]

test repo

I can see how --force gets passed to npm audit fix, but somehow npm exits with non-zero and suggest to use --force. not sure what's happening.

$ yarn-audit-fix --force          
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke /home/qwelias/.nvm/versions/node/v12.18.1/lib/node_modules/yarn-audit-fix/node_modules/.bin/npm audit fix --package-lock-only --force --prefix=/home/qwelias/prj/stuff/test-yarn-audit-fix/node_modules/.cache/yarn-audit-fix
npm WARN using --force Recommended protections disabled.
npm WARN audit Updating lodash to 4.17.20,which is outside your stated dependency range.
npm WARN audit Manual fix required in linked project at ./packages/bar for lodash@<=4.17.18.
npm WARN audit 'cd ./packages/bar' and run 'npm audit' for details.
npm WARN audit Manual fix required in linked project at ./packages/foo for lodash@<=4.17.18.
npm WARN audit 'cd ./packages/foo' and run 'npm audit' for details.

up to date, audited 7 packages in 2s

# npm audit report

lodash  <=4.17.18
Severity: high
Prototype Pollution - https://npmjs.com/advisories/782
Prototype Pollution - https://npmjs.com/advisories/1065
Prototype Pollution - https://npmjs.com/advisories/577
Prototype Pollution - https://npmjs.com/advisories/1523
fix available via `npm audit fix --force`
Will install [email protected], which is outside the stated dependency range
packages/bar/node_modules/lodash
packages/foo/node_modules/lodash

1 high severity vulnerability

To address all issues, run:
  npm audit fix --force
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 176019,
  stdout: null,
  stderr: null
}

Remove npm dependency

  • Drop --npm-path flag
  • Install npm on demand
    • Introduce new option --npm=semver/system/custom-path
    • install npm to temp dir if the current version does not match the required one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.