An opinionated CLI wrapper around Snyk for purging vulnerabilities from Node projects
You're not you when you've got hundreds of vulnerable paths
# Start fixing vulnerabilities straight away using NPX
npx snyker
# Add to your global NPM packages
npm i -g snyker
# Or to your global Yarn packages
yarn global add snyker
The Snyk CLI is great for reporting vulnerabilities and providing top level dependency upgrades and patches, but struggles when the vulnerability rests within a nested "transitive" sub-dependency. This is despite the fact that many sub-dependencies have reasonable flexibility in the version ranges they allow for their own dependencies.
This CLI takes a brute-force approach to solving this limitation of Snyk. It purges the .snyk
file from a project, checks for vulnerable paths using Snyk, then forces yarn
/ npm
to try to upgrade any dependency along the vulnerable paths before finally ignoring any vulnerability that cannot be fixed in the previous steps. If a patch is available for any outstanding vulnerability then it is also added to the Snyk policy.
Note that this tool obeys your defined package version ranges and therefore can't fix anything that requires a major upgrade if you are only permitting minor or patch upgrades.
This tool also does not make use of Snyk's ability to perform package major upgrades. It will simply ignore vulnerabilities that cannot be fixed in the aforementioned steps. It is on you to sanity check anything that this tool decides to ignore.
Snyker will list the known vulnerabilities it has been unable to fix. If Snyk reports that there are major upgrades available to fix one or more of the outstanding vulnerabilities, Snyker will output a recommended yarn
/ npm
command for performing the upgrade(s).
It is recommended that you use this tool alongside the official Snyk CLI, not replace it completely.
snyker --retries 3 --lockfile package-lock.json
Flag | Description | Default |
---|---|---|
--lockfile <string> |
Specify the lockfile to use (e.g. yarn.lock or package-lock.json ). |
yarn.lock |
--retries <int> |
Will set the number of times to retry logical steps of Snyker. | 2 |
Snyk supports a pull or merge request integration for your source control repositories which can upgrade your dependencies based on scan results.
This behaves similar to Snyker in providing a capability to upgrade dependencies, but is not available as a CLI and does not bundle ignore behaviours at the same time.
The Snyk CLI supports a snyk ignore
command to ignore a stated issue according to its snyk ID for all occurrences, its expiry date, a reason, or according to paths in the filesystem.
This commands does not perform any dependency upgrades and requires you to manually look up the vulnerability's ID to execute the correct ignore command.
Snyker currently includes the snyk ignore
capability as part of it's process.
Snyk supports a separate @snyk/protect
CLI, replacing the older snyk protect
command for patching vulnerable dependencies.
The Snyker maintainers generally advise against the usage of closed source patches for your dependencies.
Snyk has released a closed beta snyk fix
command that aims to automatically apply the recommended updates, but this is currently only available for Enterprise customers using Python.
Snyk used to support a snyk wizard
command which would perform dependency upgrades and policy ignores but this was removed on 31 March 2022.
Please check out the CONTRIBUTING docs.
Please check out the CHANGELOG docs.
Snyker is licensed under the MIT License.