Skip to content

Commit

Permalink
Initial 5.1.0 schema upgradse. Add kernel_version to linux audit script.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Jan 10, 2024
1 parent 3f46d5e commit eeec7e4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/Models/db_upgrades/db_5.1.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
$output .= "Upgrade database to 5.1.0 commenced.\n\n";

if (!$db->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';
6 changes: 6 additions & 0 deletions other/audit_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
#'''''''''''''''''''''''''''''''''
Expand All @@ -955,6 +960,7 @@ echo " <os_group>$(escape_xml "$system_os_group")</os_group>"
echo " <os_family>$(escape_xml "$system_os_family")</os_family>"
echo " <os_name>$(escape_xml "$system_os_name")</os_name>"
echo " <os_version>$(escape_xml "$system_os_version")</os_version>"
echo " <kernel_version>$(escape_xml "$kernel_version")</kernel_version>"
echo " <serial>$(escape_xml "$system_serial")</serial>"
echo " <model>$(escape_xml "$system_model")</model>"
echo " <manufacturer>$(escape_xml "$system_manufacturer")</manufacturer>"
Expand Down
1 change: 1 addition & 0 deletions other/open-audit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 '',
Expand Down

0 comments on commit eeec7e4

Please sign in to comment.