Skip to content

fix: prevent SQL injection in DatabaseDrop (Issue #12)#24

Open
bully-goose wants to merge 5 commits into
mainfrom
security-week1-database-drop
Open

fix: prevent SQL injection in DatabaseDrop (Issue #12)#24
bully-goose wants to merge 5 commits into
mainfrom
security-week1-database-drop

Conversation

@bully-goose

Copy link
Copy Markdown
Collaborator

Implements SQL injection protection for DatabaseDrop command as per Week 1 security plan.

  • Validates database name using .
  • Replaces raw string interpolation with parameterized query () for existence check.
  • Adds security test suite covering SQL injection attempts.

Depends on #22 (validators module).

- Add Validators module with valid_identifier? and sanitize_identifier
- Protect against SQL injection via identifier validation
- Enforce PostgreSQL naming constraints (63 char max, alphanumeric+underscore)
- Add comprehensive test coverage for edge cases
- Move InvalidIdentifierError and InvalidFilePathError into Pgchief::Errors
- Update Validators module to raise Errors::InvalidIdentifierError and Errors::InvalidFilePathError
- Update spec to reference new namespace
- Add identifier validation using Pgchief::Validators.sanitize_identifier
- Use parameterized query (exec_params) for database existence check
- Add security tests for SQL injection attempts
@bully-goose bully-goose force-pushed the security-week1-database-drop branch from f775844 to 1692809 Compare February 9, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants