Skip to content

fix: normalize bare-IP restrictedAddresses entries against IPv6 embeddings - #1554

Open
tilak-patel-postman wants to merge 3 commits into
developfrom
fix/restricted-addresses-exact-match-normalization
Open

fix: normalize bare-IP restrictedAddresses entries against IPv6 embeddings#1554
tilak-patel-postman wants to merge 3 commits into
developfrom
fix/restricted-addresses-exact-match-normalization

Conversation

@tilak-patel-postman

Copy link
Copy Markdown
Contributor

Summary

isAddressRestricted() (added in #1548) applied IPv6-embedding normalization (IPv4-mapped, IPv4-compatible, NAT64, IPv4-translated, 6to4) only to entries written in CIDR notation. A bare exact-match entry (e.g. '169.254.169.254': true) was checked via string equality alone, so any differently-encoded literal of that same address — ::ffff:169.254.169.254, [::ffff:a9fe:a9fe], its NAT64 form, etc. — bypassed it entirely, even when unrelated CIDR entries existed elsewhere in the same restrictedAddresses map.

Fix

Every entry that parses as a valid IP — whether written as a CIDR ('10.0.0.0/8') or a bare address ('169.254.169.254') — is now promoted into the same restrictedCidrs list (bare IPv4 as /32, bare IPv6 as /128), so both forms get matched against the normalized/unwrapped address. Hostname entries (e.g. 'internal.corp') are unaffected — they fail IP parsing and stay covered by the exact-match branch only.

Scoped to lib/requester/core.js, no other files touched.

Test plan

  • Added 8 regression tests covering: mapped/bracketed/NAT64 forms of an exact-match-only entry, an unrelated IP still correctly not matching, an exact entry mixed with an unrelated CIDR entry, a bare IPv6 entry matched via a differently-formatted literal of the same address, and hostname-entry behavior unchanged (both positive and negative).
  • Full existing unit suite passes (109/109 including new tests).
  • npx eslint clean on both changed files.

Generated with Claude Code

…dings

isAddressRestricted() applied IPv6-embedding normalization (IPv4-mapped,
IPv4-compatible, NAT64, IPv4-translated, 6to4) only to entries written in
CIDR notation. A bare exact-match entry (e.g. '169.254.169.254') was
checked via string equality alone, so any differently-encoded literal of
that same address bypassed it -- even with unrelated CIDR entries present
elsewhere in the same list.

Promote every entry that parses as a valid IP -- CIDR or bare -- into the
same restrictedCidrs list (bare IPv4 as /32, bare IPv6 as /128), so both
forms get matched against the normalized address. Hostname entries (e.g.
'internal.corp') are unaffected -- they fail IP parsing and stay on the
exact-match branch only.

Follow-up to #1548.
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.60%. Comparing base (681f020) to head (c9fefc1).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1554      +/-   ##
===========================================
+ Coverage    77.54%   77.60%   +0.06%     
===========================================
  Files           51       51              
  Lines         4338     4350      +12     
  Branches      1223     1228       +5     
===========================================
+ Hits          3364     3376      +12     
  Misses         731      731              
  Partials       243      243              
Flag Coverage Δ
integration 68.75% <71.42%> (+0.04%) ⬆️
legacy 34.22% <0.00%> (-0.10%) ⬇️
unit 47.01% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants