Updates to scanner with CVE saving and auto update
This commit is contained in:
+30
-13
@@ -172,27 +172,44 @@ enum SSHScanner {
|
|||||||
case "$package_manager" in
|
case "$package_manager" in
|
||||||
apt)
|
apt)
|
||||||
if command -v apt-cache >/dev/null 2>&1; then
|
if command -v apt-cache >/dev/null 2>&1; then
|
||||||
dpkg-query -W -f='${Package}\n' 'php*' \
|
dpkg-query -W \
|
||||||
2>/dev/null |
|
-f='${db:Status-Abbrev}|${binary:Package}|${Version}\n' \
|
||||||
grep -E '^php[0-9.-]*([a-z-]+)?$' |
|
'php*' 2>/dev/null |
|
||||||
sort -u |
|
while IFS='|' read -r state pkg installed; do
|
||||||
while IFS= read -r pkg; do
|
case "$state" in ii*) ;; *) continue ;; esac
|
||||||
[ -n "$pkg" ] || continue
|
case "$pkg" in php*) ;; *) continue ;; esac
|
||||||
|
[ -n "$installed" ] || continue
|
||||||
|
|
||||||
installed=$(dpkg-query -W -f='${Version}' \
|
policy=$(apt-cache policy "$pkg" 2>/dev/null || true)
|
||||||
"$pkg" 2>/dev/null || true)
|
|
||||||
|
|
||||||
candidate=$(apt-cache policy "$pkg" 2>/dev/null |
|
candidate=$(printf '%s\n' "$policy" |
|
||||||
sed -n 's/^[[:space:]]*Candidate: //p' |
|
sed -n 's/^[[:space:]]*Candidate: //p' |
|
||||||
head -1)
|
head -1)
|
||||||
|
|
||||||
printf '%s installed=%s candidate=%s\n' \
|
printf '%s installed=%s candidate=%s\n' \
|
||||||
"$pkg" "$installed" "${candidate:-unknown}"
|
"$pkg" "$installed" "${candidate:-unknown}"
|
||||||
|
|
||||||
apt-cache policy "$pkg" 2>/dev/null |
|
# Repository matching is informational, not an attestation.
|
||||||
grep -E 'https?://|/ubuntu |/ubuntu$' |
|
# Match the exact installed version and its repository entries.
|
||||||
head -3 |
|
printf '%s\n' "$policy" |
|
||||||
sed 's/^[[:space:]]*/ /'
|
awk -v installed="$installed" -v pkg="$pkg" '
|
||||||
|
/^[[:space:]]*(\*\*\*[[:space:]]*)?[^[:space:]]+[[:space:]]+[0-9]+$/ {
|
||||||
|
version=$1
|
||||||
|
if (version=="***") version=$2
|
||||||
|
matching=(version==installed)
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
matching && /https?:\/\// {
|
||||||
|
if ($0 ~ /archive[.]ubuntu[.]com\/ubuntu/ ||
|
||||||
|
$0 ~ /security[.]ubuntu[.]com\/ubuntu/) {
|
||||||
|
print "UBUNTU_REPOSITORY_MATCH|" pkg "|" installed
|
||||||
|
matching=0
|
||||||
|
} else {
|
||||||
|
print "OTHER_REPOSITORY_MATCH|" pkg "|" installed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
printf 'APT metadata unavailable\n'
|
printf 'APT metadata unavailable\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user