Skip to content

Commit a0c3a02

Browse files
committed
cleanup
1 parent 2cb7c63 commit a0c3a02

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

helpers/helpers_emba_dependency_check.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ check_git_hash(){
129129
check_docker_image(){
130130
local LOCAL_DOCKER_HASH=""
131131
local REMOTE_DOCKER_HASH=""
132-
LOCAL_DOCKER_HASH="$(sudo docker image inspect embeddedanalyzer/emba:latest --format '{{json .RepoDigests}}' | jq . | grep "sha" | sed -E 's/.*sha256:([0-9|[a-z]+)"/\1/' || true)"
133-
REMOTE_DOCKER_HASH="$(sudo docker manifest inspect embeddedanalyzer/emba:latest -v | jq . | grep "digest" | head -n1 | awk '{print $2}' | sed -E 's/"sha256:(.+)",/\1/' || true)"
132+
LOCAL_DOCKER_HASH="$(docker image inspect embeddedanalyzer/emba:latest --format '{{json .RepoDigests}}' | jq . | grep "sha" | sed -E 's/.*sha256:([0-9|[a-z]+)"/\1/' || true)"
133+
REMOTE_DOCKER_HASH="$(docker manifest inspect embeddedanalyzer/emba:latest -v | jq . | grep "digest" | head -n1 | awk '{print $2}' | sed -E 's/"sha256:(.+)",/\1/' || true)"
134134

135135
if [[ "${LOCAL_DOCKER_HASH}" == "${REMOTE_DOCKER_HASH}" ]]; then
136136
echo -e " Docker image version - ${GREEN}ok${NC}"
@@ -154,12 +154,6 @@ dependency_check()
154154
if [[ "${CONTAINER_NUMBER}" -ne 1 ]]; then
155155
print_output " Internet connection - \\c" "no_log"
156156

157-
if [[ -n "${PROXY_SETTINGS}" ]]; then
158-
export http_proxy="${PROXY_SETTINGS}"
159-
export https_proxy="${PROXY_SETTINGS}"
160-
print_output "[*] Info: Proxy settings detected: ${ORANGE}${PROXY_SETTINGS}${NC}" "no_log"
161-
fi
162-
163157
LATEST_EMBA_VERSION="$(curl --connect-timeout 5 -s -o - https://github.com/e-m-b-a/emba/blob/master/config/VERSION.txt | grep -w "rawLines" | sed -E 's/.*"rawLines":\["([0-9]\.[0-9]\.[0-9]).*/\1/' || true)"
164158
if [[ -z "${LATEST_EMBA_VERSION}" ]] ; then
165159
echo -e "${RED}""not ok""${NC}"
@@ -173,6 +167,13 @@ dependency_check()
173167
check_git_hash
174168
fi
175169
fi
170+
171+
if [[ -n "${PROXY_SETTINGS}" ]]; then
172+
export http_proxy="${PROXY_SETTINGS}"
173+
export https_proxy="${PROXY_SETTINGS}"
174+
print_output "[*] Info: Proxy settings detected: ${ORANGE}${PROXY_SETTINGS}${NC}" "no_log"
175+
fi
176+
176177
if [[ -f "${CONFIG_DIR}/gpt_config.env" ]]; then
177178
if grep -v -q "#" "${CONFIG_DIR}/gpt_config.env"; then
178179
# readin gpt_config.env

helpers/helpers_emba_helpers.sh

+6
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ cleaner() {
178178
done < "${TMP_DIR}"/EXIT_KILL_PIDS.log
179179
fi
180180

181+
if [[ -f "${LOG_DIR}"/emba_error.log ]]; then
182+
if ! [[ -s "${LOG_DIR}"/emba_error.log ]]; then
183+
rm "${LOG_DIR}"/emba_error.log > /dev/null || true
184+
fi
185+
fi
186+
181187
if [[ "${IN_DOCKER}" -eq 0 ]] && [[ -d "${TMP_DIR}" ]]; then
182188
rm -r "${TMP_DIR}" 2>/dev/null || true
183189
fi

installer.sh

-5
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,7 @@ chmod 755 ./external
361361

362362
if [[ "${LIST_DEP}" -eq 0 ]] || [[ ${IN_DOCKER} -eq 0 ]] || [[ ${DOCKER_SETUP} -eq 1 ]] || [[ ${FULL} -eq 1 ]]; then
363363
echo -e "\\n""${MAGENTA}""${BOLD}""Installation notes:""${NC}"
364-
echo -e "\\n""${MAGENTA}""INFO: The cron.daily update script for EMBA is located in config/emba_updater""${NC}"
365-
echo -e "${MAGENTA}""INFO: For automatic updates it should be copied to /etc/cron.daily/""${NC}"
366-
echo -e "${MAGENTA}""INFO: For manual updates just start it via sudo ./config/emba_updater""${NC}"
367-
368364
echo -e "\\n""${MAGENTA}""WARNING: If you plan using the emulator (-E switch) your host and your internal network needs to be protected.""${NC}"
369-
370365
echo -e "\\n""${MAGENTA}""INFO: Do not forget to checkout current development of EMBA at https://github.com/e-m-b-a.""${NC}"
371366
fi
372367
if [[ "${WSL}" -eq 1 ]]; then

modules/F20_vul_aggregator.sh

+21-8
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,26 @@ cve_db_lookup_version() {
495495
# BIN_VERSION_ is something like "binary:1.2.3"
496496
# function writes log files to "${LOG_PATH_MODULE}"/"${VERSION_PATH}".txt
497497
local BIN_VERSION_="${1:-}"
498+
498499
local CVE_ID=""
499500
local BIN_NAME=""
500-
501+
BIN_NAME=$(echo "${BIN_VERSION_}" | cut -d':' -f1)
501502
# we create something like "binary_1.2.3" for log paths
502-
local VERSION_PATH="${BIN_VERSION_//:/_}"
503+
# remove last : if it is there
504+
local VERSION_PATH="${BIN_VERSION_%:}"
505+
VERSION_PATH="${VERSION_PATH//:/_}"
506+
507+
# if we did the CVE analysis already in module s26, we can just use these results for our further analysis
508+
# -> we skip the complete CVE analysis here:
509+
if [[ "${BIN_NAME}" == *"linux_kernel"* ]] && [[ -s "${LOG_DIR}"/s26_kernel_vuln_verifier/"${VERSION_PATH}".txt ]]; then
510+
print_output "[*] Detected kernel vulnerability details from module S26 - going to use these details"
511+
cp "${LOG_DIR}"/s26_kernel_vuln_verifier/"${VERSION_PATH}".txt "${LOG_PATH_MODULE}" || (print_output "[-] S26 kernel vulns file found, but something was going wrong")
512+
cve_extractor "${BIN_VERSION_}"
513+
return
514+
fi
503515
# we test for the binary_name:version and for binary_name:*:
504-
print_output "[*] CVE database lookup with version information: ${ORANGE}${BIN_VERSION_}${NC}" "no_log"
516+
print_output "[*] CVE database lookup with version information: ${ORANGE}${BIN_VERSION_}${NC}"
505517

506-
BIN_NAME=$(echo "${BIN_VERSION_}" | cut -d':' -f1)
507518
mapfile -t CVE_VER_SOURCES_ARR < <(grep -l -r "cpe:[0-9]\.[0-9]:[a-z]:.*${BIN_VERSION_}:\|cpe:[0-9]\.[0-9]:[a-z]:.*${BIN_NAME}:\*:" "${NVD_DIR}" | sort -u || true)
508519

509520
if [[ "${BIN_VERSION_}" == *"dlink"* ]]; then
@@ -844,7 +855,9 @@ cve_extractor() {
844855
BINARY="$(echo "${VERSION_orig}" | cut -d ":" -f2)"
845856
VERSION="$(echo "${VERSION_orig}" | cut -d ":" -f3-)"
846857
fi
847-
local VERSION_PATH="${VERSION_orig//:/_}"
858+
local VERSION_PATH="${VERSION_orig%:}"
859+
VERSION_PATH="${VERSION_PATH//:/_}"
860+
# remove last : if it is there
848861
AGG_LOG_FILE="${VERSION_PATH}".txt
849862
else
850863
AGG_LOG_FILE="${VERSION_orig}".txt
@@ -1135,17 +1148,17 @@ cve_extractor_thread_actor() {
11351148
if [[ -f "${S26_LOG_DIR}"/cve_results_kernel_"${VERSION}".csv ]]; then
11361149
# check if the current CVE is a verified kernel CVE from s26 module
11371150
if grep -q ";${CVE_VALUE};.*;.*;1;1" "${S26_LOG_DIR}"/cve_results_kernel_"${VERSION}".csv; then
1138-
print_output "[+] ${ORANGE}INFO:${GREEN} Vulnerability ${ORANGE}${CVE_VALUE}${GREEN} is a verified kernel vulnerability (${ORANGE}kernel symbols and kernel configuration${GREEN})!"
1151+
print_output "[+] ${ORANGE}INFO:${GREEN} Vulnerability ${ORANGE}${CVE_VALUE}${GREEN} is a verified kernel vulnerability (${ORANGE}kernel symbols and kernel configuration${GREEN})!" "no_log"
11391152
((KERNEL_VERIFIED_VULN+=1))
11401153
KERNEL_VERIFIED="yes"
11411154
fi
11421155
if grep -q ";${CVE_VALUE};.*;.*;1;0" "${S26_LOG_DIR}"/cve_results_kernel_"${VERSION}".csv; then
1143-
print_output "[+] ${ORANGE}INFO:${GREEN} Vulnerability ${ORANGE}${CVE_VALUE}${GREEN} is a verified kernel vulnerability (${ORANGE}kernel symbols${GREEN})!"
1156+
print_output "[+] ${ORANGE}INFO:${GREEN} Vulnerability ${ORANGE}${CVE_VALUE}${GREEN} is a verified kernel vulnerability (${ORANGE}kernel symbols${GREEN})!" "no_log"
11441157
((KERNEL_VERIFIED_VULN+=1))
11451158
KERNEL_VERIFIED="yes"
11461159
fi
11471160
if grep -q ";${CVE_VALUE};.*;.*;0;1" "${S26_LOG_DIR}"/cve_results_kernel_"${VERSION}".csv; then
1148-
print_output "[+] ${ORANGE}INFO:${GREEN} Vulnerability ${ORANGE}${CVE_VALUE}${GREEN} is a verified kernel vulnerability (${ORANGE}kernel configuration${GREEN})!"
1161+
print_output "[+] ${ORANGE}INFO:${GREEN} Vulnerability ${ORANGE}${CVE_VALUE}${GREEN} is a verified kernel vulnerability (${ORANGE}kernel configuration${GREEN})!" "no_log"
11491162
((KERNEL_VERIFIED_VULN+=1))
11501163
KERNEL_VERIFIED="yes"
11511164
fi

0 commit comments

Comments
 (0)