Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
has-required-props
Advanced tools
Assert that your object props have non-undefined values for each required prop
Assert that your object props have non-undefined values for each required prop
$ npm install --save has-required-props
Not using Node or a module bundler? Use a UMD build via the <script>
tag.
import hasRequiredProps from 'has-required-props'
let props = { prop1: 'a', prop2: 'b' }
let requiredProps = ['prop1', 'prop2']
hasRequiredProps(requiredProps, props) // true
hasRequiredProps(requiredProps, [props, props]) // true
requiredProps = ['prop1', 'prop2', 'prop3']
hasRequiredProps(requiredProps, props) // false
// go crazy
props = {
a: {
b: 1,
c: {
d: 2
}
},
e: 3,
f: [
3,
{
g: 1,
h: {}
}
]
}
requiredProps = ['a.b', 'a.c.d', 'e', 'f.0', 'f.1.g', 'f.1.h']
hasRequiredProps(requiredProps, props) // true
// keep it simple
props = { a: 1, b: 2 }
requiredProps = 'a'
hasRequiredProps(requiredProps, props) // true
props.a = undefined
hasRequiredProps(requiredProps, props) // false
props.a = null
hasRequiredProps(requiredProps, props) // true
// curry on
const curry = require('lodash/curry')
const duckCharacteristics = ['bill', 'plumage', 'webbedFeet']
const quacksLikeADuck = curry(hasRequiredProps(duckCharacteristics))
quacksLikeADuck({ bill: {}, plumage: {}, webbedFeet: {} }) // true
quacksLikeADuck({ bill: {}, plumage: {} }) // false
FAQs
Assert that your object props have non-undefined values for each required prop
We found that has-required-props demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.