-
Notifications
You must be signed in to change notification settings - Fork 0
Deep audit: data-safety, CLI, filter, and WPF UX hardening #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0dbe84c
fix(safety): protect descendants from recursive ancestor delete
SysAdminDoc eb5e591
fix(cli): validate saved profiles and harden config/event-log paths
SysAdminDoc a9a7280
fix(filters): scope per-directory gitignore names and bound regex mat…
SysAdminDoc 8905eb4
style(wpf): color-code results, add focus rings, fix dry-run copy
SysAdminDoc 21ca088
fix(ui): guard tree protect/unprotect against non-DirectoryInfo nodes
SysAdminDoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using Xunit; | ||
|
|
||
| namespace RED | ||
| { | ||
| // Locks in the protected-folder invariant: a directory must not be deleted when | ||
| // it (or any ancestor) is the parent of a user-protected folder. Regression guard | ||
| // for the bug where a protected child was destroyed by an empty-eligible ancestor's | ||
| // recursive delete because only the child's own path was checked. | ||
| public class DeletionWorkerTests | ||
| { | ||
| private static HashSet<string> Set(params string[] paths) | ||
| { | ||
| return new HashSet<string>(paths, StringComparer.OrdinalIgnoreCase); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Protect_Self_IsProtected() | ||
| { | ||
| Assert.True(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a\b\keep", Set(@"C:\a\b\keep"))); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Protect_Ancestor_OfProtected_IsProtected() | ||
| { | ||
| var p = Set(@"C:\a\b\keep"); | ||
| // Every ancestor of a protected folder must itself be treated as protected, | ||
| // or a recursive delete of the ancestor would destroy the protected child. | ||
| Assert.True(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a\b", p)); | ||
| Assert.True(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a", p)); | ||
| Assert.True(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a\b\", p)); // trailing separator | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Protect_IsCaseInsensitive() | ||
| { | ||
| var p = Set(@"C:\Data\Keep"); | ||
| Assert.True(DeletionWorker.IsProtectedOrAncestorOfProtected(@"c:\data", p)); | ||
| Assert.True(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\DATA\KEEP", p)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Sibling_And_Unrelated_AreNotProtected() | ||
| { | ||
| var p = Set(@"C:\a\b\keep"); | ||
| Assert.False(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a\b\other", p)); | ||
| Assert.False(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\x", p)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void PrefixSibling_IsNotMistakenForAncestor() | ||
| { | ||
| // "C:\a\bc" shares a string prefix with "C:\a\b\keep" but is NOT an ancestor; | ||
| // the path-separator boundary must prevent a false protection match. | ||
| Assert.False(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a\bc", Set(@"C:\a\b\keep"))); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void EmptyOrNull_AreNotProtected() | ||
| { | ||
| Assert.False(DeletionWorker.IsProtectedOrAncestorOfProtected(@"C:\a", new HashSet<string>())); | ||
| Assert.False(DeletionWorker.IsProtectedOrAncestorOfProtected(null, Set(@"C:\a"))); | ||
| Assert.False(DeletionWorker.IsProtectedOrAncestorOfProtected("", Set(@"C:\a"))); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
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.
When a crafted/corrupt config nils one of these children, the replacement constructors do not apply RED++'s normal defaults:
ConfigOptions.SetToDefaults()is what sets values likeMaxDirectoryDepth = -1,AutoProtectRoot, and the system/hidden-directory defaults, andConfigFilters.SetToDefaults()seeds the ignore/never-empty lists. As written, a headless run with<Options xsi:nil="true"/>or<Filters xsi:nil="true"/>no longer crashes but continues with CLR zeroes or empty safety filters, so it can behave very differently from a fresh default config; call the relevantSetToDefaults()when creating these replacements.Useful? React with 👍 / 👎.