Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Notifications/NotificationsViewExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ public void Loaded(ViewLoadedParams viewStartupParams)
viewStartupParams.dynamoMenu.Items.Add(notificationsMenuItem.MenuItem);

LoadNotificationCenter();

//If TrustedLocations contain paths pointing to ProgramData, log a warning notification.
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));
}
}
Comment on lines 118 to 127
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

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.
}

private void LoadNotificationCenter()
Expand Down
18 changes: 18 additions & 0 deletions src/Notifications/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Notifications/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -150,4 +150,10 @@
<data name="NotificationsCenterTitle" xml:space="preserve">
<value>Notifications</value>
</data>
<data name="UnsafePathDetectedDetail" xml:space="preserve">
<value>An unsafe path has been detected in Trusted Locations:</value>
</data>
<data name="UnsafePathDetectedTitle" xml:space="preserve">
<value>Unsafe path detected</value>
</data>
</root>
14 changes: 13 additions & 1 deletion src/Notifications/Properties/Resources.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -135,6 +135,12 @@
<data name="ExtensionName" xml:space="preserve">
<value>Notifications</value>
</data>
<data name="NoNotificationsMsg" xml:space="preserve">
<value>You currently have no notifications. New notifications will appear above</value>
</data>
<data name="NoNotificationsTitle" xml:space="preserve">
<value>No notifications</value>
</data>
<data name="NotificationCenterDisabledMsg" xml:space="preserve">
<value>Notification Center feature is disabled. Enable it in preference panel to see latest news.</value>
</data>
Expand All @@ -144,4 +150,10 @@
<data name="NotificationsCenterTitle" xml:space="preserve">
<value>Notifications</value>
</data>
<data name="UnsafePathDetectedDetail" xml:space="preserve">
<value>An unsafe path has been detected in Trusted Locations:</value>
</data>
<data name="UnsafePathDetectedTitle" xml:space="preserve">
<value>Unsafe path detected</value>
</data>
</root>
Loading