sw-collector: Iterate through history logs

The logrotate function causes the apt history to be split into
several parts at arbitrary points in time. If history.log only
is parsed then some package installation changes stored in
zipped backup history files might get lost.

Thus sw-collector now searches all backup history files until
a date older than the current event stored in the collector.db
database is found, so that no entries get overlooked.
This commit is contained in:
Andreas Steffen
2021-12-31 14:33:22 +01:00
parent 0b76ca13ab
commit 903c68e069
4 changed files with 142 additions and 56 deletions
+8 -1
View File
@@ -21,7 +21,7 @@ INC=$INC,gnat,gprbuild,acpid,acpi-support-base,libldns-dev,libunbound-dev
INC=$INC,dnsutils,libsoup2.4-dev,ca-certificates,unzip,libsystemd-dev
INC=$INC,python3,python3-setuptools,python3-dev,python3-pip,apt-transport-https
INC=$INC,libjson-c-dev,libxslt1-dev,libapache2-mod-wsgi-py3
INC=$INC,libxerces-c-dev,libgcrypt20-dev,traceroute,iptables
INC=$INC,libxerces-c-dev
case "$BASEIMGSUITE" in
bullseye)
INC=$INC,libiptc-dev
@@ -53,6 +53,7 @@ esac
SERVICES="apache2 dbus isc-dhcp-server slapd bind9 freeradius"
INC=$INC,${SERVICES// /,}
# packages to install via APT, for SWIMA tests
APT1="libgcrypt20-dev traceroute iptables"
APT="tmux"
# additional services to disable
SERVICES="$SERVICES systemd-timesyncd.service"
@@ -136,6 +137,12 @@ log_status $?
log_action "Update package sources"
execute_chroot "apt-get update"
log_action "Install packages via APT"
execute_chroot "apt-get -y install $APT1"
log_action "Move history.log to history.log.1"
execute_chroot "mv /var/log/apt/history.log /var/log/apt/history.log.1"
log_action "Compress history.log.1 to history.log.1.gz"
execute_chroot "gzip /var/log/apt/history.log.1"
log_action "Install more packages via APT"
execute_chroot "apt-get -y install $APT"
log_action "Install packages from custom repo"
execute_chroot "apt-get -y upgrade"
@@ -17,8 +17,8 @@ alice::cat /var/log/daemon.log::accepting PT-TLS stream from PH_IP_CAROL::YES
alice::cat /var/log/daemon.log::SASL PLAIN authentication successful::YES
alice::cat /var/log/daemon.log::SASL client identity is.*carol::YES
alice::cat /var/log/daemon.log::user AR identity.*carol.*authenticated by password::YES
alice::cat /var/log/daemon.log::received software ID events with ... items for request 9 at last eid 2 of epoch::YES
alice::cat /var/log/daemon.log::received software ID events with ... items for request 9 at last eid 3 of epoch::YES
alice::cat /var/log/daemon.log::3 SWID tag target::YES
alice::cat /var/log/daemon.log::received software inventory with 3 items for request 9 at last eid 2 of epoch::YES
alice::cat /var/log/daemon.log::received software inventory with 3 items for request 9 at last eid 3 of epoch::YES
alice::cat /var/log/daemon.log::successful system command: ssh root@moon.*logger -t charon-systemd -p auth.alert.*host with IP address 192.168.0.100 is allowed::YES
moon::cat /var/log/auth.log::host with IP address 192.168.0.100 is allowed::YES
@@ -23,17 +23,17 @@ INSERT INTO sw_identifiers (
INSERT INTO sw_events (
eid, sw_id, action
) VALUES (
2, 1, 2
3, 1, 2
);
INSERT INTO sw_events (
eid, sw_id, action
) VALUES (
2, 2, 2
3, 2, 2
);
INSERT INTO sw_events (
eid, sw_id, action
) VALUES (
2, 3, 2
3, 3, 2
);