-
Notifications
You must be signed in to change notification settings - Fork 134
Add CrowdSec IP reputation #600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5ddeebf
Add CrowdSec IP reputation and access control UI for reverse proxy se…
lixmal d882360
Fix IPv6 single-host CIDR detection in access control rules
lixmal 57faaf5
Remove trusted_cidrs from CrowdSec integration
lixmal fcfc0bf
Update crowdsec selection
heisbrot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/modules/reverse-proxy/ReverseProxyCrowdSecIPReputation.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import * as React from "react"; | ||
| import { ReactNode } from "react"; | ||
| import { Label } from "@components/Label"; | ||
| import HelpText from "@components/HelpText"; | ||
| import { | ||
| Select, | ||
| SelectContent, | ||
| SelectItem, | ||
| SelectTrigger, | ||
| SelectValue, | ||
| } from "@components/Select"; | ||
| import { EyeIcon, PowerOffIcon, ShieldCheckIcon } from "lucide-react"; | ||
| import { HelpTooltip } from "@components/HelpTooltip"; | ||
| import { CrowdSecMode } from "@/interfaces/ReverseProxy"; | ||
| import Image from "next/image"; | ||
| import CrowdSecIconImage from "@/assets/integrations/crowdsec.png"; | ||
|
|
||
| type Props = { | ||
| value: CrowdSecMode; | ||
| onChange: (value: CrowdSecMode) => void; | ||
| }; | ||
|
|
||
| type CrowdSecOption = { | ||
| label: string; | ||
| description?: string; | ||
| icon: ReactNode; | ||
| }; | ||
|
|
||
| const CROWDSEC_OPTIONS: Record<CrowdSecMode, CrowdSecOption> = { | ||
| [CrowdSecMode.OFF]: { | ||
| label: "Disabled", | ||
| icon: <PowerOffIcon size={14} />, | ||
| }, | ||
| [CrowdSecMode.ENFORCE]: { | ||
| label: "Enforce", | ||
| description: | ||
| "Blocked IPs are denied immediately. If the bouncer is not yet synced, connections are denied (fail-closed).", | ||
| icon: <ShieldCheckIcon size={14} />, | ||
| }, | ||
| [CrowdSecMode.OBSERVE]: { | ||
| label: "Observe", | ||
| description: | ||
| "Blocked IPs are logged but not denied. Use this to evaluate CrowdSec before enforcing.", | ||
| icon: <EyeIcon size={14} />, | ||
| }, | ||
| }; | ||
|
|
||
| export const ReverseProxyCrowdSecIPReputation = ({ | ||
| value, | ||
| onChange, | ||
| }: Props) => { | ||
| const selected = CROWDSEC_OPTIONS[value]; | ||
|
|
||
| return ( | ||
| <div className="flex items-center gap-0 justify-between mb-6"> | ||
| <div className="flex gap-4"> | ||
| <div | ||
| className={ | ||
| "h-12 w-12 flex items-center justify-center rounded-md bg-nb-gray-900/70 p-2 border border-nb-gray-900/70 shrink-0 relative" | ||
| } | ||
| > | ||
| <Image | ||
| src={CrowdSecIconImage} | ||
| alt={"CrowdSec"} | ||
| className={"rounded-[4px]"} | ||
| /> | ||
| </div> | ||
| <div> | ||
| <Label>CrowdSec IP Reputation</Label> | ||
| <HelpText> | ||
| Detect malicious IPs with CrowdSec.{" "} | ||
| <b className={"text-white"}>Enforce</b> to block them or{" "} | ||
| <b className={"text-white"}>Observe</b> to only log without | ||
| blocking. | ||
| </HelpText> | ||
| </div> | ||
| </div> | ||
|
|
||
| <Select value={value} onValueChange={(v) => onChange(v as CrowdSecMode)}> | ||
| <SelectTrigger className="w-[260px]"> | ||
| <div className="flex items-center gap-2 whitespace-nowrap"> | ||
| {selected.icon} | ||
| <SelectValue /> | ||
| </div> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| {Object.entries(CROWDSEC_OPTIONS).map(([mode, config]) => ( | ||
| <SelectItem | ||
| key={mode} | ||
| value={mode} | ||
| extra={ | ||
| config.description ? ( | ||
| <HelpTooltip | ||
| triggerClassName="ml-[0.01rem]" | ||
| align="center" | ||
| side="right" | ||
| content={<>{config.description}</>} | ||
| /> | ||
| ) : undefined | ||
| } | ||
| > | ||
| <span className="whitespace-nowrap">{config.label}</span> | ||
| </SelectItem> | ||
| ))} | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.