Skip to main content

SKY-D311 · CI/CD pipelines

Artifact upload passes when files are missing

Medium

The catalog lists MEDIUM, but the detector reports every finding as LOW.

actions/upload-artifact only warns when its path matches no files, and the step still succeeds. SKY-D311 reports an upload step that does not set if-no-files-found: error.

Languages
GitHub Actions workflows, composite actions
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Catalog name
GitHub Actions lax artifact upload
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A build that silently produced nothing then shows green. The release job that downloads the artifact fails far from the cause, or ships without the binary, and a wrong path can go unnoticed for many releases.

What Skylos flags

.github/workflows/build.yml · YAMLReported on line 17
name: Buildon:  push:    branches: [main]permissions:  contents: readjobs:  build:    name: Build the CLI    runs-on: ubuntu-latest    timeout-minutes: 20    steps:      - uses: actions/checkout@v4        with:          persist-credentials: false      - run: go build -o dist/app ./cmd/app      - uses: actions/upload-artifact@v4        with:          name: app-linux          path: dist/app

What Skylos leaves alone

.github/workflows/build.yml · YAML
name: Buildon:  push:    branches: [main]permissions:  contents: readjobs:  build:    name: Build ${{ matrix.goos }}    runs-on: ubuntu-latest    timeout-minutes: 20    strategy:      matrix:        goos: [linux, darwin, windows]    steps:      - uses: actions/checkout@v4        with:          persist-credentials: false      - run: GOOS=${{ matrix.goos }} go build -o dist/ ./cmd/app      - uses: actions/upload-artifact@v4        with:          name: app-${{ matrix.goos }}          path: dist/          if-no-files-found: error          retention-days: 7

Why Skylos leaves it alone

The matrix, the expressions in the name and the broad dist/ path do not matter to this rule. The step sets if-no-files-found: error, so a build that wrote nothing fails the job instead of passing.

How Skylos decides

  1. Reads workflow files under .github/workflows and composite actions (action.yml, action.yaml).
  2. Checks every step whose uses: is actions/upload-artifact at any version. Other actions, including actions/upload-artifact/merge, are not read.
  3. Reports the step unless its with: sets if-no-files-found to error (any letter case). warn, ignore, a missing value and an expression are all reported.
  4. Reports LOW on the first line of the file that contains the step's uses: text. Steps with the same uses: text give one finding there.

How to fix it

Add if-no-files-found: error to uploads of build output. Keep warn or ignore only for files that may legitimately be absent, such as logs uploaded after a failure, and mark those steps.

.github/workflows/build.yml · YAML · the fix, against the flagged file
name: Buildon:  push:    branches: [main]permissions:  contents: readjobs:  build:    name: Build the CLI    runs-on: ubuntu-latest    timeout-minutes: 20    steps:      - uses: actions/checkout@v4        with:          persist-credentials: false      - run: go build -o dist/app ./cmd/app      - uses: actions/upload-artifact@v4        with:          name: app-linux          path: dist/appAdded:           if-no-files-found: error

When it can be wrong

  • Uploads of optional files, such as test logs after a failure, set ignore on purpose and are still reported.
  • Two upload steps with the same uses: text, for example actions/upload-artifact@v4, give one finding on the first such line, even when that step sets error and a later one does not. A marker must then go on that first line.

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-D311] <reason> on the reported uses: line or on the line directly above it, one rule per marker.

    YAML
    # skylos: ignore[SKY-D311] logs exist only when tests fail- uses: actions/upload-artifact@v4  if: failure()
  • [tool.skylos] ignore = ["SKY-D311"] turns the rule off for the whole project. A baseline also works, but it records the absolute file path and line, so it stops matching when the checkout moves or lines above the finding change.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.