first commit
This commit is contained in:
commit
cd1e91bb99
287 changed files with 86425 additions and 0 deletions
1
rasta_exp/docker/adagio/RASTA_VERSION
Normal file
1
rasta_exp/docker/adagio/RASTA_VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
adagio
|
7
rasta_exp/docker/adagio/README.md
Normal file
7
rasta_exp/docker/adagio/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Adagio
|
||||
|
||||
- [source](https://github.com/hgascon/adagio)
|
||||
- [paper](https://dl.acm.org/doi/10.1145/2517312.2517315)
|
||||
- language: Python 3.8 (could not find an exacte version that works, python3.8 is just the one that required the less tweaking)
|
||||
- number of years without at least 1 commit since first commit: 4 (2020, 2018, 2017, 2023)
|
||||
- License: GPL2
|
19
rasta_exp/docker/adagio/adagio/Dockerfile
Normal file
19
rasta_exp/docker/adagio/adagio/Dockerfile
Normal file
|
@ -0,0 +1,19 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
# RUN sed -i -e "s/archive.ubuntu.com/old-releases.ubuntu.com/g" /etc/apt/sources.list
|
||||
|
||||
RUN apt-get update && apt-get install -y git time
|
||||
|
||||
RUN mkdir /workspace
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -y python3.8 python3-pip python3-scipy python3-matplotlib python3-sklearn-lib
|
||||
|
||||
RUN git clone https://github.com/hgascon/adagio.git /workspace/adagio &&\
|
||||
cd /workspace/adagio && git checkout 8a2c1445df638d9c2fd2b1008a079cb092a63f0b &&\
|
||||
sed -i 's/matplotlib==3.1.1/#matplotlib==3.1.1/' /workspace/adagio/requirements.txt &&\
|
||||
sed -i 's/scikit-learn==0.21.2/#scikit-learn==0.21.2/' /workspace/adagio/requirements.txt &&\
|
||||
sed -i 's/scipy==1.3.0/#scipy==1.3.0/' /workspace/adagio/requirements.txt &&\
|
||||
pip3 install -r /workspace/adagio/requirements.txt
|
||||
|
||||
COPY run.sh /
|
24
rasta_exp/docker/adagio/adagio/run.sh
Executable file
24
rasta_exp/docker/adagio/adagio/run.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
APK_FILENAME=$1
|
||||
|
||||
export TIME="time: %e
|
||||
kernel-cpu-time: %S
|
||||
user-cpu-time: %U
|
||||
max-rss-mem: %M
|
||||
avg-rss-mem: %t
|
||||
avg-total-mem: %K
|
||||
page-size: %Z
|
||||
nb-major-page-fault: %F
|
||||
nb-minor-page-fault: %R
|
||||
nb-fs-input: %I
|
||||
nb-fs-output: %O
|
||||
nb-socket-msg-received: %r
|
||||
nb-socket-msg-sent: %s
|
||||
nb-signal-delivered: %k
|
||||
exit-status: %x"
|
||||
|
||||
WORKDIR="/workspace/adagio"
|
||||
|
||||
cd ${WORKDIR}
|
||||
/usr/bin/time -o /mnt/report -q /usr/bin/timeout --kill-after=20s ${TIMEOUT} python3 adagio.py -d /mnt/ -o /mnt -f > /mnt/stdout 2> /mnt/stderr
|
98
rasta_exp/docker/adagio/test.py
Normal file
98
rasta_exp/docker/adagio/test.py
Normal file
|
@ -0,0 +1,98 @@
|
|||
import datetime
|
||||
import importlib.util
|
||||
import logging
|
||||
import hashlib
|
||||
|
||||
from typing import Any, Type
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
import orchestrator
|
||||
|
||||
errors = orchestrator.error_collector
|
||||
utils = orchestrator.utils
|
||||
|
||||
TIMEOUT = 900
|
||||
|
||||
GUEST_MNT = "/mnt"
|
||||
PATH_APK = f"{GUEST_MNT}/app.apk"
|
||||
|
||||
WORKDIR = "/workspace/adagio"
|
||||
CMD = f"python3 adagio.py -d {GUEST_MNT} -o {GUEST_MNT} -f"
|
||||
|
||||
TOOL_NAME = "adagio"
|
||||
|
||||
# Version name -> folder name
|
||||
TOOL_VERSIONS = {
|
||||
"adagio": "adagio",
|
||||
# "latest": "latest_2022", # the current master is not stable
|
||||
}
|
||||
# Name of the default version (default folder = TOOL_VERSIONS[DEFAULT_TOOL_VERSION])
|
||||
DEFAULT_TOOL_VERSION = "adagio"
|
||||
|
||||
EXPECTED_ERROR_TYPES: list[Type[errors.LoggedError]] = [
|
||||
errors.PythonError
|
||||
] # Because androguard, but adagio doest really crash
|
||||
|
||||
|
||||
def analyse_artifacts(path: Path) -> dict[str, Any]:
|
||||
"""Analyse the artifacts of a test located at `path`."""
|
||||
report = utils.parse_report(path / "report")
|
||||
report["errors"] = list(
|
||||
map(
|
||||
lambda e: e.get_dict(),
|
||||
errors.get_errors(path / "stderr", EXPECTED_ERROR_TYPES),
|
||||
)
|
||||
)
|
||||
if report["timeout"]:
|
||||
report["tool-status"] = "TIMEOUT"
|
||||
elif check_success(path):
|
||||
report["tool-status"] = "FINISHED"
|
||||
else:
|
||||
report["tool-status"] = "FAILED"
|
||||
report["tool-name"] = TOOL_NAME
|
||||
report["date"] = str(datetime.datetime.now())
|
||||
report["apk"] = utils.sha256_sum(path / "app.apk").upper()
|
||||
return report
|
||||
|
||||
|
||||
def check_success(path: Path) -> bool:
|
||||
"""Check if the analysis finished without crashing."""
|
||||
apks = list(path.glob("*.apk"))
|
||||
if len(apks) != 1:
|
||||
raise RuntimeError(
|
||||
f"Expected to found exactly 1 apk in the root of {TOOL_VERSIONS} artifact folder, found {apks}"
|
||||
)
|
||||
apk = apks[0]
|
||||
path_result = path / utils.sha256_sum(apk).lower()
|
||||
return path_result.exists()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import docker # type: ignore
|
||||
|
||||
args = orchestrator.get_test_args(TOOL_NAME)
|
||||
|
||||
tool_folder = Path(__file__).resolve().parent
|
||||
api_key = orchestrator.get_androzoo_key()
|
||||
if args.get_apk_info:
|
||||
orchestrator.load_apk_info(args.apk_refs, args.androzoo_list, api_key)
|
||||
client = docker.from_env()
|
||||
|
||||
logging.info("Command tested: ")
|
||||
logging.info(f"[{WORKDIR}]$ {CMD}")
|
||||
|
||||
for apk_ref in args.apk_refs:
|
||||
orchestrator.test_tool_on_apk(
|
||||
client,
|
||||
tool_folder,
|
||||
api_key,
|
||||
apk_ref,
|
||||
args.tool_version,
|
||||
args.keep_artifacts,
|
||||
args.force_test,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue