|
2 | 2 | //
|
3 | 3 | // # Definitions
|
4 | 4 | //
|
5 |
| -// - A hub ITEM is a file that defines a parser, a scenario, a collection... in the case of a collection, it has dependencies on other hub items. |
6 |
| -// - The hub INDEX is a JSON file that contains a tree of available hub items. |
7 |
| -// - A REMOTE HUB is an HTTP server that hosts the hub index and the hub items. It can serve from several branches, usually linked to the CrowdSec version. |
8 |
| -// - A LOCAL HUB is a directory that contains a copy of the hub index and the downloaded hub items. |
| 5 | +// - A hub ITEM is a file that defines a parser, a scenario, a collection... in the case of a collection, it has dependencies on other hub items. |
| 6 | +// - The hub INDEX is a JSON file that contains a tree of available hub items. |
| 7 | +// - A REMOTE HUB is an HTTP server that hosts the hub index and the hub items. It can serve from several branches, usually linked to the CrowdSec version. |
| 8 | +// - A LOCAL HUB is a directory that contains a copy of the hub index and the downloaded hub items. |
9 | 9 | //
|
10 | 10 | // Once downloaded, hub items can be installed by linking to them from the configuration directory.
|
11 | 11 | // If an item is present in the configuration directory but it's not a link to the local hub, it is
|
|
17 | 17 | //
|
18 | 18 | // For the local hub (HubDir = /etc/crowdsec/hub):
|
19 | 19 | //
|
20 |
| -// - /etc/crowdsec/hub/.index.json |
21 |
| -// - /etc/crowdsec/hub/parsers/{stage}/{author}/{parser-name}.yaml |
22 |
| -// - /etc/crowdsec/hub/scenarios/{author}/{scenario-name}.yaml |
| 20 | +// - /etc/crowdsec/hub/.index.json |
| 21 | +// - /etc/crowdsec/hub/parsers/{stage}/{author}/{parser-name}.yaml |
| 22 | +// - /etc/crowdsec/hub/scenarios/{author}/{scenario-name}.yaml |
23 | 23 | //
|
24 | 24 | // For the configuration directory (InstallDir = /etc/crowdsec):
|
25 | 25 | //
|
26 |
| -// - /etc/crowdsec/parsers/{stage}/{parser-name.yaml} -> /etc/crowdsec/hub/parsers/{stage}/{author}/{parser-name}.yaml |
27 |
| -// - /etc/crowdsec/scenarios/{scenario-name.yaml} -> /etc/crowdsec/hub/scenarios/{author}/{scenario-name}.yaml |
28 |
| -// - /etc/crowdsec/scenarios/local-scenario.yaml |
| 26 | +// - /etc/crowdsec/parsers/{stage}/{parser-name.yaml} -> /etc/crowdsec/hub/parsers/{stage}/{author}/{parser-name}.yaml |
| 27 | +// - /etc/crowdsec/scenarios/{scenario-name.yaml} -> /etc/crowdsec/hub/scenarios/{author}/{scenario-name}.yaml |
| 28 | +// - /etc/crowdsec/scenarios/local-scenario.yaml |
29 | 29 | //
|
30 | 30 | // Note that installed items are not grouped by author, this may change in the future if we want to
|
31 | 31 | // support items with the same name from different authors.
|
|
35 | 35 | // Additionally, an item can reference a DATA SET that is installed in a different location than
|
36 | 36 | // the item itself. These files are stored in the data directory (InstallDataDir = /var/lib/crowdsec/data).
|
37 | 37 | //
|
38 |
| -// - /var/lib/crowdsec/data/http_path_traversal.txt |
39 |
| -// - /var/lib/crowdsec/data/jira_cve_2021-26086.txt |
40 |
| -// - /var/lib/crowdsec/data/log4j2_cve_2021_44228.txt |
41 |
| -// - /var/lib/crowdsec/data/sensitive_data.txt |
42 |
| -// |
| 38 | +// - /var/lib/crowdsec/data/http_path_traversal.txt |
| 39 | +// - /var/lib/crowdsec/data/jira_cve_2021-26086.txt |
| 40 | +// - /var/lib/crowdsec/data/log4j2_cve_2021_44228.txt |
| 41 | +// - /var/lib/crowdsec/data/sensitive_data.txt |
43 | 42 | //
|
44 | 43 | // # Using the package
|
45 | 44 | //
|
|
87 | 86 | //
|
88 | 87 | // You can also install items if they have already been downloaded:
|
89 | 88 | //
|
90 |
| -// // install a parser |
91 |
| -// force := false |
92 |
| -// downloadOnly := false |
93 |
| -// err := parser.Install(force, downloadOnly) |
94 |
| -// if err != nil { |
95 |
| -// return fmt.Errorf("unable to install parser: %w", err) |
96 |
| -// } |
| 89 | +// // install a parser |
| 90 | +// force := false |
| 91 | +// downloadOnly := false |
| 92 | +// err := parser.Install(force, downloadOnly) |
| 93 | +// if err != nil { |
| 94 | +// return fmt.Errorf("unable to install parser: %w", err) |
| 95 | +// } |
97 | 96 | //
|
98 | 97 | // As soon as you try to install an item that is not downloaded or is not up-to-date (meaning its computed hash
|
99 | 98 | // does not correspond to the latest version available in the index), a download will be attempted and you'll
|
100 | 99 | // get the error "remote hub configuration is not provided".
|
101 | 100 | //
|
102 | 101 | // To provide the remote hub configuration, use the second parameter of NewHub():
|
103 | 102 | //
|
104 |
| -// remoteHub := cwhub.RemoteHubCfg{ |
105 |
| -// URLTemplate: "https://hub-cdn.crowdsec.net/%s/%s", |
| 103 | +// remoteHub := cwhub.RemoteHubCfg{ |
| 104 | +// URLTemplate: "https://cdn-hub.crowdsec.net/crowdsecurity/%s/%s", |
106 | 105 | // Branch: "master",
|
107 | 106 | // IndexPath: ".index.json",
|
108 | 107 | // }
|
|
124 | 123 | //
|
125 | 124 | // Note that the command will fail if the hub has already been synced. If you want to do it (ex. after a configuration
|
126 | 125 | // change the application is notified with SIGHUP) you have to instantiate a new hub object and dispose of the old one.
|
127 |
| -// |
128 | 126 | package cwhub
|
0 commit comments