Skip to content

fix: properly handle directories for local files#347

Open
bmagistro wants to merge 1 commit intoOISF:masterfrom
bmagistro:bugfix-local-dir-pathing
Open

fix: properly handle directories for local files#347
bmagistro wants to merge 1 commit intoOISF:masterfrom
bmagistro:bugfix-local-dir-pathing

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 <koncept1@gmail.com>
@bmagistro bmagistro requested a review from jasonish as a code owner November 5, 2024 01:09
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