Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
cidr-matcher
Advanced tools
Fast CIDR matcher. Given an input IPv4 address, it checks if it's inside a set of IP ranges, expressed in CIDR notation.
Fast CIDR matcher. Given an input IPv4 or IPv6 address, it checks if it's inside a set of IP ranges, expressed in CIDR notation. This module is based upon the great ip6addr module.
npm install cidr-matcher
git clone https://github.com/pracucci/node-cidr-matcher.git
var CIDRMatcher = require('cidr-matcher');
var matcher = new CIDRMatcher([ '2a05:d07c:2000:0:0:0:0:0/120', '192.168.1.0/24', '192.168.2.3/32', '192.168.3.2/32' ]);
matcher.contains('192.168.1.1'); // returns true
matcher.contains('192.168.1.2'); // returns true
matcher.contains('192.168.2.1'); // returns true
matcher.contains('192.168.2.2'); // returns false
matcher.contains('192.168.3.1'); // returns false
matcher.contains('192.168.3.2'); // returns false
matcher.containsAny([ '192.168.1.1', '192.168.1.2' ]); // return true
matcher.containsAny([ '192.168.2.1', '192.168.2.2' ]); // return true
matcher.containsAny([ '192.168.3.1', '192.168.3.2' ]); // return false
assert.ok(matcher.contains('2a05:d07c:2000:0:0:0:0:0')); // return true
assert.ok(matcher.contains('2a05:d07c:2000:0:0:0:0:ff')); // return true
assert.ok(matcher.contains('2a05:d07c:3000:0:0:0:0:0')); // return false
// You can also add / remove network classes on-the-fly
matcher.addNetworkClass('192.168.5.0/24');
matcher.contains('192.168.5.1'); // returns true
matcher.removeNetworkClass('192.168.5.0/24');
matcher.contains('192.168.5.1'); // returns false
The following table shows the execution of benchmark/
across different versions of this module and other modules you can find on npm. Each benchmark is executed with a random set of 25000 IP addresses, where each IP is checked against each network range (CIDR) in the test dataset.
Module | Version | Dataset | Execution time |
---|---|---|---|
This one | 2.0.0 | AWS IPv4 (1385 CIDRs) | 228 ms |
This one | 2.0.0 | AWS IPv6 (474 CIDRs) | 1799 ms |
This one | 1.0.5 | AWS IPv4 (1385 CIDRs) | 2895 ms (without IPv4 over IPv6 support) |
This one | 1.0.5 | AWS IPv6 (474 CIDRs) | Unsupported |
is-in-subnet | 1.9.0 | AWS IPv4 (1385 CIDRs) | 96106 ms |
is-in-subnet | 1.9.0 | AWS IPv6 (474 CIDRs) | 33482 ms |
ip-range-check | 0.0.2 | AWS IPv4 (1385 CIDRs) | 390134 ms |
ip-range-check | 0.0.2 | AWS IPv6 (474 CIDRs) | 73083 ms |
If you're aware of any other module that implements the IP in CIDR and you wanna see it benchmarked, please open an Issue or submit a PR.
npm test
This software is licensed under the MIT License.
Copyright (c) 2015, Marco Pracucci marco@pracucci.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2019-07-17 2.1.1
mocha
, addressing code injection vulnerabilityFAQs
Fast CIDR matcher. Given an input IPv4 address, it checks if it's inside a set of IP ranges, expressed in CIDR notation.
The npm package cidr-matcher receives a total of 29,522 weekly downloads. As such, cidr-matcher popularity was classified as popular.
We found that cidr-matcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.