Skip to content

Commit 4a3cf1c

Browse files
zacdav-dbZac Davies
andauthored
Harden GitHub Actions (#206)
Co-authored-by: Zac Davies <zachary.davies+data@databricks.com>
1 parent 00392fa commit 4a3cf1c

5 files changed

Lines changed: 76 additions & 10 deletions

File tree

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Security-sensitive GitHub Actions changes require owner review.
2+
.github/CODEOWNERS @zacdav-db
3+
.github/workflows/ @zacdav-db

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/pr-commands.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66

77
name: Commands
88

9+
# Security note: /document and /style fetch a pull request branch and execute
10+
# package R code from that branch. Before triggering these commands on an
11+
# external contributor PR, a MEMBER or OWNER must review the PR's R code for
12+
# malicious constructs.
913
permissions:
1014
contents: read
1115
pull-requests: read

.github/workflows/test-coverage.yaml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ permissions:
1313
jobs:
1414
test-coverage:
1515
environment: runtime
16-
permissions:
17-
contents: read
18-
id-token: write # Upload coverage to Codecov via OIDC.
1916
runs-on:
2017
group: databrickslabs-protected-runner-group
2118
labels: linux-ubuntu-latest
@@ -52,14 +49,12 @@ jobs:
5249
covr::to_cobertura(cov)
5350
shell: Rscript {0}
5451

55-
- uses: codecov/codecov-action@0561704f0f02c16a585d4c7555e57fa2e44cf909 # v5.5.2
52+
- name: Upload coverage report
53+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
5654
with:
57-
# Fail if error if not on PR, or if on PR and token is given
58-
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
59-
files: ./cobertura.xml
60-
plugins: noop
61-
disable_search: true
62-
use_oidc: true
55+
name: coverage-report
56+
path: cobertura.xml
57+
if-no-files-found: error
6358

6459
- name: Show testthat output
6560
if: always()
@@ -74,3 +69,31 @@ jobs:
7469
with:
7570
name: coverage-test-failures
7671
path: ${{ runner.temp }}/package
72+
73+
upload-coverage:
74+
needs: test-coverage
75+
runs-on:
76+
group: databrickslabs-protected-runner-group
77+
labels: linux-ubuntu-latest
78+
permissions:
79+
contents: read
80+
id-token: write
81+
82+
steps:
83+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
84+
85+
- name: Download coverage artifact
86+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
87+
with:
88+
name: coverage-report
89+
path: coverage
90+
91+
- name: Upload coverage to Codecov
92+
uses: codecov/codecov-action@0561704f0f02c16a585d4c7555e57fa2e44cf909 # v5.5.2
93+
with:
94+
# Fail if error if not on PR, or if on PR and token is given
95+
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
96+
files: coverage/cobertura.xml
97+
plugins: noop
98+
disable_search: true
99+
use_oidc: true

SECURITY.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Security Runbook
2+
3+
## GitHub Actions Runtime Environment
4+
5+
Workflows that run package code with Databricks runtime secrets must declare the
6+
`runtime` GitHub Actions environment. The repository settings for that
7+
environment must enforce required reviewers before internal GitHub Actions
8+
runners are enabled.
9+
10+
Required configuration:
11+
12+
- Environment name: `runtime`
13+
- Protection rule: required reviewers enabled
14+
- Reviewers: security owners or trusted maintainers for this repository
15+
- Self-review prevention: enabled when available
16+
17+
This protects fork pull request runs by requiring an approved environment
18+
deployment before jobs can access `DATABRICKS_HOST`, `DATABRICKS_TOKEN`, or other
19+
runtime secrets.
20+
21+
Before enabling or changing internal runners, verify the environment still has
22+
required reviewers configured in GitHub repository settings under
23+
`Settings > Environments > runtime`.
24+
25+
## Pull Request Comment Commands
26+
27+
The `/document` and `/style` issue-comment commands fetch the pull request branch
28+
and execute R code from that branch. For external contributor pull requests,
29+
members and owners must review the PR's R code for malicious constructs before
30+
triggering either command.

0 commit comments

Comments
 (0)