[PR #45] feat: warn on dangerous commands #230

Open
opened 2026-02-15 17:16:23 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/openclaw/clawhub/pull/45
Author: @regenrek
Created: 1/26/2026
Status: 🔄 Open

Base: mainHead: feat/skill-command-warnings


📝 Commits (3)

  • 90bf24c feat: add skill file viewer
  • c3e2392 feat: warn on dangerous commands
  • d6ee919 fix: prevent file viewer state updates after unmount

📊 Changes

6 files changed (+651 additions, -329 deletions)

View changed files

src/components/SkillCommentsPanel.tsx (+77 -0)
📝 src/components/SkillDetailPage.tsx (+25 -329)
src/components/SkillDetailTabs.tsx (+115 -0)
src/components/SkillFilesPanel.tsx (+216 -0)
src/components/skillDetailUtils.ts (+148 -0)
📝 src/styles.css (+70 -0)

📄 Description

summary

  • Highlight dangerous commands and show warnings in file viewer.

motivation

  • Make risky install commands visible at a glance.

what's included

  • Detection of curl, wget, bash, sh, eval.
  • Warning banner and inline highlights.

what's not included

  • Viewer layout and file selection (in PR3).
  • Backend changes.

tests

  • bun run test
  • bun run lint

affected files

  • src/components/SkillFilesPanel.tsx
  • src/styles.css

prompt

# ClawdHub Security Hardening

## Goal & Success Criteria

- Block download inflation: rate limit + per‑IP/day dedupe on ZIP downloads.
- IP spoofing fixed: trust only cf-connecting-ip.
- Files tab shows full file viewer + warnings for dangerous commands.
- Each PR has Conventional Commits, full test suite runs, PR opened from regenrek fork.

## Non‑goals / Out of Scope

- Replace download stats with installs.
- Auth‑gated downloads or paid access.
- Deep static analysis beyond warning heuristics.

## Assumptions

- Rate limits: new “download” tier tighter than “read”.
- IP trust: CF‑only, no fallback.
- PRs live on regenrek fork, not upstream.

## Proposed Solution

- Single canonical rate‑limit/IP module (Convex best‑practice: no duplicated logic).
- Dedupe table keyed by hashed IP + skill + day bucket; increment only once.
- UI file viewer loads via existing getFileText; warnings from regex scan.

### Alternatives Considered

- Reuse “read” limits in convex/httpApiV1.ts:634 — too permissive.
- Fallback to x-forwarded-for — violates CF‑only requirement.
- Store raw IPs — privacy risk.

## System Design

- Increment flow: new mutation recordDownload handles dedupe + stats increment atomically.
- Cleanup: cron job prunes dedupe rows older than N days.
- UI: SkillDetailPage Files tab extracted to SkillFilesPanel with viewer + warnings.

## Interfaces & Data Contracts

- recordDownload mutation args: { skillId: Id<'skills'>, ipHash?: string, dayStart: number }.
- downloadDedupes schema: { skillId, ipHash, dayStart, createdAt }.
- Rate limit config includes download: { ip, key } in shared helper.

## Execution Details

PR 4 — Command Warnings (feat)

- Add warning detection for curl|wget|bash|sh|eval + external URLs.
- Highlight matches in viewer; show warning banner and summary list.

## Testing & Quality

- Full suite per PR: bun run test and bun run lint.
- Add unit tests for dedupe/rate limit in convex/downloads.test.ts.
- Extend handler tests to cover CF‑only IP logic.

## Risks & Mitigations

- Missing CF header → “unknown” key. Mitigate by documenting requirement.
- Dedupe table growth → cron pruning.
- Viewer perf → relies on existing 200KB cap.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/openclaw/clawhub/pull/45 **Author:** [@regenrek](https://github.com/regenrek) **Created:** 1/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/skill-command-warnings` --- ### 📝 Commits (3) - [`90bf24c`](https://github.com/openclaw/clawhub/commit/90bf24c5ef0888f636decb1b100e7fee5aacf727) feat: add skill file viewer - [`c3e2392`](https://github.com/openclaw/clawhub/commit/c3e2392b5d833d70cb896f4f7590bc921b9100e9) feat: warn on dangerous commands - [`d6ee919`](https://github.com/openclaw/clawhub/commit/d6ee9192454aa9c7506e3c032fe019ae9740c7c9) fix: prevent file viewer state updates after unmount ### 📊 Changes **6 files changed** (+651 additions, -329 deletions) <details> <summary>View changed files</summary> ➕ `src/components/SkillCommentsPanel.tsx` (+77 -0) 📝 `src/components/SkillDetailPage.tsx` (+25 -329) ➕ `src/components/SkillDetailTabs.tsx` (+115 -0) ➕ `src/components/SkillFilesPanel.tsx` (+216 -0) ➕ `src/components/skillDetailUtils.ts` (+148 -0) 📝 `src/styles.css` (+70 -0) </details> ### 📄 Description ### summary - Highlight dangerous commands and show warnings in file viewer. ### motivation - Make risky install commands visible at a glance. ### what's included - Detection of `curl`, `wget`, `bash`, `sh`, `eval`. - Warning banner and inline highlights. ### what's not included - Viewer layout and file selection (in PR3). - Backend changes. ### tests - `bun run test` - `bun run lint` ### affected files - `src/components/SkillFilesPanel.tsx` - `src/styles.css` ### prompt ``` # ClawdHub Security Hardening ## Goal & Success Criteria - Block download inflation: rate limit + per‑IP/day dedupe on ZIP downloads. - IP spoofing fixed: trust only cf-connecting-ip. - Files tab shows full file viewer + warnings for dangerous commands. - Each PR has Conventional Commits, full test suite runs, PR opened from regenrek fork. ## Non‑goals / Out of Scope - Replace download stats with installs. - Auth‑gated downloads or paid access. - Deep static analysis beyond warning heuristics. ## Assumptions - Rate limits: new “download” tier tighter than “read”. - IP trust: CF‑only, no fallback. - PRs live on regenrek fork, not upstream. ## Proposed Solution - Single canonical rate‑limit/IP module (Convex best‑practice: no duplicated logic). - Dedupe table keyed by hashed IP + skill + day bucket; increment only once. - UI file viewer loads via existing getFileText; warnings from regex scan. ### Alternatives Considered - Reuse “read” limits in convex/httpApiV1.ts:634 — too permissive. - Fallback to x-forwarded-for — violates CF‑only requirement. - Store raw IPs — privacy risk. ## System Design - Increment flow: new mutation recordDownload handles dedupe + stats increment atomically. - Cleanup: cron job prunes dedupe rows older than N days. - UI: SkillDetailPage Files tab extracted to SkillFilesPanel with viewer + warnings. ## Interfaces & Data Contracts - recordDownload mutation args: { skillId: Id<'skills'>, ipHash?: string, dayStart: number }. - downloadDedupes schema: { skillId, ipHash, dayStart, createdAt }. - Rate limit config includes download: { ip, key } in shared helper. ## Execution Details PR 4 — Command Warnings (feat) - Add warning detection for curl|wget|bash|sh|eval + external URLs. - Highlight matches in viewer; show warning banner and summary list. ## Testing & Quality - Full suite per PR: bun run test and bun run lint. - Add unit tests for dedupe/rate limit in convex/downloads.test.ts. - Extend handler tests to cover CF‑only IP logic. ## Risks & Mitigations - Missing CF header → “unknown” key. Mitigate by documenting requirement. - Dedupe table growth → cron pruning. - Viewer perf → relies on existing 200KB cap. ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 17:16:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: openclaw/clawhub#230