A comprehensive guide for code review, vulnerability detection, and identifying code weaknesses.
- Cryptography and authentication
- Injections and data validation
- Replay, CSRF, XSS attacks
- Data and secret leaks
- Practical examples
2. Performance
- Finding bottlenecks
- Inefficient allocations
- Duplicate operations
- Algorithm optimization
- Profiling
3. Code Quality
- Code duplication (DRY)
- Readability and maintainability
- Error handling
- Testing
- Documentation
4. Architecture
- Single Responsibility Principle
- Modularity
- Dependencies
- Reusability
- Scalability
- Memory safety
- Ownership and borrowing
- Panic vs Result
- Zero-cost abstractions
- Unsafe code
- Project examples
- Before/After refactoring
- Measurable improvements
- Understand the overall structure of changes
- Read commit message and PR description
- Assess the scope of changes
- Vulnerability search (see security-vulnerabilities.md)
- Input data validation check
- Cryptography and authentication analysis
- Secret leak check
- Does the logic work correctly?
- All edge cases handled
- Proper error handling
- Tests cover functionality
- Finding inefficient operations
- Unnecessary allocations
- Duplicate work
- Algorithmic complexity
- Readability
- Duplication
- Naming
- Documentation
- SOLID principles compliance
- Modularity
- Reusability
- Tech debt
- Security vulnerabilities
- Secret leaks (passwords, tokens, keys)
- Panic in production code
- Improper error handling
- Missing tests for critical logic
- Inefficient operations (O(n^2) instead of O(n))
- Code duplication (>3 repetitions)
- Missing input data validation
- Magic numbers and magic strings
- Undocumented public API
- Refactoring for readability
- Additional tests
- Documentation improvement
- Performance optimization
- Clippy - static analyzer for Rust
- cargo audit - dependency vulnerability check
- cargo deny - license and security check
- cargo tarpaulin - test coverage
- cargo bench - performance benchmarks
- git diff - viewing changes
- ripgrep (rg) - code pattern search
- tokei - code statistics
- cargo tree - dependency tree
- Security
- Correctness
- Critical bugs
- Performance (if issues exist)
- Code quality
- Testing
- Code style (if autoformatter exists)
- Minor refactoring
- Documentation (if not public API)
- Be specific: "SQL injection possible on line 42" instead of "Security issues"
- Suggest solutions: Not just "This is slow", but "Can use HashMap instead of Vec::find"
- Explain why: "This will lead to replay attack because..."
- Use metrics: "This will increase allocations by 40%"
- Be positive: Note good solutions too
Study each section in detail:
- Start with security-vulnerabilities.md - this is most important
- Then performance-issues.md - for production-ready code
- Study rust-specific.md - language specifics
- Practice on examples.md - real cases