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

fix: properly handle directories for local files #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmagistro
Copy link

@bmagistro bmagistro commented Nov 5, 2024

When loading local files and rule files are nested in a folder, the current behavior prepends the base path and not the nested path which results in a file not found error. This change updates this to use the dirpath parameter from os.walk so that it is handled correctly.

Given a structure of

  /tmp/rules/
  ├── file1.rules
  └── nested
      └── file2.rules

Today it would try to load this as the following

  • /tmp/rules/file1.rules
  • /tmp/rules/file2.rules

With the fix this would be

  • /tmp/rules/file1.rules
  • /tmp/rules/nested/file2.rules

https://redmine.openinfosecfoundation.org/issues/7370

When loading local files and rule files are nested in a folder, the
current behavior prepends the base path and not the nested path which
results in a file not found error. This change updates this to use the
`dirpath` parameter from `os.walk` so that it is handled correctly.

Given a structure of
  /tmp/rules/
  ├── file1.rules
  └── nested
      └── file2.rules

Today it would try to load this as the following
* /tmp/rules/file1.rules
* /tmp/rules/file2.rules

With the fix this would be
* /tmp/rules/file1.rules
* /tmp/rules/nested/file2.rules

Signed-off-by: Ben Magistro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant