Skip to content

Free, open source blog writer for Claude Code. Researches current sources, writes answer-first posts for Google and AI answers, has an independent reviewer score each one out of 100 and ships only after five delivery gates. 32 skills, 30 /blog commands, 5 agents. Active development at AI-Marketing-Hub/claude-blog; public releases ship here.

fix(security): CI/Deps/Misc hardening + sync_flow blocking drift

Danielc72877a2d1b6
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 6927e6e..9b60c91 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,12 +1,31 @@
version: 2
updates:
- # Python dependencies
+ # Python dependencies (root pyproject.toml + requirements.txt)
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 5
+ # Nested skill venvs - audit VULN-504 (Dependabot was blind to these)
+ - package-ecosystem: "pip"
+ directory: "/skills/blog-google/scripts"
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 3
+
+ - package-ecosystem: "pip"
+ directory: "/skills/blog-notebooklm/scripts"
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 3
+
+ - package-ecosystem: "pip"
+ directory: "/skills/blog-audio/scripts"
+ schedule:
+ interval: "weekly"
+ open-pull-requests-limit: 3
+
# GitHub Actions versions
- package-ecosystem: "github-actions"
directory: "/"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4667e41..2596186 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,6 +6,15 @@ on:
pull_request:
branches: [main, master]
+# Least-privilege token (closes audit VULN-501). Override per-job if needed.
+permissions:
+ contents: read
+
+# Cancel superseded runs on the same ref to save runner minutes.
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
test:
runs-on: ubuntu-latest
@@ -22,9 +31,12 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
+ # Use the dev extras group so PR builds resolve identically to local
+ # development. The pyproject.toml `dev` group pins pytest, textstat,
+ # and beautifulsoup4 within bounded ranges (closes audit VULN-502).
run: |
python -m pip install --upgrade pip
- pip install pytest textstat beautifulsoup4
+ pip install -e ".[dev]"
- name: Run tests
run: python -m pytest tests/ -v
diff --git a/README.md b/README.md
index 768afc4..f01fdc8 100644
--- a/README.md
+++ b/README.md
@@ -47,20 +47,27 @@ claude-blog is a Claude Code skill ecosystem for creating, optimizing, and manag
/plugin install claude-blog@AgriciDaniel-claude-blog
```
-**One-command install (Unix/macOS):**
+**Recommended: clone then verify before installing** (lets you inspect
+install.sh and pin a release tag — closes audit VULN-005):
```bash
-curl -fsSL https://raw.githubusercontent.com/AgriciDaniel/claude-blog/main/install.sh | bash
+git clone https://github.com/AgriciDaniel/claude-blog.git
+cd claude-blog
+git checkout v1.7.0 # pin to a release tag
+chmod +x install.sh && ./install.sh
```
-**Or clone and install manually:**
+**Convenience one-command install (Unix/macOS, only if you trust the
+upstream `AgriciDaniel/claude-blog` GitHub account):**
```bash
-git clone https://github.com/AgriciDaniel/claude-blog.git
-cd claude-blog
-chmod +x install.sh && ./install.sh
+curl -fsSL https://raw.githubusercontent.com/AgriciDaniel/claude-blog/main/install.sh | bash
```
+> Note: piping curl to bash gives the script execution authority on your
+> machine. The clone-then-checkout-tag flow above is safer because you
+> can inspect what runs.
+
**Windows (PowerShell):**
```powershell
.\install.ps1
diff --git a/install.ps1 b/install.ps1
index 4a1206d..1883f3b 100644
--- a/install.ps1
+++ b/install.ps1
@@ -117,20 +117,25 @@ function Main {
Write-Color White "Installing scripts..."
Copy-Item (Join-Path $ScriptDir "scripts" "analyze_blog.py") (Join-Path $SkillDir "blog" "scripts" "analyze_blog.py") -Force
- # Install Python dependencies
+ # Install Python dependencies (closes audit VULN-507/804: capture stderr
+ # to a logfile instead of swallowing it).
Write-Color White "Installing Python dependencies..."
$reqFile = Join-Path $ScriptDir "requirements.txt"
if (Test-Path $reqFile) {
- try {
- & python3 -m pip install --quiet -r $reqFile 2>$null
- Write-Color Green " Python dependencies installed."
- } catch {
- try {
- & python -m pip install --quiet -r $reqFile 2>$null
+ $pipLog = Join-Path ([System.IO.Path]::GetTempPath()) "claude-blog-pip-$([System.Guid]::NewGuid().ToString('N').Substring(0,8)).log"
+ $pipCmd = (Get-Command python3 -ErrorAction SilentlyContinue) ?? (Get-Command python -ErrorAction SilentlyContinue)
+ if ($pipCmd) {
+ $proc = Start-Process -FilePath $pipCmd.Source -ArgumentList @("-m","pip","install","--quiet","-r",$reqFile) -RedirectStandardError $pipLog -NoNewWindow -Wait -PassThru
+ if ($proc.ExitCode -eq 0) {
Write-Color Green " Python dependencies installed."
- } catch {
- Write-Color Yellow " Skipped: Install manually with 'pip install -r requirements.txt'"
+ Remove-Item -Force $pipLog -ErrorAction SilentlyContinue
+ } else {
+ Write-Color Yellow " WARNING: pip install failed (exit $($proc.ExitCode))."
+ Write-Color Yellow " See log: $pipLog"
+ Write-Color Yellow " Manual install: pip install -r requirements.txt"
}
+ } else {
+ Write-Color Yellow " Skipped: Python not found. Manual install: pip install -r requirements.txt"
}
}
diff --git a/install.sh b/install.sh
index a088c35..85a864e 100755
--- a/install.sh
+++ b/install.sh
@@ -104,11 +104,20 @@ main() {
cp "${SCRIPT_DIR}/scripts/analyze_blog.py" "${SKILL_DIR}/blog/scripts/analyze_blog.py"
chmod +x "${SKILL_DIR}/blog/scripts/analyze_blog.py"
- # Install Python dependencies
+ # Install Python dependencies (closes audit VULN-507/804: capture stderr
+ # to a logfile instead of swallowing it. Operator can diagnose failures.)
if [ -f "${SCRIPT_DIR}/requirements.txt" ] && command -v pip3 &>/dev/null; then
echo "→ Installing Python dependencies..."
- pip3 install --quiet -r "${SCRIPT_DIR}/requirements.txt" 2>/dev/null || \
- echo " Skipped: Install manually with 'pip3 install -r requirements.txt'"
+ local pip_log
+ pip_log="$(mktemp -t claude-blog-pip-XXXXXX.log)"
+ if pip3 install --quiet -r "${SCRIPT_DIR}/requirements.txt" 2>"${pip_log}"; then
+ rm -f "${pip_log}"
+ else
+ echo " WARNING: pip install failed."
+ echo " See log: ${pip_log}"
+ echo " First error: $(head -n1 "${pip_log}" 2>/dev/null || echo '(empty)')"
+ echo " Manual install: pip3 install -r requirements.txt"
+ fi
echo " Tip: Consider using a virtual environment: python3 -m venv .venv && source .venv/bin/activate"
fi
diff --git a/pyproject.toml b/pyproject.toml
index 25a7531..54f3e36 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,29 +11,38 @@ authors = [
[project.optional-dependencies]
core = [
- "textstat>=0.7.3",
- "beautifulsoup4>=4.12.0",
+ # Bounded ranges align with requirements.txt to ensure both install paths
+ # resolve to compatible majors (closes audit VULN-407 mismatch).
+ "textstat>=0.7.3,<1.0.0",
+ "beautifulsoup4>=4.12.0,<5.0.0",
]
advanced = [
- "lxml",
- "jsonschema",
- "spacy",
- "sentence-transformers",
- "scikit-learn",
- "language-tool-python",
+ # Closes audit VULN-406. All entries previously unbounded.
+ "lxml>=5.0.0,<7.0.0",
+ "jsonschema>=4.20.0,<5.0.0",
+ "spacy>=3.7.0,<4.0.0",
+ "sentence-transformers>=2.5.0,<5.0.0",
+ "scikit-learn>=1.4.0,<2.0.0",
+ "language-tool-python>=2.7.1,<3.0.0",
]
google = [
- "requests>=2.32.4",
- "google-api-python-client>=2.100.0",
- "google-auth>=2.20.0",
- "google-auth-oauthlib>=1.0.0",
- "google-auth-httplib2>=0.2.0",
- "google-analytics-data>=0.18.0",
+ "requests>=2.32.4,<3.0.0",
+ "google-api-python-client>=2.100.0,<3.0.0",
+ "google-auth>=2.20.0,<3.0.0",
+ "google-auth-oauthlib>=1.0.0,<2.0.0",
+ "google-auth-httplib2>=0.2.0,<1.0.0",
+ "google-analytics-data>=0.18.0,<1.0.0",
+]
+ads = [
+ # Optional: enables skills/blog-google/scripts/keyword_planner.py.
+ # Closes audit VULN-404 phantom-import (was previously imported with no
+ # manifest declaration).
+ "google-ads>=22.0.0,<26.0.0",
]
dev = [
- "pytest>=8.0",
- "textstat>=0.7.3",
- "beautifulsoup4>=4.12.0",
+ "pytest>=8.0,<9.0",
+ "textstat>=0.7.3,<1.0.0",
+ "beautifulsoup4>=4.12.0,<5.0.0",
]
[tool.pytest.ini_options]
diff --git a/scripts/sync_flow.py b/scripts/sync_flow.py
index 7316a1c..a2e2c96 100644
--- a/scripts/sync_flow.py
+++ b/scripts/sync_flow.py
@@ -85,6 +85,13 @@ def parse_args():
metavar="SHA",
help="Pin fetches to a FLOW commit SHA.",
)
+ parser.add_argument(
+ "--allow-drift",
+ action="store_true",
+ help="Permit lockfile drift (default: refuse to write when synced "
+ "content hashes do not match flow-prompts.lock). Required when bumping "
+ "the FLOW reference; review the diff carefully before passing this flag.",
+ )
return parser.parse_args()
@@ -321,11 +328,19 @@ def sync(args):
changes = {"added": [], "updated": [], "unchanged": [], "hashes": {}}
prompt_rows = []
+ # Phase 1: fetch and stage all content in memory. Compute would-be hashes
+ # without writing, so the drift check can fire BEFORE any filesystem
+ # mutation (audit VULN-018).
+ pending = [] # list of (target_path, content) tuples
+
for source, target in STATIC_FILES:
print(f"fetch: {source}", file=sys.stderr)
raw = fetch_file(source, args.ref, headers)
content = inject_license_header(raw, today)
- record_write(root, refs, refs / target, content, args.dry_run, changes)
+ target_path = refs / target
+ pending.append((target_path, content))
+ rel = target_path.relative_to(root).as_posix()
+ changes["hashes"][rel] = _sha256(content)
for stage in PROMPT_STAGES:
source_dir = f"docs/09-prompts/{stage}"
@@ -334,32 +349,21 @@ def sync(args):
print(f"fetch: {source}", file=sys.stderr)
raw = fetch_file(source, args.ref, headers)
prompt_rows.append(prompt_meta(stage, filename, raw))
- target = refs / "prompts" / stage / filename
+ target_path = refs / "prompts" / stage / filename
content = inject_license_header(raw, today)
- record_write(root, refs, target, content, args.dry_run, changes)
-
- record_write(
- root,
- refs,
- refs / "prompts" / "README.md",
- inject_license_header(prompt_readme(prompt_rows), today),
- args.dry_run,
- changes,
- )
+ pending.append((target_path, content))
+ rel = target_path.relative_to(root).as_posix()
+ changes["hashes"][rel] = _sha256(content)
- # Generate SHA-256 lockfile.
- lock_path = root / LOCK_REL
- lock_lines = [
- "# flow-prompts.lock. SHA-256 baseline for synced FLOW prompts.",
- f"# Ref: {args.ref or 'HEAD'} | format: <sha256hex> <rel_path> "
- "(sha256sum-compatible)",
- "",
- ]
- for rel in sorted(changes["hashes"]):
- lock_lines.append(f"{changes['hashes'][rel]} {rel}")
- lock_content = "\n".join(lock_lines) + "\n"
+ readme_path = refs / "prompts" / "README.md"
+ readme_content = inject_license_header(prompt_readme(prompt_rows), today)
+ pending.append((readme_path, readme_content))
+ readme_rel = readme_path.relative_to(root).as_posix()
+ changes["hashes"][readme_rel] = _sha256(readme_content)
- # Diff against existing lockfile and print drift report.
+ # Phase 2: compute lockfile drift against the staged hashes (pre-write).
+ lock_path = root / LOCK_REL
+ drift_lines = []
if lock_path.exists():
old_lock = lock_path.read_text(encoding="utf-8")
old_hashes = {}
@@ -368,25 +372,73 @@ def sync(args):
parts = line.split(" ", 1)
if len(parts) == 2:
old_hashes[parts[1]] = parts[0]
- drift = []
for rel, sha in sorted(changes["hashes"].items()):
old_sha = old_hashes.get(rel)
if old_sha is None:
- drift.append(f" ADDED {rel}")
+ drift_lines.append(f"ADDED {rel}")
elif old_sha != sha:
- drift.append(f" CHANGED {rel}")
+ drift_lines.append(f"CHANGED {rel}")
for rel in sorted(old_hashes):
if rel not in changes["hashes"]:
- drift.append(f" REMOVED {rel}")
- if drift:
- print("Lockfile drift detected:", file=sys.stderr)
- for line in drift:
- print(line, file=sys.stderr)
- else:
- print(
- "Lockfile: no drift (all hashes match baseline)",
- file=sys.stderr,
- )
+ drift_lines.append(f"REMOVED {rel}")
+
+ # Phase 3: enforce drift policy BEFORE any writes happen.
+ if drift_lines and not args.dry_run and not args.allow_drift:
+ print(
+ "ERROR: Lockfile drift detected. The synced content hashes do not "
+ "match flow-prompts.lock.",
+ file=sys.stderr,
+ )
+ print(
+ "Review the upstream changes carefully before bumping the lockfile.",
+ file=sys.stderr,
+ )
+ print(
+ "If the changes are legitimate, re-run with --allow-drift.",
+ file=sys.stderr,
+ )
+ print("Drift report:", file=sys.stderr)
+ for line in drift_lines:
+ print(f" {line}", file=sys.stderr)
+ sys.exit(2)
+ elif drift_lines and args.allow_drift:
+ print(
+ "NOTE: Lockfile drift detected. Proceeding because --allow-drift "
+ "was explicitly passed.",
+ file=sys.stderr,
+ )
+ for line in drift_lines:
+ print(f" {line}", file=sys.stderr)
+ elif drift_lines and args.dry_run:
+ print(
+ "DRY-RUN: Lockfile drift detected (informational, no exit):",
+ file=sys.stderr,
+ )
+ for line in drift_lines:
+ print(f" {line}", file=sys.stderr)
+ elif lock_path.exists():
+ print(
+ "Lockfile: no drift (all hashes match baseline)",
+ file=sys.stderr,
+ )
+
+ # Phase 4: write all staged content to disk. The hash for each file was
+ # already recorded in Phase 1, so we drop record_write's hash-recording
+ # side effect by passing a throwaway dict for the hashes slot. We keep the
+ # added/updated/unchanged bookkeeping by reusing `changes`.
+ for target_path, content in pending:
+ record_write(root, refs, target_path, content, args.dry_run, changes)
+
+ # Phase 5: build and write the lockfile from the now-finalized hashes.
+ lock_lines = [
+ "# flow-prompts.lock. SHA-256 baseline for synced FLOW prompts.",
+ f"# Ref: {args.ref or 'HEAD'} | format: <sha256hex> <rel_path> "
+ "(sha256sum-compatible)",
+ "",
+ ]
+ for rel in sorted(changes["hashes"]):
+ lock_lines.append(f"{changes['hashes'][rel]} {rel}")
+ lock_content = "\n".join(lock_lines) + "\n"
# Write lockfile (excluded from its own hashes tracking).
record_write(root, refs, lock_path, lock_content, args.dry_run, changes)
diff --git a/skills/blog-google/scripts/google_report.py b/skills/blog-google/scripts/google_report.py
index d33fda1..79df5c6 100644
--- a/skills/blog-google/scripts/google_report.py
+++ b/skills/blog-google/scripts/google_report.py
@@ -703,18 +703,32 @@ def generate_report(report_type, data, domain, output_dir, output_format="pdf"):
body = "\n".join(sections)
html_content = f"""<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><style>{css}</style></head><body>{body}</body></html>"""
- # Output
- safe_domain = domain.replace(":", "_").replace("/", "_")
+ # Output (closes audit VULN-014 path traversal on --domain)
+ # Whitelist: alphanumerics + dot + underscore + hyphen. Anything else
+ # (incl. "..", "/", "\\", NUL, Windows drive letters) becomes "_".
+ import re
+ safe_domain = re.sub(r"[^A-Za-z0-9._-]", "_", domain)[:128] or "report"
base_name = f"Google-SEO-Report-{safe_domain}-{report_type}"
+ # Re-resolve and assert containment inside output_dir (defense in depth).
+ out_root = Path(output_dir).resolve()
+
+ def _safe_path(name: str) -> Path:
+ candidate = (out_root / name).resolve()
+ if out_root != candidate.parent and out_root not in candidate.parents:
+ raise ValueError(
+ f"Refusing to write outside output_dir: {candidate}"
+ )
+ return candidate
+
if output_format in ("html", "both"):
- html_path = output_dir / f"{base_name}.html"
+ html_path = _safe_path(f"{base_name}.html")
with open(html_path, "w") as f:
f.write(html_content)
result["files"].append(str(html_path))
if output_format in ("pdf", "both"):
- pdf_path = output_dir / f"{base_name}.pdf"
+ pdf_path = _safe_path(f"{base_name}.pdf")
try:
HTML(string=html_content).write_pdf(str(pdf_path))
result["files"].append(str(pdf_path))
diff --git a/skills/blog-google/scripts/keyword_planner.py b/skills/blog-google/scripts/keyword_planner.py
index fb25c5f..e834c27 100644
--- a/skills/blog-google/scripts/keyword_planner.py
+++ b/skills/blog-google/scripts/keyword_planner.py
@@ -28,6 +28,7 @@ Note: Accounts without active ad spend receive bucketed volume ranges
import argparse
import json
+import os
import sys
from typing import Optional
@@ -41,7 +42,6 @@ except ImportError:
try:
from google_auth import load_config
except ImportError:
- import os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from google_auth import load_config
@@ -50,7 +50,8 @@ def _build_ads_client() -> Optional[object]:
"""Build Google Ads client from config."""
if not HAS_GOOGLE_ADS:
print(
- "Error: google-ads library required. Install with: pip install google-ads",
+ "Error: google-ads library required. Install with: "
+ "pip install 'claude-blog[ads]' (or pip install google-ads).",
file=sys.stderr,
)
return None