Fix bugs found in second multi-agent review
Security / PHP Security (semgrep) (push) Successful in 1m14s
Lint / Deploy (push) Successful in 3s
Lint / PHP (phpcs PSR-12) (push) Successful in 19s
Lint / JS (eslint) (push) Successful in 8s
Lint / PHP requirements (version + extensions) (push) Successful in 24s
Lint / Notify on failure (push) Has been skipped
Security / PHP Security (semgrep) (push) Successful in 1m14s
Lint / Deploy (push) Successful in 3s
Lint / PHP (phpcs PSR-12) (push) Successful in 19s
Lint / JS (eslint) (push) Successful in 8s
Lint / PHP requirements (version + extensions) (push) Successful in 24s
Lint / Notify on failure (push) Has been skipped
XSS / security:
- markdown.js: sanitize footnote labels to a safe slug before using them in
id/href attributes. Labels are captured before the HTML-escape pass, so a
label like x"><img onerror=...> broke out → stored XSS (the earlier quote-
escape fix didn't cover this path). Verified neutralized.
- RateLimitMiddleware: only trust X-Forwarded-For / X-Real-IP when REMOTE_ADDR
is a configured trusted proxy, and use the rightmost (proxy-appended) entry.
Previously any client could rotate XFF to escape the per-IP rate limit.
- .env.example: document TRUSTED_PROXIES so fresh deploys aren't fail-open on
the Authelia forward-auth spoofing protection.
Correctness:
- notifications.php: my previous assigned-to LIKE fix anchored only on '}', so
BULK assignments (logged {"assigned_to":N,"bulk_operation_id":..}) produced
no "assigned to you" notification — now matches both '}' and ',' delimiters.
- notifications.php: implement the documented @mention notifications (query
action_type='mention' rows for the current user); they were never delivered.
- NotificationHelper::notifyWatchers: guard unchecked prepare() so a missing
ticket_watchers table can't fatal the request after its DB write committed.
- AuditLogModel::getTicketTimeline: JSON_UNQUOTE the extracted ticket_id so
comment events actually match (string vs JSON-number comparison never did).
- AuditLogModel/audit_log.php: CSV export no longer silently truncates to the
1000-row UI cap; uses a dedicated higher export limit.
- DashboardView: quick-preview drawer read .ticket-link from the title cell
(which has none), so the title was always blank — use the cell text.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -46,8 +46,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$filters['ip_address'] = $_GET['ip_address'];
|
||||
}
|
||||
|
||||
// Get all matching logs (no limit for CSV export)
|
||||
$result = $auditLogModel->getFilteredLogs($filters, 10000, 0);
|
||||
// Get all matching logs for export. The forExport flag raises the cap
|
||||
// (model clamps to its export limit) so the CSV isn't silently truncated
|
||||
// to the 1000-row UI page limit.
|
||||
$result = $auditLogModel->getFilteredLogs($filters, PHP_INT_MAX, 0, true);
|
||||
$logs = $result['logs'];
|
||||
|
||||
// Set CSV headers
|
||||
|
||||
+32
-6
@@ -55,15 +55,18 @@ $assignSql = "SELECT
|
||||
AND al.entity_type = 'ticket'
|
||||
AND al.user_id != ?
|
||||
AND al.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
AND al.details LIKE ?
|
||||
AND (al.details LIKE ? OR al.details LIKE ?)
|
||||
ORDER BY al.created_at DESC
|
||||
LIMIT 15";
|
||||
|
||||
// Match the exact JSON value with a trailing delimiter so user 12 doesn't also
|
||||
// match 120/123/etc. The assign detail is logged as {"assigned_to":<int>}.
|
||||
$assignLike = '%"assigned_to":' . (int)$userId . '}%';
|
||||
// match 120/123/etc. Single assigns log {"assigned_to":5} (closing brace) while
|
||||
// bulk assigns log {"assigned_to":5,"bulk_operation_id":N} (comma) — match both.
|
||||
$assignId = (int)$userId;
|
||||
$assignEnd = '%"assigned_to":' . $assignId . '}%';
|
||||
$assignMid = '%"assigned_to":' . $assignId . ',%';
|
||||
$stmt = $conn->prepare($assignSql);
|
||||
$stmt->bind_param('is', $userId, $assignLike);
|
||||
$stmt->bind_param('iss', $userId, $assignEnd, $assignMid);
|
||||
$stmt->execute();
|
||||
$assignRows = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
@@ -150,10 +153,32 @@ $stmt->execute();
|
||||
$statusRows = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
// Query 4: @mentions of me (logged by add_comment.php as
|
||||
// action_type='mention', entity_type='user', entity_id=<mentioned user_id>).
|
||||
$mentionSql = "SELECT
|
||||
al.audit_id AS log_id, al.action_type, al.entity_type, al.entity_id, al.details, al.created_at,
|
||||
COALESCE(u.display_name, u.username, 'System') AS actor_name
|
||||
FROM audit_log al
|
||||
LEFT JOIN users u ON al.user_id = u.user_id
|
||||
WHERE al.action_type = 'mention'
|
||||
AND al.entity_type = 'user'
|
||||
AND al.entity_id = ?
|
||||
AND al.user_id != ?
|
||||
AND al.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
ORDER BY al.created_at DESC
|
||||
LIMIT 15";
|
||||
|
||||
$mentionEntityId = (string)$userId;
|
||||
$stmt = $conn->prepare($mentionSql);
|
||||
$stmt->bind_param('si', $mentionEntityId, $userId);
|
||||
$stmt->execute();
|
||||
$mentionRows = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
|
||||
$stmt->close();
|
||||
|
||||
// Merge, deduplicate by log_id, sort by created_at desc
|
||||
$all = [];
|
||||
$seen = [];
|
||||
foreach (array_merge($assignRows, $commentRows, $statusRows) as $row) {
|
||||
foreach (array_merge($assignRows, $commentRows, $statusRows, $mentionRows) as $row) {
|
||||
$id = (int)$row['log_id'];
|
||||
if (isset($seen[$id])) {
|
||||
continue;
|
||||
@@ -172,7 +197,7 @@ foreach ($all as $row) {
|
||||
$actionType = ($row['action_type'] === 'create' && $row['entity_type'] === 'comment')
|
||||
? 'comment'
|
||||
: $row['action_type'];
|
||||
$ticketId = ($actionType === 'comment')
|
||||
$ticketId = ($actionType === 'comment' || $actionType === 'mention')
|
||||
? ($details['ticket_id'] ?? 0)
|
||||
: $row['entity_id'];
|
||||
$isRead = $lastSeen && $row['created_at'] <= $lastSeen;
|
||||
@@ -181,6 +206,7 @@ foreach ($all as $row) {
|
||||
$title = match ($actionType) {
|
||||
'assign' => "{$row['actor_name']} assigned ticket #{$ticketId} to you",
|
||||
'comment' => "{$row['actor_name']} commented on ticket #{$ticketId}",
|
||||
'mention' => "{$row['actor_name']} mentioned you on ticket #{$ticketId}",
|
||||
'update' => (function () use ($row, $details, $ticketId) {
|
||||
// logTicketUpdate stores delta as {"status": {"from": "Open", "to": "In Progress"}}
|
||||
$from = $details['status']['from'] ?? ($details['old_value'] ?? '?');
|
||||
|
||||
Reference in New Issue
Block a user