autotailor: Add --relative-path option for layered product compatibility#2337
autotailor: Add --relative-path option for layered product compatibility#2337ggbecker wants to merge 1 commit intoOpenSCAP:mainfrom
Conversation
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
|
To which openscap versions do we want to include this change? |
|
| help="Where to save the tailoring file. If not supplied, write to " | ||
| "standard output.") | ||
| parser.add_argument( | ||
| "--relative-path", action="store_true", |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 " |
There was a problem hiding this comment.
Please add a test that covers this feature.
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 |
There was a problem hiding this comment.
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.



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:
The default behavior remains unchanged for backward compatibility.
Resolves: https://redhat.atlassian.net/browse/RHEL-143616