Skip to content

Support CPE 2.3 format in XCCDF platform applicability (#2404) - #2453

Closed
Mohit20057 wants to merge 1 commit into
OpenSCAP:mainfrom
Mohit20057:fix-cpe23-platform-applicability
Closed

Mohit20057 wants to merge 1 commit into
OpenSCAP:mainfrom
Mohit20057:fix-cpe23-platform-applicability

Conversation

@Mohit20057

Copy link
Copy Markdown
Contributor

Summary

Fixes #2404

When an XCCDF benchmark or rule uses a CPE 2.3 formatted string in <platform idref="..."> (e.g., cpe:2.3:o:...), platform applicability previously failed silently against CPE dictionaries, causing all rules to be evaluated as notapplicable.

Root Cause

  1. cpe_name_match_one() failed immediately on field count comparison (cpe_fields_num(against) < cpefn) when comparing an 11-field CPE 2.3 formatted string against a 4-field CPE 2.2 URI, and did not recognize * as an ANY wildcard.
  2. cpe_name_applicable_dict() and cpe_name_match_dict() only checked the primary <cpe-item> name (CPE 2.2 URI) and ignored the inner <cpe-23:cpe23-item> element.

Solution

  • Refactored cpe_name_match_one() to compare attributes across all 11 fields (CPE_TOTAL_FIELDNUM), handling wildcards (*) and omitted attributes for seamless cross-format matching between CPE 2.2 and CPE 2.3.
  • Added cpe23_item_get_name() and cpe_item_get_cpe23_name() accessors to retrieve <cpe-23:cpe23-item> names.
  • Updated cpe_name_applicable_dict() and cpe_name_match_dict() to match against both the primary CPE 2.2 name and the CPE 2.3 name if present.
  • Added unit test in tests/API/CPE/dict/test_api_cpe_dict.sh testing CPE 2.3 matching against CPE 2.3 and CPE 2.2 dictionaries.
  • Added integration test in tests/API/XCCDF/applicability/test_xccdf_cpe_eval.sh with a benchmark containing a CPE 2.3 platform idref, verifying that 0 rules evaluate to notapplicable.

When an XCCDF benchmark or rule uses a CPE 2.3 formatted string
in platform idref, platform applicability previously failed to match
against CPE dictionaries due to:
1. cpe_name_match_one() failing on field count difference between
   11-field CPE 2.3 formatted strings and 4-field CPE 2.2 URIs, as
   well as lack of wildcard '*' support.
2. cpe_name_applicable_dict() and cpe_name_match_dict() only
   checking primary CPE 2.2 cpe-item names and ignoring cpe23-item.

This patch refactors cpe_name_match_one() to support wildcards and
cross-format CPE 2.2 / CPE 2.3 matching, and updates dictionary lookup
to also match against cpe23-item names when present.

Fixes OpenSCAP#2404
@Mohit20057 Mohit20057 closed this Oct 21, 2026
@Mohit20057
Mohit20057 force-pushed the fix-cpe23-platform-applicability branch from abf6caf to dc9fe80 Compare October 21, 2026 07:01
@sonarqubecloud

Copy link
Copy Markdown

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.

XCCDF platform applicability silently fails (all rules notapplicable) when <platform idref> uses CPE 2.3 format instead of CPE 2.2

1 participant