Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/JD.Worker.Core/Services/JobService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ record = transition.Job;

await _jobStore.SaveAsync(record, cancellationToken);
await _scheduler.EnqueueAsync(record.JobId, cancellationToken);
_logger.LogInformation("Job {JobId} accepted with state {State}.", record.JobId, record.State);
_logger.LogInformation("Job {JobId} accepted with state {State}.", SanitizeLogValue(record.JobId), record.State);
return record;
}

/// <summary>
/// Strips CR/LF and other control characters from a value before it is written
/// to a log entry, preventing log-forging attacks (CWE-117 / CodeQL cs/log-forging).
/// </summary>
private static string SanitizeLogValue(string value) =>
value.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");

public Task<IReadOnlyList<JobRecord>> ListAsync(JobState? state, CancellationToken cancellationToken) =>
_jobStore.ListAsync(state, cancellationToken);
}
Loading