-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Add Audit Policies Support #637
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Audit Policies | ||
|
||
### Motivation | ||
|
||
Today there are a limited set of conditions in place that prevent the installation of a package (ex. integrity mismatches & engines conflicts); audits also happen post-installation meaning they are only advisory in practice. | ||
|
||
### Solution | ||
|
||
Introduce easily configurable audit definitions that can gate the installation of packages. This new feature should leverage existing functionality/commands (ex. `install`, `update` & `audit`), syntax (ex. Dependency Selectors) & metadata without expanding the scope to unbounded, arbitrary code execution (unlike `preinstall` scripts or lifecycle hooks). | ||
|
||
### Known Caveats | ||
- Adding extra validation during installation will slow down execution | ||
- this will be up to end-users to control & determine what validations are necessary to meet their own requirements | ||
- Not all usecases will be met | ||
- we will be limited by the existing commands, syntax & metadata supported | ||
- we aim to meet 80% (or the majority) of usecases with this feature | ||
- end-users with broader security needs can & still should look at locking down developer environments & enforce policies at the system/network level (something that is outside the scope of the `npm` CLI today) | ||
|
||
### Implementation | ||
|
||
```json | ||
{ | ||
"audit": { | ||
"policies": [ | ||
{ | ||
"name": "Vulnerable", | ||
"type": "error", | ||
"query": ":vulnerable" | ||
}, | ||
{ | ||
"name": "Peer Conflicts", | ||
"type": "error", | ||
"query": ".peer:not(:deduped)" | ||
}, | ||
{ | ||
"name": "Deprecated", | ||
"type": "warn", | ||
"query": ":deprecated" | ||
}, | ||
{ | ||
"name": "Outdated", | ||
"type": "log", | ||
"query": ":outdated()" | ||
}, | ||
{ | ||
"name": "Licenses", | ||
"type": "log", | ||
"query": ":not([license=MIT])" | ||
}, | ||
{ | ||
"name": "Remotes", | ||
"type": "error", | ||
"query": ":type(git), :type(remote)" | ||
}, | ||
{ | ||
"name": "Extraneous", | ||
"type": "warn", | ||
"query": ":extraneous" | ||
}, | ||
{ | ||
"name": "Missing", | ||
"type": "warn", | ||
"query": ":missing" | ||
}, | ||
{ | ||
"name": "Duplicate Peers", | ||
"type": "warn", | ||
"query": ".peer:not(:deduped)" | ||
}, | ||
{ | ||
"name": "Bad Packages", | ||
"type": "error", | ||
"query": "#phishing, #spam, #malware" | ||
}, | ||
{ | ||
"name": "Bad Actors", | ||
"type": "error", | ||
"query": ":attr(contributors, [[email protected]])" | ||
}, | ||
{ | ||
"name": "Architecture Mismatch", | ||
"type": "error", | ||
"query": "@supports(cpu:x64) { [cpu=!x64] }" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the query specifies which packages are selected, but what defines how the results are presented?
Vulnerability output is perhaps a special case, but is the output just "error, nonzero packages showed up in the query!"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question - I believe the idea would be to use something like the above but I can put some potential examples of output in the RFC itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it won't be nearly as useful if all i can do is control the exit code with a query that produces nonzero results. I suspect people will want to provide their own package that can be a function that receives the query results as an argument, and can do whatever it likes, as long as it returns an exit code, or something.