Add option (--scan-list) to scan a list of files and/or directories #1261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuation of #1254.
Adds a new mode (
--scan-list
) to/usr/bin/yara
that scans multiple files and directories (with or without recursion/-r
, as usual).FILE
(final argument) is not scanned itself in this mode, but instead contains the scan list, one item (file or directory) per line.The use case is a vast collection of potential targets (in a flat directory or a dense tree) and curated set of actual scan targets (e.g., contextual tags).
Code footprint is small, dovetailing into existing
scan_dir
andfile_queue_put
.Command-line convention is maintained:
yara [OPTION]... [NAMESPACE:]RULES_FILE... FILE | DIR | PID
.A very rough test script (not intended to thoroughly exercise):
As discussed in #1254, this PR uses POSIX.1-2008
getline(3)
(strok_s
for Windows) to parse the scan list file line by line.See also historical #550. I believe the code contribution here is value-add.