mirror of
https://github.com/actions/runner.git
synced 2025-12-10 20:36:49 +00:00
Compare commits
2 Commits
add-mask-b
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
305e79dbd3 | ||
|
|
2f074859d8 |
@@ -4,7 +4,7 @@
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:1": {},
|
||||
"ghcr.io/devcontainers/features/dotnet": {
|
||||
"version": "6.0.415"
|
||||
"version": "6.0.416"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "16"
|
||||
|
||||
@@ -1 +1 @@
|
||||
531b31914e525ecb12cc5526415bc70a112ebc818f877347af1a231011f539c5
|
||||
48f40cbefc445930c591c30353e44d6ad8d0cd6b2a416e1cf700a790242b0773
|
||||
|
||||
@@ -1 +1 @@
|
||||
722dd5fa5ecc207fcccf67f6e502d689f2119d8117beff2041618fba17dc66a4
|
||||
b7665f87ac4d2da26585a0879e42a4b95da8c29630146a554f4663441993f372
|
||||
|
||||
@@ -1 +1 @@
|
||||
8ca75c76e15ab9dc7fe49a66c5c74e171e7fabd5d26546fda8931bd11bff30f9
|
||||
8d4239572db392fc67a58fca500b7e504775aabae9d89d4e3cb26bdd3543bbcf
|
||||
|
||||
@@ -1 +1 @@
|
||||
70496eb1c99b39b3373b5088c95a35ebbaac1098e6c47c8aab94771f3ffbf501
|
||||
23b575d5206df3f31076fb0a9fef9abf9adbd3340887bffd2e6e636b3b819ed5
|
||||
|
||||
@@ -1 +1 @@
|
||||
4f8d48727d535daabcaec814e0dafb271c10625366c78e7e022ca7477a73023f
|
||||
fb6fbc30bb68ff6d0d7f2b4f397385543f3cd70caabf7fc7e47116f3fbec5943
|
||||
|
||||
@@ -1 +1 @@
|
||||
d54d7428f2b9200a0030365a6a4e174e30a1b29b922f8254dffb2924bd09549d
|
||||
6e53e214a4431c452ddc5a4e34da05f4ca53a0b63ed8c84a4cec8e20d99375f7
|
||||
|
||||
@@ -1 +1 @@
|
||||
eaa939c45307f46b7003902255b3a2a09287215d710984107667e03ac493eb26
|
||||
41e7d2f257d647cbb1460dfa1114a74c3e9c1cf73f756d6fc964f3c02785d96f
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using GitHub.Runner.Sdk;
|
||||
using GitHub.Runner.Common.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -7,28 +6,29 @@ namespace GitHub.Runner.Common
|
||||
{
|
||||
public sealed class ActionCommand
|
||||
{
|
||||
private static readonly StringEscapingUtil.EscapeMapping[] _escapeMappings = new[]
|
||||
private static readonly EscapeMapping[] _escapeMappings = new[]
|
||||
{
|
||||
new StringEscapingUtil.EscapeMapping(token: ";", replacement: "%3B"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "\r", replacement: "%0D"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "\n", replacement: "%0A"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "]", replacement: "%5D"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "%", replacement: "%25"),
|
||||
new EscapeMapping(token: ";", replacement: "%3B"),
|
||||
new EscapeMapping(token: "\r", replacement: "%0D"),
|
||||
new EscapeMapping(token: "\n", replacement: "%0A"),
|
||||
new EscapeMapping(token: "]", replacement: "%5D"),
|
||||
new EscapeMapping(token: "%", replacement: "%25"),
|
||||
};
|
||||
|
||||
private static readonly StringEscapingUtil.EscapeMapping[] _escapeDataMappings = new[]
|
||||
private static readonly EscapeMapping[] _escapeDataMappings = new[]
|
||||
{
|
||||
new StringEscapingUtil.EscapeMapping(token: "\r", replacement: "%0D"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "\n", replacement: "%0A"),
|
||||
new EscapeMapping(token: "\r", replacement: "%0D"),
|
||||
new EscapeMapping(token: "\n", replacement: "%0A"),
|
||||
new EscapeMapping(token: "%", replacement: "%25"),
|
||||
};
|
||||
|
||||
private static readonly StringEscapingUtil.EscapeMapping[] _escapePropertyMappings = new[]
|
||||
private static readonly EscapeMapping[] _escapePropertyMappings = new[]
|
||||
{
|
||||
new StringEscapingUtil.EscapeMapping(token: "\r", replacement: "%0D"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "\n", replacement: "%0A"),
|
||||
new StringEscapingUtil.EscapeMapping(token: ":", replacement: "%3A"),
|
||||
new StringEscapingUtil.EscapeMapping(token: ",", replacement: "%2C"),
|
||||
new StringEscapingUtil.EscapeMapping(token: "%", replacement: "%25"),
|
||||
new EscapeMapping(token: "\r", replacement: "%0D"),
|
||||
new EscapeMapping(token: "\n", replacement: "%0A"),
|
||||
new EscapeMapping(token: ":", replacement: "%3A"),
|
||||
new EscapeMapping(token: ",", replacement: "%2C"),
|
||||
new EscapeMapping(token: "%", replacement: "%25"),
|
||||
};
|
||||
|
||||
private readonly Dictionary<string, string> _properties = new(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -103,12 +103,12 @@ namespace GitHub.Runner.Common
|
||||
string[] pair = propertyStr.Split(new[] { '=' }, count: 2, options: StringSplitOptions.RemoveEmptyEntries);
|
||||
if (pair.Length == 2)
|
||||
{
|
||||
command.Properties[pair[0]] = StringEscapingUtil.UnescapeString(pair[1], _escapePropertyMappings);
|
||||
command.Properties[pair[0]] = UnescapeProperty(pair[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command.Data = StringEscapingUtil.UnescapeString(message.Substring(endIndex + _commandKey.Length), _escapeDataMappings);
|
||||
command.Data = UnescapeData(message.Substring(endIndex + _commandKey.Length));
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
@@ -173,12 +173,12 @@ namespace GitHub.Runner.Common
|
||||
string[] pair = propertyStr.Split(new[] { '=' }, count: 2, options: StringSplitOptions.RemoveEmptyEntries);
|
||||
if (pair.Length == 2)
|
||||
{
|
||||
command.Properties[pair[0]] = StringEscapingUtil.UnescapeString(pair[1], _escapeMappings);
|
||||
command.Properties[pair[0]] = Unescape(pair[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command.Data = StringEscapingUtil.UnescapeString(message.Substring(rbIndex + 1), _escapeMappings);
|
||||
command.Data = Unescape(message.Substring(rbIndex + 1));
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
@@ -187,5 +187,67 @@ namespace GitHub.Runner.Common
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Unescape(string escaped)
|
||||
{
|
||||
if (string.IsNullOrEmpty(escaped))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string unescaped = escaped;
|
||||
foreach (EscapeMapping mapping in _escapeMappings)
|
||||
{
|
||||
unescaped = unescaped.Replace(mapping.Replacement, mapping.Token);
|
||||
}
|
||||
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
private static string UnescapeProperty(string escaped)
|
||||
{
|
||||
if (string.IsNullOrEmpty(escaped))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string unescaped = escaped;
|
||||
foreach (EscapeMapping mapping in _escapePropertyMappings)
|
||||
{
|
||||
unescaped = unescaped.Replace(mapping.Replacement, mapping.Token);
|
||||
}
|
||||
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
private static string UnescapeData(string escaped)
|
||||
{
|
||||
if (string.IsNullOrEmpty(escaped))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string unescaped = escaped;
|
||||
foreach (EscapeMapping mapping in _escapeDataMappings)
|
||||
{
|
||||
unescaped = unescaped.Replace(mapping.Replacement, mapping.Token);
|
||||
}
|
||||
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
private sealed class EscapeMapping
|
||||
{
|
||||
public string Replacement { get; }
|
||||
public string Token { get; }
|
||||
|
||||
public EscapeMapping(string token, string replacement)
|
||||
{
|
||||
ArgUtil.NotNullOrEmpty(token, nameof(token));
|
||||
ArgUtil.NotNullOrEmpty(replacement, nameof(replacement));
|
||||
Token = token;
|
||||
Replacement = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using GitHub.Runner.Sdk;
|
||||
using GitHub.Runner.Common;
|
||||
|
||||
namespace GitHub.Runner.Common.Util
|
||||
{
|
||||
public static class StringEscapingUtil
|
||||
{
|
||||
|
||||
public static string UnescapeString(string escaped, EscapeMapping[] _escapeDataMappings)
|
||||
{
|
||||
if (string.IsNullOrEmpty(escaped))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string unescaped = escaped;
|
||||
foreach (EscapeMapping mapping in _escapeDataMappings)
|
||||
{
|
||||
unescaped = unescaped.Replace(mapping.Replacement, mapping.Token);
|
||||
}
|
||||
|
||||
return unescaped;
|
||||
}
|
||||
public class EscapeMapping
|
||||
{
|
||||
public string Replacement { get; }
|
||||
public string Token { get; }
|
||||
|
||||
public EscapeMapping(string token, string replacement)
|
||||
{
|
||||
ArgUtil.NotNullOrEmpty(token, nameof(token));
|
||||
ArgUtil.NotNullOrEmpty(replacement, nameof(replacement));
|
||||
Token = token;
|
||||
Replacement = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
message = "::do-something k1=;=%252C=%250D=%250A=]=%253A,::;-%250D-%250A-]-:-,";
|
||||
test = new ActionCommand("do-something")
|
||||
{
|
||||
Data = ";-%250D-%250A-]-:-,",
|
||||
Data = ";-%0D-%0A-]-:-,",
|
||||
};
|
||||
test.Properties.Add("k1", ";=%2C=%0D=%0A=]=%3A");
|
||||
Assert.True(ActionCommand.TryParseV2(message, commands, out verify));
|
||||
|
||||
@@ -443,21 +443,6 @@ namespace GitHub.Runner.Common.Tests.Worker
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Trait("Level", "L0")]
|
||||
[Trait("Category", "Worker")]
|
||||
public void AddMaskWithPercentEncodedString()
|
||||
{
|
||||
using (TestHostContext hc = CreateTestContext())
|
||||
{
|
||||
// Act
|
||||
_commandManager.TryProcessCommand(_ec.Object, $"::add-mask::%252F%2F", null);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("***", hc.SecretMasker.MaskSecrets("%252F%2F"));
|
||||
}
|
||||
}
|
||||
|
||||
private TestHostContext CreateTestContext([CallerMemberName] string testName = "")
|
||||
{
|
||||
var hostContext = new TestHostContext(this, testName);
|
||||
|
||||
@@ -22,7 +22,7 @@ DOWNLOAD_DIR="$SCRIPT_DIR/../_downloads/netcore2x"
|
||||
PACKAGE_DIR="$SCRIPT_DIR/../_package"
|
||||
PACKAGE_TRIMS_DIR="$SCRIPT_DIR/../_package_trims"
|
||||
DOTNETSDK_ROOT="$SCRIPT_DIR/../_dotnetsdk"
|
||||
DOTNETSDK_VERSION="6.0.415"
|
||||
DOTNETSDK_VERSION="6.0.416"
|
||||
DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION"
|
||||
RUNNER_VERSION=$(cat runnerversion)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "6.0.415"
|
||||
"version": "6.0.416"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user