
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
ip-matching
Advanced tools
Utilities for IPv4/IPv6 ranges/subnets/masks parsing/matching, string representations, ...
Standalone module with some handy features regarding IPs:
npm install --save ip-matching
# or
yarn add ip-matching
Comes with its own built-in TypeScript declarations with included documentation.
import { getMatch, IPMatch, IPSubnetwork, IPRange, matches } from 'ip-matching';
// matches(ip: string | IP, target: string | IPMatch): boolean;
matches('10.0.0.1', '10.0.0.0/24'); // true
matches('10.0.1.1', '10.0.0.0/24'); // false
matches('abc::def', 'abc:*::def'); // true
matches('abc::def', 'abc:9::def'); // false
matches('0001:2:3:4:5:6:7', '1:2:3:4:5:6:7'); // true
// getMatch returns an instance of
// IPv4, IPv6, IPRange, IPSubnetwork or IPMask, all extending IPMatch
const mySubnet: IPMatch = getMatch('fefe::0001:abcd/112');
mySubnet.type; // 'IPSubnetwork'
mySubnet instanceof IPSubnetwork; // true
mySubnet instanceof IPMatch; // true
mySubnet.toString(); // 'fefe::1:0/112'
mySubnet.matches('FEFE::1:bbbb'); // true
mySubnet.matches('FEFE::2:bbbb'); // false
mySubnet.equals(new IPSubnetwork(new IPv6('fefe::1:abcd'), 112)); // true
mySubnet.getAmount(); // 65536
(mySubnet as IPSubnetwork).getLast().toString(); // 'fefe::1:ffff'
const myIp = new IPv6('a:0:0::B:0:C');
myIp.toString(); // 'a::b:0:c'
myIp.toLongString(); // 'a:0:0:0:0:b:0:c'
myIp.toFullString(); // '000a:0000:0000:0000:0000:000b:0000:000c'
new IPv6('::ffff:a9db:*').toMixedString(); // '::ffff:169.219.*.*'
const myRange = getMatch('10.0.0.0-10.1.2.3') as IPRange;
myRange.convertToMasks().map((mask: IPMask) => mask.convertToSubnet().toString());
// [ '10.0.0.0/16', '10.1.0.0/23', '10.1.2.0/30' ]
const mask1 = getMatch('10.0.1.0/255.0.255.0') as IPMask;
const mask2 = getMatch('10.0.0.0/128.0.0.0') as IPMask;
mask1.isSubsetOf(mask2); // true
mask2.getAmount(); // 2147483648
getMatch('a::abbc:1234/ffff::ff80:000f').toString(); // 'a::ab80:4/ffff::ff80:f'
Note: The matches
function and all constructors error for invalid inputs
You can take a look at the test code or the TypeScript declarations for all the features.
10.0.0.0
10.0.0.*
or even 10.*.0.*
2001:0db8:85a3:0000:0000:8a2e:0370:7334
2001:db8:85a3::8a2e:0370:7334
or ::
or ::1
or a::
2001::*
or even 2001::*:abc:*
::ffff:127.0.0.1
(no wildcards allowed in IPv4 part)10.0.1*.0
or 2001::a*c
10.0.0.0-10.1.2.3
2001::abc-2001::1:ffff
10.0.0.0/16
2001::/123
10.0.0.0/255.0.64.0
2001:abcd::/ffff:ff8::
The IPMask's toString()
method does not automatically simplify e.g. /255.0.0.0
to /8
, even though those are equivalent. Since 2.0.0, IPMask comes with a method convertToSubnet()
which returns an equivalent IPSubnetwork if possible, otherwise undefined
.
2.1.2
package.json
)
FAQs
Utilities for IPv4/IPv6 ranges/subnets/masks parsing/matching, string representations, ...
The npm package ip-matching receives a total of 31,551 weekly downloads. As such, ip-matching popularity was classified as popular.
We found that ip-matching 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.