
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@lab009/hunter
Advanced tools
Walk a React element tree, executing a provided function against each node.
Walk a React element tree, executing a provided visitor function against each element.
This is a extract of the implementation within the awesome react-apollo
project. I've come to find many use-cases for it in my own projects and want to avoid code duplication.
With this you could, for example, perform pre-rendering parses on your React element tree to do things like data prefetching. 🤛
In the below example we walk the tree and execute the getValue
function on every element instance that has the function available. We then push the value into a values array.
import hunter from '@lab009/hunter'
class Foo extends React.Component {
constructor(props) {
super(props)
this.getValue = this.getValue.bind(this)
}
getValue() {
return this.props.value
}
render() {
return <div>{this.props.children}</div>
}
}
const app = (
<div>
<h1>Hello World!</h1>
<Foo value={1} />
<Foo value={2}>
<Foo value={4}>
<Foo value={5} />
</Foo>
</Foo>
<Foo value={3} />
</div>
)
const values = []
/**
* Visitor to be executed on each element being walked.
*
* @param element - The current element being walked.
* @param instance - If the current element is a Component or PureComponent
* then this will hold the reference to the created
* instance. For any other element type this will be null.
* @param context - The current "React Context". Any provided childContexTypes
* will be passed down the tree.
*
* @return `undefined` if you want to continue walking down the current branch,
* or return `false` if you wish to stop the traversal down the
* current branch. Stopping the traversal can be quite handy if
* you want to resolve a Promise for example. You can wait for the
* Promise to resolve and then execute a function to continue
* traversal of the branch where you left off.
*/
function visitor(element, instance, context) {
if (instance && typeof instance.getValue) {
values.push(instance.getValue())
}
};
hunter(app, visitor)
console.log(values) // [1, 2, 4, 5, 3];
Let me know if you have any...
v1.0.0 (2017-03-01)
Version 1.0.0 of the hunter.
FAQs
Walk a React element tree, executing a provided function against each node.
The npm package @lab009/hunter receives a total of 2 weekly downloads. As such, @lab009/hunter popularity was classified as not popular.
We found that @lab009/hunter 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.