Add a new YARA-X Scan operation backed by the official @virustotal/yara-x WASM package#2632
Open
zainnadeem786 wants to merge 1 commit into
Open
Add a new YARA-X Scan operation backed by the official @virustotal/yara-x WASM package#2632zainnadeem786 wants to merge 1 commit into
zainnadeem786 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds a new YARA-X Scan operation to CyberChef using the official
@virustotal/yara-xWebAssembly package.The existing YARA Rules operation remains unchanged. This PR introduces a separate operation that supports modern YARA-X syntax (including features such as
with) while preserving backward compatibility.Closes #2622.
Background
CyberChef currently provides a legacy YARA Rules operation based on
libyara-wasm.YARA-X is the official successor to YARA and provides a modern rule engine, improved performance, new language features, and officially maintained JavaScript/WASM bindings.
This feature request aims to bring modern YARA-X capabilities directly into CyberChef, allowing users to write and test YARA-X rules without switching to external tools or the YARA-X CLI.
Design
Rather than replacing the existing operation, this PR introduces a new operation:
YARA-X Scan
This approach:
Implementation
New Operation
Added:
The operation:
OperationError.Dependency
Added:
This is the official first-party JavaScript/WASM package published by the YARA-X project.
Categories
Added the new operation to the existing Yara category alongside the legacy YARA Rules operation.
WASM Initialization
The YARA-X runtime is initialized once through a cached module-level initialization promise so the WebAssembly module is only initialized once per session.
Node Test Support
Updated:
to support
file:URLs.The official YARA-X package loads its bundled WASM through a file URL during Node-based operation tests. Recent Node versions reject this by default, so the test fetch polyfill was extended to support this scenario.
Supported Features
The initial implementation supports:
Tests
Added:
Coverage includes:
withruleValidation
Successfully validated with:
A targeted Webpack build also successfully emitted the YARA-X WASM asset.
Compatibility
This PR is intentionally additive.
No existing operations were modified or removed.
The existing YARA Rules operation continues to behave exactly as before.
Users can continue using the legacy implementation while choosing YARA-X Scan whenever modern YARA-X language features are required.
Future Work
Potential future enhancements include:
Notes
This implementation intentionally focuses on the core YARA-X scanning workflow while keeping the integration small and maintainable.
Additional YARA-X functionality can be introduced in follow-up pull requests without affecting the existing legacy YARA implementation.