Skip to content

Commit 4b11259

Browse files
BrewTestBotchenrui333
authored andcommitted
yara-x 1.2.0
yara-x: add `elf` module error patch Signed-off-by: Rui Chen <[email protected]>
1 parent 3549c8b commit 4b11259

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

Formula/y/yara-x.rb

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
class YaraX < Formula
22
desc "Tool to do pattern matching for malware research"
33
homepage "https://virustotal.github.io/yara-x/"
4-
url "https://github.com/VirusTotal/yara-x/archive/refs/tags/v1.1.0.tar.gz"
5-
sha256 "90bbe970a85ff2c707b2706a89cb165cd5b8c706451cfa4b25e0aaa77250a6da"
64
license "BSD-3-Clause"
75
head "https://github.com/VirusTotal/yara-x.git", branch: "main"
86

7+
stable do
8+
url "https://github.com/VirusTotal/yara-x/archive/refs/tags/v1.2.0.tar.gz"
9+
sha256 "f825a24bb2132d284fc9b2bdde1440f6a1f55d699388fee15f859b535e8074e3"
10+
11+
# patch to fix `elf` module error, upstream commit ref, https://github.com/VirusTotal/yara-x/commit/ae9a6323ff5e6725fac69b76997db82aa53e713a
12+
patch :DATA
13+
end
14+
915
livecheck do
1016
url :stable
1117
strategy :github_latest
@@ -57,3 +63,44 @@ def install
5763
assert_match version.to_s, shell_output("#{bin}/yr --version")
5864
end
5965
end
66+
67+
__END__
68+
diff --git a/lib/src/modules/elf/mod.rs b/lib/src/modules/elf/mod.rs
69+
index 5384fcea7..7a38dc4de 100644
70+
--- a/lib/src/modules/elf/mod.rs
71+
+++ b/lib/src/modules/elf/mod.rs
72+
@@ -30,9 +30,11 @@ thread_local!(
73+
fn main(data: &[u8], _meta: Option<&[u8]>) -> Result<ELF, ModuleError> {
74+
IMPORT_MD5_CACHE.with(|cache| *cache.borrow_mut() = None);
75+
TLSH_CACHE.with(|cache| *cache.borrow_mut() = None);
76+
- parser::ElfParser::new()
77+
- .parse(data)
78+
- .map_err(|e| ModuleError::InternalError { err: e.to_string() })
79+
+
80+
+ match parser::ElfParser::new().parse(data) {
81+
+ Ok(elf) => Ok(elf),
82+
+ Err(_) => Ok(ELF::new()),
83+
+ }
84+
}
85+
86+
#[module_export]
87+
diff --git a/lib/src/modules/lnk/mod.rs b/lib/src/modules/lnk/mod.rs
88+
index 22f06a3a1..fd73767fe 100644
89+
--- a/lib/src/modules/lnk/mod.rs
90+
+++ b/lib/src/modules/lnk/mod.rs
91+
@@ -18,7 +18,12 @@ pub mod parser;
92+
93+
#[module_main]
94+
fn main(data: &[u8], _meta: Option<&[u8]>) -> Result<Lnk, ModuleError> {
95+
- parser::LnkParser::new()
96+
- .parse(data)
97+
- .map_err(|e| ModuleError::InternalError { err: e.to_string() })
98+
+ match parser::LnkParser::new().parse(data) {
99+
+ Ok(lnk) => Ok(lnk),
100+
+ Err(_) => {
101+
+ let mut lnk = Lnk::new();
102+
+ lnk.is_lnk = Some(false);
103+
+ Ok(lnk)
104+
+ }
105+
+ }
106+
}

0 commit comments

Comments
 (0)