-
Notifications
You must be signed in to change notification settings - Fork 682
Hide secrets in source tooltip, correct ExpressionResolver logic for non-containers #7662
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
Hide secrets in source tooltip, correct ExpressionResolver logic for non-containers #7662
Conversation
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
ConnectionStringReference cs => await ResolveInternalAsync(cs.Resource.ConnectionStringExpression).ConfigureAwait(false), | ||
IResourceWithConnectionString cs => await ResolveInternalAsync(cs.ConnectionStringExpression).ConfigureAwait(false), |
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.
@davidfowl @mitchdenny @davidebbo - do we even need these 2 cases? Since ConnectionStringReference
and IResourceWithConnectionString
implement IValueProvider
, shouldn't this just fall to that case?
(Note we don't necessarily need to change this in this PR, but I'm just trying to understand if I have the logic correct. If we are going to backport this to 9.1, we may not want to risk a change here.)
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.
Nevermind, I think I understand why this is necessary - because we want to intercept any "host" references inside the ConnectionString and redirect them to the containerHostName.
Would it ever work if someone implemented an IValueProvider that contained a "host" reference, but wasn't one of these?
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.
LGTM. I just had some questions for my learning.
Example with a connection string, like in @DamianEdwards's example in #7632 - |
… ExpressionResolver.EvalExpressionAsync
…, to prevent non-optional but missing value from resolving
@eerhardt I added some additional special cases for certain resource kinds in ExpressionEvaluator, enough changes that need a re-review |
@adamint please get this in 9.1 today if possible. |
Waiting on re-review. @eerhardt @davidfowl |
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.
The changes look good to me. Just a couple minor comments.
@@ -94,7 +96,7 @@ void AddStringProperty(string propertyName, string? propertyValue) | |||
value: "project", | |||
contentAfterValue: [new LaunchArgument("arg2", true), new LaunchArgument("--key", true), new LaunchArgument("secret", false)], | |||
valueToVisualize: "path/to/project arg2 --key secret", | |||
tooltip: "path/to/project arg2 --key secret")); | |||
tooltip: $"path/to/project arg2 --key {WebUtility.HtmlDecode(DashboardUIHelpers.GetMaskingText(6).Value)}")); |
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.
Are there other tests that should be added for this change? Specifically for the case(s) where we are changing ExpressionResolver - to catch secrets inside connection strings.
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.
Added those tests in ExpressionResolverTests
Co-authored-by: James Newton-King <james@newtonking.com>
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.
Dashboard changes look good. Need some tests and a little clean up.
Is there a sample where this can be manually tested?
Is there a sample where this can be manually tested? |
There is not, as there is no sample using ef migrate or this feature. We could add one? but I'm unsure exactly how to replicate the use case in #7632 - @DamianEdwards maybe for suggestion, or could you share the app you were referencing there? I've been manually testing using the following, inspired by #7632 - Update any service in TestShop.AppHost/Program.cs to include |
/backport to release/9.1 |
Started backporting to release/9.1: https://github.com/dotnet/aspire/actions/runs/13428696603 |
// We are substituting our own logic for ConnectionStringReference's GetValueAsync. | ||
// However, ConnectionStringReference#GetValueAsync will throw if the connection string is not optional but is not present. | ||
// To avoid duplicating that logic, we can defer to ConnectionStringReference#GetValueAsync, which will throw if needed. | ||
await ((IValueProvider)cs).GetValueAsync(cancellationToken).ConfigureAwait(false); |
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 would be worried about side effects. We should only do this in the null case to avoid double evaluation in the common case.
Scratch that could be an underlying issue with the args handling with executable resources. It happens in 9.0 as well so I'm looking into it. Maybe there is an inconsistency here between containers and executables. |
Also issue #7634 suggests that we should also have a show secrets button in the copy dialog. I'm not 100% sure I agree that we need to do that - but was that a deliberate choice. If it was just skipped for expediency for 9.1 and we still want to do it then we should re-open that issue or open a new one to make sure we don't loose track. |
It's a deliberate choice, I'll make a comment in #7634 as well - opening the text visualizer is an explicit action. With secret properties in the resource details view, users wouldn't otherwise be able to hide secrets without them being initially masked, of course. Here, secrets are already hidden in the source column; if users want to see all args (masked), they can expand the column or hover to show the (masked) tooltip. |
Description
Took the opportunity to clean up my code in
GetSourceViewModel
as well to add a typeCommandLineInfo
instead of relying on a tuple. Hides secrets in tooltips using the same masking characters as appear in the GridValue.Also removes logic in
ExpressionResolver
that resolves some types of expressions only for containers. All expressions exceptEndpointReferenceExpression
andEndpointReference
should be resolved for all resource types. The only other difference between containers and other types of resources is how HostUrl is resolved (special-cased for containers).Fixes #7634, fixes #7632
Checklist
<remarks />
and<code />
elements on your triple slash comments?breaking-change
template):doc-idea
template):