Files
Charon/backend/internal/crowdsec/presets.go
GitHub Actions 3eadb2bee3 feat: enhance CrowdSec configuration tests and add new import/export functionality
- Added comprehensive tests for CrowdSec configuration, including preset application and validation error handling.
- Introduced new test cases for importing CrowdSec configurations, ensuring backup creation and successful import.
- Updated existing tests to reflect changes in UI elements and functionality, including toggling CrowdSec mode and exporting configurations.
- Created utility functions for building export filenames and handling downloads, improving code organization and reusability.
- Refactored existing tests to use new test IDs and ensure accurate assertions for UI elements and API calls.
2025-12-08 21:01:24 +00:00

56 lines
1.6 KiB
Go

package crowdsec
// Preset represents a curated CrowdSec preset offered by Charon.
type Preset struct {
Slug string `json:"slug"`
Title string `json:"title"`
Summary string `json:"summary"`
Source string `json:"source"`
Tags []string `json:"tags,omitempty"`
RequiresHub bool `json:"requires_hub"`
}
var curatedPresets = []Preset{
{
Slug: "honeypot-friendly-defaults",
Title: "Honeypot Friendly Defaults",
Summary: "Lightweight parser and collection set tuned to reduce noise for tarpits and honeypots.",
Source: "charon-curated",
Tags: []string{"low-noise", "ssh", "http"},
RequiresHub: false,
},
{
Slug: "bot-mitigation-essentials",
Title: "Bot Mitigation Essentials",
Summary: "Core scenarios for bad bots and credential stuffing with minimal false positives.",
Source: "charon-curated",
Tags: []string{"bots", "auth", "web"},
RequiresHub: false,
},
{
Slug: "geolocation-aware",
Title: "Geolocation Aware",
Summary: "Adds geo-aware decisions to tighten access by region; best paired with existing ACLs.",
Source: "charon-curated",
Tags: []string{"geo", "access-control"},
RequiresHub: false,
},
}
// ListCuratedPresets returns a copy of curated presets to avoid external mutation.
func ListCuratedPresets() []Preset {
out := make([]Preset, len(curatedPresets))
copy(out, curatedPresets)
return out
}
// FindPreset returns a preset by slug.
func FindPreset(slug string) (Preset, bool) {
for _, p := range curatedPresets {
if p.Slug == slug {
return p, true
}
}
return Preset{}, false
}