8000 Stop adding list of contributors to thin data streams by jan-cerny · Pull Request #13453 · ComplianceAsCode/content · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Stop adding list of contributors to thin data streams #13453

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

Merged
merged 2 commits into from
May 13, 2025
Merged
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
30 changes: 17 additions & 13 deletions ssg/build_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def add_reference_title_elements(benchmark_el, env_yaml):
reference.text = title


def add_benchmark_metadata(element, contributors_file):
def add_benchmark_metadata(element, include_contributors):
"""
Adds benchmark metadata to an XML element.

Expand All @@ -266,7 +266,8 @@ def add_benchmark_metadata(element, contributors_file):

Args:
element (xml.etree.ElementTree.Element): The XML element to which the metadata will be added.
contributors_file (str): Path to the file containing contributors information.
include_contributors (bool): A flag indicating whether to include
contributors in the metadata.

Returns:
None
Expand All @@ -278,11 +279,12 @@ def add_benchmark_metadata(element, contributors_file):

creator = ET.SubElement(metadata, "{%s}creator" % dc_namespace)
creator.text = SSG_PROJECT_NAME

contrib_tree = parse_file(contributors_file)
for c in contrib_tree.iter('contributor'):
contributor = ET.SubElement(metadata, "{%s}contributor" % dc_namespace)
contributor.text = c.text
if include_contributors:
contributors_file = os.path.join(os.path.dirname(__file__), "../Contributors.xml")
contrib_tree = parse_file(contributors_file)
for c in contrib_tree.iter('contributor'):
contributor = ET.SubElement(metadata, "{%s}contributor" % dc_namespace)
contributor.text = c.text

source = ET.SubElement(metadata, "{%s}source" % dc_namespace)
source.text = SSG_BENCHMARK_LATEST_URI
Expand Down Expand Up @@ -905,7 +907,7 @@ def _add_version_xml(self, root):
version.text = self.version
version.set('update', SSG_BENCHMARK_LATEST_URI)

def to_xml_element(self, env_yaml=None, product_cpes=None, components_to_not_include=None):
def to_xml_element(self, env_yaml=None, product_cpes=None, components_to_not_include=None, include_contributors=True):
"""
Converts the current object to an XML element.

Expand All @@ -914,6 +916,8 @@ def to_xml_element(self, env_yaml=None, product_cpes=None, components_to_not_inc
product_cpes (list, optional): List of product CPEs. Defaults to None.
components_to_not_include (dict, optional): Components to exclude from the XML.
Defaults to None.
include_contributors (bool, optional): Whether to include contributors in the XML.
Defaults to True.

Returns:
xml.etree.ElementTree.Element: The root XML element representing the object.
Expand All @@ -932,8 +936,7 @@ def to_xml_element(self, env_yaml=None, product_cpes=None, components_to_not_inc

self._add_version_xml(root)

contributors_file = os.path.join(os.path.dirname(__file__), "../Contributors.xml")
add_benchmark_metadata(root, contributors_file)
add_benchmark_metadata(root, include_contributors)

self._add_profiles_xml(root, components_to_not_include)
self._add_values_xml(root, components_to_not_include)
Expand Down Expand Up @@ -1022,7 +1025,7 @@ def to_xccdf(self):
def __str__(self):
return self.id_

def get_benchmark_xml_for_profiles(self, env_yaml, profiles, rule_and_variables_dict):
def get_benchmark_xml_for_profiles(self, env_yaml, profiles, rule_and_variables_dict, include_contributors=True):
"""
Generates the benchmark XML for the given profiles.

Expand Down Expand Up @@ -1054,7 +1057,8 @@ def get_benchmark_xml_for_profiles(self, env_yaml, profiles, rule_and_variables_
}
return profiles_ids, self.to_xml_element(
env_yaml,
components_to_not_include=components_to_not_include
components_to_not_include=components_to_not_include,
include_contributors=include_contributors
)


Expand Down Expand Up @@ -3185,7 +3189,7 @@ def get_benchmark_xml_by_profile(self, rule_and_variables_dict):
for profile in self.benchmark.profiles:
if profile.single_rule_profile == "true":
profiles_ids, benchmark = self.benchmark.get_benchmark_xml_for_profiles(
self.env_yaml, [profile], rule_and_variables_dict
self.env_yaml, [profile], rule_and_variables_dict, include_contributors=False
)
yield profiles_ids.pop(), benchmark

Expand Down
Loading
0