Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can β€” learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company πŸ‘‡

feat(lisdex): B39 - the gate accepted any checkout and then blamed the wrong thing

CarterPerez-dev65281560b8fa
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m3-gate.sh b/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m3-gate.sh
index 51324ca8..1d3d0e54 100755
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m3-gate.sh
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m3-gate.sh
@@ -60,13 +60,23 @@ else
fi
clone() {
- local name="$1" url="$2" ref="$3"
- if [ -d "$SRC/$name/.git" ]; then
- return 0
+ local name="$1"
+ local url="$2"
+ local ref="$3"
+ local dir="$SRC/$name"
+ local current
+ if [ ! -d "$dir/.git" ]; then
+ echo "cloning $name ($ref)"
+ git clone --depth 1 --branch "$ref" "$url" "$dir" >/dev/null 2>&1 \
+ || git clone --depth 1 "$url" "$dir" >/dev/null 2>&1
+ fi
+ current="$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
+ if [ "$current" != "$ref" ]; then
+ echo " FAIL $name is checked out at '$current' but this gate measures '$ref'" >&2
+ echo " every number below would describe a different library" >&2
+ echo " run: just m3-gate-reset" >&2
+ exit 1
fi
- echo "cloning $name ($ref)"
- git clone --depth 1 --branch "$ref" "$url" "$SRC/$name" >/dev/null 2>&1 \
- || git clone --depth 1 "$url" "$SRC/$name" >/dev/null 2>&1
}
# libpng is cloned at libpng16 deliberately: the default branch (libpng18) ships
@@ -85,7 +95,7 @@ clone brotli https://github.com/google/brotli.git master
# this case and its own configure copies it. Do the same, so the gate measures a
# tree lisdex can legitimately analyse rather than one that silently resolves
# pnglibconf.h from a system-installed libpng in /usr/include.
-if [ -f "$SRC/libpng/scripts/pnglibconf.h.prebuilt" ] && [ ! -f "$SRC/libpng/pnglibconf.h" ]; then
+if [ -f "$SRC/libpng/scripts/pnglibconf.h.prebuilt" ]; then
cp "$SRC/libpng/scripts/pnglibconf.h.prebuilt" "$SRC/libpng/pnglibconf.h"
echo "seeded libpng/pnglibconf.h from the shipped prebuilt config"
fi