Refine skip rules and add analyzer tests#7
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refines file/directory skip behavior (notably for vendor folders like node_modules) in the Secrets and PII analyzers, adds targeted tests for the new skip behavior and IP suppression logic, and bumps the project/extension version to 1.3.1.
Changes:
- Switch Secrets/PII directory scanning from
Path.rglob()toos.walk()with directory pruning viashould_skip_path. - Update
should_skip_pathto be case-insensitive and to better handle file vs directory paths; expand PII “non-personal IP” suppression to include private/link-local/multicast ranges. - Add analyzer tests for skipping vendor directories and for suppressing non-personal IPs; bump versions to
1.3.1.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_secrets_analyzer.py | Removes unused pytest import; adds test ensuring vendor directories are skipped by secrets analyzer. |
| tests/test_pii_analyzer.py | Removes unused pytest import; adds tests for suppressing non-personal IPs and skipping vendor directories. |
| src/contractguard/analyzers/secrets_analyzer.py | Reworks directory scanning to os.walk() and prunes skipped directories during traversal. |
| src/contractguard/analyzers/pii_analyzer.py | Reworks directory scanning to os.walk(); expands IP suppression logic. |
| src/contractguard/analyzers/file_filters.py | Makes skip checks case-insensitive and adjusts path-part handling for files vs dirs. |
| src/contractguard/init.py | Bumps library version to 1.3.1. |
| pyproject.toml | Bumps Python package version to 1.3.1. |
| package.json | Bumps extension version to 1.3.1 and updates the packaged VSIX filename. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+123
to
+125
| (skipped_dir / "secret.env").write_text("DB_PASSWORD=admin123\n") | ||
| (tmp_path / "safe.txt").write_text("Nothing here\n") | ||
| findings = analyze(tmp_path, RULES_DIR) |
Comment on lines
+101
to
+104
| (skipped_dir / "pii.txt").write_text("ssn: 123-45-6789\n") | ||
| (tmp_path / "safe.txt").write_text("No personal info here.\n") | ||
| findings = analyze(tmp_path, RULES_DIR) | ||
| assert all("node_modules" not in f.location for f in findings) |
Comment on lines
26
to
+32
| def should_skip_path(path: Path) -> bool: | ||
| return any(part in _SKIP_DIRS for part in path.parts) | ||
| parts = path.parts | ||
| if path.exists() and path.is_file(): | ||
| parts = path.parent.parts | ||
| elif path.suffix: | ||
| parts = path.parent.parts | ||
| return any(part.casefold() in _NORMALIZED_SKIP_DIRS for part in parts) |
Comment on lines
+121
to
+123
| dirnames[:] = [ | ||
| name for name in dirnames if not should_skip_path(root_path / name) | ||
| ] |
Comment on lines
+115
to
+117
| dirnames[:] = [ | ||
| name for name in dirnames if not should_skip_path(root_path / name) | ||
| ] |
| "scripts": { | ||
| "build": "tsc -p ./tsconfig.json", | ||
| "package": "node -e \"require('fs').mkdirSync('dist-vsix',{recursive:true})\" && vsce package --out dist-vsix/contractguard-1.3.0.vsix", | ||
| "package": "node -e \"require('fs').mkdirSync('dist-vsix',{recursive:true})\" && vsce package --out dist-vsix/contractguard-1.3.1.vsix", |
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.
No description provided.