Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test environment invalid since "binary 'crowdsec' doesn't exist or is not in $PATH" #3384

Open
Eirikr70 opened this issue Dec 27, 2024 · 2 comments

Comments

@Eirikr70
Copy link

Eirikr70 commented Dec 27, 2024

What happened?

I set up the test environment to test a collection, but couldn't get it to work.
Got message
FATA unable to load hubtest: path to crowdsec binary 'crowdsec' doesn't exist or is not in $PATH, can't run
Although I have added the related path to variable PATH

eric@odroid:~/crowdsec-test/crowdsec-v1.6.4/tests/hub$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/eric/crowdsec-test/crowdsec-v1.6.4/tests

What did you expect to happen?

Capacity to test my collection, although I'm not quite sure it might have worked since it relies on docker logs.

How can we reproduce it (as minimally and precisely as possible)?

Install the test environment on Debian and try it.

Anything else we need to know?

No response

Crowdsec version

eric@odroid:~/crowdsec-test/crowdsec-v1.6.4/tests/hub$ sudo ../cscli version
version: v1.6.4-523164f6
Codename: alphaga
BuildDate: 2024-11-20_11:21:34
GoVersion: 1.23.3
Platform: linux
libre2: C++
User-Agent: crowdsec/v1.6.4-523164f6-linux
Constraint_parser: >= 1.0, <= 3.0
Constraint_scenario: >= 1.0, <= 3.0
Constraint_api: v1
Constraint_acquis: >= 1.0, < 2.0
Built-in optional components: cscli_setup, datasource_appsec, datasource_cloudwatch, datasource_docker, datasource_file, datasource_http, datasource_journalctl, datasource_k8s-audit, datasource_kafka, datasource_kinesis, datasource_loki, datasource_s3, datasource_syslog, datasource_wineventlog

OS version

eric@odroid:~/crowdsec-test/crowdsec-v1.6.4/tests/hub$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

eric@odroid:~/crowdsec-test/crowdsec-v1.6.4/tests/hub$ uname -a
Linux odroid 6.1.0-28-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.119-1 (2024-11-22) x86_64 GNU/Linux

Enabled collections and parsers

No response

Acquisition config

```console # On Linux: $ cat /etc/crowdsec/acquis.yaml /etc/crowdsec/acquis.d/* # paste output here

On Windows:

C:> Get-Content C:\ProgramData\CrowdSec\config\acquis.yaml

paste output here

Config show

$ cscli config show
# paste output here

Prometheus metrics

$ cscli metrics
# paste output here

Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.

@Eirikr70 Eirikr70 added the kind/bug Something isn't working label Dec 27, 2024
Copy link

@Eirikr70: 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 developers manage community feedback and contributions. You can check out my manifest file 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 repository.

@LaurenceJJones
Copy link
Contributor

LaurenceJJones commented Dec 29, 2024

Hey 👋🏻

When creating a test environment via the instructions: https://docs.crowdsec.net/docs/next/contributing/contributing_test_env, we should be more explicit how to define a custom path to the crowdsec binary.

cscli hubtest supports --crowdsec which is a string which points to the crowdsec binary by default its crowdsec which attempts to find it via the PATH options but you can provide /path/to/bin/crowdsec as an override.

Edit: however, its a mess really cause you have this issue #3182 which means you will have to do this

root@bookworm:/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests# mkdir -p /etc/crowdsec
root@bookworm:/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests# echo $PWD
/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests
root@bookworm:/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests# ln -s "$PWD/config/patterns" /etc/crowdsec/patterns
root@bookworm:/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests# ls -la /etc/crowdsec/patterns
lrwxrwxrwx 1 root root 57 Dec 29 10:33 /etc/crowdsec/patterns -> /tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests/config/patterns

To resolve the affirmation patterns issue.

Then within the hub directory it cannot find cscli or crowdsec so you would have to run this:

root@bookworm:/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests/hub# csdev hubtest --cscli "$(dirname $PWD)/cscli" --crowdsec "$(dirname $PWD)/crowdsec" run --all
INFO Running test 'CVE-2017-9841'

Not to also mention that csdev alias can also hit issues when not running inside the test directory so you should update the dev.yaml to have full paths instead of having ./ with sed:

root@bookworm:/tmp/tmp.hdn3hnsCvq/crowdsec-v1.6.4/tests# sed -i "s|\./|$PWD/|g" dev.yaml

all these improvements are tracked within #3183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants