Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
is-my-ip-valid
Advanced tools
The is-my-ip-valid npm package is a utility for validating IP addresses. It supports both IPv4 and IPv6 formats and provides simple methods to check if an IP address is valid.
Validate IPv4
This feature allows you to validate if a given string is a valid IPv4 address.
const isMyIpValid = require('is-my-ip-valid');
const ipv4 = '192.168.1.1';
const isValidIPv4 = isMyIpValid(ipv4);
console.log(`Is ${ipv4} a valid IPv4 address?`, isValidIPv4);
Validate IPv6
This feature allows you to validate if a given string is a valid IPv6 address.
const isMyIpValid = require('is-my-ip-valid');
const ipv6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
const isValidIPv6 = isMyIpValid(ipv6);
console.log(`Is ${ipv6} a valid IPv6 address?`, isValidIPv6);
Custom Validation
This feature allows you to create a custom validator for specific IP address formats, such as IPv4 with CIDR notation.
const isMyIpValid = require('is-my-ip-valid');
const customValidator = isMyIpValid({ version: 4, cidr: true });
const ip = '192.168.1.1/24';
const isValid = customValidator(ip);
console.log(`Is ${ip} a valid IPv4 CIDR address?`, isValid);
The 'ip' package provides utilities for IP address manipulation, including validation, conversion, and subnet calculations. It offers more comprehensive functionality compared to is-my-ip-valid, such as converting IP addresses to different formats and performing subnet calculations.
The 'ipaddr.js' package is a library for manipulating IPv4 and IPv6 addresses in JavaScript. It provides validation, parsing, and comparison functions. It is more feature-rich than is-my-ip-valid, offering detailed parsing and manipulation capabilities.
The 'netmask' package is used for IP address and network mask calculations. It allows for validation, subnet calculations, and IP range checks. It is more focused on network-related calculations compared to is-my-ip-valid.
A small lib to validate IP addresses.
npm install --save is-my-ip-valid
const validator = require('is-my-ip-valid')
const validate = validator()
const validate4 = validator({ version: 4 })
const validate6 = validator({ version: 6 })
console.log(validate('127.0.0.1'))
//=> true
console.log(validate4('127.0.0.1'))
//=> true
console.log(validate6('127.0.0.1'))
//=> false
console.log(validate('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true
console.log(validate4('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> false
console.log(validate6('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
//=> true
The code is mostly based on this wonderful library: beaugunderson/ip-address
All regexes used are audited for catastrophic backtracking by this module: substack/safe-regex
FAQs
A small lib to validate IP addresses.
We found that is-my-ip-valid 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.