Skip to content

Commit

Permalink
project: Introduces yara as a new project to analyze
Browse files Browse the repository at this point in the history
  • Loading branch information
vulder committed Oct 3, 2024
1 parent b87a13c commit efc7370
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/experiment/test_workload_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_workload_config_param_token(self) -> None:
self.assertEqual(len(commands), 1)
command = commands[0]
args = command.command.rendered_args(project=project)
self.assertEquals(args, tuple(["-c"]))
self.assertEqual(args, tuple(["-c"]))

@run_in_test_environment(UnitTestFixtures.PAPER_CONFIGS)
def test_workload_commands_requires_patch(self) -> None:
Expand Down
7 changes: 4 additions & 3 deletions varats-core/varats/project/project_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ class ProjectDomains(Enum):
CHAT_CLIENT = "Chat client"
CODEC = "Codec"
COMPRESSION = "Compression"
C_LIBRARY = "C Library"
CPP_LIBRARY = "C++ Library"
C_LIBRARY = "C Library"
MALWARE_ANALYSIS = "Malware Analysis"
DATABASE = "Database"
DATA_STRUCTURES = "Data structures"
DOCUMENTATION = "Documentation"
EDITOR = "Editor"
FILE_FORMAT = "File format"
HW_EMULATOR = "Hardware emulator"
HPC = "High Performance Applications"
HW_EMULATOR = "Hardware emulator"
PARSER = "Parser"
PLANNING = "Planning"
PROG_LANG = "Programming language"
PROTOCOL = "Protocol"
RENDERING = "Rendering"
SECURITY = "Security"
SOLVER = "Solver"
SIGNAL_PROCESSING = "Signal processing"
SOLVER = "Solver"
TEST = "Test project"
UNIX_TOOLS = "UNIX utils"
VERSION_CONTROL = "Version control"
Expand Down
78 changes: 78 additions & 0 deletions varats/varats/projects/c_projects/yara.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""Project file for yara."""
import typing as tp

import benchbuild as bb
from benchbuild.utils.cmd import make
from benchbuild.utils.settings import get_number_of_jobs
from plumbum import local

from varats.containers.containers import ImageBase, get_base_image
from varats.paper.paper_config import PaperConfigSpecificGit
from varats.project.project_domain import ProjectDomains
from varats.project.project_util import (
BinaryType,
ProjectBinaryWrapper,
RevisionBinaryMap,
get_local_project_repo,
verify_binaries,
)
from varats.project.varats_project import VProject
from varats.utils.git_util import ShortCommitHash
from varats.utils.settings import bb_cfg


class Yara(VProject):
"""
YARA is a tool aimed at (but not limited to) helping malware researchers to
identify and classify malware samples.
With YARA you can create descriptions of malware families (or whatever you
want to describe) based on textual or binary patterns.
"""

NAME = 'yara'
GROUP = 'c_projects'
DOMAIN = ProjectDomains.MALWARE_ANALYSIS

SOURCE = [
PaperConfigSpecificGit(
project_name='yara',
remote="https://github.com/VirusTotal/yara.git",
local="yara",
refspec="origin/HEAD",
limit=None,
shallow=False
)
]

CONTAINER = get_base_image(ImageBase.DEBIAN_10).run(
'apt', 'install', '-y', 'autoconf', 'autopoint', 'automake',
'autotools-dev', 'make', 'pkg-config'
)

@staticmethod
def binaries_for_revision(
revision: ShortCommitHash
) -> tp.List[ProjectBinaryWrapper]:
binary_map = RevisionBinaryMap(get_local_project_repo(Yara.NAME))

binary_map.specify_binary('yara', BinaryType.EXECUTABLE)

return binary_map[revision]

def run_tests(self) -> None:
pass

def compile(self) -> None:
"""Compile the project."""
yara_version_source = local.path(self.source_of_primary)

c_compiler = bb.compiler.cc(self)
with local.cwd(yara_version_source):
with local.env(CC=str(c_compiler)):
bb.watch(local["./bootstrap.sh"])()
bb.watch(local["./configure"])()

bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

verify_binaries(self)
3 changes: 2 additions & 1 deletion varats/varats/tools/bb_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def update_projects(
'varats.projects.c_projects.asterisk',
'varats.projects.c_projects.bison',
'varats.projects.c_projects.bitlbee',
'varats.projects.c_projects.busybox',
'varats.projects.c_projects.brotli',
'varats.projects.c_projects.busybox',
'varats.projects.c_projects.bzip2',
'varats.projects.c_projects.coreutils',
'varats.projects.c_projects.curl',
Expand Down Expand Up @@ -66,6 +66,7 @@ def update_projects(
'varats.projects.c_projects.vim',
'varats.projects.c_projects.x264',
'varats.projects.c_projects.xz',
'varats.projects.c_projects.yara',
'varats.projects.cpp_projects.clasp',
'varats.projects.cpp_projects.fast_downward',
'varats.projects.cpp_projects.libzmq',
Expand Down

0 comments on commit efc7370

Please sign in to comment.