npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

safety-latch

v0.1.4

Published

The NPM ecosystem has a problem with hooks. More precisely their install hooks since they allow an installed dependency to execute any script it pleases. This is DANGEROUS!

Downloads

4

Readme

safety-latch

The NPM ecosystem has a problem with hooks. More precisely their install hooks since they allow an installed dependency to execute any script it pleases. This is DANGEROUS!

So this tool takes inspiration from the NPM package can-i-ignore-scripts and tries to add a bit more tooling around it.

The idea is that you should do your yarn install/npm install using the --ignore-scripts flag, which will prevent these automatic hooks from running. But some packages do have a legitimate reason for using these, so therefore for some select packages, you want to enable it. Read more at naugtur's blog post

This tool scans for any package.json which contains an install hook and request that you decide if they should run or not. If a package later introduces hooks, which haven't previously used hooks, the install will fail, allowing you to define if the package should be allowed to run hooks or not.

Installation

npm i -g safety-latch

Usage

First, you need to create a configuration using safety-latch setup. This will generate a safety-latch.json file that contains your selection. You use the same command later to change this selection and to allow/disallow new packages with install hooks.

Now you can use safety-latch install to run hooks on your selected packages.

So this should change your yarn/npm behavior

Before

yarn install # npm install

After

yarn install --ignore-scripts # npm install --ignore-scripts
safety-latch install # will rebuild the allowed packages and fail if a package with hooks aren't explicitly allowed or denied

This is a longer process, but well the same old story about security vs. convenience right?

Development

The easiest way to develop on this is to do npm link so the safety-latch executable points to your dev clone, and then run yarn dev to build the tool on changes

TODO

  • [ ] Set up a source of package defaults like https://github.com/naugtur/can-i-ignore-scripts/blob/main/data.json to allow for easier screening of which packages to allow
  • [ ] Testing
  • [ ] Add a postinstall hook that fails if testPostInstall is true
  • [ ] ?