Skip to content

Commit 5945332

Browse files
committed
docs: clarify review app security
1 parent 6378189 commit 5945332

5 files changed

Lines changed: 49 additions & 5 deletions

File tree

.controlplane/readme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ For review apps, GitHub needs one repository secret:
3434
| --- | --- |
3535
| `CPLN_TOKEN_STAGING` | Service-account token for `shakacode-open-source-examples-staging`. |
3636

37+
Use a staging/review token that cannot access production Control Plane
38+
resources. In public repositories, generated review-app deploys skip fork PR
39+
heads because Docker builds use repository secrets; if a forked change needs a
40+
review app, first move the reviewed change to a trusted branch in this
41+
repository.
42+
3743
No review-app repository variables are required for the standard path. The
3844
workflow infers `qa-react-webpack-rails-tutorial` and
3945
`shakacode-open-source-examples-staging` from `.controlplane/controlplane.yml`,
@@ -111,6 +117,13 @@ Generate `SECRET_KEY_BASE` with `openssl rand -hex 64` and
111117
managed Postgres and Redis services and update `DATABASE_URL` and `REDIS_URL`
112118
accordingly.
113119

120+
Review apps run pull request code, so anything mounted through
121+
`cpln://secret/...` can be read by that code after it starts. Keep the
122+
`qa-react-webpack-rails-tutorial-secrets` dictionary limited to review-safe
123+
values: disposable databases, review-only renderer credentials, and a Pro
124+
license value that is acceptable for review-app exposure. Do not reuse
125+
production or long-lived staging secret dictionaries for review apps.
126+
114127
### Advanced Overrides
115128

116129
Most repos should leave these unset. They exist so forks and clones can test
@@ -483,6 +496,10 @@ this automated process. When an approved collaborator comments exactly
483496
After the review app exists, new pushes to the PR redeploy it automatically.
484497
Use `+review-app-delete` to delete it manually; closing the PR deletes it
485498
automatically. Use `+review-app-help` for the review-app command reference.
499+
Fork PR heads are skipped for deploys because the workflow builds Docker images
500+
with repository secrets. A trusted comment on a fork PR still should not deploy
501+
the fork head; move the reviewed change to a branch in this repository when a
502+
review app is needed.
486503
Pushes to the staging branch deploy staging, and production promotion is manual
487504
from the `cpflow-promote-staging-to-production` workflow.
488505
If staging moves off `master`, update both the `STAGING_APP_BRANCH` repository

.controlplane/shakacode-team.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ Deployments are handled by Control Plane configuration in this repo and GitHub A
1313
- New pushes to a PR redeploy only after the review app already exists.
1414
- Add `+review-app-delete` to delete a review app manually; closing the PR also
1515
deletes it automatically. Use `+review-app-help` for the command reference.
16+
- Public fork PRs can receive help comments, but deploys are limited to branches
17+
in this repository because Docker builds use repository secrets. If a forked
18+
change needs a review app, first move the reviewed change to a trusted branch
19+
in this repository.
20+
- Review apps run pull request code. Keep `CPLN_TOKEN_STAGING`,
21+
`qa-react-webpack-rails-tutorial-secrets`, database credentials, renderer
22+
credentials, and license values limited to review/staging use. Never mount
23+
production secrets into review apps.
1624

1725
### Staging Environment
1826
- **Automatic**: Any merge to the `master` branch automatically deploys to staging
@@ -34,6 +42,9 @@ Required repository secret for review apps and staging:
3442

3543
- `CPLN_TOKEN_STAGING`
3644

45+
Use a staging/review service-account token that cannot access the production
46+
Control Plane org or production secret dictionaries.
47+
3748
Required repository variables for staging deploys:
3849

3950
- `CPLN_ORG_STAGING=shakacode-open-source-examples-staging`

.controlplane/templates/app.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ spec:
4242
# Control Plane Secret named by {{APP_SECRETS}} before deploy. cpflow
4343
# resolves {{APP_SECRETS}} to `{APP_PREFIX}-secrets` — which means review
4444
# apps all share one `qa-react-webpack-rails-tutorial-secrets` (thanks to
45-
# match_if_app_name_starts_with: true on the qa template).
45+
# match_if_app_name_starts_with: true on the qa template). Review apps run
46+
# pull request code, so every mounted secret must be review-safe.
4647
- name: RENDERER_PASSWORD
4748
value: cpln://secret/{{APP_SECRETS}}.RENDERER_PASSWORD
4849
- name: REACT_ON_RAILS_PRO_LICENSE

.controlplane/templates/org.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
# other sensitive information that is shared across multiple apps
55
# in the same organization.
66

7-
# The qa-* dictionary is bootstrapped via this template; prod and
8-
# staging dictionaries are created manually with real values.
7+
# The qa-* dictionary is bootstrapped via this template for review apps.
8+
# Review apps run pull request code, so values in this dictionary must be
9+
# disposable or otherwise acceptable for review-app exposure. Prod and staging
10+
# dictionaries are created manually with separate real values.
911

1012
# Initial bootstrap (once, manually, not in CI):
1113
# cpflow apply-template secrets -a qa-react-webpack-rails-tutorial --org shakacode-open-source-examples-staging
@@ -21,7 +23,8 @@ data:
2123
# Both sides of the Rails/Node renderer handshake must match.
2224
# Generate with `openssl rand -hex 32`.
2325
RENDERER_PASSWORD: "replace-with-openssl-rand-hex-32"
24-
# JWT from https://pro.reactonrails.com/; same token across envs.
26+
# JWT from https://pro.reactonrails.com/. Use a review-safe token for public
27+
# review apps if the production token must not be exposed to pull request code.
2528
REACT_ON_RAILS_PRO_LICENSE: "replace-with-pro-license-jwt"
2629

2730
---

.github/cpflow-help.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@ For the normal generated review-app path, GitHub needs one repository secret:
2323
| --- | --- | --- |
2424
| `CPLN_TOKEN_STAGING` | Repository secret | Control Plane service-account token for the staging/review org. |
2525

26+
For public repositories, use a staging/review token that cannot access
27+
production Control Plane resources. Generated review-app deploys skip fork PR
28+
heads because Docker builds use repository secrets. If a forked change needs a
29+
review app, first move the reviewed change to a trusted branch in this
30+
repository.
31+
2632
No repository variables are required for the standard review-app path when
2733
`.controlplane/controlplane.yml` has exactly one review app entry with
2834
`match_if_app_name_starts_with: true`. cpflow infers the review-app prefix and
2935
staging org from that config.
3036

37+
Review apps run pull request code. Any value mounted through
38+
`cpln://secret/...` can be read by that code after the workload starts, so keep
39+
review-app secret dictionaries limited to disposable databases, review-only
40+
renderer credentials, and license values that are acceptable for review-app
41+
exposure.
42+
3143
Optional overrides exist for forks, clones, and unusual apps:
3244

3345
| Name | Notes |
@@ -119,7 +131,7 @@ Most apps do not need these:
119131
| Name | Notes |
120132
| --- | --- |
121133
| `DOCKER_BUILD_EXTRA_ARGS` | Newline-delimited extra Docker build tokens. |
122-
| `DOCKER_BUILD_SSH_KEY` | Private SSH key for Docker builds that fetch private dependencies. |
134+
| `DOCKER_BUILD_SSH_KEY` | Read-only, revocable deploy key for Docker builds that fetch private dependencies. Do not use a personal SSH key. |
123135
| `DOCKER_BUILD_SSH_KNOWN_HOSTS` | SSH known_hosts entries when SSH build hosts are not GitHub.com. |
124136
| `REVIEW_APP_DEPLOYING_ICON_URL` | Cosmetic custom image URL for the animated deploying icon. Set to `none` to use the text fallback icon. |
125137
| `STAGING_APP_BRANCH` | Custom staging branch. The branch must also appear in `cpflow-deploy-staging.yml`'s push filter. |

0 commit comments

Comments
 (0)