Skip to content

Conversation

@elitan
Copy link
Owner

@elitan elitan commented Jul 11, 2025

Summary

This PR implements a security-first dual function approach to address the timing information leakage concern:

  • nanoid() - Secure, purely random IDs (recommended default)
  • nanoid_sortable() - Time-ordered IDs (use only when sorting is essential)

Key Changes

  • Security improvement: Regular nanoid() no longer embeds timestamps
  • Clear guidance: README emphasizes security-first approach with warnings
  • Backward compatibility: Sortable functionality preserved in nanoid_sortable()
  • Comprehensive testing: Updated test suite for both functions
  • CI/CD: GitHub Actions workflow for automated testing

Security Benefits

  • Privacy protection: Random nanoids don't leak business activity patterns
  • Informed choice: Developers must explicitly choose sortable version
  • Clear warnings: Documentation highlights privacy trade-offs

Test Coverage

  • Basic functionality tests for both functions
  • Security characteristic verification
  • Performance benchmarks
  • Parameter validation
  • Large-scale uniqueness testing

Test plan

  • Both functions generate unique IDs
  • Regular nanoids are truly random (no time ordering)
  • Sortable nanoids maintain lexicographic time ordering
  • Timestamp extraction works only with sortable nanoids
  • Error handling works for both functions
  • Performance benchmarks show expected results
  • GitHub Actions CI passes all tests

🤖 Generated with Claude Code

elitan and others added 5 commits July 11, 2025 10:46
- Add nanoid() function for secure random IDs (recommended default)
- Add nanoid_sortable() function for time-ordered IDs (use carefully)
- Update README with security warnings and recommendations
- Update all test files for dual-function approach
- Add comprehensive dual_function_test.sql test suite
- Update init script for clean database setup
- Recommend secure nanoid() by default with clear privacy guidance

Security improvement: Regular nanoid() no longer leaks timing information.
Only use nanoid_sortable() when temporal ordering is essential.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Test both nanoid() and nanoid_sortable() functions
- Verify security characteristics (random vs time-ordered)
- Run comprehensive test suite on PostgreSQL 15
- Performance benchmarks and batch testing
- Function availability and parameter validation

Ensures all tests pass before merging changes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Updated workflow to only run on main branch since develop branch doesn't exist.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fixed aggregate function error by separating window function calls
into separate CTEs before aggregating results.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Replace \timing commands with status messages
- psql meta-commands don't work in non-interactive mode via -c flag
- Performance test now executes without syntax errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@elitan elitan merged commit 6fa7db9 into main Jul 11, 2025
1 check passed
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