Browse Source

fix: pipeline permissions (#4669)

* fix: pipeline permissions

Signed-off-by: Gustavo Carvalho <gustavo@externalsecrets.com>

* feat: comments and cleanup permissions

Signed-off-by: Gustavo Carvalho <gustavo@externalsecrets.com>

---------

Signed-off-by: Gustavo Carvalho <gustavo@externalsecrets.com>
Gustavo Fernandes de Carvalho 1 year ago
parent
commit
0c889145b5

+ 3 - 2
.github/workflows/ci.yml

@@ -138,8 +138,9 @@ jobs:
     if: needs.detect-noop.outputs.noop != 'true'
     if: needs.detect-noop.outputs.noop != 'true'
     uses: ./.github/workflows/publish.yml
     uses: ./.github/workflows/publish.yml
     permissions:
     permissions:
-      id-token: write
-      contents: read
+      contents: read  #actions/checkout
+      packages: write #for publishing artifacts
+      id-token: write #for keyless sign
     strategy:
     strategy:
       matrix:
       matrix:
         include:
         include:

+ 2 - 3
.github/workflows/codeql.yml

@@ -8,9 +8,6 @@ on:
 
 
 permissions:
 permissions:
   contents: read
   contents: read
-  packages: read
-  actions: read
-  security-events: read
 
 
 jobs:
 jobs:
   analyze:
   analyze:
@@ -19,6 +16,8 @@ jobs:
     permissions:
     permissions:
       # required for all workflows
       # required for all workflows
       security-events: write
       security-events: write
+      packages: read
+      actions: read 
     strategy:
     strategy:
       fail-fast: false
       fail-fast: false
     steps:
     steps:

+ 1 - 0
.github/workflows/dlc.yml

@@ -11,6 +11,7 @@ permissions:
 
 
 jobs:
 jobs:
   fossa-scan:
   fossa-scan:
+    if: secrets.FOSSA_API_KEY != ''
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     steps:
     steps:
       - name: "Checkout Code"
       - name: "Checkout Code"

+ 1 - 1
.github/workflows/docs.yml

@@ -13,7 +13,7 @@ jobs:
   deploy:
   deploy:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     permissions:
     permissions:
-      contents: write
+      contents: write #needed to publish documentation
     steps:
     steps:
       - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
       - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
         with:
         with:

+ 3 - 3
.github/workflows/e2e-managed.yml

@@ -55,9 +55,9 @@ jobs:
   run-e2e-managed:
   run-e2e-managed:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     permissions:
     permissions:
-      id-token: write
-      checks: write
-      contents: read
+      id-token: write #for oidc auth with aws/gcp/azure
+      checks: write   #publish the commit status
+      contents: read  #for checkout
     if: github.event_name == 'repository_dispatch'
     if: github.event_name == 'repository_dispatch'
 
 
     steps:
     steps:

+ 5 - 11
.github/workflows/e2e.yml

@@ -6,10 +6,6 @@ on:
 
 
 permissions:
 permissions:
   contents: read
   contents: read
-  issues: read
-  pull-requests: read
-  checks: read
-  statuses: read
 name: e2e tests
 name: e2e tests
 
 
 env:
 env:
@@ -64,9 +60,8 @@ jobs:
   integration-trusted:
   integration-trusted:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     permissions:
     permissions:
-      id-token: write
-      checks: write
-      contents: read
+      id-token: write #for oidc auth with aws/gcp/azure
+      contents: read  #for checkout
     if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor !='dependabot[bot]'
     if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor !='dependabot[bot]'
     steps:
     steps:
 
 
@@ -82,10 +77,9 @@ jobs:
   integration-fork:
   integration-fork:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     permissions:
     permissions:
-      id-token: write
-      checks: write
-      contents: read
-      pull-requests: write
+      id-token: write      #for oidc auth with aws/gcp/azure
+      contents: read       #for checkout
+      pull-requests: write # to publish the status as comments
     if: github.event_name == 'repository_dispatch'
     if: github.event_name == 'repository_dispatch'
     steps:
     steps:
 
 

+ 7 - 0
.github/workflows/publish.yml

@@ -45,6 +45,9 @@ jobs:
   build-publish:
   build-publish:
     name: Build and Publish
     name: Build and Publish
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
     outputs:
     outputs:
       image-tag: ${{ steps.container_info.outputs.image-tag }}
       image-tag: ${{ steps.container_info.outputs.image-tag }}
     steps:
     steps:
@@ -138,6 +141,10 @@ jobs:
   sign:
   sign:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     needs: build-publish
     needs: build-publish
+    permissions:
+      contents: read
+      id-token: write #for keyless sign
+      packages: write #to update packages with added SBOMs.
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

+ 2 - 1
.github/workflows/rebuild-image.yml

@@ -35,8 +35,9 @@ jobs:
     uses: ./.github/workflows/publish.yml
     uses: ./.github/workflows/publish.yml
     needs: checkout
     needs: checkout
     permissions:
     permissions:
-      id-token: write
       contents: read
       contents: read
+      id-token: write #for keyless sign
+      packages: write #for updating packages
     strategy:
     strategy:
       matrix:
       matrix:
         include:
         include:

+ 5 - 3
.github/workflows/release.yml

@@ -19,7 +19,8 @@ jobs:
   release:
   release:
     name: Create Release
     name: Create Release
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
-
+    permissions:
+      contents: write # to create a release and push new docs
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -62,8 +63,9 @@ jobs:
         - tag_suffix: "-ubi-boringssl" # ubi image
         - tag_suffix: "-ubi-boringssl" # ubi image
 
 
     permissions:
     permissions:
-      id-token: write
-      contents: write
+      contents: write #to update the github release
+      id-token: write #for keyless sign
+      packages: write #to update packages with added SBOMs.
 
 
     env:
     env:
       SOURCE_TAG: ${{ github.event.inputs.source_ref }}${{ matrix.tag_suffix }}
       SOURCE_TAG: ${{ github.event.inputs.source_ref }}${{ matrix.tag_suffix }}

+ 1 - 1
.github/workflows/release_esoctl.yml

@@ -22,7 +22,7 @@ jobs:
     name: Create Release for esoctl
     name: Create Release for esoctl
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     permissions:
     permissions:
-      contents: write
+      contents: write # for publishing the release
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
         uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2