Skip to content

Evaluate OVAL state with no entities as true (Fixes #2396) - #2452

Open
Mohit20057 wants to merge 1 commit into
OpenSCAP:mainfrom
Mohit20057:fix-empty-state-eval
Open

Mohit20057 wants to merge 1 commit into
OpenSCAP:mainfrom
Mohit20057:fix-empty-state-eval

Conversation

@Mohit20057

Copy link
Copy Markdown

Summary

Fixes #2396

According to the OVAL specification, child entities in state elements have minOccurs="0". A state without any entities imposes zero conditions; therefore, any collected system item vacuously satisfies it.

Previously, eval_item() in oval_resultTest.c would iterate over an empty list of state contents, leaving the results structure empty. It then passed this empty set to ores_get_result_byopr(), which mapped it to OVAL_RESULT_UNKNOWN.

This caused a critical false negative with Canonical's Ubuntu OVAL feeds, which define singleton family_state elements with no child entities. Because the inventory check evaluated to unknown, every Ubuntu Security Notice (USN) extending that inventory definition failed to evaluate to true, reporting zero vulnerabilities and exiting cleanly with code 0.

Proposed Changes

  • In src/OVAL/results/oval_resultTest.c, check whether state_contents_itr is empty before loop execution; if empty, immediately free the iterator and return OVAL_RESULT_TRUE.
  • Added a regression test suite tests/API/OVAL/unittests/empty_state.xml and tests/API/OVAL/unittests/test_empty_state.sh covering:
    • Empty family_state with default AND operator (evaluates to true).
    • Empty state with OR operator (evaluates to true).
    • Empty state with non-existent item (still correctly fails existence check).
    • Extended definition applicability check (Ubuntu USN pattern).
  • Registered test_empty_state.sh in tests/API/OVAL/unittests/CMakeLists.txt.

According to the OVAL specification, child entities in state elements
have minOccurs=0. A state without any entities imposes no conditions;
therefore, any collected system item vacuously satisfies it.

Previously, eval_item() in oval_resultTest.c would iterate over an empty
list of state contents, leaving the results structure empty. It then
passed this empty set to ores_get_result_byopr(), which mapped it to
OVAL_RESULT_UNKNOWN.

This caused a critical false negative with Canonical's Ubuntu OVAL feeds,
which define singleton family_states with no child entities. Because the
inventory check evaluated to unknown, every Ubuntu Security Notice (USN)
extending that inventory definition failed to evaluate to true, reporting
zero vulnerabilities and exiting cleanly with code 0.

This patch detects when an OVAL state contains no entities and immediately
returns OVAL_RESULT_TRUE. Also adds a regression test suite covering
entity-less states and Ubuntu applicability check patterns.

Fixes OpenSCAP#2396
@Mohit20057
Mohit20057 force-pushed the fix-empty-state-eval branch from 81ad692 to 5836ee5 Compare October 20, 2026 14:13
@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.

A state with no entities evaluates to unknown instead of true, silently voiding every Ubuntu USN result

1 participant