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

Another big update PR #979

Merged
merged 19 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/grype.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Grype docker image scan
on:
schedule:
- cron: '0 0 * * *' # do it every day
# push:
# branches:
# - '**' # matches every branch
#pull_request:
# branches:
# - '**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
Grype-EMBA-scan:
if: github.repository_owner == 'e-m-b-a'
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Grype EMBA image check
runs-on: "ubuntu-latest"
steps:
- name: Checkout EMBA
uses: actions/checkout@v3
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: true
- name: Run the Anchore Grype scan action
uses: anchore/scan-action@d5aa5b6cb9414b0c7771438046ff5bcfa2854ed7
id: scan
with:
image: "embeddedanalyzer/emba:latest"
fail-build: false
severity-cutoff: critical
- name: Upload vulnerability report
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}

4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ See [CONTRIBUTING.md](https://github.com/e-m-b-a/emba/blob/master/CONTRIBUTING.m

These people have contributed to EMBA:

* [Michael Messner (original author)](https://github.com/m-1-k-3)
* [Michael Messner (original author, maintainer)](https://github.com/m-1-k-3)
* [Pascal Eckmann (original author)](https://github.com/p4cx)
* [Benedikt Kuehne](https://github.com/BenediktMKuehne)
* [Benedikt Kuehne (EMBArk maintainer)](https://github.com/BenediktMKuehne)
* [Arnold Unterauer](https://github.com/Anemosx)
* [seanog8](https://github.com/seanog8)
* [Stefan Haboeck](https://github.com/StefanHaboeck)
Expand Down
4 changes: 2 additions & 2 deletions check_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens AG
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down Expand Up @@ -375,7 +375,7 @@ copy_right_check(){
check_tools
check
dockerchecker
copy_right_check "Siemens Energy AG" 2023 ./ ./external
copy_right_check "Siemens Energy AG" 2024 ./ ./external
list_linter_exceptions shellcheck ./ ./external
list_linter_exceptions semgrep ./ ./external
summary
Expand Down
2 changes: 1 addition & 1 deletion config/bin_version_strings.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down
2 changes: 1 addition & 1 deletion config/bin_version_strings_links.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
# Copyright 2020-2023 Siemens AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
Expand Down
2 changes: 2 additions & 0 deletions config/linux_common_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86255,6 +86255,8 @@ iptables-translate.8.gz
iptables-xml.1.gz
iptables-xml.8.gz
iptables.xslt
iptables-multi
ip6tables-multi
ipt_ah.h
ipt_ah.ko
ipt_ah.ko.xz
Expand Down
18 changes: 6 additions & 12 deletions emba
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens AG
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down Expand Up @@ -85,7 +85,6 @@ sort_modules()
}

check_quest_container() {
print_ln "no_log"
print_output "[*] Checking Quest container ${QUEST_CONTAINER} dependencies \\n" "no_log"
# wait for quest container to finish network checks
while [[ "$(docker container inspect -f '{{.State.Running}}' "${QUEST_CONTAINER}")" == "true" ]]; do
Expand All @@ -95,11 +94,9 @@ check_quest_container() {
sleep 0.1
done
reset
print_ln "no_log"
print_output "[*] Quest container ${QUEST_CONTAINER} dependency checks: \\n" "no_log"
docker logs "${QUEST_CONTAINER}"
print_output "[*] Finished Quest container ${QUEST_CONTAINER} dependency checks \\n" "no_log"
print_ln "no_log"
reset
}

Expand Down Expand Up @@ -373,11 +370,9 @@ main() {
if [[ ${IN_DOCKER} -eq 0 ]]; then
if grep -q -i wsl /proc/version; then
print_bar "no_log"
print_ln "no_log"
print_output "[*] INFO: System running in WSL environment!" "no_log"
print_output "[*] INFO: WSL is currently experimental." "no_log"
print_output "[*] INFO: Please report issues to https://github.com/e-m-b-a/emba/issues." "no_log"
print_ln "no_log"
print_bar "no_log"
export WSL=1
fi
Expand Down Expand Up @@ -547,15 +542,17 @@ main() {
export FIRMWARE=1
elif [[ -f "${FIRMWARE_PATH}" ]] && [[ -z "${FIRMWARE_PATH1}" ]]; then
PRE_CHECK=1
print_output "[*] Firmware binary detected." "no_log"
if [[ -n "${KERNEL_CONFIG}" && "${KERNEL}" -eq 1 ]]; then
print_output "[*] Kernel configuration file detected." "no_log"
else
print_output "[*] Firmware binary detected." "no_log"
fi
print_output " EMBA starts with the pre-testing phase." "no_log"
export OUTPUT_DIR="${FIRMWARE_PATH}"
elif [[ -f "${FIRMWARE_PATH}" ]] && [[ -f "${FIRMWARE_PATH1}" ]]; then
DIFF_MODE=1
print_output "[*] Multiple firmware binarie detected." "no_log"
print_output " EMBA starts in firmware diff mode ." "no_log"
elif [[ -f "${KERNEL_CONFIG}" && "${KERNEL}" -eq 1 ]]; then
print_output "[*] Kernel configuration file detected." "no_log"
else
print_output "[!] Invalid firmware file" "no_log"
print_help
Expand Down Expand Up @@ -679,8 +676,6 @@ main() {
esac
done

print_ln "no_log"

print_output "[*] EMBA sets up the docker environment.\\n" "no_log"

# try it 10 times before exit
Expand Down Expand Up @@ -733,7 +728,6 @@ main() {
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"

check_quest_container "${QUEST_CONTAINER}" &
QUEST_PID="$!"
Expand Down
19 changes: 16 additions & 3 deletions helpers/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
EMBA - EMBEDDED LINUX ANALYZER

Copyright 2020-2023 Siemens AG
Copyright 2020-2023 Siemens Energy AG
Copyright 2020-2024 Siemens Energy AG

EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under the terms of the GNU General Public License.
See LICENSE file for usage of this software.

EMBA is licensed under GPLv3

Author(s): Pascal Eckmann
Contributor(s): Michael Messner, Stefan Haboeck
Author(s) and contributors from the EMBA project are listed here: https://github.com/e-m-b-a/emba/blob/master/CONTRIBUTORS.md
-->

<!-- Used icons: https://github.com/CoreyGinnivan/system-uicons -->
Expand Down Expand Up @@ -126,6 +125,20 @@
};
}

// the following function is currently not used
// it is for future extensions
function overlay_output(link) {
var rawfile = new XMLHttpRequest();
rawfile.open('GET', link, false);
rawfile.overrideMimeType("text");
rawfile.onreadystatechange = function()
{
alert(rawfile.responseText);
//console.log(rawfile.responseText);
}
rawfile.send(null);
}

document.onkeydown = function(e) {
switch (e.keyCode) {
case 37:
Expand Down
2 changes: 1 addition & 1 deletion helpers/create_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2022 Siemens AG
# Copyright 2023-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down
2 changes: 1 addition & 1 deletion helpers/fix_bins_lnk_emulation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down
2 changes: 1 addition & 1 deletion helpers/helpers_emba_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
# Copyright 2020-2023 Siemens AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
Expand Down
5 changes: 4 additions & 1 deletion helpers/helpers_emba_dependency_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens AG
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down Expand Up @@ -88,12 +88,15 @@ version_extended() # $1-a $2-op $3-$b
local ai=${a%$al} bi=${b%$bl}

local ap=${ai//[[:digit:]]} bp=${bi//[[:digit:]]}
# nosemgrep
ap=${ap//./.0} bp=${bp//./.0}

local w=1 fmt=$a.$b x IFS=.
for x in $fmt; do [ ${#x} -gt $w ] && w=${#x}; done
fmt=${*//[^.]}; fmt=${fmt//./%${w}s}
# nosemgrep
printf -v a $fmt $ai$bp; printf -v a "%s-%${w}s" $a $al
# nosemgrep
printf -v b $fmt $bi$ap; printf -v b "%s-%${w}s" $b $bl

case $op in
Expand Down
2 changes: 1 addition & 1 deletion helpers/helpers_emba_extractors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down
4 changes: 2 additions & 2 deletions helpers/helpers_emba_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
# Copyright 2020-2023 Siemens AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
Expand All @@ -23,7 +23,7 @@ run_web_reporter_mod_name() {
for LOG_FILE in "${LOG_FILES[@]}"; do
MOD_NAME=$(basename -s .txt "${LOG_FILE}")
generate_report_file "${LOG_FILE}"
sed -i -E '/^\[REF\]|\[ANC\].*/d' "${LOG_FILE}"
sed -i -E '/^\[REF\]|\[ANC\]|\[LOV\].*/d' "${LOG_FILE}"
done
fi
}
Expand Down
32 changes: 30 additions & 2 deletions helpers/helpers_emba_html_generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens AG
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down Expand Up @@ -42,6 +42,7 @@ ARROW_LINK="<a href=\"LINK\" title=\"LINK\" >"
LOCAL_LINK="<a class=\"local\" href=\"LINK\" title=\"LINK\" >"
REFERENCE_LINK="<a class=\"reference\" href=\"LINK\" title=\"LINK\" >"
REFERENCE_MODUL_LINK="<a class=\"refmodul\" href=\"LINK\" title=\"LINK\" >"
LOCAL_OVERLAY_LINK="<a class=\"refmodul\" onclick=\"overlay_output\(\"LINK\"\) >"
REFERENCE_MODUL_EXT_LINK="<a class=\"refmodulext\" href=\"LINK\" title=\"LINK\" target=\"_blank\">"
EXPLOIT_LINK="<a href=\"https://www.exploit-db.com/exploits/LINK\" title=\"LINK\" target=\"_blank\" >"
CVE_LINK="<a href=\"https://nvd.nist.gov/vuln/detail/LINK\" title=\"LINK\" target=\"_blank\" >"
Expand Down Expand Up @@ -90,17 +91,19 @@ add_link_tags() {
# [REF] anchor
if ( grep -a -q -E '\[REF\]' "${LINK_FILE}" ) ; then
readarray -t REF_LINKS_L_NUMBER < <(grep -a -n -E '\[REF\].*' "${LINK_FILE}" | cut -d':' -f1 )
# print_output "[*] REF link found in ${LINK_FILE}" "no_log"
for REF_LINK_NUMBER in "${REF_LINKS_L_NUMBER[@]}" ; do
DEPTH="."
REF_LINK="$(sed "${REF_LINK_NUMBER}""q;d" "${LINK_FILE}" | cut -c12- | cut -d'<' -f1 || true)"
URL_REGEX='(www.|https?|ftp|file):\/\/'
if [[ -f "$(echo "${REF_LINK}" | cut -d"#" -f1)" ]] ; then
if [[ ( ("${REF_LINK: -4}" == ".txt") || ("${REF_LINK: -4}" == ".log") ) || ( ("${REF_LINK}" == *".txt#"*) || ("${REF_LINK}" == *".log#"*) ) ]] ; then
if [[ ( ("${REF_LINK: -4}" == ".txt") || ("${REF_LINK: -4}" == ".log") ) || ( ("${REF_LINK}" == *".txt#"*) || ("${REF_LINK}" == *".log#"*) || ("${REF_LINK: -2}" == ".c") ) ]] ; then
REF_ANCHOR=""
if [[ ( ("${REF_LINK}" == *".txt#"*) || ("${REF_LINK}" == *".log#"*) ) ]] ; then
REF_ANCHOR="$(echo "${REF_LINK}" | cut -d"#" -f2 || true)"
REF_LINK="$(echo "${REF_LINK}" | cut -d"#" -f1 || true)"
fi
# print_output "[*] REF link ${REF_LINK} found in ${LINK_FILE}" "no_log"
# generate reference file
generate_info_file "${REF_LINK}" "${BACK_LINK}" &
WAIT_PIDS_WR+=( "$!" )
Expand Down Expand Up @@ -371,6 +374,31 @@ add_link_tags() {
fi
fi
fi

# [LOV] anchor for JS popup messages
if ( grep -a -q -E '\[LOV\]' "${LINK_FILE}" ) ; then
readarray -t LOV_LINKS_L_NUMBER < <(grep -a -n -E '\[LOV\].*' "${LINK_FILE}" | cut -d':' -f1 )
for LOV_LINK_NUMBER in "${LOV_LINKS_L_NUMBER[@]}" ; do
DEPTH="."
LOV_LINK="$(sed "${LOV_LINK_NUMBER}""q;d" "${LINK_FILE}" | cut -c12- | cut -d'<' -f1 || true)"
if [[ -f "$(echo "${LOV_LINK}" | cut -d"#" -f1)" ]] ; then
echo "LOV_LINK: ${LOV_LINK}"
LINE_NUMBER_INFO_PREV="$(( LOV_LINK_NUMBER - 1 ))"
while [[ ("$(sed "${LINE_NUMBER_INFO_PREV}""q;d" "${LINK_FILE}")" == "${P_START}${SPAN_END}${P_END}") || ("$(sed "${LINE_NUMBER_INFO_PREV}""q;d" "${LINK_FILE}")" == "${BR}" ) ]] ; do
LINE_NUMBER_INFO_PREV=$(( LINE_NUMBER_INFO_PREV - 1 ))
echo "X LINE_NUMBER_INFO_PREV: ${LINE_NUMBER_INFO_PREV}"
done
LOV_LINE_BEFORE="$(sed "${LINE_NUMBER_INFO_PREV}""q;d" "${LINK_FILE}" || true)"
# HTML_LINK="$(echo "${LOV_LINK}" | sed -e "s@LINK@${DEPTH}/$(echo "${BACK_LINK}" | cut -d"." -f1)/$(basename "${LOV_LINK%."${LOV_LINK##*.}"}").html@g" || true)"
HTML_LINK="$(echo "${LOCAL_OVERLAY_LINK}" | sed -e "s@LINK@${LOV_LINK}@g" || true)"
echo "HTML_LINK: ${HTML_LINK}"
echo "LOV_LINE_BEFORE: ${LOV_LINE_BEFORE}"
echo "LINE_NUMBER_INFO_PREV: ${LINE_NUMBER_INFO_PREV}"
LINK_COMMAND_ARR+=( "${LINE_NUMBER_INFO_PREV}"'s@^@'"${HTML_LINK}"'@' "${LINE_NUMBER_INFO_PREV}"'s@$@'"${LINK_END}"'@')
echo "LINK_COMMAND_ARR: ${LINK_COMMAND_ARR[*]}"
fi
done
fi
fi

if [[ "${#LINK_COMMAND_ARR[@]}" -gt 0 ]] ; then
Expand Down
2 changes: 1 addition & 1 deletion helpers/helpers_emba_internet_access.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down
2 changes: 1 addition & 1 deletion helpers/helpers_emba_load_strict_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# EMBA - EMBEDDED LINUX ANALYZER
#
# Copyright 2020-2023 Siemens Energy AG
# Copyright 2020-2024 Siemens Energy AG
#
# EMBA comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
Expand Down