From 745922bdd857273d54da3c8a3a6146de63df907f Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov <52399739+KonstantinTyukalov@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:46:11 +0200 Subject: [PATCH] Added ShellTasksValidation audit action data to issues (#4756) * Add ShellTasksValidation audit action data to issues * Add validation for issues by knob * Remove knob --- .../Handlers/ProcessHandler/ProcessHandlerHelper.cs | 9 ++++++++- .../Handlers/ProcessHandler/ProcessHandlerV2.cs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerHelper.cs b/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerHelper.cs index 3315f45c39..fed6e68f4a 100644 --- a/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerHelper.cs +++ b/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerHelper.cs @@ -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; @@ -132,7 +133,13 @@ public static (bool, Dictionary) 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) { diff --git a/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerV2.cs b/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerV2.cs index a0b2eff3a8..e26cac2ae7 100644 --- a/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerV2.cs +++ b/src/Agent.Worker/Handlers/ProcessHandler/ProcessHandlerV2.cs @@ -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; @@ -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)