Skip to content

Commit

Permalink
pipelines: test: ldd-check: factory out test for dynamic objects
Browse files Browse the repository at this point in the history
Error out if ldd was not able to actually reason about whether or not
a file is a dynamic object by checking it's error message.

Signed-off-by: dann frazier <dann.frazier@chainguard.dev>
  • Loading branch information
dannf committed Jan 8, 2025
1 parent 0a5a235 commit 24c6e58
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pipelines/test/ldd-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ pipeline:
fail "$f: missing ${missing# }"
}
is_dyn_obj() {
errf="$tmpd/ldd.stderr.$$"
# ldd has this code already, let's not NIH it
# note: the actual ldd check happens in test_file()
if ldd "$1" > /dev/null 2> "$errf"; then
return 0
fi
if grep -q 'not a dynamic executable' "$errf"; then
return 1
fi
error "$1: failed to determine if file is a dynamic object: $(< "$errf")"
}
test_files_in() {
echo "[ldd-check] Testing binaries in package $pkg"
apk info -eq "$pkg" > /dev/null || \
Expand All @@ -71,7 +84,7 @@ pipeline:
[ -n "$f" ] || continue
f="/$f"
[ -f "$f" ] || continue
ldd "$f" > /dev/null 2>&1 || continue
is_dyn_obj "$f" || continue
test_file "$f"
done < "$tmpd/$pkg.list"
}
Expand Down

0 comments on commit 24c6e58

Please sign in to comment.