-
Notifications
You must be signed in to change notification settings - Fork 10
fix(security): remove exposed RPC credentials and operator-specific paths #373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
78ac0fc
77bba3d
851726e
437beb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Copy this file to .env and provide values for the scripts you intend to run. | ||
| # .env is ignored by Git. RPC providers other than Helius are supported. | ||
| PERCOLATOR_RPC_URL=https://your-rpc-provider.example | ||
|
|
||
| # Required by administrative scripts. Use an absolute path to the appropriate | ||
| # deploy-authority keypair; never commit the keypair or its contents. | ||
| PERCOLATOR_ADMIN_KEYPAIR=/absolute/path/to/deploy-authority.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,42 @@ on: | |
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| secret-scan: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| # Required to inspect every commit introduced by a push or pull request. | ||
| fetch-depth: 0 | ||
| - name: Scan each newly introduced commit for secrets | ||
| env: | ||
| BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} | ||
| HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| range="${BASE_SHA}..${HEAD_SHA}" | ||
| scan_dir="$(mktemp -d)" | ||
| trap 'rm -rf "$scan_dir"' EXIT | ||
|
|
||
| for commit in $(git rev-list --reverse "$range"); do | ||
| find "$scan_dir" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} + | ||
| git archive "$commit" | tar -x -C "$scan_dir" | ||
| docker run --rm \ | ||
| -v "$scan_dir:/repo" \ | ||
| zricethezav/gitleaks@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f \ | ||
| dir /repo --redact --no-banner --max-archive-depth=1 | ||
| done | ||
| - name: Scan the current tree for secrets | ||
| run: >- | ||
| docker run --rm | ||
| -v "$GITHUB_WORKSPACE:/repo" | ||
| zricethezav/gitleaks@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f | ||
| dir /repo --redact --no-banner --max-archive-depth=1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This invokes Gitleaks' Useful? React with 👍 / 👎. |
||
|
|
||
| build-and-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
@@ -24,7 +59,7 @@ jobs: | |
| - run: pnpm test | ||
|
|
||
| publish: | ||
| needs: build-and-test | ||
| needs: [secret-scan, build-and-test] | ||
| if: github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'release:') | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import "dotenv/config"; | ||
|
|
||
| export function requireEnvironmentVariable(name, environment = process.env) { | ||
| const value = environment[name]?.trim(); | ||
| if (!value) { | ||
| throw new Error(`${name} is not set.`); | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| export function requireRpcUrl(environment = process.env) { | ||
| return requireEnvironmentVariable("PERCOLATOR_RPC_URL", environment); | ||
| } | ||
|
|
||
| export function requireAdminKeypairPath(environment = process.env) { | ||
| return requireEnvironmentVariable("PERCOLATOR_ADMIN_KEYPAIR", environment); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a
release:push, this new job runs independently whilepublishstill has onlyneeds: build-and-test; therefore the npm publish can start—and succeed—even whensecret-scanhas failed or is still running. This defeats the protection precisely for a release commit containing a credential in the package, sopublishshould depend on both jobs.Useful? React with 👍 / 👎.