Skip to content

Add CodeQL Python coverage and ShellCheck/PSScriptAnalyzer/ruff lint gates#145

Merged
daviburg merged 10 commits into
mainfrom
security/codeql-python-and-lint-gates
Jul 8, 2026
Merged

Add CodeQL Python coverage and ShellCheck/PSScriptAnalyzer/ruff lint gates#145
daviburg merged 10 commits into
mainfrom
security/codeql-python-and-lint-gates

Conversation

@daviburg

@daviburg daviburg commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Closes the CodeQL-Python and CI-lint gaps identified during the repo security-baseline audit.

Changes

  • codeql.yml: add python to the language matrix. Python is this repo's dominant language (14,338 bytes) but had zero CodeQL coverage - the matrix only ever scanned actions.
  • lint.yml (new): three lint gates - ShellCheck is preinstalled on the runner; PSScriptAnalyzer and ruff are installed at pinned versions from their official registries (PowerShell Gallery, pip), so there's no third-party Action requiring SHA-pinning:
    • ShellCheck against all *.sh files
    • PSScriptAnalyzer (pinned to 1.25.0) against all *.ps1 files (Warning+Error severity)
    • ruff (pinned to 0.15.14) against all Python files, selecting both style (E, F) and security (S / flake8-bandit) rules
  • ruff.toml (new): line-length = 150, target-version = "py310" (matches this script's documented Python 3.10+ minimum), select = ["E", "F", "S"].
  • PSScriptAnalyzerSettings.psd1 (new): excludes PSAvoidUsingWriteHost repo-wide, since install.ps1 is an interactive irm | iex installer where console-only output is intentional.
  • trigger-getting-started.py: fixes required to pass the new ruff gate cleanly, plus one real bug found by Copilot review:
    • Removed extraneous f prefixes from 6 f-strings with no placeholders (F541).
    • Wrapped one 224-character callback-URL f-string across multiple lines.
    • Added justified # noqa: S603 / # noqa: S607 comments on the 4 subprocess.run calls to az - all use fixed argument lists (never shell=True, never untrusted/interpolated input), so these are not injection risks.
    • Bug fix (from Copilot review): the trigger callbackUrl used the unregional management.azuredevcompute.io host, which 404s (GlobalSandboxNotFound) per this repo's own gotchas.md/trigger-setup.md. Now fetches the sandbox group's ARM location and builds a regional management.{region}.azuredevcompute.io host instead. The audience field is intentionally left unregional, matching the documented canonical pattern.
  • install.ps1: added a UTF-8 BOM (encoding-only change, no functional change) to resolve PSUseBOMForUnicodeEncodedFile.

Validation

All three lint tools were run locally against the affected files before pushing, and the PR's own CI (CodeQL actions+python, Lint/ShellCheck, Lint/PSScriptAnalyzer, Lint/Ruff) is green:

  • ruff check . -> all checks passed (including after the py310 target-version fix)
  • Invoke-ScriptAnalyzer -Settings PSScriptAnalyzerSettings.psd1 -> zero findings
  • Shell scripts were manually reviewed; they already use set -euo pipefail/set -eu and consistently quote variables - confirmed clean by the CI ShellCheck job.

Went through two rounds of Copilot review: round 1 caught the regional-host bug above; round 2 caught the unpinned tool versions and an inaccurate header comment (all fixed). Round 3 was a clean pass.

@daviburg
daviburg requested review from a team and Copilot July 7, 2026 19:30
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 closes CI/security-baseline gaps by expanding CodeQL coverage to Python and introducing a new CI “Lint” workflow that enforces ShellCheck, PSScriptAnalyzer, and ruff checks across the repo. It also updates an existing Python helper script and a PowerShell installer to comply with the new lint gates.

Changes:

  • Extend CodeQL language matrix to include Python.
  • Add a new .github/workflows/lint.yml workflow with ShellCheck, PSScriptAnalyzer, and ruff gates plus corresponding repo configs (ruff.toml, PSScriptAnalyzerSettings.psd1).
  • Update trigger-getting-started.py and install.ps1 to satisfy the new linting requirements.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ruff.toml Adds repo-wide ruff configuration (line length, target version, selected rule sets).
public-preview/connector-namespace-cli/install.ps1 Encoding-only change (adds UTF-8 BOM) to satisfy PSScriptAnalyzer BOM rule.
PSScriptAnalyzerSettings.psd1 Adds analyzer settings excluding PSAvoidUsingWriteHost repo-wide.
plugin/skills/aca-sandboxes/scripts/trigger-getting-started.py Ruff-driven cleanup and Bandit suppressions; refactors long string; (note: callback URL host must be regional).
.github/workflows/lint.yml New workflow enforcing ShellCheck, PSScriptAnalyzer, and ruff checks in CI.
.github/workflows/codeql.yml Adds Python to CodeQL scan matrix.

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

Comment thread plugin/skills/aca-sandboxes/scripts/trigger-getting-started.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread ruff.toml Outdated
Comment thread .github/workflows/lint.yml Outdated
Comment thread .github/workflows/lint.yml Outdated
Copilot AI review requested due to automatic review settings July 7, 2026 20:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/lint.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@daviburg
daviburg force-pushed the security/codeql-python-and-lint-gates branch from 7487921 to 6feaafa Compare July 7, 2026 21:01
@daviburg
daviburg enabled auto-merge (squash) July 7, 2026 21:23
@daviburg
daviburg merged commit 51cb98b into main Jul 8, 2026
7 checks passed
@daviburg
daviburg deleted the security/codeql-python-and-lint-gates branch July 8, 2026 04:24
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