-
Notifications
You must be signed in to change notification settings - Fork 10
refactor: Create patterns package for pattern detection (PR #6) #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
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
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #377 +/- ##
==========================================
- Coverage 79.74% 79.71% -0.04%
==========================================
Files 86 89 +3
Lines 6938 6971 +33
==========================================
+ Hits 5533 5557 +24
- Misses 1175 1183 +8
- Partials 230 231 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
shivasurya
added a commit
that referenced
this pull request
Nov 15, 2025
Addresses coverage gaps in PR #377 by adding extensive test suites: New Test Files: - patterns/frameworks_test.go (12 test functions, 40+ test cases) - DetectFramework tests for Django, Flask, FastAPI, etc. - IsKnownFramework tests for 13 different frameworks - GetFrameworkCategory and GetFrameworkName tests - Edge cases: nil ImportMap, empty map, multiple frameworks - patterns/helpers_test.go (6 test functions) - readFileBytes tests with temp files - findFunctionAtLine tests with tree-sitter AST - Nested function detection - Error handling tests Bug Fixes: - Fixed DetectFramework to iterate over FQNs (values) not aliases (keys) - Removed unused core import from patterns.go - Fixed unconvert lint error in MatchPattern function Coverage Improvements: - patterns/frameworks.go: 0% → 100% - patterns/helpers.go: 75% → 100% - patterns/detector.go: 81.22% (no change, already tested) - **Overall package coverage: 85.0%** (up from 77.8%) All Tests Pass: ✅ 41 tests in patterns package ✅ All callgraph tests pass ✅ gradle lintGo - 0 issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Nov 15, 2025
Owner
Author
This was referenced Nov 15, 2025
Owner
Author
Merge activity
|
Moved pattern detection logic to dedicated patterns package: Files Created: - patterns/detector.go (475 LOC) - Pattern matching & vulnerability detection - patterns/frameworks.go (52 LOC) - Framework detection helpers - patterns/helpers.go (34 LOC) - Helper functions for AST traversal - patterns/doc.go (32 LOC) - Package documentation - patterns/detector_test.go (moved from patterns_test.go) Files Modified: - patterns.go - Backward compatibility wrappers with type aliases Key Features: - PatternRegistry for managing security patterns - Support for 3 pattern types: SourceSink, MissingSanitizer, DangerousFunction - Framework detection (Django, Flask, FastAPI, etc.) - Intra-procedural taint analysis integration - Full backward compatibility maintained Test Coverage: 77.8% All 15 tests pass successfully Dependencies: - Imports from core/, extraction/, analysis/taint/ - Uses core.CallGraph for pattern matching - Integrates with taint analysis for vulnerability detection 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Addresses coverage gaps in PR #377 by adding extensive test suites: New Test Files: - patterns/frameworks_test.go (12 test functions, 40+ test cases) - DetectFramework tests for Django, Flask, FastAPI, etc. - IsKnownFramework tests for 13 different frameworks - GetFrameworkCategory and GetFrameworkName tests - Edge cases: nil ImportMap, empty map, multiple frameworks - patterns/helpers_test.go (6 test functions) - readFileBytes tests with temp files - findFunctionAtLine tests with tree-sitter AST - Nested function detection - Error handling tests Bug Fixes: - Fixed DetectFramework to iterate over FQNs (values) not aliases (keys) - Removed unused core import from patterns.go - Fixed unconvert lint error in MatchPattern function Coverage Improvements: - patterns/frameworks.go: 0% → 100% - patterns/helpers.go: 75% → 100% - patterns/detector.go: 81.22% (no change, already tested) - **Overall package coverage: 85.0%** (up from 77.8%) All Tests Pass: ✅ 41 tests in patterns package ✅ All callgraph tests pass ✅ gradle lintGo - 0 issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
06d6aa9 to
6f06e94
Compare
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.

Summary
Creates dedicated
patternspackage for security pattern detection and framework identification. This PR isolates pattern matching logic into a clean, testable package structure.Changes
New Package Structure
Files Modified
patterns.go- Backward compatibility wrappers with type aliasesKey Features
Pattern Matching
Framework Detection
Test Coverage
patterns_test.gotopatterns/detector_test.goBuild Verification
✅ gradle buildGo - SUCCESS ✅ go test ./graph/callgraph/... - ALL PASS ✅ All existing tests pass - NO BREAKING CHANGESDependencies
core/,extraction/,analysis/taint/core.CallGraphfor pattern matchingGraphite Stack
Related PRs
🤖 Generated with Claude Code