Skip to content

Commit f9148b8

Browse files
authored
Merge branch 'main' into fix/secret-scanning-locations-types
2 parents 1a8554f + e424558 commit f9148b8

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

LATEST-VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.12.0
1+
v1.13.0

RELEASENOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
- Improved location matching logic for Secret Scanning alert locations in - `gh gei migrate-secret-alerts`.
2-
- Fixed a bug in `gh gei migrate-secret-alerts` where alerts with locations of non `commit` and `wiki_commit` type were not matched correctly.
2+
- Fixed a bug in `gh gei migrate-secret-alerts` where alerts with locations of non `commit` and `wiki_commit` type were not matched correctly.

releasenotes/v1.13.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `gh gei migrate-repo` logs the git and metadata archive download paths when `--keep-archive` is used.
2+
- Redact sensitive query arguments in SAS URLs

src/Octoshift/Services/OctoLogger.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ public class OctoLogger
3434

3535
private readonly List<string> _redactionPatterns =
3636
[
37-
"\\b(?<=token=)(.+?)\\b",
38-
"\\b(?<=X-Amz-Credential=)(.+?)\\b",
37+
// General purpose "Don't include the token"
38+
"\\b(?<=token=)([^&]+?)\\b",
39+
// AWS SIGv4 credential
40+
"\\b(?<=X-Amz-Credential=)([^&]+?)\\b",
41+
// Azure Blob Store SAS URL signature
42+
"\\b(?<=sig=)([^&]+?)\\b",
3943
];
4044

4145
public OctoLogger()

src/OctoshiftCLI.Tests/Octoshift/Services/OctoLoggerTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,35 @@ public void Aws_Url_X_Aws_Credential_Parameters_Should_Be_Replaced_In_Logs_And_C
110110
_consoleOutput.ToLower().Should().Contain("&x-amz-credential=***");
111111
}
112112

113+
[Theory]
114+
[InlineData("https://t3a00c49dev02arg01sa01.blob.core.windows.net/migration-archives-a9fd67c9-e987-4b3e-9cf2-439a95b7f275/f4e871a0-3214-4f94-a82b-8937cece6234.tar?sv=2023-11-03&se=2025-04-10T22%3A32%3A24Z&sr=b&sp=r&sig=y1rXBOGONXMXup%2B0%3D")]
115+
[InlineData("https://t3a00c49dev02arg01sa01.blob.core.windows.net/migration-archives-a9fd67c9-e987-4b3e-9cf2-439a95b7f275/f4e871a0-3214-4f94-a82b-8937cece6234.tar?sig=y1rXBOGONXMXup%2B0%3D&sv=2023-11-03&se=2025-04-10T22%3A32%3A24Z&sr=b&sp=r")]
116+
public void Azure_SAS_URL_Sig_Parameter_Should_Be_Redacted_In_Logs_And_Console(string sasUrl)
117+
{
118+
const string sig = "y1rXBOGONXMXup%2B0%3D";
119+
// Belt and suspenders
120+
sasUrl.Should().Contain(sig);
121+
122+
_octoLogger.Verbose = false;
123+
_octoLogger.LogInformation($"Archive (metadata) download url: {sasUrl}");
124+
_octoLogger.LogVerbose($"Archive (metadata) download url: {sasUrl}");
125+
_octoLogger.LogWarning($"Archive (metadata) download url: {sasUrl}");
126+
_octoLogger.LogSuccess($"Archive (metadata) download url: {sasUrl}");
127+
_octoLogger.LogError($"Archive (metadata) download url: {sasUrl}");
128+
_octoLogger.LogError(new OctoshiftCliException($"Archive (metadata) download url: {sasUrl}"));
129+
_octoLogger.LogError(new InvalidOperationException($"Archive (metadata) download url: {sasUrl}"));
130+
131+
_octoLogger.Verbose = true;
132+
_octoLogger.LogVerbose($"Archive (metadata) download url: {sasUrl}");
133+
134+
_consoleOutput.Should().NotContain(sasUrl);
135+
_logOutput.Should().NotContain(sasUrl);
136+
_verboseLogOutput.Should().NotContain(sasUrl);
137+
_consoleError.Should().NotContain(sasUrl);
138+
139+
_consoleOutput.ToLower().Should().Contain("sig=***");
140+
}
141+
113142
[Fact]
114143
public void LogError_For_OctoshiftCliException_Should_Log_Exception_Message_In_Non_Verbose_Mode()
115144
{

0 commit comments

Comments
 (0)