Description
Describe the Bug
Summary
Currently in the Makefile, the test-remote-cli
command is defined twice. This causes both the test-hunting-cli and the test-remote-cli commands to run when one runs make test-remote-cli
.
There are a few other minor bugs (such as a hard coded path shown below) that will also be fixed by an associated PR.
❯ make test-remote-cli > make_test_remote_cli.txt
Makefile:30: warning: overriding recipe for target 'deps'
Makefile:23: warning: ignoring old recipe for target 'deps'
Makefile:62: warning: overriding recipe for target 'test-remote-cli'
Makefile:57: warning: ignoring old recipe for target 'test-remote-cli'
Running command git clone --filter=blob:none --quiet https://github.com/elastic/detection-rules.git /tmp/pip-install-hquejjhu/detection-rules-kql_ffc62c62d4b54fe09ca4e22c79e1a45c
Running command git submodule update --init --recursive -q
Running command git clone --filter=blob:none --quiet https://github.com/elastic/detection-rules.git /tmp/pip-install-hquejjhu/detection-rules-kibana_b769dfa50e6c49119d85153af851b733
Running command git submodule update --init --recursive -q
[notice] A new release of pip is available: 25.0.1 -> 25.1.1
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting/__main__.py", line 257, in <module>
hunting()
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting/__main__.py", line 46, in generate_markdown
raise ValueError(f"Invalid path provided: {path}")
ValueError: Invalid path provided: /Users/tdejesus/code/src/detection-rules/hunting/okta/queries/initial_access_higher_than_average_failed_authentication.toml
Example of another bug, the markdown generation does not support relative paths, which are necessary for the Makefile tests to work, when hard coded paths are fixed.
detection-rules on 4750-bug-makefile-test-remote-cli-defined-twice [!?] is v1.2.9 via v3.12.10 (detection-rules-build) on eric.forte
❯ python -m hunting generate-markdown hunting/okta/queries/initial_access_higher_than_average_failed_authentication.toml
Loaded config file: /home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/.detection-rules-cfg.json
Generating Markdown for single file: hunting/okta/queries/initial_access_higher_than_average_failed_authentication.toml
Processing specific TOML file: hunting/okta/queries/initial_access_higher_than_average_failed_authentication.toml
Markdown generated: hunting/okta/docs/initial_access_higher_than_average_failed_authentication.md
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting/__main__.py", line 257, in <module>
hunting()
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/env/detection-rules-build/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting/__main__.py", line 41, in generate_markdown
markdown_generator.process_file(path)
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting/markdown.py", line 32, in process_file
self.update_or_add_entry(hunt_config, file_path)
File "/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting/markdown.py", line 96, in update_or_add_entry
'path': f"./{toml_path.relative_to(self.base_path).as_posix()}",
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/pathlib.py", line 682, in relative_to
raise ValueError(f"{str(self)!r} is not in the subpath of {str(other)!r}")
ValueError: 'hunting/okta/queries/initial_access_higher_than_average_failed_authentication.toml' is not in the subpath of '/home/forteea1/Code/clean_mains/test_dr_main/fixing_dr_release/detection-rules/hunting'
To Reproduce
- Run
make test-remote-cli
.
Expected Behavior
Only the runs test-remote-cli Makefile definition to be run.
Screenshots
No response
Desktop - OS
None
Desktop - Version
No response
Additional Context
No response