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: don't strip prefix if path is exactly "." #293

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

wxsBSD
Copy link
Contributor

@wxsBSD wxsBSD commented Jan 18, 2025

One of the things I often run is "yr scan -r rules.yara ." when I have a collection of samples and I want to scan all of them in the current directory.

With the fix in #280 the path was being stripped to an empty string which would result in an error when trying to scan. Fix it by only performing the strip if the path is not equal to ".".

One of the things I often run is "yr scan -r rules.yara ." when I have a
collection of samples and I want to scan all of them in the current directory.

With the fix in VirusTotal#280 the path was being stripped to an empty string which would
result in an error when trying to scan. Fix it by only performing the strip if
the path is not equal to ".".
Copy link

@code-review-assist code-review-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi team,

I'm currently reviewing this pull request and will provide feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:

This pull request addresses an issue where using . as a path argument in the yr scan command resulted in an error due to path stripping. The intent is to fix this behavior so that users can scan all files in the current directory using yr scan rules.yara ..

Here's a breakdown of the changes:

  • cli/src/tests/mod.rs (lines 287-296): Added a new test case to explicitly handle the . path argument, ensuring the fix works as expected.
  • cli/src/walk.rs (lines 206-219): Modified the Walker implementation to conditionally strip the prefix only if the path is not exactly .. This prevents the stripping when the path is just ., allowing the scan to work correctly in the current directory.

The core change involves adding a conditional check before stripping the prefix from the path. This ensures that if the path is exactly ., the prefix is not stripped, resolving the issue.

I'll have a more detailed review shortly. Until then, here's a little something to lighten the mood:

A dot, small and slight,
Holds a directory's might,
No longer a fright.

Best,
Gemini

@wxsBSD wxsBSD changed the title Don't strip prefix if path is exactly "." fix: Don't strip prefix if path is exactly "." Jan 18, 2025
Copy link

Gemini encountered an error creating the review. You can try again by commenting @code-review-assist review.

@plusvic plusvic changed the title fix: Don't strip prefix if path is exactly "." fix: don't strip prefix if path is exactly "." Jan 18, 2025
@plusvic plusvic merged commit 45da681 into VirusTotal:main Jan 18, 2025
15 of 17 checks passed
@wxsBSD wxsBSD deleted the dont_strip_prefix_on_dot branch January 18, 2025 23:27
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 this pull request may close these issues.

2 participants