Skip to content

Fix behavior of OSCAP_PROBE_IGNORE_PATHS variable - #2487

Merged
Mab879 merged 1 commit into
OpenSCAP:mainfrom
jan-cerny:RHEL-310454
Nov 25, 2026
Merged

Mab879 merged 1 commit into
OpenSCAP:mainfrom
jan-cerny:RHEL-310454

Conversation

@jan-cerny

Copy link
Copy Markdown
Member

If the variable is set to an empty string or contains empty strings in columns, the empty string shall be ignored and shall not cause ignoring any paths.

Resolves: https://redhat.atlassian.net/browse/RHEL-310454

If the variable is set to an empty string or contains empty strings
in columns, the empty string shall be ignored and shall not cause
ignoring any paths.

Resolves: https://redhat.atlassian.net/browse/RHEL-310454
@jan-cerny jan-cerny added this to the 1.4.7 milestone Nov 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@Mab879 Mab879 self-assigned this Nov 19, 2026

@jamesconwaydev jamesconwaydev 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.

Read through against main; the root cause and the fix line up:

  • Where the empty entries come from. oscap_split is built on strsep, so it yields an empty field for "", for a leading or trailing :, and for ::. Each went into blocked_paths.
  • Why an empty entry blocked everything. probe_path_is_blocked checks each entry with oscap_path_startswith(path, item). For item = "", the prefix splits into [""], and the loop skips the empty component and runs out of prefix with res still true. So an empty entry matched every path, and the probes ignored them all.
  • The fix is in the right place. Skipping empty fields in _add_blocked_paths means neither probe_path_is_blocked nor probe_fd_path_is_blocked, which strips the prefix and then calls the former, ever sees one.

The tests cover the cases that matter: unset, '' and ':', each collecting all 8 objects, and real paths with empty entries around them blocking exactly as before.

One thing to be aware of, which this PR doesn't change: an entry of only slashes, such as /, still matches everything, since every component is empty after splitting. That reads as intended for / ("ignore the whole filesystem"), so I'd leave it.

Read only; I didn't run it.

@Mab879
Mab879 merged commit 6805afb into OpenSCAP:main Nov 25, 2026
17 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants