Socket
Socket
Sign inDemoInstall

npm-install-security-check

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-install-security-check - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

37

index.js
#! /usr/bin/env node
var configContents
var currentDir = process.cwd()
var fs = require('fs')
var path = require('path')
// Check for a config file in parent directories until we find one
while (currentDir.length !== 0) {
var configPath = path.join(currentDir, 'npm-install-security-check.json')
try {
configContents = fs.readFileSync(configPath)
break // since we found a config file we can stop looking
} catch (err) {
// do nothing
}
var segments = currentDir.split(path.sep)
if (segments.length === 1) {
currentDir = ''
} else {
segments.pop()
currentDir = segments.join(path.sep)
}
}
if (configContents) {
try {
var config = JSON.parse(configContents)
if (config.silent) {
process.exit(0)
}
} catch (err) {
console.error(err)
}
}
var msg = 'Warning: You are running "npm install" with scripts enabled which is a potential security risk.\n' +

@@ -4,0 +41,0 @@ 'You should run npm install with the --ignore-scripts flag or update your npm config via:\n\n' +

2

package.json
{
"name": "npm-install-security-check",
"version": "1.0.3",
"version": "1.0.4",
"description": "Warn users when they are running npm install with scripts enabled",

@@ -5,0 +5,0 @@ "scripts": {

@@ -21,1 +21,15 @@ # npm-install-security-check

[npm-url]: https://www.npmjs.com/package/npm-install-security-check
## Silence warning
If you want to silence the warning that this package prints to the console
simply add the following file to the directory in which you run `npm install`
from or any of it's parent directories.
*npm-install-security-check.json *
```json
{
"silent": true
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc