Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
parse-prop-types
Advanced tools
Parses React prop-types
into a readable object at runtime.
$ npm install --save parse-prop-types
import React from 'react'
import PropTypes from 'prop-types'
import parsePropTypes from 'parse-prop-types'
const MyComponent = ({ name, show }) => (
show ? <div>{name}</div> : null
)
MyComponent.propTypes = {
name: PropTypes.string,
show: PropTypes.oneOfType([PropTypes.bool, propTypes.string]).isRequired,
}
MyComponent.defaultProps = {
name: 'Haz',
}
parsePropTypes(MyComponent)
The returned object is compatible with react-docgen
:
{
name: {
type: {
name: 'string',
},
required: false,
defaultValue: {
value: 'Haz',
},
},
show: {
type: {
name: 'oneOfType',
value: [
{ name: 'bool' },
{ name: 'string' },
],
},
required: true,
},
}
react-docgen
?react-docgen
reads file contents in order to find prop types definitions. It has some limitations, such as not allowing computed prop types and, in several situations, not being able to parse file contents correctly.
parse-prop-types
, on the other hand, doesn't deal with file contents. Instead, it parses prop types at runtime by receiving the component object itself.
Parameters
$0
any
$0.propTypes
(optional, default {}
)$0.defaultProps
(optional, default {}
)Returns Object
MIT © Diego Haz
FAQs
Parses React prop-types into a readable object
We found that parse-prop-types 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.