跳到正文
DEV Community· Raylabs·· 3 小時前AI 評分38

防止生成文章洩露私人來源連結

Prevent Private Source Links in Generated Articles

AI 導讀

編輯發布流程須在模型生成前驗證來源清單,防止私人儲存庫資料進入公開文章。來源卡片如引用私人儲存庫或缺少合資格的公開 URL,流程應立即停止;中繼資料和生成文案亦須分別檢查。政策檢查失敗後應清理來源卡片並重新生成;dry-run 測試須確認被拒內容不會建立網站提交。

正文

Mixing internal engineering provenance with public documentation inside editorial source cards can leak sensitive repository data into public articles. Editorial workflows must enforce strict separation boundaries before generating copy or pushing site updates.

Quick solution:
Validate the source list against an allowlist filter before model generation, dropping private paths while retaining public links such as the OWASP Input Validation Cheat Sheet.

python3 scripts/validate_sources.py --input source_card.yml --allow-public-only

Prerequisites include maintaining a clean separation between private repository metadata and public-facing reference URLs. A common caution is that once a private link is written to output, automated deployment checks may reject the commit entirely.

Internal Provenance Versus Public Citation Sources

Internal provenance includes repository names, internal commit hashes, and private builder branches. Public citation sources consist of verifiable third-party URLs, documentation pages, and community standards. Pipelines must treat internal provenance as trusted operational context that never appears in generated public copy, whereas public citations must satisfy rigorous eligibility rules before generation begins.

Checking Source Eligibility Before Generation

Source eligibility should be checked at the ingestion boundary before any model generation takes place. If an input card references a private repository or lacks an eligible public URL, the pipeline must halt immediately. This prevents wasted model calls and ensures that authors or automated builders never process invalid references. You can learn more about securing output generation by reviewing how to Prevent Private Urls Leaking Static Site during the build phase.

Why Metadata and Prose Both Require Validation

Validating only the metadata or only the generated prose leaves the publishing system vulnerable. Metadata fields can contain hidden private paths, while generated prose can inadvertently hallucinate internal URLs. Both layers must undergo independent assertions to confirm that zero private repository references exist in the final article payload.

Revising Failed Articles Without Bypassing Quality Hashes

When an article fails policy checks, the builder must not bypass content-bound quality hashes to force a publish. Instead, the input source card must be sanitized to remove private provenance tokens. The generation job then runs again from a clean state, producing a fresh hash that satisfies both editorial and security requirements.

Proving Zero Site Commits on Rejection

Regression tests must verify that rejected content creates no site commit. By running dry-run test suites against blocked inputs, engineers can confirm that the publishing script halts before executing any Git write operations.

Verification Checklist

  • Run source validation scripts to strip private repository references from input cards.
  • Confirm that at least one valid public URL is present in the source card.
  • Execute dry-run promotion tests to verify that rejected content creates no site commit.
  • Inspect generated metadata and prose for any accidental provenance leaks.
  • Ensure content-bound quality hashes update correctly after any revision.

來源:DEV Community · dev.to