Commit Graph

9 Commits

Author SHA1 Message Date
supriyo-biswas
b6bc44f8bc
net: prevent /32 ipv4 mask from matching all ips
Fixes: https://github.com/nodejs/node/issues/43360

PR-URL: https://github.com/nodejs/node/pull/43381
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2022-06-25 13:47:27 +01:00
cjihrig
b82a1a1ac9 src: compare IPv4 addresses in host byte order
This commit updates compare_ipv4() to use the host byte
order.

PR-URL: https://github.com/nodejs/node/pull/39096
Fixes: https://github.com/nodejs/node/issues/39074
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-06-22 02:06:46 +00:00
James M Snell
e79471deb7
net: allow net.BlockList to use net.SocketAddress objects
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37917
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-04-02 06:16:42 -07:00
James M Snell
fb9257f659
net: make net.BlockList cloneable
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37917
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-04-02 06:16:38 -07:00
Rich Trott
330f25ef82 test: prepare for consistent comma-dangle lint rule
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.

PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
2021-04-01 23:14:29 -07:00
ZiJian Liu
9574e5b632
net: throw ERR_OUT_OF_RANGE if blockList.addSubnet prefix is NaN
Fixes: https://github.com/nodejs/node/issues/36731

PR-URL: https://github.com/nodejs/node/pull/36732
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-09 14:16:38 -08:00
Zijian Liu
ed3a4c8bca test: increase coverage for net/blocklist
1. test new BlockList with invalid args
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/internal/blocklist.js.html#L34

2. test addRange with invalid start and end
https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/internal/blocklist.js.html#L78

3. test blocklist addSubnet with invalid args
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/internal/blocklist.js.html#L81

4. test blocklist check with invalid args
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/internal/blocklist.js.html#L107

5. test util.inspect case
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/internal/blocklist.js.html#L39

PR-URL: https://github.com/nodejs/node/pull/36405
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2020-12-14 06:03:41 -08:00
James M Snell
37a8179673 net: make blocklist family case insensitive
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/34864
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-08-31 15:09:47 +00:00
James M Snell
1f9b20b637 net: introduce net.BlockList
`net.BlockList` provides an object intended to be used by net APIs to
specify rules for disallowing network activity with specific IP
addresses. This commit adds the basic mechanism but does not add the
specific uses.

PR-URL: https://github.com/nodejs/node/pull/34625
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
2020-08-11 11:13:17 -07:00