Skip to content

SP-4487: fix scanoss.json skip patterns for fingerprinting and negation - #219

Merged
mscasso-scanoss merged 2 commits into
mainfrom
mscasso/fix-filtering-patterns-sp4487
Jul 10, 2026
Merged

mscasso-scanoss merged 2 commits into
mainfrom
mscasso/fix-filtering-patterns-sp4487

Conversation

@mscasso-scanoss

@mscasso-scanoss mscasso-scanoss commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Two distinct issues with settings.skip.patterns:

  • Fingerprinting skip rules were ignored: wfp_folder built FileFilters with operation_type='scanning', so settings.skip.patterns.fingerprinting (and sizes.fingerprinting) were never read. Now uses 'fingerprinting'.

  • Gitignore-style negation (!) was defeated by directory pruning: a broad root pattern such as "/*" matches the scan root '.', which pruned the whole tree before any "!keep" negation could re-include a descendant. The scan root is no longer treated as a candidate for exclusion.

Add regression tests and document the anchored-negation pattern (["/*", "!/game"]).

Summary by CodeRabbit

  • Bug Fixes
    • Fingerprinting (WFP) now applies fingerprinting-specific skip patterns and size exclusions.
    • Gitignore-style negation (!) now properly re-includes folders/files after broad skip patterns.
    • Scan root is no longer pruned by root-level or custom-pattern skipping logic.
  • Documentation
    • Added clarification and examples for anchored vs. unanchored negation semantics.
  • Tests
    • Expanded unit coverage for operation-scoped skip patterns and negation behavior.
  • Release
    • Updated release version to 1.54.1 and refreshed the changelog entry.

Two distinct issues with settings.skip.patterns:

- Fingerprinting skip rules were ignored: wfp_folder built FileFilters with
  operation_type='scanning', so settings.skip.patterns.fingerprinting (and
  sizes.fingerprinting) were never read. Now uses 'fingerprinting'.

- Gitignore-style negation (!) was defeated by directory pruning: a broad
  root pattern such as "/*" matches the scan root '.', which pruned the whole
  tree before any "!keep" negation could re-include a descendant. The scan
  root is no longer treated as a candidate for exclusion.

Add regression tests and document the anchored-negation pattern
(["/*", "!/game"]).
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 41e5ee95-391a-401a-892c-377191e300f8

📥 Commits

Reviewing files that changed from the base of the PR and between c691b23 and 4fe9307.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

Corrects fingerprinting skip-pattern selection and gitignore-style negation handling, adds focused tests and documentation, and releases the changes as version 1.54.1.

Changes

Skip pattern corrections

Layer / File(s) Summary
Filtering behavior and validation
src/scanoss/file_filters.py, src/scanoss/scanner.py, tests/test_file_filters.py, docs/source/scanoss_settings_schema.rst
Fingerprinting uses fingerprinting-specific filters, the scan root remains eligible for negation-based re-inclusion, and tests and documentation cover the updated semantics.
Release metadata
src/scanoss/__init__.py, CHANGELOG.md
The package version is updated to 1.54.1 and the filtering fixes are recorded in the changelog.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: eeisegn, isasmendiagus

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: skip pattern handling for fingerprinting and negation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mscasso/fix-filtering-patterns-sp4487

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

SCANOSS SCAN Completed 🚀

  • Detected components: 2
  • Undeclared components: 0
  • Declared components: 2
  • Detected files: 112
  • Detected files undeclared: 0
  • Detected files declared: 112
  • Licenses detected: 1
  • Licenses detected with copyleft: 0
  • Policies: ✅ 1 pass (1 total)

View more details on SCANOSS Action Summary

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/test_file_filters.py (1)

326-416: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Good regression coverage for both fixes.

The test classes TestSkipPatternOperationType and TestSkipPatternNegation directly validate the two bugs being fixed:

  • Operation-type scoping: test_fingerprinting_patterns_applied_to_fingerprinting and test_scanning_patterns_not_applied_to_fingerprinting confirm patterns are read from the correct settings section.
  • Negation: test_anchored_negation_reincludes_folder covers the ["/*", "!/game"] regression, and test_root_is_never_pruned_by_broad_pattern adds an extra guard with !/game/**.

The static-analysis path-traversal warnings on lines 338 and 380 are false positives — the paths are hardcoded in test methods, not user-supplied.

One small suggestion: TestSkipPatternNegation._filters always uses operation_type='scanning'. Consider adding at least one negation test with operation_type='fingerprinting' to confirm the root guard works across both operation types, since the guard in should_skip_dir is shared.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_file_filters.py` around lines 326 - 416, Add a negation regression
test in TestSkipPatternNegation that constructs filters with
operation_type='fingerprinting' and verifies the root guard preserves the
expected re-included paths, while keeping the existing scanning coverage. Update
_filters or add a dedicated helper so the operation type can be selected without
duplicating setup.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_file_filters.py`:
- Around line 326-416: Add a negation regression test in TestSkipPatternNegation
that constructs filters with operation_type='fingerprinting' and verifies the
root guard preserves the expected re-included paths, while keeping the existing
scanning coverage. Update _filters or add a dedicated helper so the operation
type can be selected without duplicating setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0c082da-280c-4e2c-976d-f3acc5ea2863

📥 Commits

Reviewing files that changed from the base of the PR and between 023538f and c691b23.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • docs/source/scanoss_settings_schema.rst
  • src/scanoss/__init__.py
  • src/scanoss/file_filters.py
  • src/scanoss/scanner.py
  • tests/test_file_filters.py

Comment thread CHANGELOG.md
[1.53.0]: https://github.com/scanoss/scanoss.py/compare/v1.52.1...v1.53.0
[1.53.1]: https://github.com/scanoss/scanoss.py/compare/v1.53.0...v1.53.1
[1.53.2]: https://github.com/scanoss/scanoss.py/compare/v1.53.1...v1.53.2
[1.54.0]: https://github.com/scanoss/scanoss.py/compare/v1.53.2...v1.54.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add the new release 1.54.1 in line 917 to see the full changelog

@github-actions

Copy link
Copy Markdown

SCANOSS SCAN Completed 🚀

  • Detected components: 2
  • Undeclared components: 0
  • Declared components: 2
  • Detected files: 112
  • Detected files undeclared: 0
  • Detected files declared: 112
  • Licenses detected: 1
  • Licenses detected with copyleft: 0
  • Policies: ✅ 1 pass (1 total)

View more details on SCANOSS Action Summary

@agustingroh agustingroh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@mscasso-scanoss
mscasso-scanoss merged commit fe0ab54 into main Jul 10, 2026
6 checks passed
@mscasso-scanoss
mscasso-scanoss deleted the mscasso/fix-filtering-patterns-sp4487 branch July 10, 2026 14:32
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