From eeec7e47d1c388a2e63151ad82a464f846cb1128 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 11 Jan 2024 07:52:34 +1000 Subject: [PATCH] Initial 5.1.0 schema upgradse. Add kernel_version to linux audit script. --- app/Models/db_upgrades/db_5.1.0.php | 24 ++++++++++++++++++++++++ other/audit_linux.sh | 6 ++++++ other/open-audit.sql | 1 + 3 files changed, 31 insertions(+) create mode 100644 app/Models/db_upgrades/db_5.1.0.php diff --git a/app/Models/db_upgrades/db_5.1.0.php b/app/Models/db_upgrades/db_5.1.0.php new file mode 100644 index 000000000..9206b10da --- /dev/null +++ b/app/Models/db_upgrades/db_5.1.0.php @@ -0,0 +1,24 @@ +fieldExists('kernel_version', 'devices')) { + $sql = "ALTER TABLE `devices` ADD `kernel_version` varchar(200) NOT NULL DEFAULT '' AFTER `os_cpe`"; + $query = $db->query($sql); + $output .= str_replace("\n", " ", (string)$db->getLastQuery()) . "\n\n"; + log_message('info', (string)$db->getLastQuery()); +} + +// set our versions +$sql = "UPDATE `configuration` SET `value` = '20240104' WHERE `name` = 'internal_version'"; +$db->query($sql); +$output .= str_replace("\n", " ", (string)$db->getLastQuery()) . "\n\n"; +log_message('info', (string)$db->getLastQuery()); + +$sql = "UPDATE `configuration` SET `value` = '5.1.0' WHERE `name` = 'display_version'"; +$db->query($sql); +$output .= str_replace("\n", " ", (string)$db->getLastQuery()) . "\n\n"; +log_message('info', (string)$db->getLastQuery()); + +$output .= "Upgrade database to 5.1.0 completed.\n\n"; +config('Openaudit')->internal_version = 20240104; +config('Openaudit')->display_version = '5.1.0'; diff --git a/other/audit_linux.sh b/other/audit_linux.sh index 39bac9305..8b1f053c3 100755 --- a/other/audit_linux.sh +++ b/other/audit_linux.sh @@ -933,6 +933,11 @@ else system_pc_date_os_installation="" fi +kernel_version=$(uname -r 2>/dev/null) +if [ -z "$kernel_version" ]; then + kernel_version=$(hostnamectl 2>/dev/null | grep "Kernel" | cut -d: -f2 | cut -d" " -f3) +fi + #''''''''''''''''''''''''''''''''' #' Write to the audit file ' #''''''''''''''''''''''''''''''''' @@ -955,6 +960,7 @@ echo " $(escape_xml "$system_os_group")" echo " $(escape_xml "$system_os_family")" echo " $(escape_xml "$system_os_name")" echo " $(escape_xml "$system_os_version")" +echo " $(escape_xml "$kernel_version")" echo " $(escape_xml "$system_serial")" echo " $(escape_xml "$system_model")" echo " $(escape_xml "$system_manufacturer")" diff --git a/other/open-audit.sql b/other/open-audit.sql index 6cc94a776..a083f98a6 100644 --- a/other/open-audit.sql +++ b/other/open-audit.sql @@ -1131,6 +1131,7 @@ CREATE TABLE `devices` ( `os_name` varchar(100) NOT NULL DEFAULT '', `os_version` varchar(200) NOT NULL DEFAULT '', `os_cpe` varchar(200) NOT NULL DEFAULT '', + `kernel_version` varchar(200) NOT NULL DEFAULT '', `attached_device_id` int(10) unsigned DEFAULT NULL, `manufacturer` varchar(100) NOT NULL DEFAULT '', `manufacturer_code` varchar(200) NOT NULL DEFAULT '',