@@ -5,36 +5,72 @@ This script generates the ECS mappings for the Wazuh indices.
5
5
### Requirements
6
6
7
7
- ECS repository clone. The script is meant to be launched from the root level of that repository.
8
- - Python 3.6 or higher
9
- - jq
8
+ - ` Python ` 3.6 or higher + ` venv ` module
9
+ - ` jq `
10
10
11
- ### Folder structrue
11
+ ### Folder structure
12
12
13
13
There is a folder for each module. Inside each folder, there is a ` fields ` folder with the required
14
14
files to generate the mappings. These are the inputs for the ECS generator.
15
15
16
16
### Usage
17
17
18
- ** Copy the ` generate.sh ` script to the root level of the ECS repository. **
18
+ 1 . Get a copy of the ECS repository at the same level as the ` wazuh-indexer ` repo:
19
19
20
- Use the ` generate.sh ` script to generate the mappings for a module. The script takes 3 arguments,
21
- plus 2 optional arguments to upload the mappings to the Wazuh indexer (using ** composable** indexes).
20
+ ``` console
21
+ git clone [email protected] :elastic/ecs.git
22
+ ```
22
23
23
- ``` plaintext
24
- Usage: ./generate.sh <ECS_VERSION> <INDEXER_SRC> <MODULE> [--upload <URL>]
25
- * ECS_VERSION: ECS version to generate mappings for
26
- * INDEXER_SRC: Path to the wazuh-indexer repository
27
- * MODULE: Module to generate mappings for
28
- * --upload <URL>: Upload generated index template to the OpenSearch cluster. Defaults to https://localhost:9200
29
- Example: ./generate.sh v8.10.0 ~/wazuh-indexer vulnerability-detector --upload https://indexer:9200
30
- ```
24
+ 2. Install the dependencies:
31
25
32
- For example, to generate the mappings for the ` vulnerability-detector ` module using the
33
- ECS version ` v8.10.0 ` and the Wazuh indexer in path ` ~/wazuh/wazuh-indexer ` :
26
+ ```console
27
+ cd ecs
28
+ python3 -m venv env
29
+ source env/bin/activate
30
+ pip install -r scripts/requirements.txt
31
+ ```
34
32
35
- ``` bash
36
- ./generate.sh v8.10.0 ~ /wazuh/wazuh-indexer vulnerability-detector
37
- ```
33
+ 2. Copy the `generate.sh` script to the root level of the ECS repository.
34
+
35
+ ```console
36
+ cp generate.sh ../../ecs
37
+ cd ../../ecs
38
+ bash generate.sh
39
+ ```
40
+
41
+ Expected output:
42
+ ```
43
+ Usage: generate.sh <ECS_VERSION> <INDEXER_SRC> <MODULE> [--upload <URL>]
44
+ * ECS_VERSION: ECS version to generate mappings for
45
+ * INDEXER_SRC: Path to the wazuh-indexer repository
46
+ * MODULE: Module to generate mappings for
47
+ * --upload <URL>: Upload generated index template to the OpenSearch cluster. Defaults to https://localhost:9200
48
+ Example: generate.sh v8.10.0 ~/wazuh-indexer vulnerability-detector --upload https://indexer:9200
49
+ ```
50
+
51
+ 3. Use the `generate.sh` script to generate the mappings for a module. The script takes 3 arguments,
52
+ plus 2 optional arguments to upload the mappings to the `wazuh-indexer`. Both, composable and legacy mappings
53
+ are generated. For example, to generate the mappings for the `vulnerability-detector` module using the
54
+ ECS version `v8.10.0` and assuming that path of this repository is `~/wazuh/wazuh-indexer`:
55
+
56
+ ```bash
57
+ ./generate.sh v8.10.0 ~/wazuh/wazuh-indexer vulnerability-detector
58
+ ```
59
+
60
+ The tool will output the folder where they have been generated.
61
+
62
+ ```console
63
+ Loading schemas from git ref v8.10.0
64
+ Running generator. ECS version 8.10.0
65
+ Replacing "match_only_text" type with "text"
66
+ Mappings saved to ~/wazuh/wazuh-indexer/ecs/vulnerability-detector/mappings/v8.10.0
67
+ ```
68
+
69
+ 4. When you are done. Exit the virtual environment.
70
+
71
+ ```console
72
+ deactivate
73
+ ```
38
74
39
75
### Output
40
76
@@ -48,8 +84,8 @@ For our use case, the most important files are under `mappings/<ECS_VERSION>/gen
48
84
The original output is `template.json`, which is not compatible with OpenSearch by default. In order
49
85
to make this template compatible with OpenSearch, the following changes are made:
50
86
51
- - the ` order ` property is renamed to ` priority ` .
52
- - the ` mappings ` and ` settings ` properties are nested under the ` template ` property.
87
+ - The `order` property is renamed to `priority`.
88
+ - The `mappings` and `settings` properties are nested under the `template` property.
53
89
54
90
The script takes care of these changes automatically, generating the `opensearch-template.json` file as a result.
55
91
@@ -62,7 +98,7 @@ curl -u admin:admin -k -X PUT "https://indexer:9200/_index_template/wazuh-vulner
62
98
```
63
99
64
100
Notes:
65
- - PUT and POST are interchangable .
101
+ - PUT and POST are interchangeable .
66
102
- The name of the index template does not matter. Any name can be used.
67
103
- Adjust credentials and URL accordingly.
68
104
@@ -95,7 +131,7 @@ The script will generate a JSON file with the events, and will also ask whether
95
131
indexer. If the upload option is selected, the script will ask for the indexer URL and port, credentials,
96
132
and index name.
97
133
98
- The script uses log file. Check it out for debugging or additonal information.
134
+ The script uses log file. Check it out for debugging or additional information.
99
135
100
136
#### References
101
137
0 commit comments