@@ -35,13 +35,13 @@ type Config struct {
3535 CrowdSecAcquisFile string
3636
3737 // CrowdSec container-internal paths and URLs
38- CrowdSecWhitelistPath string
39- CrowdSecProfilesPath string
40- CrowdSecNotificationsDir string
41- CrowdSecScenariosDir string
42- CrowdSecMetricsURL string
43- CrowdSecConsoleURL string
44- CrowdSecCTIURLPattern string
38+ CrowdSecWhitelistPath string
39+ CrowdSecProfilesPath string
40+ CrowdSecNotificationsDir string
41+ CrowdSecScenariosDir string
42+ CrowdSecMetricsURL string
43+ CrowdSecConsoleURL string
44+ CrowdSecCTIURLPattern string
4545
4646 // Traefik container-internal paths
4747 TraefikCaptchaHTMLPath string
@@ -60,14 +60,17 @@ type Config struct {
6060 GerbilContainerName string
6161 TraefikContainerName string
6262
63-
6463 // Services
6564 Services []string
6665 ServicesWithCrowdsec []string
6766 IncludeCrowdsec bool
6867 IncludePangolin bool
6968 IncludeGerbil bool
7069
70+ // CrowdSec list limits (0 = unlimited)
71+ DecisionListLimit int
72+ AlertListLimit int
73+
7174 // NATS Messaging (optional)
7275 NatsURL string
7376 NatsToken string
@@ -83,37 +86,37 @@ type Config struct {
8386// It also creates required directories and dynamically builds service lists from compose file
8487func Load () (* Config , error ) {
8588 cfg := & Config {
86- Port : getEnvAsInt ("PORT" , 8080 ),
87- Environment : getEnv ("ENVIRONMENT" , "development" ),
88- LogLevel : getEnv ("LOG_LEVEL" , "info" ),
89- LogFile : getEnv ("LOG_FILE" , "./logs/crowdsec-manager.log" ),
90- DockerHost : getEnv ("DOCKER_HOST" , "" ),
91- DockerHosts : getEnv ("DOCKER_HOSTS" , "" ),
92- ComposeFile : getEnv ("COMPOSE_FILE" , "./docker-compose.yml" ),
93- PangolinDir : getEnv ("PANGOLIN_DIR" , "." ),
94- ConfigDir : getEnv ("CONFIG_DIR" , "./config" ),
95- DatabasePath : getEnv ("DATABASE_PATH" , "./data/settings.db" ),
96- TraefikDynamicConfig : getEnv ("TRAEFIK_DYNAMIC_CONFIG" , "/etc/traefik/dynamic_config.yml" ),
97- TraefikStaticConfig : getEnv ("TRAEFIK_STATIC_CONFIG" , "/etc/traefik/traefik_config.yml" ),
98- TraefikAccessLog : getEnv ("TRAEFIK_ACCESS_LOG" , "/var/log/traefik/access.log" ),
99- TraefikErrorLog : getEnv ("TRAEFIK_ERROR_LOG" , "/var/log/traefik/traefik.log" ),
100- CrowdSecAcquisFile : getEnv ("CROWDSEC_ACQUIS_FILE" , "/etc/crowdsec/acquis.yaml" ),
101- CrowdSecWhitelistPath : getEnv ("CROWDSEC_WHITELIST_PATH" , "/etc/crowdsec/parsers/s02-enrich/mywhitelists.yaml" ),
102- CrowdSecProfilesPath : getEnv ("CROWDSEC_PROFILES_PATH" , "/etc/crowdsec/profiles.yaml" ),
103- CrowdSecNotificationsDir : getEnv ("CROWDSEC_NOTIFICATIONS_DIR" , "/etc/crowdsec/notifications" ),
104- CrowdSecScenariosDir : getEnv ("CROWDSEC_SCENARIOS_DIR" , "/etc/crowdsec/scenarios" ),
105- CrowdSecMetricsURL : getEnv ("CROWDSEC_METRICS_URL" , "http://localhost:6060/metrics" ),
106- CrowdSecConsoleURL : getEnv ("CROWDSEC_CONSOLE_URL" , "https://app.crowdsec.net/" ),
107- CrowdSecCTIURLPattern : getEnv ("CROWDSEC_CTI_URL_PATTERN" , "https://app.crowdsec.net/cti/{{.Value}}" ),
108- TraefikCaptchaHTMLPath : getEnv ("TRAEFIK_CAPTCHA_HTML_PATH" , "/etc/traefik/conf/captcha.html" ),
109- TraefikCaptchaEnvPath : getEnv ("TRAEFIK_CAPTCHA_ENV_PATH" , "/etc/traefik/captcha.env" ),
89+ Port : getEnvAsInt ("PORT" , 8080 ),
90+ Environment : getEnv ("ENVIRONMENT" , "development" ),
91+ LogLevel : getEnv ("LOG_LEVEL" , "info" ),
92+ LogFile : getEnv ("LOG_FILE" , "./logs/crowdsec-manager.log" ),
93+ DockerHost : getEnv ("DOCKER_HOST" , "" ),
94+ DockerHosts : getEnv ("DOCKER_HOSTS" , "" ),
95+ ComposeFile : getEnv ("COMPOSE_FILE" , "./docker-compose.yml" ),
96+ PangolinDir : getEnv ("PANGOLIN_DIR" , "." ),
97+ ConfigDir : getEnv ("CONFIG_DIR" , "./config" ),
98+ DatabasePath : getEnv ("DATABASE_PATH" , "./data/settings.db" ),
99+ TraefikDynamicConfig : getEnv ("TRAEFIK_DYNAMIC_CONFIG" , "/etc/traefik/dynamic_config.yml" ),
100+ TraefikStaticConfig : getEnv ("TRAEFIK_STATIC_CONFIG" , "/etc/traefik/traefik_config.yml" ),
101+ TraefikAccessLog : getEnv ("TRAEFIK_ACCESS_LOG" , "/var/log/traefik/access.log" ),
102+ TraefikErrorLog : getEnv ("TRAEFIK_ERROR_LOG" , "/var/log/traefik/traefik.log" ),
103+ CrowdSecAcquisFile : getEnv ("CROWDSEC_ACQUIS_FILE" , "/etc/crowdsec/acquis.yaml" ),
104+ CrowdSecWhitelistPath : getEnv ("CROWDSEC_WHITELIST_PATH" , "/etc/crowdsec/parsers/s02-enrich/mywhitelists.yaml" ),
105+ CrowdSecProfilesPath : getEnv ("CROWDSEC_PROFILES_PATH" , "/etc/crowdsec/profiles.yaml" ),
106+ CrowdSecNotificationsDir : getEnv ("CROWDSEC_NOTIFICATIONS_DIR" , "/etc/crowdsec/notifications" ),
107+ CrowdSecScenariosDir : getEnv ("CROWDSEC_SCENARIOS_DIR" , "/etc/crowdsec/scenarios" ),
108+ CrowdSecMetricsURL : getEnv ("CROWDSEC_METRICS_URL" , "http://localhost:6060/metrics" ),
109+ CrowdSecConsoleURL : getEnv ("CROWDSEC_CONSOLE_URL" , "https://app.crowdsec.net/" ),
110+ CrowdSecCTIURLPattern : getEnv ("CROWDSEC_CTI_URL_PATTERN" , "https://app.crowdsec.net/cti/{{.Value}}" ),
111+ TraefikCaptchaHTMLPath : getEnv ("TRAEFIK_CAPTCHA_HTML_PATH" , "/etc/traefik/conf/captcha.html" ),
112+ TraefikCaptchaEnvPath : getEnv ("TRAEFIK_CAPTCHA_ENV_PATH" , "/etc/traefik/captcha.env" ),
110113 TraefikDynamicConfigSearch : []string {
111114 "/etc/traefik/config/dynamic_config.yml" ,
112115 "/etc/traefik/dynamic_config.yaml" ,
113116 "/etc/traefik/config/dynamic_config.yaml" ,
114117 },
115- CaptchaGracePeriod : getEnvAsInt ("CAPTCHA_GRACE_PERIOD" , 1800 ),
116- BackupDir : getEnv ("BACKUP_DIR" , "./backups" ),
118+ CaptchaGracePeriod : getEnvAsInt ("CAPTCHA_GRACE_PERIOD" , 1800 ),
119+ BackupDir : getEnv ("BACKUP_DIR" , "./backups" ),
117120 RetentionDays : getEnvAsInt ("RETENTION_DAYS" , 60 ),
118121 BackupItems : []string {"docker-compose.yml" , "config" },
119122 CrowdsecContainerName : getEnv ("CROWDSEC_CONTAINER_NAME" , "crowdsec" ),
@@ -123,6 +126,8 @@ func Load() (*Config, error) {
123126 IncludeCrowdsec : getEnvAsBool ("INCLUDE_CROWDSEC" , true ),
124127 IncludePangolin : getEnvAsBool ("INCLUDE_PANGOLIN" , true ),
125128 IncludeGerbil : getEnvAsBool ("INCLUDE_GERBIL" , true ),
129+ DecisionListLimit : getEnvAsInt ("DECISION_LIST_LIMIT" , 200 ),
130+ AlertListLimit : getEnvAsInt ("ALERT_LIST_LIMIT" , 200 ),
126131 NatsURL : getEnv ("NATS_URL" , "" ),
127132 NatsToken : getEnv ("NATS_TOKEN" , "" ),
128133 NatsEnabled : getEnvAsBool ("NATS_ENABLED" , false ),
@@ -212,6 +217,16 @@ func (c *Config) GetServices() []string {
212217 return c .Services
213218}
214219
220+ // EffectiveLimit returns the effective list limit, applying the hard safety cap.
221+ // If the configured limit is 0 (unlimited), it returns maxLimit.
222+ // If the configured limit exceeds maxLimit, it returns maxLimit.
223+ func EffectiveLimit (configured , maxLimit int ) int {
224+ if configured <= 0 || configured > maxLimit {
225+ return maxLimit
226+ }
227+ return configured
228+ }
229+
215230// getEnv retrieves an environment variable or returns the default value if not set
216231func getEnv (key , defaultValue string ) string {
217232 if value := os .Getenv (key ); value != "" {
0 commit comments