SKY-D305 · CI/CD pipelines
Multi-line if with ${{ }} that is always true
An if: written as a YAML block (if: |) keeps a line break after the last line. When the block holds ${{ … }}, GitHub no longer sees one expression but text with an expression inside, and any non-empty text is true. SKY-D305 reports a block if: that contains ${{.
- Languages
- GitHub Actions workflows
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- GitHub Actions unsound multiline condition
Why it matters
The condition never stops the job. In the example, a release meant to run only for version tags and main also runs when someone starts the workflow by hand on any branch, and publishes that branch.
What Skylos flags
name: Releaseon: push: tags: ["v*"] workflow_dispatch:permissions: contents: readjobs: publish: if: | ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }} runs-on: ubuntu-latest environment: release steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: ./scripts/publish.sh env: REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}What Skylos leaves alone
name: Releaseon: push: tags: ["v*"] workflow_dispatch:permissions: contents: readjobs: publish: if: | startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' runs-on: ubuntu-latest environment: release steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: ./scripts/publish.sh env: REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}Why Skylos leaves it alone
The block has no ${{ }}. GitHub reads the whole if: text as the expression, and the trailing line break does not change its value.
How Skylos decides
- Reads workflow files under
.github/workflows, not composite actions. - Goes through the file line by line for
if:followed by a block marker,|or>with any modifier (|-,>-,|+), on its own or after a list dash. - Takes the lines below it that are indented further, and reports when any of them contains
${{. - One HIGH finding on the
if:line.
How to fix it
Write the condition without ${{ }}, either on one line or as a block. GitHub treats a bare if: as an expression.
name: Releaseon: push: tags: ["v*"] workflow_dispatch:permissions: contents: readjobs: publish:Removed: if: |Removed: ${{ startsWith(github.ref, 'refs/tags/v') ||Removed: github.ref == 'refs/heads/main' }}Added: if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' runs-on: ubuntu-latest environment: release steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: ./scripts/publish.sh env: REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}When it can be wrong
if: |-andif: >-drop the final line break, so a${{ }}block written with them works as intended. Skylos still reports them, even though its own message suggests a stripped block.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put
# skylos: ignore[SKY-D305]on the reportedif:line or on the line directly above it, one rule per marker.YAML # skylos: ignore[SKY-D305] |- strips the trailing line breakif: |- ${{ github.event_name == 'push' }}[tool.skylos] ignore = ["SKY-D305"]turns the rule off for the whole project.A baseline works, but it records the absolute file path and the line, so it stops matching when the checkout moves or lines above shift.