Skip to content

Commit

Permalink
Add audit logging to new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ganiuszka committed Sep 2, 2024
1 parent 7202671 commit 069c0b8
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Web/Pages/ApplicationSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public function saveGeneral($sender, $param)
$web_config = $this->getModule('web_config');
$web_config->setConfig($this->web_config);
$web_config->setLanguage($this->Language->SelectedValue);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_APPLICATION,
"Save application general settings"
);
}
}

Expand All @@ -151,6 +157,12 @@ public function saveDisplay($sender, $param)
$this->web_config['baculum']['date_time_format'] = $this->DateTimeFormat->Text;
$this->web_config['baculum']['job_age_on_job_status_graph'] = $this->JobAgeOnJobStatusGraph->getValue();
$this->getModule('web_config')->setConfig($this->web_config);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_APPLICATION,
"Save application display settings"
);
}
}

Expand All @@ -159,6 +171,12 @@ public function saveFeatures($sender, $param)
if (count($this->web_config) > 0) {
$this->web_config['baculum']['enable_messages_log'] = ($this->EnableMessagesLog->Checked === true) ? 1 : 0;
$this->getModule('web_config')->setConfig($this->web_config);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_APPLICATION,
"Save application features settings"
);
}
}

Expand Down Expand Up @@ -233,11 +251,21 @@ public function startSelfTest($sender, $param): void
'oAppSettingsSelfTest.load_table_cb',
[$result->output]
);
$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_APPLICATION,
"Run application self test"
);
} else {
$this->getCallbackClient()->callClientFunction(
'oAppSettingsSelfTest.set_error',
[$result->output]
);
$this->getModule('audit')->audit(
AuditLog::TYPE_ERROR,
AuditLog::CATEGORY_APPLICATION,
"Error while running application self test"
);
}
}
}
6 changes: 6 additions & 0 deletions Web/Pages/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,12 @@ public function deployAPIAccessLink($sender, $param)
[$step_id, $url]
);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_APPLICATION,
"New API has been deployed to host: {$host}"
);

// It is last step. Add new API host to host config
$this->saveAPIHost(
$host,
Expand Down
11 changes: 11 additions & 0 deletions Web/Pages/NewVirtualFullJobWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* terms pursuant to its AGPLv3 Section 7.
*/

use Bacularis\Common\Modules\AuditLog;
use Bacularis\Common\Modules\Params;
use Bacularis\Web\Modules\BaculumWebPage;
use Prado\Web\Javascripts\TJavaScript;
Expand Down Expand Up @@ -860,10 +861,20 @@ public function wizardCompleted($sender, $param)
);
if ($result->error === 0) {
$this->getModule('api')->set(['console'], ['reload']);
$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_CONFIG,
"Create new virtual full backup job. Name: {$job['Name']}"
);
$this->goToPage('JobList');
} else {
$this->CreateResourceErrMsg->Display = 'Dynamic';
$this->CreateResourceErrMsg->Text = $result->output;
$this->getModule('audit')->audit(
AuditLog::TYPE_ERROR,
AuditLog::CATEGORY_CONFIG,
"Error while creating new virtual full backup job. Name: {$job['Name']}, Error: {$result->error}, Output: {$result->output}"
);
}
}

Expand Down
36 changes: 36 additions & 0 deletions Web/Pages/Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

use Prado\Prado;
use Bacularis\Common\Modules\AuditLog;
use Bacularis\Web\Modules\BaculumWebPage;
use Bacularis\Web\Modules\ConfigConfig;
use Bacularis\Web\Modules\PatternConfig;
Expand Down Expand Up @@ -194,6 +195,12 @@ public function saveConfigs($sender, $param)

// update config list
$this->loadConfigList(null, null);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_CONFIG,
"Save config. Name: {$name}"
);
} else {
$cb->callClientFunction(
'oConfig.show_error',
Expand All @@ -202,6 +209,11 @@ public function saveConfigs($sender, $param)
Prado::localize('Error while writing config.')
]
);
$this->getModule('audit')->audit(
AuditLog::TYPE_ERROR,
AuditLog::CATEGORY_CONFIG,
"Error while saving config. Name: {$name}"
);
}
}

Expand Down Expand Up @@ -246,6 +258,12 @@ public function removeConfigs($sender, $param)

// update config list
$this->loadConfigList(null, null);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_CONFIG,
"Remove configs. Name: {$names}"
);
}

public function loadPattern($sender, $param)
Expand Down Expand Up @@ -338,6 +356,12 @@ public function savePattern($sender, $param)

// update config list
$this->loadConfigList(null, null);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_CONFIG,
"Save pattern. Name: {$name}"
);
} else {
$cb->callClientFunction(
'oPattern.show_error',
Expand All @@ -346,6 +370,12 @@ public function savePattern($sender, $param)
Prado::localize('Error while writing pattern.')
]
);

$this->getModule('audit')->audit(
AuditLog::TYPE_ERROR,
AuditLog::CATEGORY_CONFIG,
"Error while saving pattern. Name: {$name}"
);
}
}

Expand All @@ -366,5 +396,11 @@ public function removePatterns($sender, $param)

// update config list
$this->loadConfigList(null, null);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_CONFIG,
"Remove patterns. Name: {$names}"
);
}
}
18 changes: 18 additions & 0 deletions Web/Pages/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,12 @@ public function saveUserAPIHostResourceAccess($sender, $param)
$api_host,
'user_access_window_error'
);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_SECURITY,
"Save user API host access to resources. API host: $api_host"
);
}

/**
Expand Down Expand Up @@ -2480,6 +2486,12 @@ public function saveAPIHostResourceAccess($sender, $param)
$api_host,
'api_host_access_window_error'
);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_SECURITY,
"Save API host access to resources. API host: $api_host"
);
}

/**
Expand Down Expand Up @@ -3291,5 +3303,11 @@ public function saveAPIHostGroupAPIHostResourceAccess($sender, $param)
$api_host,
'api_host_group_access_window_error'
);

$this->getModule('audit')->audit(
AuditLog::TYPE_INFO,
AuditLog::CATEGORY_SECURITY,
"Save API host group access to resources. API host: $api_host"
);
}
}

0 comments on commit 069c0b8

Please sign in to comment.