mirror of
https://github.com/usnistgov/macos_security.git
synced 2026-02-03 14:03:24 +00:00
Merge branch 'dev_2.0' into dev_2.0_compliance_script
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import platform
|
||||
from mscp.common_utils import set_logger
|
||||
from mscp.generate import (
|
||||
generate_scap,
|
||||
@@ -10,6 +11,11 @@ from mscp.generate import (
|
||||
)
|
||||
from mscp.cli import Customparser, validate_file
|
||||
|
||||
def get_macos_version() -> float:
|
||||
version_str, _, _ = platform.mac_ver()
|
||||
if version_str:
|
||||
major = int(version_str.split(".")[0])
|
||||
return float(major)
|
||||
|
||||
def main() -> None:
|
||||
logger = set_logger()
|
||||
@@ -67,7 +73,7 @@ def main() -> None:
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--os_version",
|
||||
default=15.0,
|
||||
default=get_macos_version(),
|
||||
type=float,
|
||||
help="Operating system version (eg: 14.0, 15.0).",
|
||||
)
|
||||
|
||||
@@ -40,6 +40,7 @@ class Sectionmap(StrEnum):
|
||||
SRG = "srg"
|
||||
SUPPLEMENTAL = "supplemental"
|
||||
SYSTEM_SETTINGS = "systemsettings"
|
||||
SETTINGS = "settings"
|
||||
|
||||
|
||||
class BaseModelWithAccessors(BaseModel):
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# Standard python modules
|
||||
import argparse
|
||||
import sys
|
||||
import platform
|
||||
from pathlib import Path
|
||||
|
||||
# Local python modules
|
||||
@@ -17,6 +18,11 @@ from .generate import (
|
||||
generate_scap,
|
||||
)
|
||||
|
||||
def get_macos_version() -> float:
|
||||
version_str, _, _ = platform.mac_ver()
|
||||
if version_str:
|
||||
major = int(version_str.split(".")[0])
|
||||
return float(major)
|
||||
|
||||
class Customparser(argparse.ArgumentParser):
|
||||
"""
|
||||
@@ -68,7 +74,7 @@ def parse_cli() -> None:
|
||||
|
||||
parser.add_argument(
|
||||
"--os_version",
|
||||
default=15.0,
|
||||
default=get_macos_version(),
|
||||
type=float,
|
||||
help="Operating system version (eg: 14.0, 15.0).",
|
||||
)
|
||||
|
||||
@@ -474,9 +474,9 @@ def generate_documents(
|
||||
language,
|
||||
)
|
||||
|
||||
if output_format == "adoc":
|
||||
gems_asciidoctor: Path = Path("mscp_gems/bin/asciidoctor")
|
||||
gems_asciidoctor_pdf: Path = Path("mscp_gems/bin/asciidoctor-pdf")
|
||||
# if output_format == "adoc":
|
||||
# gems_asciidoctor: Path = Path("mscp_gems/bin/asciidoctor")
|
||||
# gems_asciidoctor_pdf: Path = Path("mscp_gems/bin/asciidoctor-pdf")
|
||||
|
||||
# output, error = run_command("which asciidoctor")
|
||||
# logger.debug(f"which asciidoctor output: {output}, error: {error}")
|
||||
@@ -485,6 +485,10 @@ def generate_documents(
|
||||
# if not gems_asciidoctor.exists():
|
||||
# logger.error("Asciidoctor not installed!!")
|
||||
# sys.exit()
|
||||
output, error = run_command("bundle install --gemfile Gemfile --path mscp_gems --binstubs")
|
||||
if error:
|
||||
logger.error(f"Bundle install failed: {error}")
|
||||
sys.exit()
|
||||
|
||||
output, error = run_command(f"bundle exec asciidoctor {output_file}")
|
||||
if error:
|
||||
@@ -499,6 +503,10 @@ def generate_documents(
|
||||
# if not gems_asciidoctor.exists():
|
||||
# logger.error("Asciidoctor not installed!!")
|
||||
# sys.exit()
|
||||
output, error = run_command("bundle install --gemfile Gemfile --path mscp_gems --binstubs")
|
||||
if error:
|
||||
logger.error(f"Bundle install failed: {error}")
|
||||
sys.exit()
|
||||
|
||||
output, error = run_command(f"bundle exec asciidoctor-pdf {output_file}")
|
||||
if error:
|
||||
@@ -513,6 +521,10 @@ def generate_documents(
|
||||
# if not gems_asciidoctor_pdf.exists():
|
||||
# logger.error("Asciidoctor not installed!!")
|
||||
# sys.exit()
|
||||
output, error = run_command("bundle install --gemfile Gemfile --path mscp_gems --binstubs")
|
||||
if error:
|
||||
logger.error(f"Bundle install failed: {error}")
|
||||
sys.exit()
|
||||
|
||||
output, error = run_command(f"bundle exec asciidoctor-pdf {output_file}")
|
||||
if error:
|
||||
|
||||
Reference in New Issue
Block a user