Skip to content

Conversation

@RobertGlobant20
Copy link
Contributor

Purpose

If TrustedLocations list contain paths pointing to ProgramData, we will be logging a warning notification (also in console but that functionality already existed).
Also added resource strings for localization of messages shown in the notification (and adding missing localization resources).

Declarations

Check these if you believe they are true

Release Notes

If TrustedLocations list contain paths pointing to ProgramData, we will be logging a warning notification (also in console but that functionality already existed).

Reviewers

@zeusongit @reddyashish

FYIs

@jnealb

If TrustedLocations list contain paths pointing to ProgramData, we will be logging a warning notification (also in console but that functionality already existed).
Also added resource strings for localization of messages shown in the notification.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9862

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a security warning notification when trusted locations point to potentially unsafe paths in ProgramData. The implementation logs a warning when any trusted location starts with the CommonApplicationData path, helping users identify potential security risks in their Dynamo configuration.

Key Changes:

  • Added localized resource strings for unsafe path detection notifications
  • Implemented validation logic to detect and warn about trusted locations in ProgramData

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Notifications/Properties/Resources.resx Added resource strings for "No notifications" UI text and unsafe path warning messages
src/Notifications/Properties/Resources.en-US.resx Added English-specific resource strings for unsafe path detection warnings
src/Notifications/NotificationsViewExtension.cs Implemented validation logic to check trusted locations against ProgramData path and display warnings
Files not reviewed (1)
  • src/Notifications/Properties/Resources.Designer.cs: Language not supported

Comment on lines 117 to 124
string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations)
{
if (location.StartsWith(programDataPath))
{
Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, Properties.Resources.UnsafePathDetectedDetail + "\n" + location));
}
}
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path comparison using StartsWith() may produce false positives on case-sensitive file systems or when paths have different separator formats. Use Path.GetFullPath() to normalize both paths before comparison, and consider using StringComparison.OrdinalIgnoreCase for the comparison to handle case differences on Windows.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 118 to 125
foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations)
{
if (location.StartsWith(programDataPath))
{
Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, Properties.Resources.UnsafePathDetectedDetail + "\n" + location));
}
}
notificationsMenuItem.NotificationsChangeHandler.Invoke(this, null);
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NotificationsChangeHandler.Invoke() call is placed outside the loop, which means it will be called even when no unsafe paths are detected. This should be moved inside the conditional block (after line 122) or wrapped in a check to only invoke when notifications were actually added.

Suggested change
foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations)
{
if (location.StartsWith(programDataPath))
{
Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, Properties.Resources.UnsafePathDetectedDetail + "\n" + location));
}
}
notificationsMenuItem.NotificationsChangeHandler.Invoke(this, null);
bool notificationAdded = false;
foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations)
{
if (location.StartsWith(programDataPath))
{
Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, Properties.Resources.UnsafePathDetectedDetail + "\n" + location));
notificationAdded = true;
}
}
if (notificationAdded)
{
notificationsMenuItem.NotificationsChangeHandler.Invoke(this, null);
}

Copilot uses AI. Check for mistakes.
@RobertGlobant20
Copy link
Contributor Author

Adding GIF showing the expected behavior when having ProgramData in Trusted paths and when not having it.
devenv_maaPKL3pEL

RobertGlobant20 and others added 2 commits November 25, 2025 11:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Refactoring code for preventing false positives in the StartsWith call
@zeusongit zeusongit requested a review from a team November 25, 2025 20:52
@RobertGlobant20
Copy link
Contributor Author

Hi team, do you have any comment about this changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant