From 43749f83090ad52cbc1e3422ada15deb8f1e4344 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Tue, 19 Mar 2024 11:16:55 +1000 Subject: [PATCH] Only use executables in ScriptsModel::download if we're based_on audit_linux.sh. --- app/Models/ScriptsModel.php | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/app/Models/ScriptsModel.php b/app/Models/ScriptsModel.php index 549692010..da24073b1 100644 --- a/app/Models/ScriptsModel.php +++ b/app/Models/ScriptsModel.php @@ -406,26 +406,28 @@ public function download(int $id = 0): ?string } if (!empty($instance->config->executables) and $instance->config->executables) { - $sql = "SELECT * FROM executables"; - $result = $this->db->query($sql)->getResult(); - $exclusions = array(); - if (!empty($result)) { - foreach ($result as $item) { - $path = str_replace('\\', '\\\\', $item->path); - if ($item->exclude === 'n') { - $replace = $find . "\nexecutables[" . ($item->id + 1) . ']="' . $path . '"'; - $file = str_replace($find, $replace, $file); - } - if ($item->exclude === 'y') { - #$replace = $find . "\nexclusions[" . ($item->id + 1) . ']="' . $path . '"'; - #$file = str_replace($find, $replace, $file); - $exclusions[] = $path; + if ($data->based_on === 'audit_linux.sh') { + $sql = "SELECT * FROM executables"; + $result = $this->db->query($sql)->getResult(); + $exclusions = array(); + if (!empty($result)) { + foreach ($result as $item) { + $path = str_replace('\\', '\\\\', $item->path); + if ($item->exclude === 'n') { + $replace = $find . "\nexecutables[" . ($item->id + 1) . ']="' . $path . '"'; + $file = str_replace($find, $replace, $file); + } + if ($item->exclude === 'y') { + #$replace = $find . "\nexclusions[" . ($item->id + 1) . ']="' . $path . '"'; + #$file = str_replace($find, $replace, $file); + $exclusions[] = $path; + } } } - } - if (!empty($exclusions)) { - $replace = $find . "\nexclusions=\"" . implode('|', $exclusions) . "\""; - $file = str_replace($find, $replace, $file); + if (!empty($exclusions)) { + $replace = $find . "\nexclusions=\"" . implode('|', $exclusions) . "\""; + $file = str_replace($find, $replace, $file); + } } }