Skip to content

autotailor: Add --relative-path option for layered product compatibility#2337

Open
ggbecker wants to merge 1 commit intoOpenSCAP:mainfrom
ggbecker:fix-autotailor-relative-path
Open

autotailor: Add --relative-path option for layered product compatibility#2337
ggbecker wants to merge 1 commit intoOpenSCAP:mainfrom
ggbecker:fix-autotailor-relative-path

Conversation

@ggbecker
Copy link
Copy Markdown
Member

@ggbecker ggbecker commented Apr 10, 2026

Add a new --relative-path flag that generates benchmark references using relative paths instead of absolute file:// URIs. This enables compatibility with Red Hat Satellite and other layered products that cannot resolve local filesystem paths.

When --relative-path is specified:

  • Absolute paths are converted to basename only
  • Relative paths are preserved as provided by the user

The default behavior remains unchanged for backward compatibility.

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

Add a new --relative-path flag that generates benchmark references
using relative paths instead of absolute file:// URIs. This enables
compatibility with Red Hat Satellite and other layered products that
cannot resolve local filesystem paths.

When --relative-path is specified:
- Absolute paths are converted to basename only
- Relative paths are preserved as provided by the user

The default behavior remains unchanged for backward compatibility.

Resolves: RHEL-143568
@ggbecker
Copy link
Copy Markdown
Member Author

To which openscap versions do we want to include this change?

@sonarqubecloud
Copy link
Copy Markdown

@jan-cerny jan-cerny self-assigned this Apr 10, 2026
help="Where to save the tailoring file. If not supplied, write to "
"standard output.")
parser.add_argument(
"--relative-path", action="store_true",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the new option in the man page.

benchmark = ET.SubElement(root, "{%s}benchmark" % NS)
datastream_uri = pathlib.Path(
self.original_ds_filename).absolute().as_uri()
if self.use_relative_path:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The to_xml method starts getting long. I suggest extracting the code that determines the URI to a separate method eg. _get_datastream_uri()

"standard output.")
parser.add_argument(
"--relative-path", action="store_true",
help="Use relative path (basename only) for the benchmark href instead of "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test that covers this feature.

@jan-cerny
Copy link
Copy Markdown
Member

To which openscap versions do we want to include this change?

Good question. The answer isn't clear. The RHEL ticket is reported against RHEL 10. That'd mean we shall merge it only to the main branch and it will be a part of OpenSCAP version 1.4.5. However, in the RHEL ticket description, they say they use it for RHEL 9 content, which would suggest that they will need the fix also in RHEL 9, which contains OpenSCAP 1.3.xx and therefore we would need it merge it also to the maint-1.3 branch so that it would become part of OpenSCAP 1.3.15.

In general, we try to do the backporting only for bugfixes, in this case it's difficult to say whether this is a bugfix or a new feature, but I feel this would be more of a bugfix.

If you agree, then please after this PR is merged create another PR with the same contents but to the maint-1.3 branch.

# Preserve relative paths as-is, convert absolute paths to basename
ds_path = pathlib.Path(self.original_ds_filename)
if ds_path.is_absolute():
# Convert absolute path to basename for compatibility with layered products
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option name is -relative-path but if this branch is executed there will be a basename which doesn't have to be a relative path. Consider some better name for the command line option.

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.

2 participants