|
| 1 | +# Suppression File Synchronization |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +DependencyCheck maintains two suppression files: |
| 6 | +- **Base Suppression File**: `core/src/main/resources/dependencycheck-base-suppression.xml` - Manually curated suppressions that ship with releases |
| 7 | +- **Generated Suppressions File**: Maintained on the `generatedSuppressions` branch - Auto-generated suppressions from GitHub issue reports |
| 8 | + |
| 9 | +## Strategy |
| 10 | + |
| 11 | +The two files serve different purposes and should remain separate: |
| 12 | +- The **generated file** is automatically maintained via GitHub Actions when issues are reported |
| 13 | +- The **base file** should contain only manually curated suppressions that are NOT in the generated file |
| 14 | +- Both files are loaded at runtime, so suppressions in either file will be applied |
| 15 | + |
| 16 | +## Synchronization Tools |
| 17 | + |
| 18 | +Two tools are available to help keep the files in sync in case of overlap (current situation as of Nov 10, 2025): |
| 19 | + |
| 20 | +### 1. Git History Analyzer |
| 21 | + |
| 22 | +The `SuppressionSyncAnalyzer` analyzes git history of the generated suppressions file to find suppressions that were **modified or deleted**: |
| 23 | + |
| 24 | +- ✅ Focuses on intentional changes (not just duplicates) |
| 25 | +- ✅ Provides git commit context (why was it changed?) |
| 26 | +- ✅ Catches consolidations (e.g., 20 individual rules → 1 broad rule) |
| 27 | +- ✅ Shows GitHub commit links for review |
| 28 | +- ✅ Handles the "V" option to view commits in browser |
| 29 | + |
| 30 | +**Interactive mode** (recommended): |
| 31 | +```bash |
| 32 | +./deduplicate-suppressions.sh |
| 33 | +# or explicitly: |
| 34 | +./deduplicate-suppressions.sh analyzer |
| 35 | +``` |
| 36 | + |
| 37 | +This will: |
| 38 | +1. Fetch the latest from the `generatedSuppressions` branch |
| 39 | +2. Analyze git history for modifications/deletions |
| 40 | +3. Check if old versions exist in base file |
| 41 | +4. Interactively show each one with: |
| 42 | + - What's currently in base |
| 43 | + - What happened in generated (modified/deleted) |
| 44 | + - Git commit info with clickable GitHub link |
| 45 | +5. Let you decide: Remove, Keep, View commit, Quit, or Auto-remove all |
| 46 | + |
| 47 | +**Non-interactive mode**: |
| 48 | +```bash |
| 49 | +./deduplicate-suppressions.sh analyzer --non-interactive |
| 50 | +``` |
| 51 | + |
| 52 | +This automatically removes ALL obsolete suppressions from base. |
| 53 | + |
| 54 | +### 2. Duplicate Detector (Legacy) |
| 55 | + |
| 56 | +The `SuppressionDeduplicator` finds exact duplicates between the two files. This is less sophisticated but faster for simple cases. |
| 57 | + |
| 58 | +**Interactive mode**: |
| 59 | +```bash |
| 60 | +./deduplicate-suppressions.sh deduplicator |
| 61 | +``` |
| 62 | + |
| 63 | +**Non-interactive mode**: |
| 64 | +```bash |
| 65 | +./deduplicate-suppressions.sh deduplicator --non-interactive |
| 66 | +``` |
| 67 | + |
| 68 | +### Backup |
| 69 | + |
| 70 | +The tool automatically creates a backup of the base suppression file before making changes: |
| 71 | +- Backup location: `dependencycheck-base-suppression.xml.backup` |
| 72 | + |
| 73 | +## How Issues Are Detected |
| 74 | + |
| 75 | +### Git History Analyzer |
| 76 | +Finds suppressions in base that match the OLD version from git history where: |
| 77 | +1. The suppression was **deleted** from generated |
| 78 | +2. OR the suppression was **modified** in generated (indicating consolidation or correction) |
| 79 | + |
| 80 | +### Duplicate Detector |
| 81 | +Two suppressions are considered duplicates if: |
| 82 | +1. They have matching **key fields** (packageUrl, gav, filePath, or sha1) |
| 83 | +2. AND they have overlapping **CPEs**, **CVEs**, or **vulnerability names** |
| 84 | + |
| 85 | +## Implementation Details |
| 86 | + |
| 87 | +- `utils/src/main/java/org/owasp/dependencycheck/utils/SuppressionSyncAnalyzer.java` - Git history analyzer |
| 88 | +- `utils/src/main/java/org/owasp/dependencycheck/utils/SuppressionDeduplicator.java` - Duplicate detector |
| 89 | +- `utils/src/test/java/org/owasp/dependencycheck/utils/SuppressionSyncAnalyzerTest.java` - Tests for git diff parsing |
| 90 | + |
| 91 | +### Running Tests |
| 92 | + |
| 93 | +To verify the git diff parsing logic works correctly: |
| 94 | + |
| 95 | +```bash |
| 96 | +mvn -pl utils test -Dtest=SuppressionSyncAnalyzerTest |
| 97 | +``` |
0 commit comments