Skip to content

Commit bed2706

Browse files
committed
Guard ClawHub publish on private source
1 parent ba84662 commit bed2706

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ To publish after source visibility/review access is resolved and ClawHub login i
135135
npm run clawhub:publish
136136
```
137137

138-
Optional environment variables for publishing are `CLAWHUB_OWNER`, `CLAWHUB_CHANGELOG`, `CLAWHUB_SOURCE_REPO`, `CLAWHUB_SOURCE_REF`, and `CLAWHUB_CLAWSCAN_NOTE`.
138+
The publish wrapper refuses to publish while the source repository is private. Set `CLAWHUB_ALLOW_PRIVATE_SOURCE=1` only if ClawHub has approved a private-source review path for this package.
139+
140+
Optional environment variables for publishing are `CLAWHUB_OWNER`, `CLAWHUB_CHANGELOG`, `CLAWHUB_SOURCE_REPO`, `CLAWHUB_SOURCE_REF`, `CLAWHUB_CLAWSCAN_NOTE`, and `CLAWHUB_ALLOW_PRIVATE_SOURCE`.
139141

140142
## Known Limits
141143

docs/CLAWHUB_READINESS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ Gateway auth rate limiting is configured:
8888
## Deployment Decision
8989

9090
Do not publish this package publicly to ClawHub while the repository remains private unless ClawHub has an approved private-source review workflow for this owner.
91+
92+
`npm run clawhub:publish` enforces that decision by refusing private-source publishing unless `CLAWHUB_ALLOW_PRIVATE_SOURCE=1` is set after review access is approved.

docs/COMPLETION_AUDIT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Do not mark public ClawHub deployment complete until one of these is true:
4040
| Live smoke test script | `scripts/live-smoke.mjs`, run by `npm run live:smoke` | Complete |
4141
| CI workflow | `.github/workflows/ci.yml` runs lint, tests, and package validation | Complete |
4242
| ClawHub dry-run | `npm run clawhub:dry-run` passes from local folder with source metadata | Complete |
43+
| Accidental publish guard | `npm run clawhub:publish` refuses private source unless `CLAWHUB_ALLOW_PRIVATE_SOURCE=1` is set after private-source review approval | Complete |
4344
| Direct GitHub-source ClawHub dry-run | `clawhub package publish CompleteTech-LLC-AI-Research/openclaw-mautic-plugin --dry-run` fails because repo is private | Blocked |
4445
| Repo clean and pushed | `git status --short --branch` reports `main...origin/main` after latest push | Complete |
4546

scripts/clawhub-package.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const args = new Set(process.argv.slice(2));
66
const publish = args.has("--publish");
77
const allowDirty = args.has("--allow-dirty");
88
const json = !args.has("--no-json");
9+
const allowPrivateSource = process.env.CLAWHUB_ALLOW_PRIVATE_SOURCE === "1";
910

1011
function run(command, commandArgs, options = {}) {
1112
return spawnSync(command, commandArgs, {
@@ -33,6 +34,12 @@ function sourceRepoFromPackage() {
3334
return match[1].replace(/^git\+/, "");
3435
}
3536

37+
function repoVisibility(sourceRepo) {
38+
const result = run("gh", ["repo", "view", sourceRepo, "--json", "visibility", "--jq", ".visibility"]);
39+
if (result.status !== 0) return "UNKNOWN";
40+
return result.stdout.trim().toUpperCase();
41+
}
42+
3643
const status = requireSuccess(run("git", ["status", "--porcelain"]), "git status");
3744
if (status && !allowDirty) {
3845
throw new Error("Working tree is dirty. Commit changes first or pass --allow-dirty for a local dry-run only.");
@@ -46,6 +53,16 @@ const changelog = process.env.CLAWHUB_CHANGELOG;
4653
const clawscanNote = process.env.CLAWHUB_CLAWSCAN_NOTE
4754
|| "Mautic plugin uses network access for Mautic REST API calls, an optional token-protected private console bridge, and opt-in workspace staging under a guarded root. Production defaults disable maintenance, automation, and workspace file access.";
4855

56+
if (publish) {
57+
const visibility = repoVisibility(sourceRepo);
58+
if (visibility !== "PUBLIC" && !allowPrivateSource) {
59+
throw new Error(
60+
`Refusing to publish because source repo ${sourceRepo} visibility is ${visibility}. `
61+
+ "Make the repo public or set CLAWHUB_ALLOW_PRIVATE_SOURCE=1 only after ClawHub has approved a private-source review path.",
62+
);
63+
}
64+
}
65+
4966
const command = [
5067
"exec",
5168
"--yes",

0 commit comments

Comments
 (0)