Skip to content
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

Bug: Handle possible exception when checking directory ACLs. #129

Merged

Conversation

Cazzar
Copy link
Contributor

@Cazzar Cazzar commented Dec 20, 2023

It was possible for an UnauthorizedAccessException to throw during checking if a path is valid.

At this point, if we get such an error, safely log and return it is invalid.

Example exception
11:02:28.309 ERR | Exception during raise of "Void Draw()"
11:02:28.309 ERR | System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
11:02:28.309 ERR |    at System.Security.AccessControl.Win32.GetSecurityInfo(ResourceType resourceType, String name, SafeHandle handle, AccessControlSections accessControlSections, RawSecurityDescriptor& resultSd)
11:02:28.309 ERR |    at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
11:02:28.309 ERR |    at System.IO.FileSystemAclExtensions.GetAccessControl(DirectoryInfo directoryInfo)
11:02:28.309 ERR |    at Ktisis.Helpers.Common.IsPathValid(String path) in /home/runner/work/Ktisis/Ktisis/Ktisis/Helpers/Common.cs:line 17
11:02:28.309 ERR |    at Ktisis.Interface.Windows.FileDialogManager.setupDialog(String filters) in /home/runner/work/Ktisis/Ktisis/Ktisis/Interface/Windows/FileDialogManager.cs:line 96
11:02:28.309 ERR |    at Ktisis.Interface.Windows.FileDialogManager.OpenFileDialog(String title, String filters, Action`2 callback, Int32 selectionCountMax, String startPath, Boolean isModal) in /home/runner/work/Ktisis/Ktisis/Ktisis/Interface/Windows/FileDialogManager.cs:line 52
11:02:28.309 ERR |    at Ktisis.Interface.Windows.Workspace.Tabs.PoseTab.ImportExportPose(Actor* actor) in /home/runner/work/Ktisis/Ktisis/Ktisis/Interface/Windows/Workspace/Tabs/PoseTab.cs:line 174
11:02:28.309 ERR |    at Ktisis.Interface.Windows.Workspace.Tabs.PoseTab.Draw(GameObject target) in /home/runner/work/Ktisis/Ktisis/Ktisis/Interface/Windows/Workspace/Tabs/PoseTab.cs:line 60
11:02:28.309 ERR |    at Ktisis.Interface.Windows.Workspace.Workspace.Draw() in /home/runner/work/Ktisis/Ktisis/Ktisis/Interface/Windows/Workspace/Workspace.cs:line 94
11:02:28.309 ERR |    at Ktisis.Interface.KtisisGui.Draw() in /home/runner/work/Ktisis/Ktisis/Ktisis/Interface/KtisisGui.cs:line 40
11:02:28.309 ERR |    at Dalamud.Utility.EventHandlerExtensions.HandleInvoke(Action act) in C:\goatsoft\companysecrets\dalamud\Utility\EventHandlerExtensions.cs:line 112

UnauthorizedAccessExceptions are now caught and logged with an error message including the relevant path. This change improves the robustness of the directory access check.
@chirpxiv chirpxiv merged commit 34d01aa into ktisis-tools:main Mar 22, 2024
2 checks passed
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.

2 participants