Skip to content

Commit

Permalink
Added ShellTasksValidation audit action data to issues (#4756)
Browse files Browse the repository at this point in the history
* Add ShellTasksValidation audit action data to issues

* Add validation for issues by knob

* Remove knob
  • Loading branch information
KonstantinTyukalov authored Jul 18, 2024
1 parent b74907b commit 745922b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using Agent.Sdk.Knob;
using Microsoft.TeamFoundation.DistributedTask.WebApi;
using Microsoft.VisualStudio.Services.Agent.Util;
using Microsoft.VisualStudio.Services.Common;

Expand Down Expand Up @@ -132,7 +133,13 @@ public static (bool, Dictionary<string, object>) ValidateInputArguments(
{
if (enableAudit && !enableValidation)
{
context.Warning(StringUtil.Loc("ProcessHandlerInvalidScriptArgs"));
var issue = new Issue
{
Type = IssueType.Warning,
Message = StringUtil.Loc("ProcessHandlerInvalidScriptArgs"),
};
issue.Data.Add("auditAction", "1"); // ShellTasksValidation = 1
context.AddIssue(issue);
}
if (enableValidation)
{
Expand Down
9 changes: 8 additions & 1 deletion src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using Agent.Sdk.Knob;
using Microsoft.TeamFoundation.DistributedTask.WebApi;
using Microsoft.VisualStudio.Services.Agent.Util;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -288,7 +289,13 @@ private void ValidateScriptArgs(

if (!shouldThrow && enableSecureArgumentsAudit)
{
ExecutionContext.Warning(StringUtil.Loc("ProcessHandlerInvalidScriptArgs"));
var issue = new Issue
{
Type = IssueType.Warning,
Message = StringUtil.Loc("ProcessHandlerInvalidScriptArgs"),
};
issue.Data.Add("auditAction", "1"); // ShellTasksValidation = 1
ExecutionContext.AddIssue(issue);
}
}
if (enableTelemetry && telemetry != null)
Expand Down

0 comments on commit 745922b

Please sign in to comment.