fix(workflows): elevate GITHUB_TOKEN permissions when needed (#822)

I am not 100% sure I was able to fix all the cases in which we
need higher permissions than the strict default.

At least, I tried.

It may be reasonable to make an interim release to check whether I
successfully fixed all the cases.

Ref issue: https://github.com/ooni/probe/issues/2154
This commit is contained in:
Simone Basso 2022-07-01 12:11:32 +02:00 committed by GitHub
parent 9b08dcac3f
commit 5371c7f486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 75 additions and 52 deletions

View File

@ -1,9 +1,10 @@
# alltests runs the whole test suite # Runs the whole test suite
name: alltests name: alltests
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,4 +1,4 @@
# android checks whether we can build for Android # Builds and publishes Android packages
name: android name: android
on: on:
push: push:
@ -10,10 +10,14 @@ on:
jobs: jobs:
build_and_publish: build_and_publish:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/setup-go@v1 - uses: actions/setup-go@v1
with: with:
go-version: "1.18.3" go-version: "1.18.3"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@ -1,10 +1,11 @@
# performs several code quality checks # Performs code quality checks
name: checks name: checks
on: on:
pull_request: pull_request:
push: push:
branches: branches:
- "master" - "master"
jobs: jobs:
perform_code_quality_checks: perform_code_quality_checks:
runs-on: "${{ matrix.os }}" runs-on: "${{ matrix.os }}"

View File

@ -1,10 +1,4 @@
# CodeQL runs a CodeQL scan. # Runs a CodeQL scan.
#
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL" name: "CodeQL"
on: on:
@ -17,6 +11,8 @@ jobs:
analyze: analyze:
name: Analyze name: Analyze
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
permissions: # See https://github.com/ooni/probe/issues/2154
security-events: write
strategy: strategy:
fail-fast: false fail-fast: false
@ -27,31 +23,13 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v1 uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2

View File

@ -1,4 +1,4 @@
# runs tests and computes the code coverage # Runs tests and computes the code coverage
name: coverage name: coverage
on: on:
pull_request: pull_request:
@ -6,8 +6,8 @@ on:
branches: branches:
- "master" - "master"
- "release/**" - "release/**"
jobs:
jobs:
measure_coverage: measure_coverage:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:

View File

@ -1,4 +1,4 @@
# debianrepo ensures we can install on debian with the official build instructions # Ensures we can install on debian with the official build instructions
name: debianrepo name: debianrepo
on: on:
push: push:

View File

@ -1,9 +1,10 @@
# generate verifies that `go generate ./...` is not broken # Verifies that `go generate ./...` is not broken
name: generate name: generate
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,12 +1,12 @@
# runs gosec security scanner # Runs the gosec security scanner
name: gosec name: gosec
on: on:
push: push:
branches: branches:
- "master" - "master"
- "release/**" - "release/**"
jobs:
jobs:
gosec: gosec:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
env: env:
@ -18,8 +18,9 @@ jobs:
steps: steps:
- name: Checkout Source - name: Checkout Source
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Run Gosec security scanner - name: Run Gosec security scanner
continue-on-error: true continue-on-error: true # TODO(https://github.com/ooni/probe/issues/2180)
uses: securego/gosec@master uses: securego/gosec@master
with: with:
args: ./... args: ./...

View File

@ -1,4 +1,4 @@
# ios checks whether we can build for iOS # Builds for iOS and publishes packages
name: ios name: ios
on: on:
push: push:
@ -10,6 +10,9 @@ on:
jobs: jobs:
build_and_publish: build_and_publish:
runs-on: macos-10.15 runs-on: macos-10.15
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/setup-go@v1 - uses: actions/setup-go@v1
with: with:

View File

@ -1,9 +1,10 @@
# jafar checks whether the jafar tool is still WAI. # Checks whether the jafar tool is still WAI.
name: jafar name: jafar
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,4 +1,4 @@
# linux builds and publishes ooniprobe for Linux # Builds and publishes ooniprobe for Linux
name: linux name: linux
on: on:
push: push:
@ -10,6 +10,8 @@ on:
jobs: jobs:
build_and_publish_386: build_and_publish_386:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -33,6 +35,8 @@ jobs:
build_and_publish_amd64: build_and_publish_amd64:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -55,6 +59,8 @@ jobs:
build_and_publish_armv7: build_and_publish_armv7:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -79,6 +85,8 @@ jobs:
build_and_publish_arm64: build_and_publish_arm64:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:

View File

@ -1,4 +1,4 @@
# macos builds ooniprobe for macos # Builds ooniprobe for macos
name: macos name: macos
on: on:
push: push:
@ -10,6 +10,8 @@ on:
jobs: jobs:
build_and_publish: build_and_publish:
runs-on: "macos-11" runs-on: "macos-11"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/setup-go@v1 - uses: actions/setup-go@v1
with: with:

View File

@ -1,4 +1,4 @@
# miniooni checks whether we can build the research client miniooni # This workflow checks whether we can build the research client miniooni
# and publishes the linux binaries as artifacts and, if we're building # and publishes the linux binaries as artifacts and, if we're building
# a tag, into the current release. We don't publish artifacts for # a tag, into the current release. We don't publish artifacts for
# Windows and macOS because they're not signed. For releases, we have # Windows and macOS because they're not signed. For releases, we have
@ -15,6 +15,8 @@ on:
jobs: jobs:
build_and_publish: build_and_publish:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/setup-go@v1 - uses: actions/setup-go@v1
@ -39,14 +41,17 @@ jobs:
with: with:
name: miniooni-linux-386 name: miniooni-linux-386
path: ./CLI/miniooni-linux-386 path: ./CLI/miniooni-linux-386
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v1
with: with:
name: miniooni-linux-amd64 name: miniooni-linux-amd64
path: ./CLI/miniooni-linux-amd64 path: ./CLI/miniooni-linux-amd64
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v1
with: with:
name: miniooni-linux-armv7 name: miniooni-linux-armv7
path: ./CLI/miniooni-linux-armv7 path: ./CLI/miniooni-linux-armv7
- uses: actions/upload-artifact@v1 - uses: actions/upload-artifact@v1
with: with:
name: miniooni-linux-arm64 name: miniooni-linux-arm64

View File

@ -8,6 +8,7 @@ on:
branches: branches:
- "master" - "master"
- "release/**" - "release/**"
jobs: jobs:
test_netxlite_package: test_netxlite_package:
runs-on: "${{ matrix.os }}" runs-on: "${{ matrix.os }}"

View File

@ -1,4 +1,4 @@
# oohelperd builds and publishes oohelperd for Linux # Builds and publishes oohelperd for Linux
name: oohelperd name: oohelperd
on: on:
push: push:
@ -10,6 +10,8 @@ on:
jobs: jobs:
build_and_publish: build_and_publish:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-go@v1 - uses: actions/setup-go@v1

View File

@ -1,9 +1,10 @@
# qafbmessenger runs QA checks for the fbmessenger experiment # Runs QA checks for the fbmessenger experiment
name: "qafbmessenger" name: "qafbmessenger"
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,9 +1,10 @@
# qahhfm runs QA checks for the hhfm experiment # Runs QA checks for the hhfm experiment
name: "qahhfm" name: "qahhfm"
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,9 +1,10 @@
# qahirl runs QA checks for the hirl experiment # Runs QA checks for the hirl experiment
name: "qahirl" name: "qahirl"
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,9 +1,10 @@
# qatelegram runs QA checks for the telegram experiment # Runs QA checks for the telegram experiment
name: "qatelegram" name: "qatelegram"
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,9 +1,10 @@
# qawebconnectivity runs QA checks for the webconnectivity experiment # Runs QA checks for the webconnectivity experiment
name: "qawebconnectivity" name: "qawebconnectivity"
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,9 +1,10 @@
# qawhatsapp runs QA checks for the whatsapp experiment # Runs QA checks for the whatsapp experiment
name: "qawhatsapp" name: "qawhatsapp"
on: on:
push: push:
branches: branches:
- "release/**" - "release/**"
jobs: jobs:
test: test:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -1,4 +1,4 @@
# vendors Go modules and publishes tarball # Vendors Go modules and publishes tarball
name: tarball name: tarball
on: on:
push: push:
@ -8,6 +8,9 @@ on:
jobs: jobs:
generate_tarball: generate_tarball:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -1,4 +1,4 @@
# windows builds ooniprobe for Windows # Builds ooniprobe for Windows and publishes binaries.
name: windows name: windows
on: on:
push: push:
@ -37,6 +37,8 @@ jobs:
test: test:
needs: build needs: build
runs-on: "windows-2019" runs-on: "windows-2019"
permissions: # See https://github.com/ooni/probe/issues/2154
actions: read
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v2
@ -47,6 +49,10 @@ jobs:
publish: publish:
needs: test needs: test
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
permissions: # See https://github.com/ooni/probe/issues/2154
contents: write
actions: read
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v2