Skip to content
项目

关于

对 npm 或 yarn 锁文件进行检查,分析并检测安全问题。

安全与隐私

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
更新延迟

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

lockfile linting 🌈

lint lockfiles for improved security and trust policies

lockfile-lint main CI license Security Responsible Disclosure npx lockfile-lint

About

Lockfiles are used as trusted whitelist of resources manifest to fetch packages from. However, keeping track of the changes introduced to lockfiles is not an easy task as they are designed to be consumed by machines 🤖.

What happens when someone creates a Pull Request and sneaks a malicious resource package that replaces a real library? 😱

Exactly! Lint your lockfiles to ensure they adhere to pre-defined security policies and mitigate this vector of attack.

Why is this important? read: Why npm lockfiles can be a security blindspot for injecting malicious modules

Learn Node.js Security

Node.js Security

Screenshot 2024-09-12 at 20 08 07

Learn Node.js Secure Coding techniques and best practices from Liran Tal

Usage

Easily invoked with npx on any project and lint it:

npx lockfile-lint --path yarn.lock --allowed-hosts npm yarn --validate-https

The standard npm-shrinkwrap.json filename is detected automatically, like package-lock.json:

npx lockfile-lint --path npm-shrinkwrap.json --allowed-hosts npm yarn --validate-https

For a nonstandard npm lockfile filename, pass --type npm explicitly.

If you get no results, congratulations, the file passes!

If lockfile-lint detects exceptions to the policies it will report them:

carbon

Refer to lockfile-lint for more details on the CLI usage.

You can use lockfile-lint as a standalone CLI tool, or as an API library using the following npm packages:

  • lockfile-lint - a CLI tool that can be easily integrated as a pre-commit hook or part of a CI/build
  • lockfile-lint-api - a library providing a programmatic API

Security Disclaimer

Please be advised of the following security disclaimers that are outside of the control of a lockfile linter:

When you whitelist all hosts from npmjs, yarnpkg, github or other registries you implicitly convey that you trust all the packages originating from these sources. As such, a malicious package can exist in a registry source that you whitelist. Direct dependencies that you should add to a project should be well vetted before adding such as using a tool like npq.

References

FAQ

What about pnpm support?

pnpm doesn't maintain the tarball source of an npm package so unlike yarn, and npm, there's no way to inject an attacker-controlled malicious source file in pnpm-lock.yaml. Other vectors that were explored were to inject new packages into the lockfile (that aren't in package.json) yet pnpm isn't prone to these malicious attempts and would not install them.

If you have witnessed a possible attack vector on pnpm's lockfile, please open an issue with reproducible steps.

How is this different from npm audit?

npm audit is a tool to audit your dependencies for known vulnerabilities. However, it doesn't address the issue of malicious packages being injected into your lockfile. lockfile-lint is a tool that is designed to address this issue.

Documentation

Contributing

Please consult CONTRIBUTING for guidelines on contributing to this project.

Author

lockfile-lint © Liran Tal, Released under the Apache-2.0 License.

探索相关项目

加载中…