Skip to content

520 fallback UI#521

Open
chlaplan wants to merge 10 commits into
MicrosoftDocs:mainfrom
chlaplan:520-Fallback-UI
Open

520 fallback UI#521
chlaplan wants to merge 10 commits into
MicrosoftDocs:mainfrom
chlaplan:520-Fallback-UI

Conversation

@chlaplan
Copy link
Copy Markdown

@chlaplan chlaplan commented May 6, 2026

#520 and #519

chlaplan and others added 7 commits May 4, 2026 17:44
• FolderHashScanForm.cs — New dialog for folder-based hash file scanning with browse, subfolder toggle, file checklist, and hash type selection
Modified Files
CustomRuleConditionsPanel.cs
• Added hash mode panel with Single File, Multiple Files radio buttons and Folder Scan... button
• "Folder Scan..." button directly opens FolderHashScanForm dialog
• Multi-file and folder scan modes batch files into a single FolderScan-type rule using New-CIPolicy -ScanPath (instead of one PowerShell call per file)
• Selected files are copied to a temp folder preserving subfolder structure from the source
• Stores SourceFolderPath and HashTypesToKeep on the rule for downstream processing
FolderHashScanForm.cs
• Browse folder with optional Include subfolders checkbox
• Scan Folder button enumerates files by common PE/script extensions
• Select All / Deselect All for the file checklist
• Hash type checkboxes: Hash SHA1, Hash SHA256, Hash Page SHA1, Hash Page SHA256, and All (toggle)
• Exposes SelectedFiles, SelectedHashTypes, SourceFolderPath, IncludeSubfolders, AllFilesSelected
• Dark mode support
SigningRules_Control.cs
• Added AddRuleToTableWithoutClosing() method to support batch rule insertion without closing the custom rules panel
Policy.cs (PolicyCustomRules class)
• Added HashTypesToKeep property (HashSet<string>) — hash types to retain when filtering generated policy XML
• Added SourceFolderPath property (string) — original folder path for FriendlyName correction
MainForm.cs
• Added using System.Linq
• FriendlyName fix: after scan, replaces temp folder path in each rule's FriendlyName with the original source folder path (preserving subfolders)
• Hash type filtering: removes unwanted hash types (Hash SHA1, Hash Page SHA256, etc.) from generated policy based on user's checkbox selections
• Progress bar improvements:
• ProcessCustomValueRules(BackgroundWorker, SiPolicy) now reports incremental progress 0–25% per rule
• ProcessSignerRules(BackgroundWorker, SiPolicy) shows "Processing rule X of Y ..." with accurate counts
• FolderScan shows phased status: "Scanning folder: ...", "Scan complete. Applying hash type filters ...", "Filtered: kept X of Y hash rules.", "Merging scanned policy rules ..."
• ProgressChanged handler respects custom UserState messages
This reverts commit 162dd88.
• Added -NoLogo -NonInteractive flags to PowerShell invocation to reduce startup overhead
• Fixed potential deadlock: moved StandardOutput.ReadToEnd() and StandardError.ReadToEnd() before WaitForExit() to prevent buffer-full hang

MainForm.cs
• Fixed progress bar stalling at 25% during Folder Scan by reporting progress after skipping non-applicable rules
• Added mid-scan progress report (~55%) before CreateScannedPolicyFromPS(PolicyCustomRules, string, string) so UI shows activity during long scans
• Updated progress status text: "Scanning and processing rules (this may take a few minutes) ..." for the 25-80% range
…UI-Process

518 update file scan UI process
 -OmitPaths and -Fallback passed as single string instead of array.

Fix: The script now splits the comma-separated values into proper arrays ($FallbackArray, $OmitArray) and uses splatting (@omitSplat) to conditionally pass -OmitPaths only when paths are specified. Applied to both app/Scripts/ and app/MSIX/ copies
@chlaplan
Copy link
Copy Markdown
Author

Last change:

Excluded folders being checked are still getting added to the XML, seems to be two bugs in the code

  1. If only one folder is checked, it won't exclude the folder, has to be > 1, line 306 should be > 0, not > 1.
  2. -OmitPaths and -Fallback passed as single string instead of array

2. Total file count (updates from "counting files..." to the actual number once enumeration finishes)
3. Elapsed time (heartbeat every 2 seconds)
@jgeurten jgeurten requested review from Copilot, jgeurten and jsuther1974 and removed request for jgeurten and jsuther1974 May 14, 2026 17:53
Copy link
Copy Markdown
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 addresses Issue #520/#519 by making “File Scan” (folder scan) behavior and UI clearer around Level vs Fallback rule levels, and by ensuring Hash is always included as a fallback so unsigned files aren’t silently skipped during New-CIPolicy scans.

Changes:

  • Always append Hash to the fallback list generated for scanned policies, and add more robust PowerShell invocation flags.
  • Update folder-scan UI to annotate selected rule levels as “(Level)” vs “(Fallback)”, and improve omit-path selection usability.
  • Refine progress reporting text/ranges to better reflect scanning time.

Reviewed changes

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

Show a summary per file
File Description
WDAC-Policy-Wizard/app/src/PSCmdlets.cs Ensures Hash is included in fallback list and adjusts PowerShell process invocation/output handling.
WDAC-Policy-Wizard/app/src/MainForm.cs Updates progress messaging and adjusts progress reporting timing for scans.
WDAC-Policy-Wizard/app/src/CustomRuleConditionsPanel.Designer.cs UI layout/anchoring tweaks and wiring for rule-level check behavior.
WDAC-Policy-Wizard/app/src/CustomRuleConditionsPanel.cs Adds omit-path bulk select buttons; annotates rule level/fallback selections and enforces Hash selection behavior.
WDAC-Policy-Wizard/app/Scripts/CreateScannedPolicy.ps1 Switches to array inputs for -Fallback/-OmitPaths and suppresses key-collision warning.
WDAC-Policy-Wizard/app/MSIX/CreateScannedPolicy.ps1 Same as above for MSIX packaging script copy.
Files not reviewed (1)
  • WDAC-Policy-Wizard/app/src/CustomRuleConditionsPanel.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 206 to 213
try
{
process.Start();
process.WaitForExit();

// Read streams asynchronously to avoid deadlocks and allow PS to flush output
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();

Comment thread WDAC-Policy-Wizard/app/src/CustomRuleConditionsPanel.cs
Comment on lines +2835 to +2840
// Ensure Hash is in checked list (unless it would be the only/first item making it Level)
if (!checkedItems.Contains("Hash"))
{
uncheckedItems.Remove("Hash");
checkedItems.Add("Hash");
}
Comment on lines +158 to +163
fallbacks = string.Join(",", customRule.Scan.Levels.Skip(1));
// Always ensure Hash is the final fallback for unsigned files
if (!fallbacks.Contains("Hash", StringComparison.OrdinalIgnoreCase))
{
fallbacks += ",Hash";
}
Copy link
Copy Markdown

@jsuther1974 jsuther1974 left a comment

Choose a reason for hiding this comment

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

Changes look good to me.

Comment thread WDAC-Policy-Wizard/app/src/CustomRuleConditionsPanel.cs Outdated
Comment thread WDAC-Policy-Wizard/app/src/CustomRuleConditionsPanel.cs
chlaplan added 2 commits May 14, 2026 20:18
Added scan results at the end, displaying amount of files and time it took
Added UI progress elapse time, let the admin know it's still working.
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.

4 participants