Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ docker run -p 8080:8080 secure-pride
Published image: `ghcr.io/secure-pride/secure-pride` (releases before 2026-10-21: `ghcr.io/mazze93/secure-pride`). Release, scan-gate, and
publish pipeline: [docs/DOCKER_IMAGE_WORKFLOW.md](docs/DOCKER_IMAGE_WORKFLOW.md).

## Deploy from GitHub

Cloudflare Workers Builds is connected to `Secure-Pride/secure-pride`.
Merges to `main` trigger `npm run build && npm run build:worker`, followed
by `npx wrangler deploy`. Both `securepride.org` and `www.securepride.org`
are attached to the `secure-pride` Worker. Preview builds are disabled.

See the [deployment runbook](docs/DEPLOYMENT.md) for the configured settings,
release checks, credential scope, known gaps, and rollback. The runbook records the setup baseline; verify the build result and deployed
version after each merge.

## Contribution gate

A change is not ready to merge unless it:
Expand Down
6 changes: 3 additions & 3 deletions _redirects
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Force www → apex (pick one canonical form; apex is simpler with Cloudflare Pages)
# Cloudflare Pages handles HTTPS automatically — no HTTP→HTTPS redirect needed here.
# Canonical WWW-to-apex fallback for Worker static assets.
# The zone redirect uses the same method-preserving status for API POSTs.

# Redirect www to apex
https://www.securepride.org/* https://securepride.org/:splat 301
https://www.securepride.org/* https://securepride.org/:splat 308
182 changes: 182 additions & 0 deletions docs/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# Deploy the public site from GitHub

## Current deployment

Configured in the Cloudflare dashboard on **2026-11-14**.

| Setting | Value |
| --- | --- |
| GitHub repository | `Secure-Pride/secure-pride` |
| Worker | `secure-pride` |
| Production branch | `main` |
| Root directory | `/` |
| Build command | `npm run build && npm run build:worker` |
| Deploy command | `npx wrangler deploy` |
| Preview builds | Disabled |
| Build cache | Disabled |
| Build token | Dedicated token named `secure-pride GitHub build token` |
| Production custom domains | `securepride.org`, `www.securepride.org` |
| Runtime compatibility date | `2026-08-10` |

The Git connection is saved. Its first successful Git-triggered production
build has **not yet been verified**. At setup, production still served the
previous manually deployed Worker version `d4add5dc`.

The Node build version is declared in [`.nvmrc`](../.nvmrc), currently
`24.19.0`. This is separate from the Worker's compatibility date.
No build variables or secrets were configured in the dashboard at setup.

## Release through a pull request

1. Open a pull request against `main`.
2. Wait for the repository's required `validate` check and resolve review threads.
3. Review the diff, then merge through GitHub's normal protected-branch flow.
4. Open Cloudflare → Workers & Pages → `secure-pride` → Deployments.
5. Confirm the Git-triggered build uses the merged commit.
6. Confirm both build stages succeed, deployment succeeds, and the new
version receives production traffic.
7. Run the smoke checks below.

Every push to `main` triggers the configured build and deploy commands.
Cloudflare's build command does not itself run tests or wait for a separate
GitHub Actions run. The protected pull-request workflow is the release gate.
Feature-branch pushes do not create Cloudflare preview builds.

The current GitHub ruleset requires `validate`, pull requests, and resolved
review threads. It does not require an approving review and does not require
the branch to be current with `main`. These are observed settings, not claims
that every security check is required.

## What the build produces

- `npm run build` generates the Astro site in `dist/`, then creates
`dist/_headers`, including the generated Content-Security-Policy.
- `npm run build:worker` compiles `functions/` to
`.worker-build/index.js`.
- Wrangler deploys that entry point and `dist/` using
[`wrangler.toml`](../wrangler.toml).
- Static assets use the `ASSETS` binding. Only `/api/*` runs the Worker first.
- The Rust scanner's WASM package is committed under
`functions/_lib/scanner/pkg/`; this deployment command does not rebuild Rust.
Changes to the Rust engine must follow the scanner verification workflow.

Do not remove `build:worker` from the build command. A static Astro build alone
does not generate the configured Worker entry point.

## Smoke checks

Use invented input only. Never paste a real draft, credential, or personal
record into a deployment check.

```bash
curl --fail-with-body --silent --show-error https://securepride.org/api/health
curl --fail-with-body --silent --show-error https://www.securepride.org/api/health
curl --fail-with-body --silent --show-error \
--header 'Content-Type: application/json' \
--data '{"text":"Hello"}' \
https://securepride.org/api/scan
curl --silent --show-error --head https://securepride.org/tools/scanner/
```

Expected health body: `{"status":"ok","service":"secure-pride-dlp"}`.
The scan response must identify `engine: "scanner-rs"`; HTTP 200 alone
does not verify the engine. Open the scanner page and check an invented
example manually. Inspect the response headers for the generated CSP.

Check Worker Settings after deployment: Logs, Traces, Issues, and Logpush
should remain disabled. No Tail Worker or telemetry export was configured
at setup. Disabled Worker logs do not mean that Cloudflare collects no
platform metrics or security events.

## Credentials and exposure

The founder explicitly approved Cloudflare's automatic build token.
It is dedicated by name, **not restricted to this Worker**. The displayed
permissions include editing Workers and several storage services across the
account, Workers Routes for all account zones, and account/user reads.

Keep the credential inside Cloudflare Builds. Never commit or copy its value
into documentation. Review scope and lifetime in the token owner’s profile.
A narrower deployment credential is follow-up work; do not revoke the
working credential until its replacement has deployed successfully.

Runtime secrets belong in Worker Settings → Runtime variables and secrets,
not build variables. At setup, no runtime variables or secrets were listed,
including `SP_AUDIT_SALT`. The scanner therefore uses its source-defined
fallback salt. This does not block deployment. Do not enable persistent
logging to compensate, and do not copy an unknown Pages secret.

The production `workers.dev` URL and version preview URLs were disabled
in the dashboard after founder approval on 2026-11-14. HTTP probes returned
404 (Cloudflare code 1042) for both the production Worker hostname and the
previous version hostname. `workers_dev = false` and `preview_urls = false`
in Wrangler preserve that setting on later deployments. Disabling preview **builds** does not disable preview
**URLs**. Review these alternate entry points before relying on zone-scoped
security rules. Keep both Wrangler flags false so later deployments do not restore
alternate public entry points.

## Observed Cloudflare follow-ups

These are observations and approved changes from **2026-11-14**.

| Area | Observed | Next action |
| --- | --- | --- |
| Scanner rate limiting | `Scanner burst limit` is active: 10 POST requests per 10 seconds per IP, with a 10-second block. Covers `/api/scan` and `/api/scan/` on both production domains. The leaked-password condition was deployed as a separate active Block custom rule before repurposing the rate-limit slot. | A 15-request synthetic burst returned twelve 200 responses identifying `scanner-rs` and three 429 responses (1015). Enforcement is approximate; it is not a strict global quota. Review shared-IP false positives. |
| DNSSEC | Multi-provider DNS and multi-signer DNSSEC are now off. DNSSEC remains enabled, with the same DS record. Google Public DNS returned `Status: 0` and `AD: true` for NS, DS, and apex A before the change, and for apex/www A afterward. Published NS records name only Cloudflare. | The original warning did not establish a DNS outage. Keep the single-provider configuration unless an intentional secondary-provider design is introduced. |
| Transport | Certificates active; Always Use HTTPS and TLS 1.3 enabled; minimum TLS 1.2. HSTS is on for one month, without subdomains or preload. | Reconcile the TLS 1.3-only policy with actual client compatibility. Review every subdomain before expanding HSTS. |
| Build verification | Connection saved; no Git-triggered deployment verified at setup. | Verify the first merge-to-deploy cycle and record the commit, build result, and version. |

## Verification record — 2026-11-14

- Both production hostnames returned the expected health body with HTTP 200
(www follows its canonical redirect).
- Production and previous-version `workers.dev` hostnames returned HTTP 404,
Cloudflare code 1042, after URL disabling.
- The synthetic scanner burst triggered HTTP 429, Cloudflare code 1015.
Successful requests identified the Rust scanner. Fifteen parallel requests
took about ten seconds; twelve passed and three were blocked. This is
evidence of enforcement, not proof of an exact ten-request ceiling.
- Initial Python-default-User-Agent HTTP probes were blocked with Cloudflare
code 1010. A declared Mozilla-compatible deployment-check User-Agent
received the results above. This is a bot-filter limitation, not an outage.
- Both DNS toggles were confirmed off after reloading the dashboard. UI
automation initially reported a state-change error while each save was
completing; the persisted values and public DNS responses were then checked.
- A POST to www initially received a 301 redirect; a client that rewrote
it as GET then failed. The live WWW-to-apex rule now uses 308, with path
and query preservation. A manual method-preserving follow returned
HTTP 200 with `engine: "scanner-rs"`. The static `_redirects` fallback
also declares 308. Use the apex URL directly for scanner API clients.
- The build token remains broad. TLS minimum and HSTS scope were left
unchanged; no unknown subdomain was forced into HSTS.

To undo the scanner limit, edit its threshold or restore its prior expression
from the historical record. Keep `Block leaked credentials` active while doing
so. To reopen alternate URLs deliberately, change both Wrangler flags and
review the exposure before deploying. Do not disable DNSSEC as a rollback.

## Failure and rollback

If the build fails, inspect its dependency-install, build, or deploy stage.
Confirm the Node version, repository root, Worker name, entry point,
and both build commands. Do not report a saved Git connection as a passing
deployment.

If a released version fails smoke checks, first pause automatic builds to
prevent new builds, then cancel or finish every active and queued build.
A build already running can otherwise deploy the bad commit again after
rollback. Only then use Cloudflare Deployments to roll back to the last
known-good version, and verify the active version and traffic allocation. Re-run health and scanner checks
on both custom domains. Revert the bad commit through a pull request so a
later push does not reintroduce it. Restore automatic builds only after the correction is ready.

Keep the historical Pages rollback procedure in
[DECISION-015](decisions/DECISION-015.md) as a separate disaster-recovery
path. A Worker version rollback does not require DNS changes.

## References

- [Worker hosting decision](decisions/DECISION-015.md)
- [Cloudflare Workers Builds configuration](https://developers.cloudflare.com/workers/ci-cd/builds/configuration/)
- [Production and preview branches](https://developers.cloudflare.com/workers/ci-cd/builds/build-branches/)
- [workers.dev configuration](https://developers.cloudflare.com/workers/configuration/routing/workers-dev/)
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Operational standards for AI-assisted development.
- **[COPILOT-INSTRUCTIONS-README.md](COPILOT-INSTRUCTIONS-README.md)**: How to use the charter
- **[QUICK-REFERENCE.md](QUICK-REFERENCE.md)**: One-page cheat sheet

## Deployment

- [GitHub-to-Worker deployment runbook](DEPLOYMENT.md): build settings, release verification, known configuration gaps, and rollback.

## Brand & Design

Brand voice, design system, and documentation templates in [brand/](brand/).
Expand Down Expand Up @@ -35,6 +39,7 @@ Significant decisions are recorded in [decisions/](decisions/).
- [DECISION-012](decisions/DECISION-012.md): Serve the Content-Security-Policy, with build-time hashes
- [DECISION-013](decisions/DECISION-013.md): Ship the Rust scanner on the public scan route
- [DECISION-014](decisions/DECISION-014.md): Scanner page uses the porcelain and charcoal site
- [DECISION-015](decisions/DECISION-015.md): Serve the public site from a Worker; GitHub Builds setup recorded on 2026-11-14

## Threat Model

Expand Down
57 changes: 57 additions & 0 deletions docs/decisions/DECISION-015.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,60 @@ The Pages project is not deleted. Rollback is not a CNAME change by itself. Remo
`npm run build && npm run build:worker`, then `wrangler deploy`. On the Worker URL, `/tools/scanner/` is the porcelain page and `POST /api/scan` with `{"text":"Hello"}` returns `engine: "scanner-rs"`. Read the deployed Worker settings and confirm observability is disabled before any hostname moves.

Cloudflare will not attach a Worker custom domain to a hostname that already has a CNAME. Both hostnames currently CNAME to `secure-pride.pages.dev`. Delete those two records, then attach `securepride.org` and `www.securepride.org` as custom domains. The public site does not answer on those hostnames between the deletion and the new records becoming active. Confirm the Worker URL before deleting the records.

## Outcome update — 2026-11-14

The Cloudflare dashboard now lists `securepride.org` and
`www.securepride.org` as production custom domains on `secure-pride`.
The Worker still served manually deployed version `d4add5dc` at setup.

The founder requested GitHub deployment and approved creating Cloudflare's
automatic build token after its broad account-wide permissions were
displayed. Workers Builds is now connected to `Secure-Pride/secure-pride`,
production branch `main`, root `/`. It runs
`npm run build && npm run build:worker`, then `npx wrangler deploy`.
Preview builds and build caching are disabled.

This supersedes the earlier connection-specific inability to configure
Workers Builds. The hosting architecture and compatibility date are
unchanged. The token is dedicated by name, not Worker-scoped; its scope is
a recorded trade-off. No token value is stored here.

The connection was saved successfully. A Git-triggered build has not yet
been verified. Logs, traces, Issues, and Logpush are off in the observed
Worker settings. Runtime variables and secrets were empty.

See [the deployment runbook](../DEPLOYMENT.md) for release checks, rollback,
alternate-hostname exposure, and the dated Cloudflare follow-up list.

## Hardening outcome — 2026-11-14

The founder approved the configuration follow-ups. The multi-provider and
multi-signer DNS options were disabled while DNSSEC stayed enabled. Public
validation returned authenticated answers before and after; the earlier
warning was a configuration inconsistency, not a demonstrated outage.

Both alternate Worker URL switches were disabled and verified with HTTP 404
responses. Wrangler now declares `workers_dev = false` and
`preview_urls = false` so subsequent deployments preserve the restriction.
Custom domains remain attached and return healthy responses.

The existing leaked-password condition was first deployed as an active
Block custom rule. Only after that rule was active was the single rate-limit
slot repurposed for `POST /api/scan` and `/api/scan/` on both production
hostnames: 10 requests per 10 seconds per IP, blocked for 10 seconds. This
keeps credential protection while adding a short scanner burst control.
The short window limits shared-IP lockout duration. A synthetic burst
produced 429 responses; counters are approximate, not a strict quota.

The dedicated build token remains account-wide. Its replacement requires a
separate verified credential migration. Minimum TLS and HSTS scope remain
unchanged because client and subdomain compatibility have not been assessed.

A follow-up POST check found that the WWW-to-apex redirect used 301, which
can rewrite POST to GET. The zone rule now uses 308 while retaining its
path and query behavior. A method-preserving follow returned HTTP 200 from
the Rust scanner. The repository's static redirect fallback is aligned to
308 as well. The first save attempt stopped at Cloudflare's proxy warning;
verification caught the unchanged 301, and the deployment was completed
before the successful 308 check.
5 changes: 4 additions & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
name = "secure-pride"
compatibility_date = "2026-08-10"
main = ".worker-build/index.js"
workers_dev = true
# Production is served only on the custom domains. Keep alternate URLs off
# in source so a later Wrangler deployment cannot reopen them.
workers_dev = false
preview_urls = false

# A new Worker turns Workers Logs on unless this is set. Scan requests
# stay out of that store. See DECISION-015.
Expand Down
Loading