2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2021-03-09 03:18:52 +00:00
|
|
|
, fetchpatch
|
2020-05-29 06:06:01 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, autoreconfHook
|
|
|
|
, pcre
|
|
|
|
, pkg-config
|
|
|
|
, protobufc
|
2020-04-24 23:36:52 +00:00
|
|
|
, withCrypto ? true, openssl
|
|
|
|
, enableMagic ? true, file
|
|
|
|
, enableCuckoo ? true, jansson
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2021-03-09 03:18:52 +00:00
|
|
|
version = "4.0.5";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "yara";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "VirusTotal";
|
|
|
|
repo = "yara";
|
|
|
|
rev = "v${version}";
|
2021-03-09 03:18:52 +00:00
|
|
|
sha256 = "1gkdll2ygdlqy1f27a5b84gw2bq75ss7acsx06yhiss90qwdaalq";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
nativeBuildInputs = [ autoreconfHook pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
buildInputs = [ pcre protobufc ]
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals withCrypto [ openssl ]
|
|
|
|
++ lib.optionals enableMagic [ file ]
|
|
|
|
++ lib.optionals enableCuckoo [ jansson ]
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
preConfigure = "./bootstrap.sh";
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
# If static builds are disabled, `make all-am` will fail to find libyara.a and
|
|
|
|
# cause a build failure. It appears that somewhere between yara 4.0.1 and
|
|
|
|
# 4.0.5, linking the yara binaries dynamically against libyara.so was broken.
|
|
|
|
#
|
|
|
|
# This was already fixed in yara master. Backport the patch to yara 4.0.5.
|
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fix-build-with-no-static.patch";
|
|
|
|
url = "https://github.com/VirusTotal/yara/commit/52e6866023b9aca26571c78fb8759bc3a51ba6dc.diff";
|
|
|
|
sha256 = "074cf99j0rqiyacp60j1hkvjqxia7qwd11xjqgcr8jmfwihb38nr";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
configureFlags = [
|
2021-01-15 22:18:51 +00:00
|
|
|
(lib.withFeature withCrypto "crypto")
|
|
|
|
(lib.enableFeature enableMagic "magic")
|
|
|
|
(lib.enableFeature enableCuckoo "cuckoo")
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "The pattern matching swiss knife for malware researchers";
|
2020-05-29 06:06:01 +00:00
|
|
|
homepage = "http://Virustotal.github.io/yara/";
|
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|