Skip to content

feat: add PSScriptAnalyzer linter aspect#850

Open
kain88-de wants to merge 3 commits into
aspect-build:mainfrom
kain88-de:add-powershell
Open

feat: add PSScriptAnalyzer linter aspect#850
kain88-de wants to merge 3 commits into
aspect-build:mainfrom
kain88-de:add-powershell

Conversation

@kain88-de

@kain88-de kain88-de commented Apr 30, 2026

Copy link
Copy Markdown

Adds PSScriptAnalyzer as a bring-your-own linter following the yamllint/ rubocop pattern. Includes the Bazel aspect, a PowerShell wrapper script that produces both human-readable and SARIF output in a single pwsh invocation, and a working example workspace under examples/powershell/.


Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

New linter: PSScriptAnalyzer (PowerShell)
Added lint_ps_script_analyzer_aspect for linting PowerShell (.ps1, .psm1) files with PSScriptAnalyzer. Follows the bring-your-own pattern — users supply pwsh,
PSScriptAnalyzer, and ConvertToSARIF via http_archive. See examples/powershell/ for a complete setup.
auto fix for formatting violations

Test plan

  • Covered by existing test cases
  • New test cases added -> added good and bad examples

Adds PSScriptAnalyzer as a bring-your-own linter following the yamllint/ rubocop pattern.
Includes the Bazel aspect, a PowerShell wrapper script that produces both human-readable and SARIF output in a single pwsh invocation, and a working example workspace under examples/powershell/.
@CLAassistant

CLAassistant commented Apr 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aspect-workflows

aspect-workflows Bot commented Apr 30, 2026

Copy link
Copy Markdown

Bazel 7 (Test)

6 test targets passed

Targets
//format/test:custom_args_test [k8-fastbuild] 432ms
//format/test:ls-files_test [k8-fastbuild]    937ms
//lint/rust:test_human [k8-fastbuild]         206ms
//lint/rust:test_patch [k8-fastbuild]         201ms
//lint/rust:test_sarif [k8-fastbuild]         466ms
//tools/sarif:sarif_test [k8-fastbuild]       148ms

Bazel 8 (Test)

All tests were cache hits

6 tests (100.0%) were fully cached saving 1s.


Bazel 9 (Test)

All tests were cache hits

6 tests (100.0%) were fully cached saving 1s.

CheckmkCI pushed a commit to Checkmk/checkmk that referenced this pull request Jun 3, 2026
Hermetic Bazel lint aspect for .ps1 / .psm1 files using PSScriptAnalyzer.
Vendors the stalled upstream aspect-build/rules_lint#850 into
bazel/tools/ so the migration when upstream merges is a load() path
swap plus deletion of two files; the rest of the wiring (module
extension, settings file, aspect registration, filegroup tags) stays.

Pwsh, PSScriptAnalyzer, and ConvertToSARIF are pulled as hermetic
http_archives via a module extension. Settings start with severity =
Error only; widening to Warning/Information is a follow-up once the
existing PowerShell code is clean at the Error level.

Opt-in by filegroup tag (lint-with-psscriptanalyzer) — there is no
native ps1_library rule kind. agents/windows/plugins and the relay
windows-installer scripts are tagged in this commit; remaining
filegroups under cmk/plugins/*/agents/ and agents/wnx/ will be tagged
incrementally.

Change-Id: I580f923216bfb94dd43bff68e1bb0665db0b037e
JIRA-Ref: CMK-34289
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