From 8de18a2b8df932dd51fa0b59d60cf4e994e3a451 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 11 Oct 2023 09:21:32 -0700 Subject: [PATCH] GitHub Workflows security hardening Summary: X-link: https://github.com/facebookincubator/velox/pull/6969 This PR adds explicit [permissions section](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions) to workflows. This is a security best practice because by default workflows run with [extended set of permissions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token) (except from `on: pull_request` [from external forks](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)). By specifying any permission explicitly all others are set to none. By using the principle of least privilege the damage a compromised workflow can do (because of an [injection](https://securitylab.github.com/research/github-actions-untrusted-input/) or compromised third party tool or action) is restricted. It is recommended to have [most strict permissions on the top level](https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions) and grant write permissions on [job level](https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs) case by case. X-link: https://github.com/facebook/watchman/pull/1071 Reviewed By: xavierd Differential Revision: D50095358 Pulled By: genevievehelsel fbshipit-source-id: 4fc80c6b7c48df08207f68420b48a90ffcfddf27 --- build/fbcode_builder/getdeps.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/fbcode_builder/getdeps.py b/build/fbcode_builder/getdeps.py index 7f43c91bd53..b6ea1aa2c61 100755 --- a/build/fbcode_builder/getdeps.py +++ b/build/fbcode_builder/getdeps.py @@ -988,6 +988,9 @@ def write_job_for_platform(self, platform, args): # noqa: C901 on:{run_on} +permissions: + contents: read # to fetch code (actions/checkout) + jobs: """ )