-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redact ?token=
querystring parameter from GHES <3.8 archive URLs in logs
#1152
Conversation
src/Octoshift/Services/OctoLogger.cs
Outdated
@@ -156,5 +155,17 @@ public virtual void LogSuccess(string msg) | |||
Console.ResetColor(); | |||
} | |||
|
|||
public virtual void RegisterSecret(string secret) => _secrets.Add(secret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also avoid this refactor, and keep a separate list of _secrets
which we replace as well as the "redaction patterns". That's probably a safer approach to avoid surprises - but I'd love to hear what y'all think.
… logs Existing code allows us to redact secrets in the logs outputted to the shell and to log files. Secret strings are registered, and then replaced in the output. This PR also allows classes using `OctoLogger` to register regular expressions to replace, and begins redacting GHES download tokens for GHES <3.8. Fixes #1151.
@@ -188,6 +189,8 @@ public override MigrateRepoCommandHandler BuildHandler(MigrateRepoCommandArgs ar | |||
var ghesVersionChecker = ghesVersionCheckerFactory.Create(ghesApi); | |||
var warningsCountLogger = sp.GetRequiredService<WarningsCountLogger>(); | |||
|
|||
log.AddRedactionPattern(new Regex("\\?token=[A-Z0-9]{29}")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have manually tested that this works as expected on GHES 3.7, and the URL is not logged.
223aaaf
to
9f78feb
Compare
Existing code allows us to redact secrets in the logs to stop them being outputted to the shell and to log files. Secret strings are registered during execution, and then replaced in the output.
This PR also allows classes using
OctoLogger
to register regular expressions to replace, and begins redacting GHES download tokens for GHES <3.8 using a simple regular expression.Fixes #1151.
ThirdPartyNotices.txt
(if applicable)