Skip to content

Refine skip rules and add analyzer tests#7

Merged
CodeforGood1 merged 2 commits into
CodeforGood1:mainfrom
Blackplane-Systems:main
May 11, 2026
Merged

Refine skip rules and add analyzer tests#7
CodeforGood1 merged 2 commits into
CodeforGood1:mainfrom
Blackplane-Systems:main

Conversation

@CodeforGood1
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 11, 2026 19:02
@CodeforGood1 CodeforGood1 merged commit c30cb3d into CodeforGood1:main May 11, 2026
3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() to os.walk() with directory pruning via should_skip_path.
  • Update should_skip_path to 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)
]
Comment thread package.json
"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",
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