crowdsecurity / crowdsec

CrowdSec - the open-source and participative security solution offering crowdsourced protection against malicious IPs and access to the most advanced real-world CTI.
https://crowdsec.net
MIT License
8.99k stars 467 forks source link

[cscli/crowdsec] Test environment improvements #3183

Open LaurenceJJones opened 2 months ago

LaurenceJJones commented 2 months ago

What would you like to be added?

Currently if a user wants to download a test environment its pretty hard to get it configured correctly here are the issue:

/kind enhancement

Why is this needed?

Easier to setup a dev / test environment

github-actions[bot] commented 2 months ago

@LaurenceJJones: Thanks for opening an issue, it is currently awaiting triage.

In the meantime, you can:

  1. Check Crowdsec Documentation to see if your issue can be self resolved.
  2. You can also join our Discord.
  3. Check Releases to make sure your agent is on the latest version.
Details I am a bot created to help the [crowdsecurity](https://github.com/crowdsecurity) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/crowdsecurity/crowdsec/blob/master/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [BirthdayResearch/oss-governance-bot](https://github.com/BirthdayResearch/oss-governance-bot) repository.
github-actions[bot] commented 2 months ago

@LaurenceJJones: There are no 'kind' label on this issue. You need a 'kind' label to start the triage process.

Details I am a bot created to help the [crowdsecurity](https://github.com/crowdsecurity) developers manage community feedback and contributions. You can check out my [manifest file](https://github.com/crowdsecurity/crowdsec/blob/master/.github/governance.yml) to understand my behavior and what I can do. If you want to use this for your project, you can check out the [BirthdayResearch/oss-governance-bot](https://github.com/BirthdayResearch/oss-governance-bot) repository.
Natsui31 commented 2 months ago
Example of bug repro from fresh debian 12

``` apt update \ && apt install -y gettext curl wget git libsqlite3-0 cd $(mktemp -d) wget https://github.com/crowdsecurity/crowdsec/releases/download/v1.6.2/crowdsec-release.tgz tar xvzf crowdsec-release.tgz cd crowdsec-v1.6.2 ./test_env.sh export PATH=$PATH:"$PWD/cmd/crowdsec-cli/":"$PWD/cmd/crowdsec/" alias csdev="$PWD/cmd/crowdsec-cli/cscli -c $PWD/config/dev.yaml" git clone https://github.com/crowdsecurity/hub export PATH=$PATH:"$PWD/cmd/crowdsec/":"$PWD/cmd/crowdsec-cli/" cd hub csdev hubtest run --all ```

With this environment, we got the same error as described in [cscli] We added patterns_dir option to config.yaml but isnt used in hubtest On my test environment, config_paths.pattern_dir is not set.

root@05391e978e44:/tmp/tmp.MqISOY3GSv/crowdsec-v1.6.2/hub# csdev hubtest run --all
+ /tmp/tmp.MqISOY3GSv/crowdsec-v1.6.2/cmd/crowdsec-cli/cscli -c /tmp/tmp.MqISOY3GSv/crowdsec-v1.6.2/config/dev.yaml hubtest run --all
INFO Running test 'CVE-2017-9841'
ERRO running test 'CVE-2017-9841' failed: unable to copy 'patterns' from '/etc/crowdsec/patterns' to '/tmp/tmp.MqISOY3GSv/crowdsec-v1.6.2/hub/.tests/CVE-2017-9841/runtime/patterns': open /etc/crowdsec/patterns: no such file or directory
INFO Running test 'CVE-2019-18935'
ERRO running test 'CVE-2019-18935' failed: unable to copy 'patterns' from '/etc/crowdsec/patterns' to '/tmp/tmp.MqISOY3GSv/crowdsec-v1.6.2/hub/.tests/CVE-2019-18935/runtime/patterns': open /etc/crowdsec/patterns: no such file or directory
INFO Running test 'CVE-2021-4034'
ERRO running test 'CVE-2021-4034' failed: unable to copy 'patterns' from '/etc/crowdsec/patterns' to '/tmp/tmp.MqISOY3GSv/crowdsec-v1.6.2/hub/.tests/CVE-2021-4034/runtime/patterns': open /etc/crowdsec/patterns: no such file or directory
...

I assume that behavior could be disruptive when testing:

Note: I expect the test environment to be isolated from any pre-existing installations, ensuring that the results are not influenced by previously installed versions.