Skip to content

Commit c1ed615

Browse files
committed
SimpleRisk 20241209-001 Release
1 parent 7f8f436 commit c1ed615

2,550 files changed

Lines changed: 121043 additions & 159343 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

simplerisk/admin/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@
11211121
</div>
11221122
</div>
11231123
</div>
1124-
<form name="backups_settings" method="post" action="">
1124+
<form name="backups_settings" method="post" action="" class="block-on-submit">
11251125
<div class="card-body my-2 border">
11261126
<div class="row">
11271127
<div class="col-md-12">

simplerisk/api/index.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function getRoute() { return app(); }
102102
app()->post('/assessment/update', 'updateAssessment');
103103

104104
app()->post('/datatable/framework_controls', 'getFrameworkControlsDatatable');
105-
app()->get('/datatable/mitigation_controls', 'getMitigationControlsDatatable');
105+
app()->post('/datatable/mitigation_controls', 'getMitigationControlsDatatable');
106106
app()->get('/role_responsibilities/get_responsibilities', 'getResponsibilitiesByRoleIdForm');
107107

108108
/******************** Risk Management Datatatable API **********************/
@@ -136,7 +136,7 @@ function getRoute() { return app(); }
136136
app()->post('/governance/add_control', 'addControlResponse');
137137
app()->post('/governance/update_control', 'updateControlResponse');
138138

139-
app()->get('/compliance/define_tests', 'getDefineTestsResponse');
139+
app()->post('/compliance/define_tests', 'getDefineTestsResponse');
140140
app()->get('/compliance/test', 'getTestResponse');
141141
app()->get('/compliance/initiate_audits', 'getInitiateTestAuditsResponse');
142142
app()->post('/compliance/active_audits', 'getActiveTestAuditsResponse');
@@ -265,6 +265,9 @@ function getRoute() { return app(); }
265265
app()->get('/complianceforgescf/disable', 'api_complianceforgescf_disable');
266266
app()->get('/complianceforgescf/status', 'api_complianceforgescf_status');
267267

268+
/************************** DATATABLE API BEGIN *******************************/
269+
app()->post('/get/datatable', 'getDatatableAPI');
270+
/*************************** DATATABLE API END ********************************/
268271

269272
/************************** SIMPLERISK EXTRAS APIS ************************************/
270273

simplerisk/api/v2/index.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
app()->post('/assessment/update', 'updateAssessment');
151151

152152
app()->post('/datatable/framework_controls', 'getFrameworkControlsDatatable');
153-
app()->get('/datatable/mitigation_controls', 'getMitigationControlsDatatable');
153+
app()->post('/datatable/mitigation_controls', 'getMitigationControlsDatatable');
154154
app()->get('/role_responsibilities/get_responsibilities', 'getResponsibilitiesByRoleIdForm');
155155

156156
/******************** Risk Management Datatatable API **********************/
@@ -184,7 +184,7 @@
184184
app()->post('/governance/add_control', 'addControlResponse');
185185
app()->post('/governance/update_control', 'updateControlResponse');
186186

187-
app()->get('/compliance/define_tests', 'getDefineTestsResponse');
187+
app()->post('/compliance/define_tests', 'getDefineTestsResponse');
188188
app()->get('/compliance/test', 'getTestResponse');
189189
app()->get('/compliance/initiate_audits', 'getInitiateTestAuditsResponse');
190190
app()->post('/compliance/active_audits', 'getActiveTestAuditsResponse');
@@ -322,6 +322,10 @@
322322
// Enable / disable the Incident Management Extra
323323
app()->post('/admin/incidentmanagement', 'incidentManagementAPI');
324324

325+
/************************** DATATABLE API BEGIN *******************************/
326+
app()->post('/get/datatable', 'getDatatableAPI');
327+
/*************************** DATATABLE API END ********************************/
328+
325329
/************************** SIMPLERISK EXTRAS APIS ************************************/
326330

327331
// If the Advanced Search Extra is enabled

simplerisk/assessments/contacts.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<div id="aseessment-contact--add" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="aseessment-contact--add" aria-hidden="true">
9292
<div class="modal-dialog modal-lg modal-dialog-scrollable modal-dialog-centered">
9393
<div class="modal-content">
94-
<form method="post" action="">
94+
<form method="post" action="" name="aseessment-contact--add-form">
9595
<div class="modal-header">
9696
<h4 class="modal-title"><?= $escaper->escapeHtml($lang['AddNewAssessmentContact']); ?></h4>
9797
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
@@ -111,7 +111,7 @@
111111
</div>
112112
<div class="form-group">
113113
<label><?= $escaper->escapeHtml($lang['Phone']);?> :</label>
114-
<input required class = "form-control" name="phone" maxlength="200" size="100" value="" type="text">
114+
<input class = "form-control" name="phone" maxlength="200" size="100" value="" type="text">
115115
</div>
116116
<div class="form-group">
117117
<label><?= $escaper->escapeHtml($lang['ContactManager']);?> :</label>
@@ -137,7 +137,7 @@
137137
<div id="aseessment-contact--edit" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="aseessment-contact--edit" aria-hidden="true">
138138
<div class="modal-dialog modal-lg modal-dialog-scrollable modal-dialog-centered">
139139
<div class="modal-content">
140-
<form method="post" action="">
140+
<form method="post" action="" name="aseessment-contact--edit-form">
141141
<input type='hidden' name='id' value=''/>
142142
<div class="modal-header">
143143
<h4 class="modal-title"><?= $escaper->escapeHtml($lang['UpdateAssessmentContact']); ?></h4>
@@ -158,7 +158,7 @@
158158
</div>
159159
<div class="form-group">
160160
<label><?= $escaper->escapeHtml($lang['Phone']);?> :</label>
161-
<input name="phone" class = "form-control" maxlength="200" value="" size="100" type="text" required>
161+
<input name="phone" class = "form-control" maxlength="200" value="" size="100" type="text">
162162
</div>
163163
<div class="form-group">
164164
<label><?= $escaper->escapeHtml($lang['ContactManager']);?> :</label>
@@ -264,6 +264,16 @@
264264
$("#aseessment-contact--delete").modal("show");
265265

266266
});
267+
268+
// Phone number validation before submitting the add/edit assessment contact form data
269+
$('body').on("submit", "[name=aseessment-contact--add-form], [name=aseessment-contact--edit-form]", function() {
270+
let phone_regex = /^[+]?[\d\s-]{10,15}$/;
271+
let input_value = $(this).find("[name=phone]").val();
272+
if (!phone_regex.test(input_value)) {
273+
toastr.error("<?= $escaper->escapeHtml($lang['PleaseEnterAValidPhoneNumber']) ?>");
274+
event.preventDefault();
275+
}
276+
});
267277

268278
});
269279

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
<?php
2-
/* This Source Code Form is subject to the terms of the Mozilla Public
3-
* License, v. 2.0. If a copy of the MPL was not distributed with this
4-
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2+
/* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

6-
// Include required functions file
7-
require_once(realpath(__DIR__ . '/../includes/renderutils.php'));
8-
render_header_and_sidebar(['blockUI', 'selectize', 'datatables', 'WYSIWYG', 'multiselect', 'CUSTOM:pages/compliance.js', 'CUSTOM:common.js'], ['check_compliance' => true]);
6+
// Include required functions file
7+
require_once(realpath(__DIR__ . '/../includes/renderutils.php'));
8+
render_header_and_sidebar(['blockUI', 'selectize', 'datatables', 'WYSIWYG', 'multiselect', 'CUSTOM:pages/compliance.js', 'CUSTOM:common.js'], ['check_compliance' => true]);
99

10-
// Include required functions file
11-
require_once(realpath(__DIR__ . '/../includes/governance.php'));
12-
require_once(realpath(__DIR__ . '/../includes/compliance.php'));
10+
// Include required functions file
11+
require_once(realpath(__DIR__ . '/../includes/compliance.php'));
1312

1413
?>
1514
<div class="row bg-white">
1615
<div class="col-12">
17-
<div class="compliance-content-container">
18-
<?php display_active_audits(); ?>
19-
</div>
16+
<?php
17+
display_active_audits();
18+
?>
2019
</div>
2120
</div>
2221
<?php
23-
// Render the footer of the page. Please don't put code after this part.
24-
render_footer();
22+
// Render the footer of the page. Please don't put code after this part.
23+
render_footer();
2524
?>

simplerisk/compliance/past_audits.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<?php
2-
/* This Source Code Form is subject to the terms of the Mozilla Public
3-
* License, v. 2.0. If a copy of the MPL was not distributed with this
4-
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2+
/* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

6-
// Include required functions file
7-
require_once(realpath(__DIR__ . '/../includes/renderutils.php'));
8-
render_header_and_sidebar(['blockUI', 'selectize', 'datatables', 'WYSIWYG', 'multiselect', 'datetimerangepicker', 'CUSTOM:pages/compliance.js'], ['check_compliance' => true]);
6+
// Include required functions file
7+
require_once(realpath(__DIR__ . '/../includes/renderutils.php'));
8+
render_header_and_sidebar(['blockUI', 'selectize', 'datatables', 'WYSIWYG', 'multiselect', 'datetimerangepicker', 'CUSTOM:pages/compliance.js'], ['check_compliance' => true]);
99

10-
// Include required functions file
11-
require_once(realpath(__DIR__ . '/../includes/governance.php'));
12-
require_once(realpath(__DIR__ . '/../includes/compliance.php'));
10+
// Include required functions file
11+
require_once(realpath(__DIR__ . '/../includes/compliance.php'));
1312

1413
?>
15-
<div class="row bg-white compliance-content-container">
14+
<div class="row bg-white">
1615
<div class="col-12">
17-
<?php display_past_audits(); ?>
16+
<?php
17+
display_past_audits();
18+
?>
1819
</div>
1920
</div>
2021
<?php

simplerisk/cron/cron_backup.php

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,22 @@ function do_backup($force=false) {
9595

9696
// Get the path to the database backup file
9797
$db_backup_file = $timestamp_path . '/simplerisk-db-backup-' . $timestamp . '.sql';
98+
99+
// Get the mysqldump command
100+
$cmd = get_mysqldump_command();
101+
102+
// Add the output redirect to the mysqldump command
103+
$db_backup_cmd = $cmd . ' > ' . escapeshellarg($db_backup_file);
104+
105+
// Backup the database
106+
$mysqldump = system($db_backup_cmd);
107+
108+
$db_zip_file_name = $timestamp_path . '/simplerisk-db-backup-' . $timestamp . '.zip';
98109
create_zip_file($db_backup_file, $db_zip_file_name);
99110

100111
// Remove the uncompressed database backup
101112
unlink($db_backup_file);
113+
102114
// Create a zip file containing the current SimpleRisk files
103115
$simplerisk_directory = realpath(__DIR__) . '/../';
104116
$app_zip_file_name = $timestamp_path . '/simplerisk-app-backup-' . $timestamp . '.zip';
@@ -119,45 +131,56 @@ function do_backup($force=false) {
119131
$stmt->bindParam(":app_zip_file_name", $app_zip_file_name, PDO::PARAM_STR);
120132
$stmt->bindParam(":db_zip_file_name", $db_zip_file_name, PDO::PARAM_STR);
121133
$stmt->execute();
122-
123-
// Delete backup information from the database that is older than the backup_remove days ago
124-
$stmt = $db->prepare("DELETE FROM `backups` WHERE timestamp < (NOW() - INTERVAL :backup_remove DAY);");
134+
135+
// Get the list of expired backups
136+
$stmt = $db->prepare("SELECT * FROM `backups` WHERE timestamp < (NOW() - INTERVAL :backup_remove DAY);");
125137
$stmt->bindParam(":backup_remove", $backup_remove, PDO::PARAM_INT);
126138
$stmt->execute();
127-
128-
// Close the database connection
129-
db_close($db);
130-
131-
$directories = glob($backup_path."/*");
132-
$now = time();
133-
134-
// Remove all directories older than the backup remove days
135-
foreach ($directories as $directory)
136-
{
137-
// If it is a directory
138-
if (is_dir($directory))
139-
{
140-
// If the directory was created more than the backup_remove days ago
141-
// 60 seconds x 60 minutes x 24 hours x # of days
142-
if ($now - filemtime($directory) >= 60 * 60 * 24 * $backup_remove)
143-
{
144-
// Remove all files from this directory
145-
array_map('unlink', glob("$directory/*.*"));
146-
147-
// Remove the directory
148-
rmdir($directory);
149-
150-
$message = "Removed backup older than {$backup_remove} days: {$directory}.";
151-
write_debug_log_cli($message);
152-
write_log(0, 0, $message, 'backup');
139+
$backups_to_delete = $stmt->fetchAll(PDO::FETCH_ASSOC);
140+
141+
// Iterate through the list of expired backups and clean them up
142+
foreach ($backups_to_delete as $backup_to_delete) {
143+
144+
// Initializing variables in every iteration
145+
$parent_directory = dirname($backup_to_delete['app_zip_file_name']);
146+
$missing_backup_directory = !is_dir($parent_directory);
147+
$backup_directory_delete_successful = false;
148+
149+
// If the backup directory exists
150+
if (!$missing_backup_directory) {
151+
152+
// Remove all files from this directory
153+
array_map('unlink', glob("$parent_directory/*.*"));
154+
155+
// Remove the directory
156+
rmdir($parent_directory);
157+
158+
// Check if the directory was successfully removed
159+
$backup_directory_delete_successful = !is_dir($parent_directory);
160+
if ($backup_directory_delete_successful) {
161+
$message = "Removed backup older than {$backup_remove} days: '{$parent_directory}'.";
162+
} else {
163+
$message = "Failed to remove backup directory '{$parent_directory}', not deleting the associated database entry.";
153164
}
165+
} else {
166+
$message = "Backup directory '{$parent_directory}' was already deleted, cleaned up associated database entry.";
154167
}
168+
169+
// Delete the database entry if the directory was either missing already or successfully deleted
170+
if ($missing_backup_directory || $backup_directory_delete_successful) {
171+
$stmt = $db->prepare("DELETE FROM `backups` WHERE `random_id` = :random_id;");
172+
$stmt->bindParam(":random_id", $backup_to_delete['random_id'], PDO::PARAM_STR);
173+
$stmt->execute();
174+
}
175+
176+
write_debug_log_cli($message);
177+
write_log(0, 0, $message, 'backup');
155178
}
156-
179+
157180
$message = "Backup successfully completed.";
158181
write_debug_log_cli($message);
159182
write_log(0, 0, $message, 'backup');
160-
183+
161184
// If the backup was requested from the UI
162185
if ($force) {
163186
set_alert(true, "good", $message);

simplerisk/css/style.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

simplerisk/css/style.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

simplerisk/header.php

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
'CUSTOM:common.js' => ['Yes', 'Cancel', 'FieldIsRequired'],
77
'EXTRA:JS:assessments:questionnaire_templates.js' => ['SelectedOnAnotherTab', 'ID', 'SelectedQuestions', 'SearchForQuestion', 'ConfirmDisableTabbedExperience', 'ConfirmDeleteTab', 'NewTab', 'Default'],
88
'CUSTOM:pages/plan-project.js' => ['AreYouSureYouWantToDeleteThisProject'],
9-
'datatables' => ['All', 'datatables_ShowAll', 'datatables_ShowLess', 'First', 'Previous', 'Next', 'Last']
9+
'datatables' => ['All', 'datatables_ShowAll', 'datatables_ShowLess', 'First', 'Previous', 'Next', 'Last'],
10+
'blockUI' => ['ProcessingPleaseWait'],
1011
];
1112

1213
?>
@@ -116,13 +117,44 @@
116117
$.blockUI.defaults.css = {
117118
padding: 0,
118119
margin: 0,
119-
width: '30%',
120+
width: '20%',
120121
top: '40%',
121-
left: '35%',
122+
left: '40%',
122123
textAlign: 'center',
123124
cursor: 'wait',
124-
blockMsgClass: 'blockMsg'
125+
color: 'var(--sr-light)',
126+
backgroundColor: 'rgba(0, 0, 0, 0)', // hide the background, so only the spinner is visible
125127
};
128+
129+
$.blockUI.defaults.overlayCSS = {
130+
backgroundColor: 'var(--sr-dark)',
131+
opacity: 0.6,
132+
cursor: 'wait'
133+
}
134+
135+
$.blockUI.defaults.message = "<i class='fa fa-spinner fa-spin' style='font-size:24px;'></i>";
136+
137+
// Store the original blockUI object, so we can still call it as a function and reassign its properties to the new implementation
138+
var _original_blockui = $.blockUI;
139+
140+
// Redefine the blockUI function call, so we can have different 'defaults' for it than for the block() function
141+
$.blockUI = function(arguments){
142+
_original_blockui({
143+
css: {
144+
padding: 5,
145+
border: '3px solid var(--sr-default)',
146+
backgroundColor: 'var(--sr-dark)',
147+
},
148+
message: "<i class='fa fa-spinner fa-spin' style='font-size:24px; padding-right: 10px;'></i>" + _lang['ProcessingPleaseWait'],
149+
});
150+
};
151+
152+
// Assign the properties of the original to the new implementation
153+
Object.assign($.blockUI, _original_blockui);
154+
});
155+
156+
$(document).on('submit', 'form.block-on-submit', function (e) {
157+
$.blockUI();
126158
});
127159
</script>
128160
<?php
@@ -585,6 +617,7 @@ function resize() {el.width((el.val().length + 1) * int);}
585617
var label = $(this).parent().find("span.editable");
586618
$(this).hide();
587619
label.text($(this).val());
620+
label.attr("title", $(this).val());
588621
label.show();
589622
});
590623
});

0 commit comments

Comments
 (0)