
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
babel-plugin-proxy
Advanced tools
Use ES6 proxies today!
npm install babel-plugin-proxy --save-dev
Proxies are awesome feature of ES2015 that enables redefining some language operations. For example we can intercept every object property access with our own function.
The problem is that proper proxy implementation requires native browser support (currently it works in Firefox and Edge). This plugin is proof of concept that proxies can be implemented with ES5 features. It is not suitable for production environments because performance impact is huge.
We are intercepting every property access (except these connected with function invocation) and property assignment with custom interceptor functions that performs runtime check if object is proxied.
proxy.foo = 5;
proxy.foo;
becomes:
globalSetInterceptor(proxy, "foo", 5);
globalGetInterceptor(proxy, 'foo');
These interceptors performs runtime check if object should be proxied. You can check out whole runtime here
Proxies for example allow us to create objects that will warn us when undefined
key is being accessed.
var proxy = new Proxy({}, {
get: function(target, propKey) {
if (!(propKey in target)) {
console.log("Accessing undefined key!");
}
return target[propKey];
}
});
proxy.a = 5;
console.log(proxy.a);
console.log(proxy.b);
output:
5
Accessing undefined key!
undefined
FAQs
Use ES2015 proxies today!
The npm package babel-plugin-proxy receives a total of 390 weekly downloads. As such, babel-plugin-proxy popularity was classified as not popular.
We found that babel-plugin-proxy 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
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.