feat: Implement architectural improvements (Items 7-10)#53
Open
feat: Implement architectural improvements (Items 7-10)#53
Conversation
## Item 7: Path Validation - Add path_validation.py with PathValidator class - TOCTOU-safe file reading via _safe_read_sql_file() - Symlink protection with opt-in allow_symlinks parameter - Windows reserved name detection - Unicode normalization for homoglyph attack prevention - 100% test coverage (71 tests) ## Item 10: Prompt Injection Mitigation - Add prompt_sanitization.py with 4-layer defense - Input sanitization with tag escaping (not removal) - Unicode NFKC normalization for Cyrillic bypass prevention - Output validation with semantic relevance checking - sqlglot-based SQL validation for destructive operations - Environment variable CLGRAPH_DISABLE_PROMPT_SANITIZATION for debugging - 95% test coverage (100 tests) ## Item 9: File Splitting - Extract lineage_utils.py from lineage_builder.py (~592 lines) - Extract sql_column_tracer.py from lineage_builder.py (~296 lines) - Extract tvf_registry.py from query_parser.py (~72 lines) - Maintain backward compatibility via re-exports ## Item 8: Pipeline Decomposition - Extract LineageTracer component (~400 lines) - Extract MetadataManager component (~185 lines) - Extract PipelineValidator component (~169 lines) - Extract SubpipelineBuilder component (~183 lines) - Pipeline now uses facade pattern with lazy initialization - All 1,052 existing tests pass without modification File size reductions: - pipeline.py: 2,795 → 2,426 lines - lineage_builder.py: 3,419 → 2,666 lines - query_parser.py: 2,354 → 2,313 lines
a1b2e5f to
9715afd
Compare
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.
Summary
This PR implements the architectural improvements outlined in the design plan (Items 7-10):
Item 7: Path Validation
path_validation.pymodule withPathValidatorclass_safe_read_sql_file()allow_symlinksparameterItem 10: Prompt Injection Mitigation
prompt_sanitization.pymodule with 4-layer defenseCLGRAPH_DISABLE_PROMPT_SANITIZATIONfor debuggingItem 9: File Splitting
lineage_utils.pyfromlineage_builder.py(~592 lines)sql_column_tracer.pyfromlineage_builder.py(~296 lines)tvf_registry.pyfromquery_parser.py(~72 lines)Item 8: Pipeline Decomposition
LineageTracercomponent (~400 lines)MetadataManagercomponent (~185 lines)PipelineValidatorcomponent (~169 lines)SubpipelineBuildercomponent (~183 lines)File Size Reductions
pipeline.pylineage_builder.pyquery_parser.pyTest Plan
ruff checkpassesruff formatpasses🤖 Generated with Claude Code