Skip to content

Commit 540a42d

Browse files
committed
Fix CodeRabbit review issues: path traversal, URLs, docs, setup.sh
- Add path traversal validation in configApply() for source and destination paths in file-manifest.json - Use default-assignment for CODEFORGE_DIR in deprecation guard - Replace old GitHub Pages URLs with custom domain (codeforge.core-directive.com) - Add .checksums/ and .markers/ to architecture docs tree - Clarify "How to Reset" section in troubleshooting docs - Fix "merged" → "migrated content from" in changelog wording
1 parent c5172e8 commit 540a42d

File tree

8 files changed

+49
-17
lines changed

8 files changed

+49
-17
lines changed

.devcontainer/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
- **`agent-system/README.md`** — updated `verify-no-regression.py` comment to list both consumers (implementer, refactorer); hyphenated "question-surfacing protocol"
111111
- **`orchestrator-system-prompt.md`** — clarified plan mode allows investigator delegation for research; added catch-all entry in selection criteria pointing to the full specialist catalog
112112
- **MD040 compliance** — added `text` language specifiers to 7 fenced code blocks across `investigator.md`, `tester.md`, and `documenter.md`
113+
- **`setup.js` path traversal**`configApply()` now validates that source paths resolve within `.codeforge/` and destination paths resolve within allowed directories (`CLAUDE_CONFIG_DIR`, `HOME`, `/usr/local/`), preventing directory traversal via `../` in manifest entries
114+
- **`setup.sh` CODEFORGE_DIR** — deprecation guard now uses default-assignment semantics (`:=`) instead of unconditional overwrite, preserving any user-defined `CODEFORGE_DIR` from `.env`
115+
- **Docs site URLs** — replaced `anexileddev.github.io/CodeForge/` with custom domain `codeforge.core-directive.com/` across README.md, CLAUDE.md, and .devcontainer/README.md
116+
- **Architecture docs** — added `.checksums/` and `.markers/` directories to the `.codeforge/` tree in architecture.md
117+
- **Troubleshooting docs** — renamed "Reset to Defaults" to "How to Reset" and clarified that `--reset` preserves `.codeforge/` user modifications; added step for restoring default config sources
113118

114119
### Changed
115120

.devcontainer/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,4 @@ Three mechanisms handle port access depending on your client:
201201

202202
VS Code auto-detects all ports opened inside the container (configured via `portsAttributes` in `devcontainer.json`). Outside VS Code, `dbr` provides dynamic port discovery via a reverse connection model (container→host). The container daemon auto-starts and is inert without the host daemon (`dbr host-daemon`). Both mechanisms coexist. See [devcontainer-bridge](https://github.com/bradleybeddoes/devcontainer-bridge).
203203

204-
For full setup instructions, see the [Port Forwarding reference](https://anexileddev.github.io/CodeForge/reference/port-forwarding/) in the docs.
204+
For full setup instructions, see the [Port Forwarding reference](https://codeforge.core-directive.com/reference/port-forwarding/) in the docs.

.devcontainer/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ The `setup-projects.sh` script auto-detects projects under `/workspaces/` and ma
432432

433433
## Troubleshooting
434434

435-
Common issues and solutions. For detailed troubleshooting, see the [Troubleshooting](https://anexileddev.github.io/CodeForge/reference/troubleshooting/) page on the docs site.
435+
Common issues and solutions. For detailed troubleshooting, see the [Troubleshooting](https://codeforge.core-directive.com/reference/troubleshooting/) page on the docs site.
436436

437437
| Problem | Solution |
438438
|---------|----------|
@@ -447,11 +447,11 @@ Common issues and solutions. For detailed troubleshooting, see the [Troubleshoot
447447
## Further Reading
448448

449449
**CodeForge Documentation**:
450-
- [Configuration Reference](https://anexileddev.github.io/CodeForge/customization/configuration/) — all env vars and config options
451-
- [Plugin System](https://anexileddev.github.io/CodeForge/plugins/) — plugin architecture and per-plugin docs
452-
- [Optional Features](https://anexileddev.github.io/CodeForge/customization/optional-features/) — mcp-qdrant and other optional components, disabling features
453-
- [Keybinding Customization](https://anexileddev.github.io/CodeForge/customization/keybindings/) — resolving VS Code conflicts
454-
- [Troubleshooting](https://anexileddev.github.io/CodeForge/reference/troubleshooting/) — common issues and solutions
450+
- [Configuration Reference](https://codeforge.core-directive.com/customization/configuration/) — all env vars and config options
451+
- [Plugin System](https://codeforge.core-directive.com/plugins/) — plugin architecture and per-plugin docs
452+
- [Optional Features](https://codeforge.core-directive.com/customization/optional-features/) — mcp-qdrant and other optional components, disabling features
453+
- [Keybinding Customization](https://codeforge.core-directive.com/customization/keybindings/) — resolving VS Code conflicts
454+
- [Troubleshooting](https://codeforge.core-directive.com/reference/troubleshooting/) — common issues and solutions
455455

456456
**External**:
457457
- [Claude Code Documentation](https://docs.anthropic.com/en/docs/claude-code)

.devcontainer/scripts/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fi
4646
if [ "$CONFIG_SOURCE_DIR" = "$DEVCONTAINER_DIR/config" ] || [ "$CONFIG_SOURCE_DIR" = "/workspaces/.devcontainer/config" ]; then
4747
echo "[setup] WARNING: CONFIG_SOURCE_DIR pointing to .devcontainer/config is deprecated (moved to .codeforge in v2.0)"
4848
echo "[setup] Redirecting to .codeforge."
49-
CODEFORGE_DIR="${WORKSPACE_ROOT:?}/.codeforge"
49+
: "${CODEFORGE_DIR:=${WORKSPACE_ROOT:?}/.codeforge}"
5050
unset CONFIG_SOURCE_DIR
5151
if [ -f "$ENV_FILE" ]; then
5252
sed -i 's|^CONFIG_SOURCE_DIR=.*\.devcontainer/config.*|# CONFIG_SOURCE_DIR removed (v2.0: now uses .codeforge)|' "$ENV_FILE"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ CodeForge operates in three layers, each building on the one below:
109109

110110
**Claude Code** — The AI assistant, executing tools and coordinating work. CodeForge enhances it through configuration — replacing built-in subagents, adding safety guardrails, and wiring up quality checks that run automatically.
111111

112-
For the full architecture breakdown — hook pipeline, agent routing, skill loading, and design principles — see the [Architecture Reference](https://anexileddev.github.io/CodeForge/reference/architecture/).
112+
For the full architecture breakdown — hook pipeline, agent routing, skill loading, and design principles — see the [Architecture Reference](https://codeforge.core-directive.com/reference/architecture/).
113113

114114
## Configuration
115115

@@ -127,7 +127,7 @@ All configuration lives in `.devcontainer/` and deploys automatically on contain
127127

128128
Config files use SHA-256 change detection — your edits persist across container rebuilds unless the source changes. Set a file's overwrite mode to `"never"` in `file-manifest.json` to permanently preserve your customizations.
129129

130-
For the complete configuration guide, see the [documentation site](https://anexileddev.github.io/CodeForge/customization/configuration/).
130+
For the complete configuration guide, see the [documentation site](https://codeforge.core-directive.com/customization/configuration/).
131131

132132
## Quick Start
133133

docs/src/content/docs/reference/architecture.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ CodeForge ships 38 skills across the skill-engine, spec-workflow, ticket-workflo
171171
| +-- connect-external-terminal.sh # External terminal connection (Linux/macOS)
172172
| +-- connect-external-terminal.ps1 # External terminal connection (Windows)
173173
+-- .codeforge-preserve # Lists additional files to preserve during updates
174+
+-- .checksums/ # File hashes for change detection (gitignored)
175+
+-- .markers/ # Migration state markers (gitignored)
174176
```
175177

176178
## Design Principles

docs/src/content/docs/reference/troubleshooting.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,17 @@ Any local feature can be disabled without removing it from `devcontainer.json` b
130130
- Subsequent starts skip unchanged config files (SHA-256 comparison).
131131
- Disable steps you don't need via `.env` (e.g., `SETUP_PROJECTS=false`). See [Environment Variables — Setup Variables](./environment/#setup-variables-env).
132132

133-
## How to Reset to Defaults
133+
## How to Reset
134134

135-
1. **Reset config files** — delete `~/.claude/` and restart the container. `setup-config.sh` will recopy all files from `.codeforge/config/`. Note that `--reset` preserves `.codeforge/` user modifications (only `.devcontainer/` is wiped).
135+
1. **Reset runtime config** — delete `~/.claude/` and restart the container. `setup-config.sh` will redeploy all files from `.codeforge/config/`. This resets the deployed copies but preserves your `.codeforge/` source files (user modifications remain intact).
136136

137-
2. **Reset aliases**delete the `# Claude Code environment and aliases` block from `~/.bashrc` and `~/.zshrc`, then run `bash /workspaces/.devcontainer/scripts/setup-aliases.sh`.
137+
2. **Restore default config sources**run `git checkout .codeforge/config/` to discard any local edits to the source files, then restart the container to redeploy.
138138

139-
3. **Full reset**rebuild the container from scratch (VS Code: **Dev Containers: Rebuild Container**).
139+
3. **Reset aliases**delete the `# Claude Code environment and aliases` block from `~/.bashrc` and `~/.zshrc`, then run `bash /workspaces/.devcontainer/scripts/setup-aliases.sh`.
140140

141-
4. **Reset a single feature** — set it to `"version": "none"`, rebuild, then set it back to the desired version and rebuild again.
141+
4. **Full reset** — rebuild the container from scratch (VS Code: **Dev Containers: Rebuild Container**). This recreates everything but still preserves `.codeforge/` user modifications since they live in the repository.
142+
143+
5. **Reset a single feature** — set it to `"version": "none"`, rebuild, then set it back to the desired version and rebuild again.
142144

143145
## Related
144146

setup.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,37 @@ function configApply() {
532532
);
533533
}
534534

535-
const srcPath = path.join(codeforgeDir, entry.src);
535+
const codeforgeRoot = path.resolve(codeforgeDir);
536+
const srcPath = path.resolve(codeforgeRoot, entry.src);
537+
if (!srcPath.startsWith(codeforgeRoot + path.sep)) {
538+
console.log(" Skip: " + entry.src + " (source path escapes .codeforge/)");
539+
skipped++;
540+
continue;
541+
}
536542
if (!fs.existsSync(srcPath)) {
537543
console.log(" Skip: " + entry.src + " (not found)");
538544
skipped++;
539545
continue;
540546
}
541547

542-
const destDir = expandVars(entry.dest);
548+
const homeDir = path.resolve(process.env.HOME || "/home/vscode");
549+
const allowedDestRoots = [
550+
path.resolve(claudeConfigDir),
551+
homeDir,
552+
"/usr/local",
553+
];
554+
const destDir = path.resolve(expandVars(entry.dest));
555+
const destAllowed = allowedDestRoots.some(
556+
(root) => destDir === root || destDir.startsWith(root + path.sep),
557+
);
558+
if (!destAllowed) {
559+
console.log(
560+
" Skip: " + entry.dest + " (destination outside allowed directories)",
561+
);
562+
skipped++;
563+
continue;
564+
}
565+
543566
const filename = entry.destFilename || path.basename(entry.src);
544567
const destPath = path.join(destDir, filename);
545568
fs.mkdirSync(destDir, { recursive: true });

0 commit comments

Comments
 (0)