Skip to content

[RRFC] all commands (without context) should respect --ignore-scripts #709

Closed as not planned
@darcyclarke

Description

@darcyclarke

Motivation ("The Why")

Today, the ecosystem has been incorrectly trained to believe that --ignore-scripts ensures no "scripts" are executed & the nuance of the various situations where that is true has historically been hard to document & educate (ex. bug bounty submissions based on the GitHub program/scope encompassing "Arbitrary script execution upon package install with the --ignore-scripts flag" https://bounty.github.com/targets/npm-cli.html). For v10 (ref. npm/statusboard#487 / npm/cli#6641), I'm recommending the team makes all commands respect this flag properly (no matter how silly the situation).

How

Current Behaviour

  • npm makes nuanced decisions about which scripts to run even when --ignore-scripts is defined (ex. git deps run prepare, prepack, npm test will run scripts.test etc.)

Desired Behaviour

  • running install, publish, pack & more will ignore all defined scripts when --ignore-scripts is set (ex. git repos would no longer be treated uniquely during install & prepare/prepack etc. wouldn't be executed)
  • running npm test --ignore-scripts or npm run foo --ignore-scripts executes nothing (seems weird, but the result would be consistent)

References

Bikeshedding

  • you may want to look at grouping scripts & providing net-new flags to provide nuanced behavior some have asked for (ex. --ignore-pre-scripts / --ignore-post-scripts / --ignore-lifecycle-scripts or something similar) but --ignore-scripts should be the most broad in its enforcement & is the most requested

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions