Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modernize DynamoModel.cs to C# 12 idioms #16880
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
base: master
Are you sure you want to change the base?
Modernize DynamoModel.cs to C# 12 idioms #16880
Changes from all commits
846d5e2378d341083000617fcbe4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
Copilot Autofix
AI 2 months ago
In general, to fix clear-text storage issues in logs, you either (a) avoid logging the sensitive value at all, or (b) log only a redacted/derived form (such as a hash, prefix, or generic tag) that is sufficient for diagnostics without exposing the original value. For filesystem paths coming from user-controlled configuration, you typically only need to indicate that a problematic path exists and maybe show a minimally identifying portion, not the entire absolute path.
For this specific case, the best fix that preserves existing functionality is to avoid logging the full trusted location path and instead log only a safe, truncated representation. We can transform
trustedLocbefore passing it toLogger.Log, e.g. by logging only the last directory segment or a redacted form such as"...\folder"or"[redacted]". This keeps the information that an unsafe path exists and roughly which entry it is, while no longer storing the full user path in clear text. We only need to change the logging line inDynamoModel.cs; the rest of the flow (loading and storing trusted locations in memory and XML) is outside the identified sink and should remain unchanged.Concretely, in
src/DynamoCore/Models/DynamoModel.cs, within the constructor (or initialization method) near lines 1038–1045, replacewith a version that uses a safe representation of
trustedLoc. A simple approach that requires no new imports is to derive a short identifier, such as the last path component usingPath.GetFileName(trustedLoc.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)), and log that instead. However, we must not add new imports other than standard ones, andSystem.IOis already imported at the top of the file, so we can safely usePath. We will compute asafeLocationDescriptioninline and use that in the log message. This change affects onlyDynamoModel.cs; no changes are required inPreferenceSettings.csfor this particular sink.Uh oh!
There was an error while loading. Please reload this page.