Skip to content

Commit

Permalink
Remove option to build SCAP 1.2 from compose_ds.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-cerny committed May 10, 2024
1 parent 8382b93 commit d323be0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions build-scripts/compose_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ def parse_args():
parser.add_argument("--cpe-oval", help="CPE OVAL file name")
parser.add_argument("--enable-sce", action='store_true', help="Enable building sce data")
parser.add_argument(
"--output-12", help="Output SCAP 1.2 source data stream file name")
parser.add_argument(
"--output-13", required=True,
"--output", required=True,
help="Output SCAP 1.3 source data stream file name")
parser.add_argument(
"--multiple-ds",
Expand Down Expand Up @@ -280,12 +278,9 @@ def upgrade_ds_to_scap_13(ds):
return ds


def _store_ds(ds, output_13, output_12):
if output_12:
ds.write(output_12, xml_declaration=True, encoding="utf-8")

def _store_ds(ds, output):
ds_13 = upgrade_ds_to_scap_13(ds)
ds_13.write(output_13, xml_declaration=True, encoding="utf-8")
ds_13.write(output, xml_declaration=True, encoding="utf-8")


def append_id_to_file_name(path, id_):
Expand Down Expand Up @@ -317,13 +312,12 @@ def _compose_multiple_ds(args):
ds = compose_ds(
xccdf, oval, ocil, cpe_dict, cpe_oval, args.enable_sce
)
output_13 = _get_thin_ds_output_path(args.output_13, xccdf.replace("xccdf_", ""))
output_12 = None
output = _get_thin_ds_output_path(args.output, xccdf.replace("xccdf_", ""))

if not os.path.exists(os.path.dirname(output_13)):
os.makedirs(os.path.dirname(output_13))
if not os.path.exists(os.path.dirname(output)):
os.makedirs(os.path.dirname(output))

_store_ds(ds, output_13, output_12)
_store_ds(ds, output)


if __name__ == "__main__":
Expand All @@ -336,4 +330,4 @@ def _compose_multiple_ds(args):
ds = compose_ds(
args.xccdf, args.oval, args.ocil, args.cpe_dict, args.cpe_oval, args.enable_sce
)
_store_ds(ds, args.output_13, args.output_12)
_store_ds(ds, args.output)
2 changes: 1 addition & 1 deletion cmake/SSGCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ macro(ssg_build_sds PRODUCT)

add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml"
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${SSG_BUILD_SCRIPTS}/compose_ds.py" --xccdf "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-xccdf.xml" --oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-oval.xml" --ocil "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ocil.xml" --cpe-dict "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-dictionary.xml" --cpe-oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-oval.xml" --output-13 "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml" --multiple-ds "${SSG_THIN_DS_COMPONENTS_DIR}" ${COMPOSE_EXTRA_ARGS}
COMMAND env "PYTHONPATH=$ENV{PYTHONPATH}" "${PYTHON_EXECUTABLE}" "${SSG_BUILD_SCRIPTS}/compose_ds.py" --xccdf "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-xccdf.xml" --oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-oval.xml" --ocil "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ocil.xml" --cpe-dict "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-dictionary.xml" --cpe-oval "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-cpe-oval.xml" --output "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml" --multiple-ds "${SSG_THIN_DS_COMPONENTS_DIR}" ${COMPOSE_EXTRA_ARGS}
COMMAND "${XMLLINT_EXECUTABLE}" --nsclean --format --output "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml" "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-ds.xml"
DEPENDS generate-ssg-${PRODUCT}-xccdf.xml "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-xccdf.xml"
DEPENDS generate-ssg-${PRODUCT}-oval.xml "${CMAKE_BINARY_DIR}/ssg-${PRODUCT}-oval.xml"
Expand Down

0 comments on commit d323be0

Please sign in to comment.