[RRFC] Warn/Prompt/Error for configuration conflicts
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
Direzione di ricerca
Esamina la precedenza della configurazione di npm CLI attraverso i punti di ingresso npm install e npm clean-install, usando ~/.npmrc, project/.npmrc e le opzioni CLI come i casi descritti qui. Il lavoro è completato solo quando il comportamento per i valori in conflitto è stabilito, inclusa la gestione di TTY e CI, invece di lasciare aperta la scelta tra richiedere un input, mostrare un avviso e generare un errore.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Motivation ("The Why")
Recent supply chain attacks have spurred many important improvements to the npm CLI, including configuration options that help prevent being the victim of one. However, the npm configuration is not always "user-controlled", which can lead to unexpected (and potentially compromising) outcomes. In particular, a user may have a secure user-level configuration (~/.npmrc) but run a command in a compromised/malicious project and end up in a bad situation. Alternatively, a user may have a secure user-level configuration but have some third-party script unexpectedly run npm install --ignore-scripts=false <malicious-package>[^1].
For this reason I would propose the npm CLI attempts to prevent such a security-conscious user from being the victim of a supply chain attack by alerting them when this situation arises, or at the very least leave a trace when it happens.
[^1]: as described in https://lists.archlinux.org/archives/list/[email protected]/thread/L2JXQNYBGWOQQQXDEPEAICBHKFEFANUC/
Example
You have a user level configuration
$ cat ~/.npmrc
ignore-scripts=true
min-release-age=7
And you have just cloned an (untrusted) repository with a local configuration file
$ cat random-github-project/.npmrc
ignore-scripts=false
min-release-age=0
If you install dependencies, it won't inform you about the configuration conflicts
$ npm --version
11.12.1
$ npm install # or npm clean-install
added X packages, and audited Y packages in 420ms
found Z vulnerabilities
How
Current Behaviour
The option value in the "closest" configuration wins and is used.
Desired Behaviour
If there is a conflict for an option between configurations (files or CLI) the npm CLI should either
- Prompt the user for confirmation that the configurations are conflicting, and which option value will be used, or
- Output a warning that there was a conflict, or
- Error and not do anything
Where an example of a configuration mismatch is if one explicitly specifies ignore-scripts=false and another one explicitly specifies ignore-scripts=true.
I would personally advocate for using (1) when a TTY is detected and falling back to (2) otherwise, e.g. in CI.
The behavior itself may be configurable, but in that case should only be respected when provided at the user level (~/.npmrc) or CLI.
In some ideal world it should not be considered a problem when, say, the project-level configuration is more strict than the user-level configuration[^2]. However, I imagine it can be difficult and contentious to determine when a configuration is "more strict".
[^2]: For example, ignore-scripts=false in ~/.npmrc and ignore-scripts=true in project/.npmrc.
References
- Relates to #856
- Lingua principale
- JavaScript
- Stelle
- 780
- Fork
- 266
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/rfcs
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
Issue simili
-
docs: add SECURITY.md vulnerability reporting policyForse già presa @AK-Lmn l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
flisk-sh/linux2wasm#12 ·
I maintainer di solito rispondono entro 1 giorno
-
possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Mintplex-Labs/anything-llm#7388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
v6: Minified bootstrap.min.css is missing header infoForse già presa @lazerg l’ha presa oggi. Apertabug build confirmed has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
[workshop-sync] workshop/side-quest-26-01-forecast-costs.md: forecast default history window is inaccurateForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadocumentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
githubnext/gh-aw-workshop#6332 ·
I maintainer di solito rispondono entro 1 giorno