Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: is-cidr@5.0.3 #6949

Merged
merged 1 commit into from Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/commands/token.js
@@ -1,5 +1,4 @@
const Table = require('cli-table3')
const { v4: isCidrV4, v6: isCidrV6 } = require('is-cidr')
const log = require('../utils/log-shim.js')
const profile = require('npm-profile')

Expand Down Expand Up @@ -137,7 +136,7 @@ class Token extends BaseCommand {
const readonly = conf.readOnly

const password = await readUserInfo.password()
const validCIDR = this.validateCIDRList(cidr)
const validCIDR = await this.validateCIDRList(cidr)
log.info('token', 'creating')
const result = await pulseTillDone.withPromise(
otplease(this.npm, conf, c => profile.createToken(password, readonly, validCIDR, c))
Expand Down Expand Up @@ -209,7 +208,8 @@ class Token extends BaseCommand {
return byId
}

validateCIDRList (cidrs) {
async validateCIDRList (cidrs) {
const { v4: isCidrV4, v6: isCidrV6 } = await import('is-cidr')
const maybeList = [].concat(cidrs).filter(Boolean)
const list = maybeList.length === 1 ? maybeList[0].split(/,\s*/) : maybeList
for (const cidr of list) {
Expand Down
15 changes: 6 additions & 9 deletions node_modules/cidr-regex/index.js
@@ -1,18 +1,15 @@
"use strict";

const ipRegex = require("ip-regex");
import ipRegex from "ip-regex";

const defaultOpts = {exact: false};

const v4str = `${ipRegex.v4().source}\\/(3[0-2]|[12]?[0-9])`;
const v6str = `${ipRegex.v6().source}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;

// can not precompile the non-exact regexes because global flag makes the regex object stateful
// which would require the user to reset .lastIndex on subsequent calls
// pre-compile only the exact regexes as global flag makes regex objects stateful
const v4exact = new RegExp(`^${v4str}$`);
const v6exact = new RegExp(`^${v6str}$`);
const v46exact = new RegExp(`(?:^${v4str}$)|(?:^${v6str}$)`);

module.exports = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");
module.exports.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");
module.exports.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");
const cidrRegex = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");
export const v4 = cidrRegex.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");
export const v6 = cidrRegex.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");
export default cidrRegex;
34 changes: 12 additions & 22 deletions node_modules/cidr-regex/package.json
@@ -1,42 +1,32 @@
{
"name": "cidr-regex",
"version": "3.1.1",
"version": "4.0.3",
"description": "Regular expression for matching IP addresses in CIDR notation",
"author": "silverwind <me@silverwind.io>",
"contributors": [
"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"
],
"repository": "silverwind/cidr-regex",
"license": "BSD-2-Clause",
"scripts": {
"test": "make test"
},
"type": "module",
"exports": "./index.js",
"sideEffects": false,
"engines": {
"node": ">=10"
"node": ">=14"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"cidr",
"regex",
"notation",
"cidr notation",
"prefix",
"prefixes",
"ip",
"ip address"
],
"dependencies": {
"ip-regex": "^4.1.0"
"ip-regex": "^5.0.0"
},
"devDependencies": {
"eslint": "7.8.1",
"eslint-config-silverwind": "18.0.8",
"jest": "26.4.2",
"tsd": "0.13.1",
"updates": "10.3.6",
"versions": "8.4.3"
"eslint": "8.37.0",
"eslint-config-silverwind": "65.1.3",
"tsd": "0.28.1",
"updates": "13.2.9",
"versions": "10.4.2",
"vitest": "0.29.8"
}
}
40 changes: 20 additions & 20 deletions node_modules/ip-regex/index.js
@@ -1,23 +1,23 @@
'use strict';

const word = '[a-fA-F\\d:]';
const b = options => options && options.includeBoundaries ?
`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))` :
'';

const boundry = options => options && options.includeBoundaries
? `(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`
: '';

const v4 = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';

const v6seg = '[a-fA-F\\d]{1,4}';
const v6segment = '[a-fA-F\\d]{1,4}';

const v6 = `
(?:
(?:${v6seg}:){7}(?:${v6seg}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:${v6seg}:){6}(?:${v4}|:${v6seg}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
(?:${v6seg}:){5}(?::${v4}|(?::${v6seg}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
(?:${v6seg}:){4}(?:(?::${v6seg}){0,1}:${v4}|(?::${v6seg}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
(?:${v6seg}:){3}(?:(?::${v6seg}){0,2}:${v4}|(?::${v6seg}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
(?:${v6seg}:){2}(?:(?::${v6seg}){0,3}:${v4}|(?::${v6seg}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:${v6seg}:){1}(?:(?::${v6seg}){0,4}:${v4}|(?::${v6seg}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::${v6seg}){0,5}:${v4}|(?::${v6seg}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
(?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
(?:${v6segment}:){6}(?:${v4}|:${v6segment}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
(?:${v6segment}:){5}(?::${v4}|(?::${v6segment}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
(?:${v6segment}:){4}(?:(?::${v6segment}){0,1}:${v4}|(?::${v6segment}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
(?:${v6segment}:){3}(?:(?::${v6segment}){0,2}:${v4}|(?::${v6segment}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
(?:${v6segment}:){2}(?:(?::${v6segment}){0,3}:${v4}|(?::${v6segment}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
(?:${v6segment}:){1}(?:(?::${v6segment}){0,4}:${v4}|(?::${v6segment}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
(?::(?:(?::${v6segment}){0,5}:${v4}|(?::${v6segment}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
`.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();

Expand All @@ -26,11 +26,11 @@ const v46Exact = new RegExp(`(?:^${v4}$)|(?:^${v6}$)`);
const v4exact = new RegExp(`^${v4}$`);
const v6exact = new RegExp(`^${v6}$`);

const ip = options => options && options.exact ?
v46Exact :
new RegExp(`(?:${b(options)}${v4}${b(options)})|(?:${b(options)}${v6}${b(options)})`, 'g');
const ipRegex = options => options && options.exact
? v46Exact
: new RegExp(`(?:${boundry(options)}${v4}${boundry(options)})|(?:${boundry(options)}${v6}${boundry(options)})`, 'g');

ip.v4 = options => options && options.exact ? v4exact : new RegExp(`${b(options)}${v4}${b(options)}`, 'g');
ip.v6 = options => options && options.exact ? v6exact : new RegExp(`${b(options)}${v6}${b(options)}`, 'g');
ipRegex.v4 = options => options && options.exact ? v4exact : new RegExp(`${boundry(options)}${v4}${boundry(options)}`, 'g');
ipRegex.v6 = options => options && options.exact ? v6exact : new RegExp(`${boundry(options)}${v6}${boundry(options)}`, 'g');

module.exports = ip;
export default ipRegex;
2 changes: 1 addition & 1 deletion node_modules/ip-regex/license
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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:

Expand Down
13 changes: 8 additions & 5 deletions node_modules/ip-regex/package.json
@@ -1,16 +1,19 @@
{
"name": "ip-regex",
"version": "4.3.0",
"version": "5.0.0",
"description": "Regular expression for matching IP addresses (IPv4 & IPv6)",
"license": "MIT",
"repository": "sindresorhus/ip-regex",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -37,8 +40,8 @@
"validate"
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.19.1",
"xo": "^0.47.0"
}
}
14 changes: 7 additions & 7 deletions node_modules/is-cidr/index.js
@@ -1,9 +1,9 @@
"use strict";
const {v4, v6} = require("cidr-regex");
import {v4 as v4Re, v6 as v6Re} from "cidr-regex";

const re4 = v4({exact: true});
const re6 = v6({exact: true});
const re4 = v4Re({exact: true});
const re6 = v6Re({exact: true});

module.exports = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);
module.exports.v4 = str => re4.test(str);
module.exports.v6 = str => re6.test(str);
const isCidr = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);
export const v4 = isCidr.v4 = str => re4.test(str);
export const v6 = isCidr.v6 = str => re6.test(str);
export default isCidr;
38 changes: 12 additions & 26 deletions node_modules/is-cidr/package.json
@@ -1,46 +1,32 @@
{
"name": "is-cidr",
"version": "4.0.2",
"version": "5.0.3",
"description": "Check if a string is an IP address in CIDR notation",
"author": "silverwind <me@silverwind.io>",
"contributors": [
"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"
],
"repository": "silverwind/is-cidr",
"license": "BSD-2-Clause",
"scripts": {
"test": "make test"
},
"type": "module",
"exports": "./index.js",
"sideEffects": false,
"engines": {
"node": ">=10"
"node": ">=14"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"cidr",
"regex",
"notation",
"cidr notation",
"prefix",
"prefixes",
"ip",
"ip address",
"network"
],
"dependencies": {
"cidr-regex": "^3.1.1"
"cidr-regex": "4.0.3"
},
"devDependencies": {
"eslint": "7.10.0",
"eslint-config-silverwind": "18.0.10",
"jest": "26.4.2",
"updates": "11.1.5",
"versions": "8.4.3"
},
"jest": {
"verbose": false,
"testTimeout": 10000
"eslint": "8.37.0",
"eslint-config-silverwind": "65.1.3",
"tsd": "0.28.1",
"updates": "13.2.9",
"versions": "10.4.2",
"vitest": "0.29.8"
}
}
33 changes: 18 additions & 15 deletions package-lock.json
Expand Up @@ -113,7 +113,7 @@
"hosted-git-info": "^7.0.1",
"ini": "^4.1.1",
"init-package-json": "^6.0.0",
"is-cidr": "^4.0.2",
"is-cidr": "^5.0.3",
"json-parse-even-better-errors": "^3.0.0",
"libnpmaccess": "^8.0.1",
"libnpmdiff": "^6.0.2",
Expand Down Expand Up @@ -4919,15 +4919,15 @@
}
},
"node_modules/cidr-regex": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-3.1.1.tgz",
"integrity": "sha512-RBqYd32aDwbCMFJRL6wHOlDNYJsPNTt8vC82ErHF5vKt8QQzxm1FrkW8s/R5pVrXMf17sba09Uoy91PKiddAsw==",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-4.0.3.tgz",
"integrity": "sha512-HOwDIy/rhKeMf6uOzxtv7FAbrz8zPjmVKfSpM+U7/bNBXC5rtOyr758jxcptiSx6ZZn5LOhPJT5WWxPAGDV8dw==",
"inBundle": true,
"dependencies": {
"ip-regex": "^4.1.0"
"ip-regex": "^5.0.0"
},
"engines": {
"node": ">=10"
"node": ">=14"
}
},
"node_modules/clean-stack": {
Expand Down Expand Up @@ -7827,12 +7827,15 @@
"inBundle": true
},
"node_modules/ip-regex": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz",
"integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-5.0.0.tgz",
"integrity": "sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==",
"inBundle": true,
"engines": {
"node": ">=8"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-array-buffer": {
Expand Down Expand Up @@ -7935,15 +7938,15 @@
}
},
"node_modules/is-cidr": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-4.0.2.tgz",
"integrity": "sha512-z4a1ENUajDbEl/Q6/pVBpTR1nBjjEE1X7qb7bmWYanNnPoKAvUCPFKeXV6Fe4mgTkWKBqiHIcwsI3SndiO5FeA==",
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-5.0.3.tgz",
"integrity": "sha512-lKkM0tmz07dAxNsr8Ii9MGreExa9ZR34N9j8mTG5op824kcwBqinZPowNjcVWWc7j+jR8XAMMItOmBkniN0jOA==",
"inBundle": true,
"dependencies": {
"cidr-regex": "^3.1.1"
"cidr-regex": "4.0.3"
},
"engines": {
"node": ">=10"
"node": ">=14"
}
},
"node_modules/is-core-module": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -75,7 +75,7 @@
"hosted-git-info": "^7.0.1",
"ini": "^4.1.1",
"init-package-json": "^6.0.0",
"is-cidr": "^4.0.2",
"is-cidr": "^5.0.3",
"json-parse-even-better-errors": "^3.0.0",
"libnpmaccess": "^8.0.1",
"libnpmdiff": "^6.0.2",
Expand Down