Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
d555db2
lib: flag to conditionally modify proto on deprecate
RafaelGSS Jul 8, 2025
f753645
net: update net.blocklist to allow file save and file management
alphaleadership Jul 8, 2025
1cffcc0
test: add missing port=0 arg in test-debugger-extract-function-name
dario-piotrowicz Jul 8, 2025
04c7514
meta: add marco-ippolito to security release stewards
marco-ippolito Jul 9, 2025
cfaa299
lib: fix incorrect `ArrayBufferPrototypeGetDetached` primordial type
dario-piotrowicz Jul 9, 2025
c9ded6b
doc: add sponsorship link to RafaelGSS
RafaelGSS Jul 9, 2025
515b581
module: throw error when re-runing errored module jobs
joyeecheung Jul 9, 2025
3a3eb68
repl: improve REPL disabling completion on proxies and getters
dario-piotrowicz Jul 9, 2025
2178007
src: check import attributes value types as strings
legendecas Jul 9, 2025
85d6a28
inspector: initial support for Network.loadNetworkResource
islandryu Jul 10, 2025
cb95e18
doc: add scroll margin to links
silverwind Jul 10, 2025
c52aaac
dns: support max timeout
theanarkh Jul 10, 2025
3924c43
doc: add missing `<code>` blocks
aduh95 Jul 10, 2025
45ffdb3
doc: add stability index to the `--watch-kill-signal` flag
dario-piotrowicz Jul 10, 2025
83cdf17
test_runner: clean up promisified interval generation
Renegade334 Jul 10, 2025
9d02960
doc: add missing environment variables to manpage
HumaneLogic Jul 11, 2025
467dbd3
repl: fix repl crashing on variable declarations without init
dario-piotrowicz Jul 11, 2025
623e264
tools: ignore CVE mention when linting release proposals
aduh95 Jul 13, 2025
d2e7f8e
doc: remove unused import in `zlib.md`
coderaiser Jul 14, 2025
6cb5e0d
doc: refine `util.parseArgs` `default` definition
Slayer95 Jul 15, 2025
1940a2c
doc: fix typed list formatting
avivkeller Jul 15, 2025
999b5e5
doc: run license-builder
github-actions[bot] Jul 16, 2025
2d1dcb8
doc: clarify ERR_FS_FILE_TOO_LARGE to reflect fs.readFile() I/O limit
haramj Jul 16, 2025
0e547e0
tools,test: enforce best practices to detect never settling promises
aduh95 Jul 16, 2025
9b2e965
doc: add RafaelGSS as steward July 25
RafaelGSS Jul 16, 2025
34c4900
doc: add missing section for `setReturnArrays` in `sqlite.md`
geeksilva97 Jul 17, 2025
e3e729c
build: remove suppressions.supp
RafaelGSS Jul 17, 2025
a9511a6
test: mark test-inspector-network-fetch as flaky on Windows
joyeecheung Jul 17, 2025
16dc53c
test: move http proxy tests to test/client-proxy
joyeecheung Jul 3, 2025
7f654ce
http,https: add built-in proxy support in http/https.request and Agent
joyeecheung Jul 1, 2025
324d9fc
meta: enable jsdoc/check-tag-names rule
anonrig Jul 18, 2025
135fca5
crypto: avoid copying buffers to UTF-8 strings in `crypto.hash()`
Renegade334 Jul 14, 2025
15e6c28
node-api,doc: update links to ecma262 with section names
legendecas Jul 18, 2025
9791ff3
worker: add web locks api
IlyasShabi May 29, 2025
b1a318d
doc: update release key for aduh95
aduh95 Jul 18, 2025
eeeb40e
crypto: add tls.setDefaultCACertificates()
joyeecheung Jul 18, 2025
71bb6cd
esm: js-string Wasm builtins in ESM Integration
guybedford Jul 10, 2025
1a44265
repl: handle errors from getters during completion
islandryu Jul 19, 2025
ef89c2f
src,test: fix config file parsing for flags defaulted to true
geeksilva97 Jul 20, 2025
8d869e6
fs: fix return value of fs APIs
theanarkh Jul 20, 2025
82d4175
test: update `startCLI` to set `--port=0` by default
dario-piotrowicz Jul 20, 2025
7fc3143
benchmark: reduce N for diagnostics_channel subscribe benchmark
artimmy Jul 20, 2025
88e434e
doc: add new environment variables doc page
dario-piotrowicz Jul 20, 2025
6f81b27
doc: fix typo in writing-test.md
SeokhunEom Jul 21, 2025
4ffa756
doc: avoid suggesting testing fast api with intense loop
legendecas Jul 21, 2025
83023e5
test: skip tests that cause timeouts on IBM i
abmusse Jul 21, 2025
d89390f
src: add cache to nearest parent package json
IlyasShabi Jul 21, 2025
f122602
deps: update corepack to 0.34.0
nodejs-github-bot Jul 22, 2025
fb52d0d
deps: upgrade openssl sources to openssl-3.0.17
nodejs-github-bot Jul 20, 2025
3f813ea
deps: update archs files for openssl-3.0.17
nodejs-github-bot Jul 20, 2025
15d8cc9
test: update WPT for WebCryptoAPI to 19d82c57ab
nodejs-github-bot Jul 20, 2025
c607004
test: update WPT for WebCryptoAPI to ab08796857
nodejs-github-bot Jul 21, 2025
51b8dfd
doc: add Aditi-1400 to collaborators
Aditi-1400 Jul 22, 2025
2a5f35b
deps: V8: cherry-pick 3d750c2aa9ef
targos Jun 18, 2025
f67b686
perf_hooks: do not expose SafeMap via Histogram wrapper
Renegade334 Jul 22, 2025
20be901
tools: bump @eslint/plugin-kit from 0.3.1 to 0.3.3 in /tools/eslint
dependabot[bot] Jul 22, 2025
72adf52
deps: update ada to 3.2.6
nodejs-github-bot Jul 22, 2025
88b99ee
src: remove declarations of removed BaseObject static fns
addaleax Jul 22, 2025
b919fe0
esm: unflag --experimental-wasm-modules
guybedford Feb 13, 2025
bfe4781
deps: update googletest to 7e17b15
nodejs-github-bot Jul 22, 2025
a34e445
deps: update sqlite to 3.50.3
nodejs-github-bot Jul 22, 2025
af789d9
deps: update undici to 7.12.0
nodejs-github-bot Jul 23, 2025
2b5d451
deps: update amaro to 1.1.1
nodejs-github-bot Jul 23, 2025
96c9dd7
meta: move one or more collaborators to emeritus
nodejs-github-bot Jul 23, 2025
7e0a0fc
test: expand linting rules around `assert` w literal messages
addaleax Jul 23, 2025
86babf9
src: use C++20 `consteval` for `FastStringKey`
addaleax Jul 21, 2025
77649ad
src: use `FastStringKey` for `TrackV8FastApiCall`
addaleax Jul 21, 2025
075d196
util: respect nested formats in styleText
himself65 Jul 23, 2025
dfb72d1
doc: add constraints for mem leak to threat model
RafaelGSS Jul 24, 2025
06cd746
doc: improve onboarding instructions
joyeecheung Jul 24, 2025
51f578a
tools: add support for URLs to PR commits in `merge.sh`
aduh95 Jul 24, 2025
d5640ca
cli: support `${pid}` placeholder in --cpu-prof-name
haramj Jul 24, 2025
3da5bc0
doc: fix broken sentence in `URL.parse`
SuperchupuDev Jul 24, 2025
ad6757e
benchmark: fix sqlite-is-transaction
RafaelGSS Jul 24, 2025
09717eb
benchmark: drop misc/punycode benchmark
RafaelGSS Jul 24, 2025
a28d804
benchmark: small lint fix on _cli.js
RafaelGSS Jul 24, 2025
28538f2
benchmark: add --track to benchmark
RafaelGSS Jul 25, 2025
a0d22e9
test: remove timeout in test-https-proxy-request-handshake-failure
joyeecheung Jul 25, 2025
195d603
tools: clarify README linter error message
joyeecheung Jul 25, 2025
55838e7
src: call unmask after install signal handler
theanarkh Jul 25, 2025
5457c7a
benchmark: adjust configuration for string-decoder bench
RafaelGSS Jul 25, 2025
3d2f919
process: make execve's args argument optional
mureinik Jul 26, 2025
9a8d202
doc: copyedit SECURITY.md
Trott Jul 26, 2025
1c3aadb
test: fix flaky test-worker-message-port-transfer-filehandle test
himself65 Jul 26, 2025
55a90ee
deps: upgrade npm to 11.5.1
npm-cli-bot Jul 26, 2025
fe0195f
module: fix conditions override in synchronous resolve hooks
joyeecheung Jul 26, 2025
f281272
buffer: cache Environment::GetCurrent to avoid repeated calls
mertcanaltin Jul 26, 2025
f5da494
cli: add --use-env-proxy
joyeecheung Jul 26, 2025
39978f5
test: prepare test-crypto-rsa-dsa for newer OpenSSL
richardlau May 1, 2025
dc66422
build,deps,tools: prepare to update to OpenSSL 3.5
richardlau Jul 25, 2025
ba8e95a
test: use mustSucceed in test-fs-read
mete0rfish Jul 27, 2025
1e99086
test: mark web lock held test as flaky
IlyasShabi Jul 27, 2025
927742b
doc: update the instruction on how to verify releases
aduh95 Jul 27, 2025
1f06ca9
deps: upgrade openssl sources to openssl-3.5.1
nodejs-github-bot Jul 27, 2025
998cef1
deps: update archs files for openssl-3.5.1
nodejs-github-bot Jul 27, 2025
931ec10
2025-07-31, Version 24.5.0 (Current)
aduh95 Jul 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
net: update net.blocklist to allow file save and file management
PR-URL: #58087
Fixes: #56252
Reviewed-By: Ethan Arrowood <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
alphaleadership authored and targos committed Jul 17, 2025
commit f753645cd80853817ea91a8840af643f6a62b26b
32 changes: 32 additions & 0 deletions doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,38 @@ added:
* `value` {any} Any JS value
* Returns `true` if the `value` is a `net.BlockList`.

### `blockList.fromJSON(value)`

> Stability: 1 - Experimental

<!-- YAML
added: REPLACEME
-->

```js
const blockList = new net.BlockList();
const data = [
'Subnet: IPv4 192.168.1.0/24',
'Address: IPv4 10.0.0.5',
'Range: IPv4 192.168.2.1-192.168.2.10',
'Range: IPv4 10.0.0.1-10.0.0.10',
];
blockList.fromJSON(data);
blockList.fromJSON(JSON.stringify(data));
```

* `value` Blocklist.rules

### `blockList.toJSON()`

> Stability: 1 - Experimental

<!-- YAML
added: REPLACEME
-->

* Returns Blocklist.rules

## Class: `net.SocketAddress`

<!-- YAML
Expand Down
126 changes: 125 additions & 1 deletion lib/internal/blocklist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';

const {
ArrayIsArray,
Boolean,
JSONParse,
NumberParseInt,
ObjectSetPrototypeOf,
Symbol,
} = primordials;
Expand Down Expand Up @@ -32,6 +35,7 @@ const { owner_symbol } = internalBinding('symbols');

const {
ERR_INVALID_ARG_VALUE,
ERR_INVALID_ARG_TYPE,
} = require('internal/errors').codes;

const { validateInt32, validateString } = require('internal/validators');
Expand Down Expand Up @@ -139,10 +143,130 @@ class BlockList {
return Boolean(this[kHandle].check(address[kSocketAddressHandle]));
}

/*
* @param {string[]} data
* @example
* const data = [
* // IPv4 examples
* 'Subnet: IPv4 192.168.1.0/24',
* 'Address: IPv4 10.0.0.5',
* 'Range: IPv4 192.168.2.1-192.168.2.10',
* 'Range: IPv4 10.0.0.1-10.0.0.10',
*
* // IPv6 examples
* 'Subnet: IPv6 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64',
* 'Address: IPv6 2001:0db8:85a3:0000:0000:8a2e:0370:7334',
* 'Range: IPv6 2001:0db8:85a3:0000:0000:8a2e:0370:7334-2001:0db8:85a3:0000:0000:8a2e:0370:7335',
* 'Subnet: IPv6 2001:db8:1234::/48',
* 'Address: IPv6 2001:db8:1234::1',
* 'Range: IPv6 2001:db8:1234::1-2001:db8:1234::10'
* ];
*/
#parseIPInfo(data) {
for (const item of data) {
if (item.includes('IPv4')) {
const subnetMatch = item.match(
/Subnet: IPv4 (\d{1,3}(?:\.\d{1,3}){3})\/(\d{1,2})/,
);
if (subnetMatch) {
const { 1: network, 2: prefix } = subnetMatch;
this.addSubnet(network, NumberParseInt(prefix));
continue;
}
const addressMatch = item.match(/Address: IPv4 (\d{1,3}(?:\.\d{1,3}){3})/);
if (addressMatch) {
const { 1: address } = addressMatch;
this.addAddress(address);
continue;
}

const rangeMatch = item.match(
/Range: IPv4 (\d{1,3}(?:\.\d{1,3}){3})-(\d{1,3}(?:\.\d{1,3}){3})/,
);
if (rangeMatch) {
const { 1: start, 2: end } = rangeMatch;
this.addRange(start, end);
continue;
}
}
// IPv6 parsing with support for compressed addresses
if (item.includes('IPv6')) {
// IPv6 subnet pattern: supports both full and compressed formats
// Examples:
// - 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64 (full)
// - 2001:db8:85a3::8a2e:370:7334/64 (compressed)
// - 2001:db8:85a3::192.0.2.128/64 (mixed)
const ipv6SubnetMatch = item.match(
/Subnet: IPv6 ([0-9a-fA-F:]{1,39})\/([0-9]{1,3})/i,
);
if (ipv6SubnetMatch) {
const { 1: network, 2: prefix } = ipv6SubnetMatch;
this.addSubnet(network, NumberParseInt(prefix), 'ipv6');
continue;
}

// IPv6 address pattern: supports both full and compressed formats
// Examples:
// - 2001:0db8:85a3:0000:0000:8a2e:0370:7334 (full)
// - 2001:db8:85a3::8a2e:370:7334 (compressed)
// - 2001:db8:85a3::192.0.2.128 (mixed)
const ipv6AddressMatch = item.match(/Address: IPv6 ([0-9a-fA-F:]{1,39})/i);
if (ipv6AddressMatch) {
const { 1: address } = ipv6AddressMatch;
this.addAddress(address, 'ipv6');
continue;
}

// IPv6 range pattern: supports both full and compressed formats
// Examples:
// - 2001:0db8:85a3:0000:0000:8a2e:0370:7334-2001:0db8:85a3:0000:0000:8a2e:0370:7335 (full)
// - 2001:db8:85a3::8a2e:370:7334-2001:db8:85a3::8a2e:370:7335 (compressed)
// - 2001:db8:85a3::192.0.2.128-2001:db8:85a3::192.0.2.129 (mixed)
const ipv6RangeMatch = item.match(/Range: IPv6 ([0-9a-fA-F:]{1,39})-([0-9a-fA-F:]{1,39})/i);
if (ipv6RangeMatch) {
const { 1: start, 2: end } = ipv6RangeMatch;
this.addRange(start, end, 'ipv6');
continue;
}
}
}
}


toJSON() {
return this.rules;
}

fromJSON(data) {
// The data argument must be a string, or an array of strings that
// is JSON parseable.
if (ArrayIsArray(data)) {
for (const n of data) {
if (typeof n !== 'string') {
throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
}
}
} else if (typeof data !== 'string') {
throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
} else {
data = JSONParse(data);
if (!ArrayIsArray(data)) {
throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
}
for (const n of data) {
if (typeof n !== 'string') {
throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
}
}
}

this.#parseIPInfo(data);
}


get rules() {
return this[kHandle].getRules();
}

[kClone]() {
const handle = this[kHandle];
return {
Expand Down
72 changes: 72 additions & 0 deletions test/parallel/test-blocklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,75 @@ const util = require('util');
assert(BlockList.isBlockList(new BlockList()));
assert(!BlockList.isBlockList({}));
}

// Test exporting and importing the rule list to/from JSON
{
const ruleList = [
'Address: IPv4 10.0.0.5',
'Address: IPv6 ::',
'Subnet: IPv4 192.168.1.0/24',
'Subnet: IPv6 8592:757c:efae:4e45::/64',
];

const test2 = new BlockList();
const test3 = new BlockList();
const test4 = new BlockList();
const test5 = new BlockList();

const bl = new BlockList();
bl.addAddress('10.0.0.5');
bl.addAddress('::', 'ipv6');
bl.addSubnet('192.168.1.0', 24);
bl.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');

// Test invalid inputs (input to fromJSON must be an array of
// string rules or a serialized json string of an array of
// string rules.
[
1, null, Symbol(), [1, 2, 3], '123', [Symbol()], new Map(),
].forEach((i) => {
assert.throws(() => test2.fromJSON(i), {
code: 'ERR_INVALID_ARG_TYPE',
});
});

// Invalid rules are ignored.
test2.fromJSON(['1', '2', '3']);
assert.deepStrictEqual(test2.rules, []);

// Direct output from toJSON method works
test2.fromJSON(bl.toJSON());
assert.deepStrictEqual(test2.rules.sort(), ruleList);

// JSON stringified output works
test3.fromJSON(JSON.stringify(bl));
assert.deepStrictEqual(test3.rules.sort(), ruleList);

// A raw array works
test4.fromJSON(ruleList);
assert.deepStrictEqual(test4.rules.sort(), ruleList);

// Individual rules work
ruleList.forEach((item) => {
test5.fromJSON([item]);
});
assert.deepStrictEqual(test5.rules.sort(), ruleList);

// Each of the created blocklists should handle the checks identically.
[
['10.0.0.5', 'ipv4', true],
['10.0.0.6', 'ipv4', false],
['::', 'ipv6', true],
['::1', 'ipv6', false],
['192.168.1.0', 'ipv4', true],
['193.168.1.0', 'ipv4', false],
['8592:757c:efae:4e45::', 'ipv6', true],
['1111:1111:1111:1111::', 'ipv6', false],
].forEach((i) => {
assert.strictEqual(bl.check(i[0], i[1]), i[2]);
assert.strictEqual(test2.check(i[0], i[1]), i[2]);
assert.strictEqual(test3.check(i[0], i[1]), i[2]);
assert.strictEqual(test4.check(i[0], i[1]), i[2]);
assert.strictEqual(test5.check(i[0], i[1]), i[2]);
});
}
1 change: 0 additions & 1 deletion test/parallel/test-net-blocklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const common = require('../common');
const net = require('net');
const assert = require('assert');

const blockList = new net.BlockList();
blockList.addAddress('127.0.0.1');
blockList.addAddress('127.0.0.2');
Expand Down