Skip to content

Commit b3a53c6

Browse files
authoredNov 6, 2023
deps: is-cidr@5.0.3 (#6949)
1 parent dce3b08 commit b3a53c6

File tree

10 files changed

+88
-109
lines changed

10 files changed

+88
-109
lines changed
 

‎lib/commands/token.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const Table = require('cli-table3')
2-
const { v4: isCidrV4, v6: isCidrV6 } = require('is-cidr')
32
const log = require('../utils/log-shim.js')
43
const profile = require('npm-profile')
54

@@ -137,7 +136,7 @@ class Token extends BaseCommand {
137136
const readonly = conf.readOnly
138137

139138
const password = await readUserInfo.password()
140-
const validCIDR = this.validateCIDRList(cidr)
139+
const validCIDR = await this.validateCIDRList(cidr)
141140
log.info('token', 'creating')
142141
const result = await pulseTillDone.withPromise(
143142
otplease(this.npm, conf, c => profile.createToken(password, readonly, validCIDR, c))
@@ -209,7 +208,8 @@ class Token extends BaseCommand {
209208
return byId
210209
}
211210

212-
validateCIDRList (cidrs) {
211+
async validateCIDRList (cidrs) {
212+
const { v4: isCidrV4, v6: isCidrV6 } = await import('is-cidr')
213213
const maybeList = [].concat(cidrs).filter(Boolean)
214214
const list = maybeList.length === 1 ? maybeList[0].split(/,\s*/) : maybeList
215215
for (const cidr of list) {

‎node_modules/cidr-regex/index.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
"use strict";
2-
3-
const ipRegex = require("ip-regex");
1+
import ipRegex from "ip-regex";
42

53
const defaultOpts = {exact: false};
6-
74
const v4str = `${ipRegex.v4().source}\\/(3[0-2]|[12]?[0-9])`;
85
const v6str = `${ipRegex.v6().source}\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])`;
96

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

16-
module.exports = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");
17-
module.exports.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");
18-
module.exports.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");
12+
const cidrRegex = ({exact} = defaultOpts) => exact ? v46exact : new RegExp(`(?:${v4str})|(?:${v6str})`, "g");
13+
export const v4 = cidrRegex.v4 = ({exact} = defaultOpts) => exact ? v4exact : new RegExp(v4str, "g");
14+
export const v6 = cidrRegex.v6 = ({exact} = defaultOpts) => exact ? v6exact : new RegExp(v6str, "g");
15+
export default cidrRegex;

‎node_modules/cidr-regex/package.json

+12-22
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,32 @@
11
{
22
"name": "cidr-regex",
3-
"version": "3.1.1",
3+
"version": "4.0.3",
44
"description": "Regular expression for matching IP addresses in CIDR notation",
55
"author": "silverwind <me@silverwind.io>",
66
"contributors": [
77
"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"
88
],
99
"repository": "silverwind/cidr-regex",
1010
"license": "BSD-2-Clause",
11-
"scripts": {
12-
"test": "make test"
13-
},
11+
"type": "module",
12+
"exports": "./index.js",
13+
"sideEffects": false,
1414
"engines": {
15-
"node": ">=10"
15+
"node": ">=14"
1616
},
1717
"files": [
1818
"index.js",
1919
"index.d.ts"
2020
],
21-
"keywords": [
22-
"cidr",
23-
"regex",
24-
"notation",
25-
"cidr notation",
26-
"prefix",
27-
"prefixes",
28-
"ip",
29-
"ip address"
30-
],
3121
"dependencies": {
32-
"ip-regex": "^4.1.0"
22+
"ip-regex": "^5.0.0"
3323
},
3424
"devDependencies": {
35-
"eslint": "7.8.1",
36-
"eslint-config-silverwind": "18.0.8",
37-
"jest": "26.4.2",
38-
"tsd": "0.13.1",
39-
"updates": "10.3.6",
40-
"versions": "8.4.3"
25+
"eslint": "8.37.0",
26+
"eslint-config-silverwind": "65.1.3",
27+
"tsd": "0.28.1",
28+
"updates": "13.2.9",
29+
"versions": "10.4.2",
30+
"vitest": "0.29.8"
4131
}
4232
}

‎node_modules/ip-regex/index.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
'use strict';
2-
31
const word = '[a-fA-F\\d:]';
4-
const b = options => options && options.includeBoundaries ?
5-
`(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))` :
6-
'';
2+
3+
const boundry = options => options && options.includeBoundaries
4+
? `(?:(?<=\\s|^)(?=${word})|(?<=${word})(?=\\s|$))`
5+
: '';
76

87
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}';
98

10-
const v6seg = '[a-fA-F\\d]{1,4}';
9+
const v6segment = '[a-fA-F\\d]{1,4}';
10+
1111
const v6 = `
1212
(?:
13-
(?:${v6seg}:){7}(?:${v6seg}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
14-
(?:${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
15-
(?:${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
16-
(?:${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
17-
(?:${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
18-
(?:${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
19-
(?:${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
20-
(?::(?:(?::${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
13+
(?:${v6segment}:){7}(?:${v6segment}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
14+
(?:${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
15+
(?:${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
16+
(?:${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
17+
(?:${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
18+
(?:${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
19+
(?:${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
20+
(?::(?:(?::${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
2121
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
2222
`.replace(/\s*\/\/.*$/gm, '').replace(/\n/g, '').trim();
2323

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

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

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

36-
module.exports = ip;
36+
export default ipRegex;

‎node_modules/ip-regex/license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
44

55
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:
66

‎node_modules/ip-regex/package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
22
"name": "ip-regex",
3-
"version": "4.3.0",
3+
"version": "5.0.0",
44
"description": "Regular expression for matching IP addresses (IPv4 & IPv6)",
55
"license": "MIT",
66
"repository": "sindresorhus/ip-regex",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "sindresorhus@gmail.com",
1011
"url": "sindresorhus.com"
1112
},
13+
"type": "module",
14+
"exports": "./index.js",
1215
"engines": {
13-
"node": ">=8"
16+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
1417
},
1518
"scripts": {
1619
"test": "xo && ava && tsd"
@@ -37,8 +40,8 @@
3740
"validate"
3841
],
3942
"devDependencies": {
40-
"ava": "^1.4.1",
41-
"tsd": "^0.7.2",
42-
"xo": "^0.24.0"
43+
"ava": "^3.15.0",
44+
"tsd": "^0.19.1",
45+
"xo": "^0.47.0"
4346
}
4447
}

‎node_modules/is-cidr/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
"use strict";
2-
const {v4, v6} = require("cidr-regex");
1+
import {v4 as v4Re, v6 as v6Re} from "cidr-regex";
32

4-
const re4 = v4({exact: true});
5-
const re6 = v6({exact: true});
3+
const re4 = v4Re({exact: true});
4+
const re6 = v6Re({exact: true});
65

7-
module.exports = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);
8-
module.exports.v4 = str => re4.test(str);
9-
module.exports.v6 = str => re6.test(str);
6+
const isCidr = str => re4.test(str) ? 4 : (re6.test(str) ? 6 : 0);
7+
export const v4 = isCidr.v4 = str => re4.test(str);
8+
export const v6 = isCidr.v6 = str => re6.test(str);
9+
export default isCidr;

‎node_modules/is-cidr/package.json

+12-26
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,32 @@
11
{
22
"name": "is-cidr",
3-
"version": "4.0.2",
3+
"version": "5.0.3",
44
"description": "Check if a string is an IP address in CIDR notation",
55
"author": "silverwind <me@silverwind.io>",
66
"contributors": [
77
"Felipe Apostol <flipjs.io@gmail.com> (http://flipjs.io/)"
88
],
99
"repository": "silverwind/is-cidr",
1010
"license": "BSD-2-Clause",
11-
"scripts": {
12-
"test": "make test"
13-
},
11+
"type": "module",
12+
"exports": "./index.js",
13+
"sideEffects": false,
1414
"engines": {
15-
"node": ">=10"
15+
"node": ">=14"
1616
},
1717
"files": [
1818
"index.js",
1919
"index.d.ts"
2020
],
21-
"keywords": [
22-
"cidr",
23-
"regex",
24-
"notation",
25-
"cidr notation",
26-
"prefix",
27-
"prefixes",
28-
"ip",
29-
"ip address",
30-
"network"
31-
],
3221
"dependencies": {
33-
"cidr-regex": "^3.1.1"
22+
"cidr-regex": "4.0.3"
3423
},
3524
"devDependencies": {
36-
"eslint": "7.10.0",
37-
"eslint-config-silverwind": "18.0.10",
38-
"jest": "26.4.2",
39-
"updates": "11.1.5",
40-
"versions": "8.4.3"
41-
},
42-
"jest": {
43-
"verbose": false,
44-
"testTimeout": 10000
25+
"eslint": "8.37.0",
26+
"eslint-config-silverwind": "65.1.3",
27+
"tsd": "0.28.1",
28+
"updates": "13.2.9",
29+
"versions": "10.4.2",
30+
"vitest": "0.29.8"
4531
}
4632
}

‎package-lock.json

+18-15
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"hosted-git-info": "^7.0.1",
114114
"ini": "^4.1.1",
115115
"init-package-json": "^6.0.0",
116-
"is-cidr": "^4.0.2",
116+
"is-cidr": "^5.0.3",
117117
"json-parse-even-better-errors": "^3.0.0",
118118
"libnpmaccess": "^8.0.1",
119119
"libnpmdiff": "^6.0.3",
@@ -4919,15 +4919,15 @@
49194919
}
49204920
},
49214921
"node_modules/cidr-regex": {
4922-
"version": "3.1.1",
4923-
"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-3.1.1.tgz",
4924-
"integrity": "sha512-RBqYd32aDwbCMFJRL6wHOlDNYJsPNTt8vC82ErHF5vKt8QQzxm1FrkW8s/R5pVrXMf17sba09Uoy91PKiddAsw==",
4922+
"version": "4.0.3",
4923+
"resolved": "https://registry.npmjs.org/cidr-regex/-/cidr-regex-4.0.3.tgz",
4924+
"integrity": "sha512-HOwDIy/rhKeMf6uOzxtv7FAbrz8zPjmVKfSpM+U7/bNBXC5rtOyr758jxcptiSx6ZZn5LOhPJT5WWxPAGDV8dw==",
49254925
"inBundle": true,
49264926
"dependencies": {
4927-
"ip-regex": "^4.1.0"
4927+
"ip-regex": "^5.0.0"
49284928
},
49294929
"engines": {
4930-
"node": ">=10"
4930+
"node": ">=14"
49314931
}
49324932
},
49334933
"node_modules/clean-stack": {
@@ -7827,12 +7827,15 @@
78277827
"inBundle": true
78287828
},
78297829
"node_modules/ip-regex": {
7830-
"version": "4.3.0",
7831-
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz",
7832-
"integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==",
7830+
"version": "5.0.0",
7831+
"resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-5.0.0.tgz",
7832+
"integrity": "sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==",
78337833
"inBundle": true,
78347834
"engines": {
7835-
"node": ">=8"
7835+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
7836+
},
7837+
"funding": {
7838+
"url": "https://github.com/sponsors/sindresorhus"
78367839
}
78377840
},
78387841
"node_modules/is-array-buffer": {
@@ -7935,15 +7938,15 @@
79357938
}
79367939
},
79377940
"node_modules/is-cidr": {
7938-
"version": "4.0.2",
7939-
"resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-4.0.2.tgz",
7940-
"integrity": "sha512-z4a1ENUajDbEl/Q6/pVBpTR1nBjjEE1X7qb7bmWYanNnPoKAvUCPFKeXV6Fe4mgTkWKBqiHIcwsI3SndiO5FeA==",
7941+
"version": "5.0.3",
7942+
"resolved": "https://registry.npmjs.org/is-cidr/-/is-cidr-5.0.3.tgz",
7943+
"integrity": "sha512-lKkM0tmz07dAxNsr8Ii9MGreExa9ZR34N9j8mTG5op824kcwBqinZPowNjcVWWc7j+jR8XAMMItOmBkniN0jOA==",
79417944
"inBundle": true,
79427945
"dependencies": {
7943-
"cidr-regex": "^3.1.1"
7946+
"cidr-regex": "4.0.3"
79447947
},
79457948
"engines": {
7946-
"node": ">=10"
7949+
"node": ">=14"
79477950
}
79487951
},
79497952
"node_modules/is-core-module": {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"hosted-git-info": "^7.0.1",
7676
"ini": "^4.1.1",
7777
"init-package-json": "^6.0.0",
78-
"is-cidr": "^4.0.2",
78+
"is-cidr": "^5.0.3",
7979
"json-parse-even-better-errors": "^3.0.0",
8080
"libnpmaccess": "^8.0.1",
8181
"libnpmdiff": "^6.0.3",

0 commit comments

Comments
 (0)
Please sign in to comment.