Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support docker compose v2 API #961

Merged
merged 13 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions emba
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,6 @@ main() {
exit 1
fi
fi
if ! command -v docker-compose > /dev/null ; then
print_output "[!] No docker-compose found" "no_log"
print_output "$(indent "Install docker-compose via apt-get install docker-compose to use EMBA with docker")" "no_log"
exit 1
fi

OPTIND=1
ARGUMENTS=()
Expand Down Expand Up @@ -721,21 +716,21 @@ main() {
disable_strict_mode "${STRICT_MODE}" 0
if [[ "${ONLY_DEP}" -gt 0 ]]; then
# check dependencies mode:
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" docker-compose run --rm emba -c './emba -f /firmware -i "$@"' _ "${ARGUMENTS[@]}"
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" "${DOCKER_COMPOSE[@]}" run --rm emba -c './emba -f /firmware -i "$@"' _ "${ARGUMENTS[@]}"
D_RETURN=$?
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" docker-compose run --rm emba_quest -c './emba -f /firmware -i "$@"' _ "${ARGUMENTS[@]}"
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" "${DOCKER_COMPOSE[@]}" run --rm emba_quest -c './emba -f /firmware -i "$@"' _ "${ARGUMENTS[@]}"
if [[ $? -ne ${D_RETURN} ]]; then
D_RETURN=1
fi
elif [[ "${DIFF_MODE}" -gt 0 ]]; then
FIRMWARE_PATH1="$(abs_path "${FIRMWARE_PATH1}")"
# firmware diff mode - needs two firmware files:
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" LOG="${LOG_DIR}" docker-compose run -v "${FIRMWARE_PATH1}":/firmware2 --rm emba -c './emba -l /logs -f /firmware -o /firmware2 -i "$@"' _ "${ARGUMENTS[@]}"
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" LOG="${LOG_DIR}" "${DOCKER_COMPOSE[@]}" run -v "${FIRMWARE_PATH1}":/firmware2 --rm emba -c './emba -l /logs -f /firmware -o /firmware2 -i "$@"' _ "${ARGUMENTS[@]}"
D_RETURN=$?
else
# default EMBA analysis mode:
local QUEST_CONTAINER_=""
QUEST_CONTAINER_="$(EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" LOG="${LOG_DIR}" docker-compose run --detach --rm emba_quest -c './emba -l /logs -f /firmware -i "$@"' _ "${ARGUMENTS[@]}")"
QUEST_CONTAINER_="$(EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" LOG="${LOG_DIR}" "${DOCKER_COMPOSE[@]}" run --detach --rm emba_quest -c './emba -l /logs -f /firmware -i "$@"' _ "${ARGUMENTS[@]}")"
export QUEST_CONTAINER="${QUEST_CONTAINER_}"
print_output "[*] Quest container ${QUEST_CONTAINER_} started and detached.\\n" "main"
print_ln "no_log"
Expand All @@ -745,7 +740,7 @@ main() {
store_kill_pids "${QUEST_PID}"
disown "${QUEST_PID}" 2> /dev/null || true

EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" LOG="${LOG_DIR}" docker-compose run --rm emba -c './emba -l /logs -f /firmware -i "$@"' _ "${ARGUMENTS[@]}"
EMBA="${INVOCATION_PATH}" FIRMWARE="${FIRMWARE_PATH}" LOG="${LOG_DIR}" "${DOCKER_COMPOSE[@]}" run --rm emba -c './emba -l /logs -f /firmware -i "$@"' _ "${ARGUMENTS[@]}"
D_RETURN=$?
# stop quest container
if [[ "$( docker container inspect -f '{{.State.Status}}' "${QUEST_CONTAINER_}" )" == "running" ]]; then
Expand Down
20 changes: 20 additions & 0 deletions helpers/helpers_emba_dependency_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ check_docker_image(){
fi
}

check_docker_version() {
# DOCKER_VER=$(pip3 show docker | grep Version: | awk '{print $2}' || true)
# if [[ $(version "${DOCKER_VER}") -ge $(version "7.0.0") ]]; then
print_output " Docker version - \\c" "no_log"
if command -v docker > /dev/null; then
if docker --help | grep -q compose; then
export DOCKER_COMPOSE=("docker" "compose")
else
export DOCKER_COMPOSE=("docker-compose")
fi
echo -e "${GREEN}""${DOCKER_COMPOSE[@]} ok""${NC}"
else
echo -e "${RED}""not ok""${NC}"
DEP_ERROR=1
fi
}

dependency_check()
{
local LATEST_EMBA_VERSION=""
Expand Down Expand Up @@ -292,6 +309,9 @@ dependency_check()
echo -e "${GREEN}""ok""${NC}"
fi

if [[ "${USE_DOCKER}" -eq 1 && "${IN_DOCKER}" -ne 1 ]]; then
check_docker_version
fi
# EMBA is developed for and on KALI Linux
# In our experience we can say that it runs on most Debian based systems without any problems
if [[ "${USE_DOCKER}" -eq 0 ]] ; then
Expand Down
15 changes: 10 additions & 5 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,16 @@ if [[ $(version "${DOCKER_COMP_VER}") -lt $(version "1.28.5") ]]; then
fi

# check pip3 docker version TODO move into pipenv
DOCKER_VER=$(pip3 show docker | grep Version: | awk '{print $2}' || true)
if [[ $(version "${DOCKER_VER}") -ge $(version "7.0.0") ]]; then
echo -e "\n${ORANGE}WARNING: compatibility of the used docker version is unknown!${NC}"
echo -e "\n${ORANGE}Please consider downgrading your pip3 docker version. \$pip3 install \"docker<7.0.0\"${NC}"
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
export DOCKER_COMPOSE=("docker-compose")
# DOCKER_VER=$(pip3 show docker | grep Version: | awk '{print $2}' || true)
# if [[ $(version "${DOCKER_VER}") -ge $(version "7.0.0") ]]; then
if command -v docker 2>/dev/null; then
if docker --help | grep -q compose; then
echo -e "\n${ORANGE}WARNING: compatibility of the used docker version is unknown!${NC}"
echo -e "\n${ORANGE}Please consider downgrading your pip3 docker version. \$pip3 install \"docker<7.0.0\"${NC}"
read -p "If you know what you are doing you can press any key to continue ..." -n1 -s -r
export DOCKER_COMPOSE=("docker" "compose")
fi
fi

if [[ "${OTHER_OS}" -eq 1 ]]; then
Expand Down
2 changes: 1 addition & 1 deletion installer/I05_emba_docker_image_dl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ I05_emba_docker_image_dl() {
docker pull "${CONTAINER}"
sed -i "/image:/c\ image: ${CONTAINER}" docker-compose.yml
export DOCKER_CLI_EXPERIMENTAL=disabled
docker-compose up --no-start
"${DOCKER_COMPOSE[@]}" up --no-start
else
echo "Estimated download-Size: ~5500 MB"
echo -e "${ORANGE}""WARNING: docker command missing - no docker pull possible.""${NC}"
Expand Down
Loading