mirror of
https://github.com/e-m-b-a/emba.git
synced 2026-10-11 22:09:54 +00:00
adjust regex
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
],
|
||||
"grep_commands": [
|
||||
"^[dD]nsmasq\\ version\\ [0-9]\\.[0-9]+",
|
||||
"dnsmasq-[0-9]\\.[0-9]+",
|
||||
"dnsmasq\\ [0-9]\\.[0-9]+"
|
||||
"dnsmasq-[0-9]\\.[0-9]+$",
|
||||
"dnsmasq\\ [0-9]\\.[0-9]+$"
|
||||
],
|
||||
"vendor_names": [
|
||||
"dnsmasq",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"GPL-2.0-only"
|
||||
],
|
||||
"grep_commands": [
|
||||
"[0-9](\\.[0-9]+)+?\\ -\\ $Id:\\ ez-ipupdate.c,v\\ [0-9]\\.[0-9]+",
|
||||
"[0-9](\\.[0-9]+)+?\\ -\\ \\$Id:\\ ez-ipupdate.c,v\\ [0-9]\\.[0-9]+",
|
||||
"ez-ipupdate:\\ -\\ [0-9](\\.[0-9]+)+?"
|
||||
],
|
||||
"vendor_names": [
|
||||
@@ -17,7 +17,7 @@
|
||||
"ez-ipupdate"
|
||||
],
|
||||
"version_extraction": [
|
||||
"sed -r 's/([0-9](\\.[0-9]+)+?)\\ -\\ $Id:\\ ez-ipupdate.c,v\\ [0-9]\\.[0-9]+/::ez-ipupdate:\\1/'",
|
||||
"sed -r 's/([0-9](\\.[0-9]+)+?)\\ -\\ \\$Id:\\ ez-ipupdate.c,v\\ [0-9]\\.[0-9]+/::ez-ipupdate:\\1/'",
|
||||
"sed -r 's/ez-ipupdate:\\ -\\ ([0-9](\\.[0-9]+)+?)/::ez-ipupdate:\\1/'"
|
||||
],
|
||||
"affected_paths": [
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"LGPL-3.0-only OR GPL-2.0-only"
|
||||
],
|
||||
"grep_commands": [
|
||||
"'\"^lua_cjson\\.c$\"AND\"^Memory\\ allocation\\ error\\ in\\ CJSON\\ protected\\ call$\"AND\"^[0-9]\\.[0-9](\\.[0-9]){0,1}+$\"'"
|
||||
"'\"^lua_cjson\\.c$\"AND\"^Memory\\ allocation\\ error\\ in\\ CJSON\\ protected\\ call$\"AND\"^[0-9]\\.[0-9](\\.[0-9]){0,1}$\"'"
|
||||
],
|
||||
"vendor_names": [
|
||||
"lua"
|
||||
|
||||
@@ -980,7 +980,10 @@ create_minimal_binary_corpus() {
|
||||
lVERSION_IDENTIFIER="${lVERSION_IDENTIFIER%\"}"
|
||||
fi
|
||||
|
||||
grep -o -a -E ".{0,300}${lVERSION_IDENTIFIER//[\^\$]/}.{0,300}" "${lBINARY_PATH}" >>"${lCORPUS_FILE_tmp}" || true
|
||||
lVERSION_IDENTIFIER=${lVERSION_IDENTIFIER%$}
|
||||
lVERSION_IDENTIFIER=${lVERSION_IDENTIFIER#^}
|
||||
|
||||
grep -o -a -E ".{0,300}${lVERSION_IDENTIFIER}.{0,300}" "${lBINARY_PATH}" >>"${lCORPUS_FILE_tmp}" || true
|
||||
|
||||
lCORP_SIZE=$(wc -c <"${lCORPUS_FILE_tmp}")
|
||||
write_log "[*] Generated corpus for binary ${lBINARY_PATH} with size ${lCORP_SIZE} - rule ${lRULE_IDENTIFIER}/${lVERSION_IDENTIFIER}" "${lCORPUS_log}"
|
||||
|
||||
@@ -489,10 +489,11 @@ bvi_static_rules() {
|
||||
local lBASENAME=""
|
||||
local lMODE=""
|
||||
local lMODE_ENTRY=""
|
||||
local lMODE_COUNT="0"
|
||||
local lPATH_COUNT="0"
|
||||
local lMODE_COUNT=0
|
||||
local lPATH_COUNT=0
|
||||
for lCFG_FILE in "${BIN_VERSION_CFG_ARR[@]}"; do
|
||||
lBASENAME="$(basename "${lCFG_FILE}" .json)"
|
||||
lMODE_COUNT=0
|
||||
|
||||
# one jq pass: affected_paths count|space separated parsing modes
|
||||
while IFS='|' read -r lPATH_COUNT lMODE; do
|
||||
|
||||
@@ -10,16 +10,16 @@ software versions by grepping the `strings` output of firmware binaries
|
||||
with the regex patterns defined in `config/bin_version_identifiers/*.json`.
|
||||
|
||||
Instead of copying entire firmware binaries into the test suite (which can
|
||||
be 100+ MB), `../bin_version_testdata/*.bin` holds only the relevant byte
|
||||
be 100+ MB), `../../bin_version_testdata/*.bin` holds only the relevant byte
|
||||
windows around the grep matches. Every test bin is named
|
||||
`<identifier>_<grep id>.bin`, following the corpus naming of
|
||||
`create_minimal_binary_corpus` in
|
||||
`../../modules/S09_firmware_base_version_check.sh`.
|
||||
`../../../modules/S09_firmware_base_version_check.sh`.
|
||||
|
||||
## Statistics
|
||||
|
||||
`../bin_version_testdata` is compared against all static rules of
|
||||
`../../config/bin_version_identifiers` by
|
||||
`../../bin_version_testdata` is compared against all static rules of
|
||||
`../../../config/bin_version_identifiers` by
|
||||
`../../modules/s09_bin_version_identifiers.bats`. It reports how many grep
|
||||
entries are matched by a test bin, how many are missing a test bin and which
|
||||
test bins are stale or orphaned.
|
||||
@@ -40,4 +40,4 @@ The check mirrors `S09_firmware_base_version_check`:
|
||||
2. Leading/trailing `'` and surrounding `"` are stripped per element.
|
||||
3. Anchors are dropped, as the test bins are extracted as context windows
|
||||
around the matches.
|
||||
4. Each element is tested with `grep -a -q -o -E` against the test bin.
|
||||
4. Each element is tested with `grep -a -q -o -E` against the test bin.
|
||||
|
||||
Reference in New Issue
Block a user