Add CrowdSec IP reputation and trusted IPs for reverse proxy#600
Add CrowdSec IP reputation and trusted IPs for reverse proxy#600
Conversation
📝 WalkthroughWalkthroughAdditive type and UI changes to introduce CrowdSec support: new CrowdSecMode constant/type and optional crowdsec fields on reverse-proxy interfaces; access-control UI and serialization updated to surface and persist CrowdSec mode when a domain supports it; event cells render CrowdSec-related auth methods and verdict metadata. Changes
Sequence Diagram(s)(Skipped) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/modules/reverse-proxy/table/ReverseProxyAccessControlCell.tsx (1)
110-117: Consider applying the same IPv6 fix to existing allowed/blocked CIDR filtering.For consistency, the allowed/blocked IP filtering at lines 110-117 should also handle
/128suffixes if IPv6 support is being added across the feature.Example fix for existing filters
const allowedIps = - restrictions?.allowed_cidrs?.filter((c) => c.endsWith("/32")) ?? []; + restrictions?.allowed_cidrs?.filter((c) => c.endsWith("/32") || c.endsWith("/128")) ?? []; const allowedCidrs = - restrictions?.allowed_cidrs?.filter((c) => !c.endsWith("/32")) ?? []; + restrictions?.allowed_cidrs?.filter((c) => !c.endsWith("/32") && !c.endsWith("/128")) ?? []; const blockedIps = - restrictions?.blocked_cidrs?.filter((c) => c.endsWith("/32")) ?? []; + restrictions?.blocked_cidrs?.filter((c) => c.endsWith("/32") || c.endsWith("/128")) ?? []; const blockedCidrs = - restrictions?.blocked_cidrs?.filter((c) => !c.endsWith("/32")) ?? []; + restrictions?.blocked_cidrs?.filter((c) => !c.endsWith("/32") && !c.endsWith("/128")) ?? [];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/modules/reverse-proxy/table/ReverseProxyAccessControlCell.tsx` around lines 110 - 117, Update the CIDR filtering in ReverseProxyAccessControlCell.tsx so the allowed/blocked IP lists treat IPv6 host addresses the same as IPv4: change the .endsWith("/32") checks used to populate allowedIps and blockedIps to also accept "/128" (e.g., treat strings that end with "/32" OR "/128" as single-host IPs) and invert that logic for allowedCidrs and blockedCidrs (keep entries that do not end with "/32" AND do not end with "/128"); update the expressions that compute allowedIps, allowedCidrs, blockedIps, and blockedCidrs accordingly so IPv6 single-address CIDRs are classified consistently with IPv4.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/modules/reverse-proxy/table/ReverseProxyAccessControlCell.tsx`:
- Around line 110-117: Update the CIDR filtering in
ReverseProxyAccessControlCell.tsx so the allowed/blocked IP lists treat IPv6
host addresses the same as IPv4: change the .endsWith("/32") checks used to
populate allowedIps and blockedIps to also accept "/128" (e.g., treat strings
that end with "/32" OR "/128" as single-host IPs) and invert that logic for
allowedCidrs and blockedCidrs (keep entries that do not end with "/32" AND do
not end with "/128"); update the expressions that compute allowedIps,
allowedCidrs, blockedIps, and blockedCidrs accordingly so IPv6 single-address
CIDRs are classified consistently with IPv4.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 228346a6-219f-4254-a28b-7fc853939eb2
📒 Files selected for processing (6)
src/interfaces/ReverseProxy.tssrc/modules/reverse-proxy/ReverseProxyAccessControlRules.tsxsrc/modules/reverse-proxy/ReverseProxyModal.tsxsrc/modules/reverse-proxy/events/ReverseProxyEventsAuthMethodCell.tsxsrc/modules/reverse-proxy/events/ReverseProxyEventsReasonCell.tsxsrc/modules/reverse-proxy/table/ReverseProxyAccessControlCell.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/modules/reverse-proxy/ReverseProxyAccessControlRules.tsx`:
- Around line 142-144: The ip rule normalization currently preserves
user-supplied CIDR suffixes which can widen access; update the logic that builds
allowed_cidrs so when rule.type === "ip" you first strip any existing CIDR
suffix from rule.value and then append the host mask (use "/128" for IPv6 when
rule.value includes ":" else "/32" for IPv4), and continue to push that
normalized value into allowed_cidrs when rule.action === "allow" (refer to the
variables rule.type, rule.value, suffix, value, and allowed_cidrs in
ReverseProxyAccessControlRules.tsx).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3d8f49ff-ff0a-4c01-a546-7e18182e1263
📒 Files selected for processing (3)
src/interfaces/ReverseProxy.tssrc/modules/reverse-proxy/ReverseProxyAccessControlRules.tsxsrc/modules/reverse-proxy/table/ReverseProxyAccessControlCell.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/interfaces/ReverseProxy.ts
| const suffix = rule.value.includes(":") ? "/128" : "/32"; | ||
| const value = rule.type === "ip" && !rule.value.includes("/") ? `${rule.value}${suffix}` : rule.value; | ||
| if (rule.action === "allow") allowed_cidrs.push(value); |
There was a problem hiding this comment.
Normalize ip rules to host masks unconditionally.
ip rules currently keep user-provided CIDR suffixes (e.g., /24, /64) when present, which can silently turn an IP rule into a range rule and broaden access-control scope.
Proposed fix
- const suffix = rule.value.includes(":") ? "/128" : "/32";
- const value = rule.type === "ip" && !rule.value.includes("/") ? `${rule.value}${suffix}` : rule.value;
+ const rawValue = rule.value.split("/")[0];
+ const suffix = rawValue.includes(":") ? "/128" : "/32";
+ const value = rule.type === "ip" ? `${rawValue}${suffix}` : rule.value;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/modules/reverse-proxy/ReverseProxyAccessControlRules.tsx` around lines
142 - 144, The ip rule normalization currently preserves user-supplied CIDR
suffixes which can widen access; update the logic that builds allowed_cidrs so
when rule.type === "ip" you first strip any existing CIDR suffix from rule.value
and then append the host mask (use "/128" for IPv6 when rule.value includes ":"
else "/32" for IPv4), and continue to push that normalized value into
allowed_cidrs when rule.action === "allow" (refer to the variables rule.type,
rule.value, suffix, value, and allowed_cidrs in
ReverseProxyAccessControlRules.tsx).
Add CrowdSec IP reputation integration and trusted IP support to the reverse proxy access control UI.
Issue ticket number and link
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
netbirdio/docs#698
Related PRs