Sanitize your public API functions

This commit is contained in:
Jordan Brown
2018-09-15 15:16:38 -04:00
parent 4eb0b89b08
commit a8ae7efcaf
2 changed files with 14 additions and 0 deletions
@@ -119,6 +119,14 @@ namespace Tgstation.Server.Host.Components
/// <inheritdoc />
public async Task CompileProcess(Job job, IServiceProvider serviceProvider, Action<int> progressReporter, CancellationToken cancellationToken)
{
//DO NOT FOLLOW THE SUGGESTION FOR A THROW EXPRESSION HERE
if (job == null)
throw new ArgumentNullException(nameof(job));
if (serviceProvider == null)
throw new ArgumentNullException(nameof(serviceProvider));
if (progressReporter == null)
throw new ArgumentNullException(nameof(progressReporter));
var databaseContext = serviceProvider.GetRequiredService<IDatabaseContext>();
var ddSettingsTask = databaseContext.DreamDaemonSettings.Where(x => x.InstanceId == metadata.Id).Select(x => new DreamDaemonSettings
@@ -247,6 +247,8 @@ namespace Tgstation.Server.Host.Core
/// <inheritdoc />
public int? JobProgress(Job job)
{
if (job == null)
throw new ArgumentNullException(nameof(job));
lock (this)
{
if (!jobs.TryGetValue(job.Id, out var handler))
@@ -258,6 +260,10 @@ namespace Tgstation.Server.Host.Core
/// <inheritdoc />
public async Task WaitForJobCompletion(Job job, User canceller, CancellationToken jobCancellationToken, CancellationToken cancellationToken)
{
if (job == null)
throw new ArgumentNullException(nameof(job));
if (canceller == null)
throw new ArgumentNullException(nameof(canceller));
JobHandler handler;
lock (this)
{