diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 1230149..3419030 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -4,3 +4,7 @@ updates: directory: "/" schedule: interval: "daily" + # Wait a week before proposing a newly-published version, mirroring the uv + # `exclude-newer` policy. Reduces exposure to compromised fresh releases. + cooldown: + default-days: 7 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b692c07..aa56808 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,13 +6,19 @@ on: branches: - main +permissions: {} + jobs: validate: runs-on: ubuntu-latest + permissions: + contents: read steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - - uses: actions/setup-python@v7 + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.11" @@ -21,7 +27,7 @@ jobs: - name: Load cached Pre-Commit Dependencies id: cached-pre-commit-dependencies - uses: actions/cache@v6 + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: ~/.cache/pre-commit/ key: pre-commit-|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} @@ -33,6 +39,8 @@ jobs: run: pre-commit run --show-diff-on-failure --color=always --all-files test: + permissions: + contents: read strategy: fail-fast: true matrix: @@ -43,6 +51,8 @@ jobs: coverage: ${{ matrix.python-version == '3.11' }} test-platform-compat: + permissions: + contents: read if: github.event_name == 'push' strategy: fail-fast: true @@ -57,22 +67,27 @@ jobs: needs: - test - validate + permissions: + contents: read if: github.event.pull_request.head.repo.fork == false && github.repository_owner == 'litestar-org' runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v7 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Download Artifacts - uses: actions/download-artifact@v8 + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: coverage-xml - name: Fix coverage file for sonarcloud run: sed -i "s/home\/runner\/work\/litestar\/litestar/github\/workspace/g" coverage.xml - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@master + - name: SonarQube Cloud Scan + uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io codeql: needs: @@ -80,14 +95,17 @@ jobs: - validate runs-on: ubuntu-latest permissions: + contents: read security-events: write steps: - name: Checkout repository - uses: actions/checkout@v7 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Initialize CodeQL Without Dependencies - uses: github/codeql-action/init@v4 + uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 with: setup-python-dependencies: false languages: python - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 + uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0676c8b..f9f3bfb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -4,19 +4,23 @@ on: schedule: - cron: "0 4 * * *" +permissions: {} + jobs: codeql: runs-on: ubuntu-latest permissions: + contents: read security-events: write steps: - name: Checkout repository - uses: actions/checkout@v7 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: "main" + persist-credentials: false - name: Initialize CodeQL With Dependencies - uses: github/codeql-action/init@v4 + uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 + uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index a70afa7..fcefc0e 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -4,19 +4,23 @@ on: release: types: [published] +permissions: {} + jobs: docs: permissions: contents: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up uv - uses: astral-sh/setup-uv@v9.0.0 + uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 with: python-version: "3.11" - enable-cache: true + enable-cache: false - name: Install dependencies run: uv sync --all-groups @@ -28,6 +32,6 @@ jobs: run: uv run python tools/build_docs.py docs-build - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 + uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4 with: folder: docs-build diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6b3c486..fcb262d 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -4,23 +4,28 @@ on: release: types: [published] +permissions: {} + jobs: publish-release: runs-on: ubuntu-latest permissions: + contents: read id-token: write steps: - name: Check out repository - uses: actions/checkout@v7 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up uv - uses: astral-sh/setup-uv@v9.0.0 + uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 with: python-version: "3.11" - enable-cache: true + enable-cache: false - name: Build package distributions run: uv build - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # release/v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 91e6dcb..e07b119 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,19 +15,25 @@ on: type: string default: "ubuntu-latest" +permissions: {} + jobs: test: runs-on: ${{ inputs.os }} timeout-minutes: 10 + permissions: + contents: read defaults: run: shell: bash steps: - name: Check out repository - uses: actions/checkout@v7 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - name: Set up uv - uses: astral-sh/setup-uv@v9.0.0 + uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 with: python-version: ${{ inputs.python-version }} enable-cache: true @@ -43,7 +49,7 @@ jobs: if: inputs.coverage run: uv run pytest docs/examples tests --cov=project_template --cov-report=xml - - uses: actions/upload-artifact@v7 + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 if: inputs.coverage with: name: coverage-xml diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml new file mode 100644 index 0000000..c54d5b3 --- /dev/null +++ b/.github/workflows/zizmor.yml @@ -0,0 +1,25 @@ +name: GitHub Actions Security Analysis + +on: + push: + branches: ["main"] + pull_request: + branches: ["**"] + +permissions: {} + +jobs: + zizmor: + runs-on: ubuntu-latest + permissions: + security-events: write # upload SARIF results to the Security tab + contents: read # only needed for private or internal repos + actions: read # only needed for private or internal repos + steps: + - name: Checkout repository + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false + + - name: Run zizmor 🌈 + uses: zizmorcore/zizmor-action@6599ee8b7a49aef6a770f63d261d214911a7ce02 # v0.6.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a1fa0b..b1b384d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,10 @@ repos: rev: 0.11.31 hooks: - id: uv-lock + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: v1.28.0 + hooks: + - id: zizmor - repo: https://github.com/charliermarsh/ruff-pre-commit rev: "v0.0.290" hooks: