Skip to content

Commit

Permalink
Only use executables in ScriptsModel::download if we're based_on audi…
Browse files Browse the repository at this point in the history
…t_linux.sh.
  • Loading branch information
mark-unwin committed Mar 19, 2024
1 parent 99f72f3 commit 43749f8
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions app/Models/ScriptsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 43749f8

Please sign in to comment.