Skip to content

Commit 2264e23

Browse files
committed
Separate out the rust testing and use pull_request_target
pull_request_target allows PR's to access the headless license, for this to be safe we need to prevent people from running the job. To prevent the job from being ran we add an environment requirement on testing that a reviewer must review the code and then manually approve it to run.
1 parent 652a1d5 commit 2264e23

File tree

2 files changed

+49
-27
lines changed

2 files changed

+49
-27
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Rust CI
22

3+
# TODO: The paths need to include all rust projects. Those exist outside the rust directory.
4+
35
on:
46
workflow_dispatch:
57
push:
@@ -10,33 +12,6 @@ on:
1012
- 'rust/**'
1113

1214
jobs:
13-
# Check that code compiles and tests pass
14-
test:
15-
# The testing environment is used to access the BN_SERIAL secret.
16-
environment: testing
17-
name: cargo test
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v4
21-
# We need to add wayland as it's used for file picker in the WARP integration
22-
- name: Install system dependencies
23-
run: sudo apt-get install libwayland-dev
24-
# Pull in Binary Ninja
25-
- name: Setup Binary Ninja
26-
id: setup-binja
27-
uses: Vector35/setup-binary-ninja@v1-beta
28-
with:
29-
license: '${{ secrets.BN_SERIAL }}'
30-
python-support: 'false'
31-
dev-branch: 'true'
32-
- uses: actions-rust-lang/setup-rust-toolchain@v1
33-
- name: Test
34-
# For now, we run the tests single threaded, there are some data races in core around platform types
35-
run: cargo test --all-features -- --test-threads=1
36-
env:
37-
BINARYNINJADIR: ${{ steps.setup-binja.outputs.install-path }}
38-
BN_LICENSE: ${{ secrets.BN_LICENSE }}
39-
4015
# Check lints with clippy
4116
clippy:
4217
name: cargo clippy

.github/workflows/rust_testing.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Rust Testing
2+
3+
# This workflow will have access to two secrets, `BN_SERIAL` and `BN_LICENSE`, they are exposed only for the test job
4+
# and only if workflow has been approved to run. If there is no approval they workflow won't run.
5+
# What security issues arise from this? If a person makes a PR that leaks the `BN_SERIAL` or `BN_LICENSE` and a maintainer
6+
# approves it than the those secrets would leak.
7+
8+
on:
9+
workflow_dispatch:
10+
push:
11+
paths:
12+
- 'rust/**'
13+
# Pull request target allows us to use the bn license and serial for PR's
14+
# to insure we do not leak the license the workflow is required to be approved manually.
15+
pull_request_target:
16+
paths:
17+
- 'rust/**'
18+
19+
jobs:
20+
# Check that code compiles and tests pass
21+
test:
22+
# Using the testing environment gives us the needed secrets, it also requires a maintainer to approve it to run.
23+
environment: testing
24+
name: cargo test
25+
runs-on: ubuntu-latest
26+
permissions:
27+
issues: read
28+
steps:
29+
- uses: actions/checkout@v4
30+
# We need to add wayland as it's used for file picker in the WARP integration
31+
- name: Install system dependencies
32+
run: sudo apt-get install libwayland-dev
33+
# Pull in Binary Ninja
34+
- name: Setup Binary Ninja
35+
id: setup-binja
36+
uses: Vector35/setup-binary-ninja@v1-beta
37+
with:
38+
license: '${{ secrets.BN_SERIAL }}'
39+
python-support: 'false'
40+
dev-branch: 'true'
41+
- uses: actions-rust-lang/setup-rust-toolchain@v1
42+
- name: Test
43+
# For now, we run the tests single threaded, there are some data races in core around platform types
44+
run: cargo test --all-features -- --test-threads=1
45+
env:
46+
BINARYNINJADIR: ${{ steps.setup-binja.outputs.install-path }}
47+
BN_LICENSE: ${{ secrets.BN_LICENSE }}

0 commit comments

Comments
 (0)