Open lukekarrys opened 1 year ago
This will be discussed in todays weekly office hours if anyone would like to join the discussion: https://github.com/npm/rfcs#open-office-hours
We would like to see use cases around sharing these configs, with a plan to pave those paths as they come up.
I have hundreds of internal JavaScript repos. Being able to have one source that can be our internal source of truth for all those repos is wildly preferable than having to have each team maintaining a subset of those repos have to know enough about policies to write them themselves either puts additional burden on them or puts additional burden on those who are responsible for health of the JavaScript packages across the company to educate multiple teams.
Being able to have a single source of truth that I can point to and say "you are now required to add this" vs. having to do education will dramatically speed up adoption - weeks vs. years. I can also very easily imagine this being basically 1:1 mirrored in open source GitHub orgs as well.
There have been many past RFCs addressing
npm audit
and it's need for configurability. Some of the prior art here includes:npm audit
surfaced applied to a particular project--query
flag to configure which packages in a tree would get auditednpm install
(and similar commands) to fail when attempting to install packages not from a specific registryA big thanks to the authors of those RFCs and everyone who participated in their discussion, including @bnb, @ljharb, @thescientist13, @wesleytodd, @naugtur!
This RFC does not specifically supersede any of the above RFCs, but instead is being used as a high level outline of the future plans of
npm audit
and net new behavior of blocking installs based on auditable packages. If an existing can be implemented fully after the ratified version of this RFC, then it will be closed with a link to this RFC and a comment showing how it could be implemented.The purpose of this RFC is to create a configurable and sustainable base that will give the ecosystem the building blocks to implement features like "Only Registry Dependencies", "Recommend Unique" and a subset of "Audit Assertions".
Exit Criteria
npm
, or other toolsaudit
that will act as a single audit filter:vulnerable
query that can match the current behavior of a plainnpm audit
callImplementation
audit
withinpackage.json
or.audit-config.json
fileThe existence of a valid non-empty policy config will cause
npm audit
to only run the specified policies. In order to easily match the current behavior ofnpm audit
, a:vulnerable
query selector will be availableThe audit policy spec is mostly unchanged from it's proposal in https://github.com/npm/rfcs/pull/637. See that RFC for more examples of possible queries that can be used as policies.
Each
type
maps to a loglevel that will be shown when a package matching the policy is found, either during reification (install
,update
, etc) oraudit
. Atype
oferror
will also set theexitCode
to1
duringaudit
.If the
blockInstall
property istrue
the reification process will be halted during any command that could update the tree without making any changes to the tree on disk. This is a separate property so policies withtype: 'error'
can be opted out from halting the install process.expectEntries
can be a boolean, number, or string (such as>=5
) that further filter whether the policy is matched. The default istrue
meaning any result from the query will match. For example, ifexpectEntries: >=2
as specified in the config, the policy would only be matched 2 or more matching packages were found.Each policy config item maps to an individual
npm audit
command that can be run. For example,npm audit --query=".peer:not(:deduped)" --expect-entries=2 --audit-level=error
would be equivalent to the policy config:{ query: '.peer:not(:deduped)', expectEntries: 2, type: 'error' }
.Non-Goals
While this RFC pulls from many many existing RFCs, it doesn't aim to implement all the proposals in each one. Specific non-goals from the above RFCs are called out below. Note that none of the above RFCs are not being closed by the creation of this RFC, so discussion can continue in those or new RFCs for areas outlined below.
The theme of these non-goals is "can they be solved in the future on top of this RFC?" If the answer is yes, they should stay as non-goals. If the answer is no, then they should be discussed in the context of "what needs to be added to this RFC?" so they answer can be yes.
query
with the idea the future additions to the spec can be done in an additive and backwards compatible manner vis future RFCs.