mirror of
https://github.com/VirusTotal/yara.git
synced 2026-10-12 02:10:00 +00:00
282 lines
6.2 KiB
Python
282 lines
6.2 KiB
Python
# Copyright (c) 2019. The YARA Authors. All Rights Reserved.
|
|
#
|
|
# Redistribution and use in source and binary forms, with or without modification,
|
|
# are permitted provided that the following conditions are met:
|
|
#
|
|
# 1. Redistributions of source code must retain the above copyright notice, this
|
|
# list of conditions and the following disclaimer.
|
|
#
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
# this list of conditions and the following disclaimer in the documentation and/or
|
|
# other materials provided with the distribution.
|
|
#
|
|
# 3. Neither the name of the copyright holder nor the names of its contributors
|
|
# may be used to endorse or promote products derived from this software without
|
|
# specific prior written permission.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
COPTS = [
|
|
"-D_GNU_SOURCE",
|
|
"-DHAVE_STDBOOL_H=1",
|
|
# Tell the compiler we want the C99 standard.
|
|
"-std=c99",
|
|
]
|
|
|
|
cc_library(
|
|
name = "blob",
|
|
hdrs = ["blob.h"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "util",
|
|
srcs = ["util.c"],
|
|
copts = COPTS,
|
|
textual_hdrs = ["util.h"],
|
|
deps = ["@//:libyara"],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_alignment",
|
|
srcs = ["test-alignment.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_arena",
|
|
srcs = ["test-arena.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_atoms",
|
|
srcs = ["test-atoms.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "mapper",
|
|
srcs = ["mapper.c"],
|
|
copts = ["-O0"],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_rules",
|
|
srcs = ["test-rules.c"],
|
|
copts = COPTS,
|
|
data = [
|
|
"data/base64",
|
|
"data/baz.yar",
|
|
"data/foo.yar",
|
|
"data/include/bar.yar",
|
|
"data/xor.out",
|
|
"data/xorwide.out",
|
|
"data/xorwideandascii.out",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":blob",
|
|
":mapper",
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_pe",
|
|
srcs = ["test-pe.c"],
|
|
copts = COPTS,
|
|
data = [
|
|
"data/05cd06e6a202e12be22a02700ed6f1604e803ca8867277d852e8971efded0650",
|
|
"data/079a472d22290a94ebb212aa8015cdc8dd28a968c6b4d3b88acdd58ce2d3b885",
|
|
"data/079a472d22290a94ebb212aa8015cdc8dd28a968c6b4d3b88acdd58ce2d3b885.upx",
|
|
"data/3b8b90159fa9b6048cc5410c5d53f116943564e4d05b04a843f9b3d0540d0c1c",
|
|
"data/6c2abf4b80a87e63eee2996e5cea8f004d49ec0c1806080fa72e960529cba14c",
|
|
"data/ChipTune.efi",
|
|
"data/c6f9709feccf42f2d9e22057182fe185f177fb9daaa2649b4669a24f2ee7e3ba_0h_410h",
|
|
"data/ca21e1c32065352d352be6cde97f89c141d7737ea92434831f998080783d5386",
|
|
"data/mtxex.dll",
|
|
"data/mtxex_modified_rsrc_rva.dll",
|
|
"data/pe_imports",
|
|
"data/pe_mingw",
|
|
"data/tiny",
|
|
"data/tiny-idata-51ff",
|
|
"data/tiny-idata-5200",
|
|
"data/tiny-macho",
|
|
"data/tiny-overlay",
|
|
"data/weird_rich",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_elf",
|
|
srcs = ["test-elf.c"],
|
|
copts = COPTS,
|
|
data = [
|
|
"data/elf_with_imports",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":blob",
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_api",
|
|
srcs = ["test-api.c"],
|
|
copts = COPTS,
|
|
data = [
|
|
"data/baz.yar",
|
|
"data/x.txt",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_bitmask",
|
|
srcs = ["test-bitmask.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_math",
|
|
srcs = ["test-math.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_string",
|
|
srcs = ["test-string.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_stack",
|
|
srcs = ["test-stack.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
# This test fails when running under ASAN
|
|
cc_test(
|
|
name = "test_exception",
|
|
srcs = ["test-exception.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_macho",
|
|
srcs = ["test-macho.c"],
|
|
copts = COPTS,
|
|
data = [
|
|
"data/tiny-macho",
|
|
"data/tiny-universal",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":blob",
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_dex",
|
|
srcs = ["test-dex.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":blob",
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_dotnet",
|
|
srcs = ["test-dotnet.c"],
|
|
copts = COPTS,
|
|
data = [
|
|
"data/0ca09bde7602769120fadc4f7a4147347a7a97271370583586c9e587fd396171",
|
|
"data/756684f4017ba7e931a26724ae61606b16b5f8cc84ed38a260a34e50c5016f59",
|
|
"data/bad_dotnet_pe",
|
|
"data/tiny",
|
|
],
|
|
linkstatic = True,
|
|
deps = [
|
|
":blob",
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "test_re_split",
|
|
srcs = ["test-re-split.c"],
|
|
copts = COPTS,
|
|
linkstatic = True,
|
|
deps = [
|
|
":util",
|
|
"@//:libyara",
|
|
],
|
|
)
|