CrowdSec no longer blocks new tickets and recurring tickets: the work-booking fields CrowdSec's copy of the OWASP Core Rule Set took for the Unix command sched are renamed book_at, book_minutes, book_onsite, book_time and book_agent in New Ticket, Dispatch's link to it, the Schedule window, the helper window and recurring tickets, the cron job window's field is job_schedule, the tickets list's Scheduled tab is show=booked, Maintenance > Cron sorts by when, and Stripe Checkout returns with checkout in place of session_id, each still accepting the old name; CONTRIBUTING.md rule and 26.12.6 changelog

This commit is contained in:
johnnyq
2026-12-05 03:37:49 -05:00
parent 2e51f18461
commit f99768bcb6
18 changed files with 71 additions and 41 deletions

View File

@@ -16,8 +16,9 @@
* there is nothing to change about it until cron has run once.
*/
// The list: by schedule until a heading is clicked - the every-minute jobs, then the day's in the order they run
$sort = "schedule";
// The list: by schedule until a heading is clicked - the every-minute jobs, then the day's in the order they run.
// Its key is when, not schedule: a web application firewall takes a value starting sched for the Unix command.
$sort = "when";
$order = "ASC";
require_once "includes/inc_all_admin.php";
@@ -233,23 +234,26 @@ $command_block = function () use ($cron_command) {
};
$owner_note = $file_owner !== '' ? ' (<code>' . escapeHtml($file_owner) . '</code> here)' : '';
// The list - only these sort; anything else asked for falls back to the schedule
// The list - only these sort; anything else asked for falls back to the schedule (schedule is when's name from before)
if ($sort === 'schedule') {
$sort = 'when';
}
$sort_keys = [
'job' => function ($job) { return strtolower($job['label']); },
'schedule' => function ($job) { return $job['schedule'] === 'Daily' ? 100000 + intval(substr($job['daily_at'], 0, 2)) * 60 + intval(substr($job['daily_at'], 3, 2)) : $job['interval_minutes']; },
'when' => function ($job) { return $job['schedule'] === 'Daily' ? 100000 + intval(substr($job['daily_at'], 0, 2)) * 60 + intval(substr($job['daily_at'], 3, 2)) : $job['interval_minutes']; },
'last_run' => function ($job) { return $job['last_run_at'] ? strtotime($job['last_run_at']) : 0; },
// What needs a look first
'status' => function ($job) { return array_search($job['state'], ['failed', 'lost', 'queued', 'running', 'paused', 'skipped', 'never', 'completed', 'unused'], true); },
];
if (!isset($sort_keys[$sort])) {
$sort = 'schedule';
$sort = 'when';
}
uasort($jobs, function ($a, $b) use ($sort_keys, $sort, $order) {
$compared = $sort_keys[$sort]($a) <=> $sort_keys[$sort]($b);
return ($order === 'DESC' ? -$compared : $compared) ?: $a['position'] <=> $b['position'];
});
// A heading sorts its own way round first - names A to Z, the latest run and what needs a look at the top - then the other
$sort_first = ['job' => 'ASC', 'schedule' => 'ASC', 'last_run' => 'DESC', 'status' => 'ASC'];
$sort_first = ['job' => 'ASC', 'when' => 'ASC', 'last_run' => 'DESC', 'status' => 'ASC'];
$sort_link = function ($column, $label) use ($sort_first) {
return sortLink($column, $label, $sort_first[$column] ?? null);
};
@@ -387,7 +391,7 @@ $status_looks = [
<thead class="table-light text-nowrap">
<tr>
<th class="ps-3" colspan="2"><?= $sort_link('job', 'Job') ?></th>
<th class="d-none d-md-table-cell"><?= $sort_link('schedule', 'Schedule') ?></th>
<th class="d-none d-md-table-cell"><?= $sort_link('when', 'Schedule') ?></th>
<th class="d-none d-md-table-cell"><?= $sort_link('last_run', 'Last run') ?></th>
<th><?= $sort_link('status', 'Status') ?></th>
<th></th>

View File

@@ -51,7 +51,7 @@ ob_start();
<label class="form-label">Schedule</label>
<div class="input-group">
<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
<select class="form-select select2" name="schedule" id="cronJobSchedule">
<select class="form-select select2" name="job_schedule" id="cronJobSchedule">
<?php if ($cron_job_interval_safe) { ?>
<option value="Interval" <?= $cron_job_schedule === 'Interval' ? 'selected' : '' ?>>Every so many minutes</option>
<?php } ?>

View File

@@ -47,7 +47,8 @@ if (isset($_POST['edit_cron_job'])) {
$cron_job_name = escapeSql($row['cron_job_name']);
$enabled = isset($_POST['enabled']) ? 1 : 0;
$schedule = $_POST['schedule'] === 'Daily' ? 'Daily' : 'Interval';
// (job_schedule - a web application firewall takes a field named sched... for the Unix command; schedule is from before)
$schedule = ($_POST['job_schedule'] ?? $_POST['schedule'] ?? '') === 'Daily' ? 'Daily' : 'Interval';
// A job the registry marks interval-unsafe only accepts the daily schedule. The form
// does not offer anything else, so anything else arriving here is a crafted request