Skip to content

docs: update copilot instructions with shell script best practices#8482

Open
djsly wants to merge 2 commits intomainfrom
djsly/update-copilot-instructions
Open

docs: update copilot instructions with shell script best practices#8482
djsly wants to merge 2 commits intomainfrom
djsly/update-copilot-instructions

Conversation

@djsly
Copy link
Copy Markdown
Collaborator

@djsly djsly commented May 8, 2026

Add learnings from the DirtyFrag/CopyFail2 PR review cycle (#8475, #8476):

  • ShellSpec tests expected for all shell script changes (not just security-critical)
  • Scriptless provisioning: security hotfix functions must be in cse_main.sh
  • Prefer simple single-purpose functions with positional args
  • Use OS helper functions (isUbuntu, isMarinerOrAzureLinux, isACL)
  • Define functions at top-level, not nested inside other functions
  • VHD cleanup-vhd.sh must verify removal and fail on error

Add learnings from PR #8475/#8476 review cycle:
- ShellSpec tests expected for all shell script changes
- Scriptless provisioning: define hotfix functions in cse_main.sh
- Prefer simple functions with positional args
- Use OS helper functions (isUbuntu, isMarinerOrAzureLinux)
- Define functions at top-level, not nested
- VHD cleanup must not silently ignore failures

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

Updates the repository’s Copilot instructions to capture recent review learnings for shell-script and VHD build hygiene, so future contributions follow the same guardrails used in the DirtyFrag/CopyFail2 mitigation work.

Changes:

  • Adds guidance that VHD cleanup must not ignore failures and should verify removal of sensitive components.
  • Strengthens ShellScripts guidelines around ShellSpec expectations, scriptless provisioning compatibility, OS helper usage, and function scoping.
  • Encourages simpler function design (single-purpose, positional args) to reduce fragility in provisioning scripts.


- use shellcheck for sanity checking
- use ShellSpec for testing
- use ShellSpec for testing — all shell script changes should have corresponding tests in `spec/parts/linux/`

When making changes, reason whether the file is used in VHD building stage, or provision stage, or both. Make sure the changes are valid in its life stage. as an example, [windows-vhd-configuration.ps1](./vhdbuilder/packer/windows/windows-vhd-configuration.ps1) defines container images to be cached in VHD, while [configure-windows-vhd.ps1](./vhdbuilder/packer/windows/configure-windows-vhd.ps1) executes commands at provision time.

VHD cleanup steps in `cleanup-vhd.sh` must not silently ignore failures. Verify removal of security-sensitive components and fail the build if expected state is not achieved.
Clarify that all shell scripts must pass the CI shellcheck gate
(make validate-shell), which enforces POSIX compliance even in
bash scripts (e.g. [ ] not [[ ]], = not ==).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants