Develop a PowerShell script to parse .cveignore files containing CVE exception rules.
The parser should:
- Accept a file path or a directory path.
- Ignore comments and blank lines.
- Parse records using the format
CVE|LibraryVersions|AllowedReason|AllowedExpiry. - Validate CVE identifiers, library/version combinations, required fields, and optional expiry dates.
- Exclude invalid rules and return all valid rules as structured PowerShell objects.
The implementation is available in Parse-CVEIgnore.ps1.
The script validates each record, generates warnings for invalid entries, and continues processing the remaining records.
Run the parser against the sample input:
$rules = @(.\Parse-CVEIgnore.ps1 -Path .\.cveignore)
$rules.CountAlternatively, pass the current directory:
.\Parse-CVEIgnore.ps1 -Path .The sample .cveignore dataset contains 24 CVE records.
- 23 valid records returned.
- 1 invalid record rejected due to a malformed expiry date.
- Invalid records generate warnings without stopping the parser.
Environment: Tested using Windows PowerShell 5.1.