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

Panic with .\ directory prefix #280

Open
edeca opened this issue Jan 6, 2025 · 1 comment · May be fixed by #283
Open

Panic with .\ directory prefix #280

edeca opened this issue Jan 6, 2025 · 1 comment · May be fixed by #283

Comments

@edeca
Copy link

edeca commented Jan 6, 2025

When using YARA-X 0.12.0 a panic is generated if the path starts with .\. This is how PowerShell auto-completes folder names relative to the current directory. Example:

PS C:\<my_user_directory>\yara> yr scan -r "C:\<path>\rule.yar" .\samples\
thread '<unnamed>' panicked at C:\Users\runneradmin/.cargo\registry\src\index.crates.io-6f17d22bba15001f\globwalk-0.9.1\src\lib.rs:381:78:
called `Result::unwrap()` on an `Err` value: StripPrefixError(())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Also affects Linux:

-> % ./yr scan -r rule.yar ./samples
thread '<unnamed>' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/globwalk-0.9.1/src/lib.rs:381:78:
called `Result::unwrap()` on an `Err` value: StripPrefixError(())
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Testing:

  • .\samples - does not work
  • .\samples\ - does not work
  • samples\ - works
  • samples - works
  • ..\yara\samples\ - works

All the working examples are fine with the backslash substituted for a forward slash (on Windows), so the only difference is the .\.

@edeca
Copy link
Author

edeca commented Jan 6, 2025

This is a known issue in the globwalk crate.

wxsBSD added a commit to wxsBSD/yara-x that referenced this issue Jan 9, 2025
As identified in VirusTotal#280 there is a bug in globwalk when using relative paths. Fix
it by trying to canonicalize the path, and if that fails falls back to using the
relative path. This is fine because the reason canonicalization failed is
because the relative path was to a place that doesn't exist, and that does not
trigger the bug (it errors out before we get there). We intentionally want this
behavior so we get the nicer error reporting with colors. ;)

Fixes VirusTotal#280.
@wxsBSD wxsBSD linked a pull request Jan 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant