Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix utils/rule_dir_json.py when no product is detected when rendering OVAL #7978

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ssg/oval.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
ET._namespace_map[ovalns] = "oval"


def applicable_platforms(oval_file, oval_version_string=None):
def applicable_platforms(oval_file, oval_version_string=None, product=None):
"""
Returns the applicable platforms for a given oval file
"""
Expand All @@ -38,6 +38,9 @@ def applicable_platforms(oval_file, oval_version_string=None):
oval_version_list = [int(num) for num in oval_version_string.split(".")]
subst_dict = dict(target_oval_version=oval_version_list)

if product is not None:
subst_dict["product"] = product

oval_filename_components = oval_file.split(os.path.sep)
if len(oval_filename_components) > 3:
subst_dict["rule_id"] = oval_filename_components[-3]
Expand Down
2 changes: 1 addition & 1 deletion utils/rule_dir_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def handle_ovals(product_list, product_yamls, rule_obj):
oval_product, _ = os.path.splitext(oval_name)
oval_obj = {'name': oval_name, 'product': oval_product}

platforms = ssg.oval.applicable_platforms(oval_path)
platforms = ssg.oval.applicable_platforms(oval_path, product=oval_product)
Copy link
Member

Choose a reason for hiding this comment

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

oval_product contains the directory name such as shared, firefox, jre, etc... it doesn't really contain a product per se. If the product is really relevant for the script, we should make it as a parameter and let cmake pass the right product. If we don't need it then we can just put some default value so it doesn't traceback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uhm... let me see what I can do

Copy link
Member

Choose a reason for hiding this comment

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

Probably the default example product introduced in #7979 will do the trick on a good-enough level - the utility in question is not designed to be product-specific, so for the time being let's hope that usage of the default product won't impact its result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, actually this PR is not needed any more.

cs_platforms = ','.join(platforms)

oval_obj['platforms'] = platforms
Expand Down