Validate dataset primary key identifiers#4
Open
bob-codedaptive wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
primaryKeyColumn/primary_key_column) was a raw string interpolated into backend CREATE TABLE DDL without being validated, enabling SQL identifier quote-breakout and statement injection.validateDatasetColumnIdentifier/validate_dataset_column_identifierwas already applied to columns and indexes but the primary-key field was omitted across Swift and Rust stores, leaving a high-impact SQL injection surface.Description
DatasetSchema.primaryKeyColumn/primary_key_columnbefore any backend/state access in Swift stores:PersistenceKitSQLite/SQLiteDatasetStore.swift,PersistenceKitPostgreSQL/PostgreSQLDatasetStore.swift, andPersistenceKitInMemory/InMemoryDatasetStore.swift.rust/src/sqlite.rs,rust/src/postgres.rs, andrust/src/dataset_store.rs(InMemory), so the PK name is checked prior to constructing/issuing DDL.DatasetStoreTests.swiftandrust/src/sqlite.rs).Testing
cargo test create_dataset_rejects_primary_key_column_with_double_quoteand the new Rust unit passed (ok).swift test --filter DatasetStoreTests/invalidIdentifier_primaryKeyColumn_sqlInjection_doubleQuotebut the run was blocked/failed due to a missing local package dependency (packages/libs/SubstrateTypes), so Swift-side tests could not be executed in this environment.Codex Task