fix(migrations): reject temp schema objects - #2517
Conversation
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 08:46:27 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2517 +/- ##
=======================================
Coverage 95.95% 95.95%
=======================================
Files 226 226
Lines 25391 25427 +36
Branches 9234 9245 +11
=======================================
+ Hits 24363 24399 +36
Misses 417 417
Partials 611 611 🚀 New features to boost your workflow:
|
The temp-schema regex anchored table|index|view|trigger directly after `create`, so `CREATE UNIQUE INDEX temp.idx ...` slipped past the D1 remote-authorizer guard despite being rejected at deploy.
b902058 to
31f9495
Compare
…chema
cleanSql blanked the contents of double-quoted, backtick-quoted, and
bracket-quoted identifiers the same way it blanks string literals,
hiding a legitimate "temp".scratch (or `temp`.scratch, [temp].scratch)
reference from the D1_FORBIDDEN temp-schema scan. Also close the same
gap for SQLite's single-quote-as-identifier fallback ('temp'.scratch),
distinguishing it from an ordinary string value by checking whether the
closing quote is immediately followed by a schema-qualifying dot.
…qualified
The temp-schema pattern in D1_FORBIDDEN is deliberately unanchored, so
unconditionally preserving every quoted identifier's text let an
ordinary column/table name that merely spells out forbidden-looking
text (e.g. a column named "create temp note") leak into the scan and
false-positive. Unify all four quoting styles (', ", `, []) under one
rule: only preserve content when the closing quote is immediately
followed by a schema-qualifying dot; otherwise blank it like a value.
Motivation
CREATE TEMP/CREATE TEMPORARYforms and missed schema-qualified temporary objects likeCREATE TABLE temp.scratch, allowing D1-incompatible migrations to pass CI and fail at remote apply.Description
scripts/check-migrations.mjsto also match schema-qualified temp objects by adding a regex that catchesCREATE ... temp.fortable,index,view, andtriggerforms.test/unit/check-migrations-script.test.tsto coverCREATE TABLE temp.scratchand atempschema index, and expand the existing TEMP/TEMPORARY coverage into a parameterized test.Testing
npx vitest run test/unit/check-migrations-script.test.tsand observed all tests pass (11 passed).npm run db:migrations:checkand it reported the repository migrations OK (no new duplicates and next free number reported).npm run test:ci, butnpm run actionlintcould not complete due to network resolution issues togithub.comand the actionlint fallback reported unknown self-hosted runner labels in unchanged workflow files, so the full gate could not be completed locally.npm audit --audit-level=moderate, but the npm audit endpoint returned403 Forbidden, so that check could not be completed here.Codex Task