Repository navigation
Conversation
CI linted only Rust, so mistakes in the repository's shell, Python and PowerShell scripts could merge unchecked: unused imports and variables, a PowerShell function with a non-approved verb, and Python exceptions raised inside an except block without saying whether the cause is kept. Run ShellCheck, ruff and PSScriptAnalyzer in the existing Format job. That job is already part of the CI publication gate, so this adds no new required check and changes neither the gate nor the workflow verifier. A PR that adds a finding now fails Format. The tools are pinned: - ruff and ShellCheck come from hash-locked pip requirements (.github/lint-requirements.txt, compiled from the .in file next to it) and are installed with --require-hashes and --only-binary. - setup-python is pinned to a commit SHA. - PSScriptAnalyzer is downloaded as a fixed version and checked against a SHA-256 before it is imported. Rule selection is explicit. ruff uses E4, E7, E9, F and B instead of its default set, which changes between releases. PSScriptAnalyzer fails on Error, Warning and ParseError findings; ParseError is named because the analyzer drops syntax errors when the severity filter does not list them. PSScriptAnalyzerSettings.psd1 excludes three rules for every script, each with its reason written beside it: - PSAvoidUsingWriteHost, because these are console scripts. - PSUseShouldProcessForStateChangingFunctions and PSUseSingularNouns, because both protect exported cmdlets and these helpers are private. The findings in the existing scripts are fixed or suppressed with the reason on the line: - Remove unused imports and three assigned-but-unused variables. - Suppress ShellCheck SC2016 where a literal $auto is matched, SC2043 on a one-item loop that is meant to grow, and SC2329 on a function called only through an EXIT trap. - Suppress ruff B023 on a lambda that runs inside its loop iteration, and add "from None" to two ArchiveError raises that deliberately drop the caught FileExistsError. - Rename the PowerShell helper Quote-Arg to ConvertTo-QuotedArg to use an approved verb. - Replace non-ASCII characters in PowerShell comments with ASCII, which the analyzer's encoding rule is expected to flag. The ShellCheck and ruff findings were fixed against local runs. The PowerShell findings were not measured locally, so the first CI run is the first measurement and may show that the PowerShell step needs more changes. Signed-off-by: Teemu Kuusisto <[email protected]>
The Format job now runs ShellCheck, ruff and PSScriptAnalyzer, but neither DEVELOPMENT.md nor AGENTS.md said so. A contributor or agent would learn about the checks only from a failing PR. DEVELOPMENT.md gains a local check for shell, Python and PowerShell files, using the same hash-locked requirements as CI and the same PSScriptAnalyzer settings file. It covers Linux arm64, where shellcheck-py has no wheel and the combined install fails, so ruff and ShellCheck are installed separately. It also says how to change the pinned tool versions and that Install-Module does not check the package hash CI checks. The CI summary now lists the new checks under Lint & format. AGENTS.md gains the rule for a finding: fix it, or suppress that one finding with a stated reason where the code is right. Where a rule is wrong for a whole class of files, the only other route is a rule exclusion in the lint config; excluding a file, or turning a rule off only to make a finding go away, is not allowed. Adding or widening such an exclusion goes under "Ask first", with the reason written beside it and stated in the PR. Signed-off-by: Teemu Kuusisto <[email protected]>
siloteemu
force-pushed
the
ci/lint-all-scripts
branch
from
November 25, 2026 15:57
872da47 to
2a16c58
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
cargo fmt, and clippy with warnings as errors). The repository also holds 27 shell scripts, 15 Python files and 10 PowerShell scripts outsidethird_party, and a mistake in any of them can merge unchecked. The only existing Python check is bandit insecurity.yml, which scans a hard-coded list of 6 files.exceptblock without saying whether the cause is kept..github/workflows/ci.yml,AGENTS.mdandDEVELOPMENT.md, andAGENTS.mdlists editing.github/workflows/under "Ask first", so it is offered for the maintainers to accept or reject. No maintainer has agreed to it yet.Technical Details
Three steps are appended to the existing
Formatjob in.github/workflows/ci.yml: Lint shell scripts, Lint Python and Lint PowerShell. There is no new job, and the job name, runner, timeout and permissions are unchanged. The job therefore stays in the CI publication gate, and no change toscripts/verify_workflow_structure.pyorscripts/release_tools.pywas needed. No release, nightly or GUI release job changed, so no pinned digest changed.How the tools are installed:
shellcheck-pywheel) and ruff come from the new hash-locked.github/lint-requirements.inand.github/lint-requirements.txt, compiled withuv pip compilein the same style assecurity-requirements.txt. They are installed with--only-binary=:all: --require-hashesunderactions/setup-pythonat the commit SHA thatsecurity.ymland the workflow verifier already pin.curl(https only, TLS 1.2 or later, retries, a maximum time) and checked against a pinned SHA-256 before it is extracted and imported./.githubcovers the new requirements file, in itssecurity-toolsgroup, sodependabot.ymlis unchanged.Rule selection is explicit, because default rule sets change between releases:
ruff.tomlselectsE4,E7,E9,FandB.PSScriptAnalyzerSettings.psd1fails onError,WarningandParseErrorfindings.ParseErroris named because the analyzer drops syntax errors when the severity filter does not list them. It excludes three rules for every script, each with its reason written beside it:PSAvoidUsingWriteHost(console scripts and installers),PSUseShouldProcessForStateChangingFunctionsandPSUseSingularNouns(both protect exported cmdlets, and the flagged functions are private helpers).Findings that were already in the tree are fixed, or suppressed on the line with a reason:
e2e/linux/test_e2e_daemon.sh. SC2016 suppressed where a literal$autois matched, SC2043 on a one-item loop that is meant to grow, and SC2329 added to the existing SC2317 suppression on a function called only through anEXITtrap.from Noneadded to twoArchiveErrorraises that deliberately drop the caughtFileExistsError, and B023 suppressed on a lambda that runs inside its own loop iteration.Quote-Argrenamed toConvertTo-QuotedArg(approved verb), and non-ASCII characters in comments replaced with ASCII, which the analyzer's encoding rule is expected to flag.DEVELOPMENT.mdgains the local lint commands, including how to install ruff and ShellCheck on Linux arm64, whereshellcheck-pyhas no wheel and the combined install fails, and how to change the pinned versions.AGENTS.mdgains the rule for a finding (fix it, or suppress that one finding with a stated reason, and never exclude a file) and an "Ask first" line for adding or widening a rule exclusion in the lint config. Both files are covered by the same request to the maintainers: they are part of what is offered for acceptance.Not in this PR, as possible follow-ups:
gui/linux.run:shell in the workflows.git ls-files '*.sh'does not match.ruff formatand PowerShell 5.1 compatibility checks.e2e/windows/helpers.cargo fmtfails (if: always()).shellcheck-pywheel.Overlap: PRs #52, #105 and #114 touch nearby files (
ci.yml, scan configs, new scripts), and a local merge with each head was clean. If #114 lands first, the new scripts it adds will be linted by this check and may need fixes.Security impact: CI-only change, and nothing shipped to users changes. It adds no secrets, no new permissions and no new action digests. It does add new third-party download paths into a required job: PyPI wheels, checked by the hash lock, and the PSScriptAnalyzer package from the PowerShell Gallery, checked by SHA-256 before extraction. It cannot weaken isolation or turn an enforcement failure into permissive behavior.
Test Plan
Run locally on Linux aarch64 only. Not tested on Windows or macOS.
ruff check .and ShellCheck 0.11.0 over all 27 tracked.shfiles, before and after the fixes.python3 scripts/verify_workflow_structure.py .pip download --require-hashesfor the CI platform (x86_64, CPython 3.12, manylinux) to confirm the hash lock is accepted there, and a fresh download of the PSScriptAnalyzer package to confirm its SHA-256.python3 -m unittest discover -s scripts -p 'test_*.py',scripts/check_linux_mxc_packaging.shandscripts/test_security_tier0.sh, each also run on an untouched copy oforigin/mainfor comparison.Test Result
Passed locally:
ruff check .reports 0 findings (6 before the fixes)..shfiles (6 before the fixes).python3 scripts/verify_workflow_structure.py .reports OK.pip download --require-hashes.Failing or skipped locally, for reasons of this machine and identical on untouched
origin/main:origin/maincopy gives the same result, with the same 59 failing test names. The cause is the machine, not this change: it has no trustedbwrap, and it is linux-aarch64, so the installer tests report no release artifact for that platform.scripts/check_linux_mxc_packaging.shandscripts/test_security_tier0.shfail the same way on untouchedorigin/main, so they are evidence for neither outcome.Not verified:
pwshcould not be run in the environment used. The PowerShell findings are therefore not measured locally, and the PowerShell half of the defect-detection check is unproven. TheFormatjob is the first place the PowerShell step runs, and it may report findings that need another change.pip installcommand was not run on the CI platform (only the hash lock was checked there), and the CI run itself has not been measured.