Skip to content

Commit

Permalink
Merge pull request #11406 from Commandcracker/master
Browse files Browse the repository at this point in the history
Building on Windows
  • Loading branch information
jan-cerny authored Jan 3, 2024
2 parents 39854d6 + e3f471b commit 62ac8eb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
33 changes: 29 additions & 4 deletions build-scripts/generate_guides.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,33 @@
BenchmarkData = collections.namedtuple(
"BenchmarkData", ["title", "profiles", "product"])

XSLT_PREFIX = os.getenv('XSLT_PREFIX', default='/usr')
XSLT_PATH = os.path.join(XSLT_PREFIX, "share/openscap/xsl/xccdf-guide.xsl")
OPENSCAP_POSSIBLE_ROOT_DIRS = [
os.getenv("OPENSCAP_ROOT_DIR"),
os.getenv("ProgramFiles"),
os.getenv("XSLT_PREFIX"),
"/usr",
"/usr/bin",
"/usr/sbin",
"/usr/local",
"/usr/share/",
"/usr/local/share",
"/opt",
"/opt/local",
]

for root_dir in OPENSCAP_POSSIBLE_ROOT_DIRS:
if root_dir is None:
continue
for subpath in [os.path.join("share", "openscap", "xsl"), "xsl"]:
file_path = os.path.join(root_dir, subpath, "xccdf-guide.xsl")
if os.path.exists(file_path):
XCCDF_GUIDE_XSL = file_path
break
else:
continue
break
else:
XCCDF_GUIDE_XSL = None


def get_benchmarks(ds, product):
Expand Down Expand Up @@ -45,7 +70,7 @@ def parse_args():
help="Path to a SCAP source data stream, eg. 'ssg-rhel9-ds.xml'")
parser.add_argument(
"--oscap-version", required=True,
help=f"Version of OpenSCAP that owns {XSLT_PATH}, eg. 1.3.8")
help=f"Version of OpenSCAP that owns {XCCDF_GUIDE_XSL}, eg. 1.3.8")
parser.add_argument(
"--product", required=True,
help="Product ID, eg. rhel9")
Expand Down Expand Up @@ -136,7 +161,7 @@ def generate_html_index(benchmarks, data_stream, output_dir):


def generate_html_guides(ds, benchmarks, oscap_version, output_dir):
xslt = ET.parse(XSLT_PATH)
xslt = ET.parse(XCCDF_GUIDE_XSL)
transform = ET.XSLT(xslt)
for benchmark_id, benchmark_data in benchmarks.items():
for profile_id in benchmark_data.profiles:
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindOpenSCAP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(OPENSCAP_POSSIBLE_ROOT_DIRS
foreach(NAME ${OPENSCAP_POSSIBLE_ROOT_DIRS})
find_file(OPENSCAP_XCCDF_XSL_1_2 NAMES xccdf_1.1_to_1.2.xsl
PATHS "${NAME}"
PATH_SUFFIXES "share/openscap/xsl/"
PATH_SUFFIXES "share/openscap/xsl/" "xsl/"
)
endforeach()

Expand Down
5 changes: 4 additions & 1 deletion utils/gen_stig_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def get_stats(root, ns):
stats["total"] = total
stats["missing"] = missing
stats["implemented"] = implemented
stats["coverage"] = implemented / total * 100
if total != 0:
stats["coverage"] = implemented / total * 100
else:
stats["coverage"] = 0
stats["missing_rules"] = missing_rules
return stats

Expand Down

0 comments on commit 62ac8eb

Please sign in to comment.