Skip to content

Performance counter webform#1

Merged
jeffstokes72 merged 1 commit intobroken-malletfrom
cursor/performance-counter-webform-a43d
Feb 9, 2026
Merged

Performance counter webform#1
jeffstokes72 merged 1 commit intobroken-malletfrom
cursor/performance-counter-webform-a43d

Conversation

@jeffstokes72
Copy link
Copy Markdown
Owner

@jeffstokes72 jeffstokes72 commented Feb 9, 2026

Add a PowerShell 7+ mass-processing webform and headless script to analyze directory trees of BLG files, generate mirrored reports, and create a master HTML index with worst-case highlighting.


Open in Cursor Open in Web


Note

Medium Risk
Introduces substantial new PowerShell automation with parallel execution and a local HTTP server/job runner; risk is mainly around filesystem traversal, concurrency, and serving local files (path handling).

Overview
Adds PowerShell 7+ mass-processing support for PAL BLG analysis: a new Invoke-PalMass library (PALMass.ps1) that scans one or more input directory trees for .blg files, runs PAL in parallel across multiple threshold XMLs, and writes a mirrored output tree plus results.csv/results.json and a master index.html sorted by “worst” (derived from parsed XML alert counts).

Introduces two entrypoints: Invoke-PALMass.ps1 for headless batch runs (optionally opening the master report) and Start-PALMassWeb.ps1, a lightweight local HttpListener web UI to pick directories/thresholds, start a background job, poll status via status.json, and serve generated outputs under /out/. Documentation in Readme.txt is updated with usage, defaults, and outputs.

Written by Cursor Bugbot for commit bf607e3. This will update automatically on new commits. Configure here.

Co-authored-by: Jeff Stokes <jeffstokes1972@gmail.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 9, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@jeffstokes72 jeffstokes72 marked this pull request as ready for review February 9, 2026 17:46
@jeffstokes72 jeffstokes72 merged commit 9092dfa into broken-mallet Feb 9, 2026
1 check passed
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issues.


# Process each BLG in parallel; within each BLG, run all selected threshold XMLs.
$results = $blg | ForEach-Object -Parallel {
param($blgPath)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Parallel scriptblock param makes pipeline variable null

High Severity

The ForEach-Object -Parallel scriptblock declares param($blgPath), but this parameter set mechanism isn't how -Parallel delivers the pipeline item. The current pipeline object is available as $_ (or $PSItem), not through a param() block. As a result, $blgPath is always $null, and the entire parallel processing loop fails immediately when it tries to call $blgPath.Equals(...) or pass $blgPath to functions like Get-RelativePath.

Fix in Cursor Fix in Web

$counts = Get-PalAlertCountsFromReportXml -ReportXmlPath $runOut.XmlPath
$score = ([int]$counts.Criticals * 10) + ([int]$counts.Warnings * 2) + (if (-not $ok) { 1000 } else { 0 })

$reportLink = Get-RelativePath -BasePath $outputRoot -FullPath $runOut.HtmlPath
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Resolve-Path fails on non-existent error-case report path

Medium Severity

When Invoke-PalSingleRun throws (caught at the catch block), $runOut.HtmlPath is set to a path for a file that doesn't exist on disk. Then Get-RelativePath calls Resolve-Path -LiteralPath on that non-existent path, which throws an unhandled error. This means any PAL analysis failure cascades into a secondary exception, losing the original error information and the result entry for that run.

Additional Locations (2)

Fix in Cursor Fix in Web


$indexPath = Join-Path -Path $OutputRoot -ChildPath "index.html"

$sorted = @($Results | Sort-Object -Property Score -Descending, Criticals -Descending, Warnings -Descending)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid Sort-Object syntax breaks master report generation

High Severity

The Sort-Object call uses invalid syntax for multi-property sorting. The form -Property Score -Descending, Criticals -Descending, Warnings -Descending only binds Score to -Property and sets the -Descending switch; the remaining tokens Criticals and Warnings become unbound positional arguments, which causes a runtime error since Sort-Object has no positional parameter to accept them. The correct syntax is -Property Score, Criticals, Warnings -Descending. This prevents Write-PalMasterHtmlReport from completing, so no master HTML report is ever generated.

Fix in Cursor Fix in Web

@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 9, 2026

Bugbot Autofix prepared fixes for 3 of the 3 bugs found in the latest run.

  • ✅ Fixed: Parallel scriptblock param makes pipeline variable null
    • Replaced param($blgPath) with $blgPath = $_ since ForEach-Object -Parallel delivers the pipeline item via $_, not through a param() block.
  • ✅ Fixed: Resolve-Path fails on non-existent error-case report path
    • Added a Test-Path guard in Get-RelativePath so that non-existent paths fall back to [IO.Path]::GetFullPath() instead of calling Resolve-Path which would throw.
  • ✅ Fixed: Invalid Sort-Object syntax breaks master report generation
    • Changed Sort-Object call to use a single comma-separated property list (Score, Criticals, Warnings) with one -Descending switch, which is the correct PowerShell syntax.

View PR

Or push these changes by commenting:

@cursor push 3d49380850
Preview (3d49380850)
diff --git a/PAL2/PALWizard/bin/Debug/PALMass.ps1 b/PAL2/PALWizard/bin/Debug/PALMass.ps1
--- a/PAL2/PALWizard/bin/Debug/PALMass.ps1
+++ b/PAL2/PALWizard/bin/Debug/PALMass.ps1
@@ -79,7 +79,11 @@
         [Parameter(Mandatory=$true)][string] $FullPath
     )
     $base = (Resolve-Path -LiteralPath $BasePath).Path
-    $full = (Resolve-Path -LiteralPath $FullPath).Path
+    if (Test-Path -LiteralPath $FullPath) {
+        $full = (Resolve-Path -LiteralPath $FullPath).Path
+    } else {
+        $full = [IO.Path]::GetFullPath($FullPath)
+    }
 
     $baseUri = New-Object System.Uri(($base.TrimEnd([IO.Path]::DirectorySeparatorChar) + [IO.Path]::DirectorySeparatorChar))
     $fullUri = New-Object System.Uri($full)
@@ -192,7 +196,7 @@
 
     $indexPath = Join-Path -Path $OutputRoot -ChildPath "index.html"
 
-    $sorted = @($Results | Sort-Object -Property Score -Descending, Criticals -Descending, Warnings -Descending)
+    $sorted = @($Results | Sort-Object -Property Score, Criticals, Warnings -Descending)
     $top = @($sorted | Select-Object -First $HighlightTopN)
     $topSet = @{}
     foreach ($r in $top) { $topSet[$r.RunId] = $true }
@@ -329,7 +333,7 @@
 
     # Process each BLG in parallel; within each BLG, run all selected threshold XMLs.
     $results = $blg | ForEach-Object -Parallel {
-        param($blgPath)
+        $blgPath = $_
 
         . $using:palMassLibPath

@jeffstokes72 jeffstokes72 self-assigned this Feb 9, 2026
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