コード例 #1
0
def main():
    oscap_executable = sys.argv[1]

    xccdf = tempfile.NamedTemporaryFile()
    xccdf.write(svg_benchmark.encode("utf-8"))
    xccdf.flush()

    out = ssgcommon.subprocess_check_output(
        [oscap_executable, "xccdf", "generate", "guide",
         xccdf.name]).decode("utf-8")

    # check whether oscap threw away the SVG elements
    sys.exit(0 if "circle" in out else 1)
コード例 #2
0
def generate_guide_for_input_content(input_content, benchmark_id, profile_id):
    """Returns HTML guide for given input_content and profile_id
    combination. This function assumes only one Benchmark exists
    in given input_content!
    """

    args = [OSCAP_PATH, "xccdf", "generate", "guide"]
    if benchmark_id != "":
        args.extend(["--benchmark-id", benchmark_id])
    if profile_id != "":
        args.extend(["--profile", profile_id])
    args.append(input_content)

    return ssgcommon.subprocess_check_output(args).decode("utf-8")
コード例 #3
0
def generate_guide_for_input_content(input_content, benchmark_id, profile_id):
    """Returns HTML guide for given input_content and profile_id
    combination. This function assumes only one Benchmark exists
    in given input_content!
    """

    args = [OSCAP_PATH, "xccdf", "generate", "guide"]
    if benchmark_id != "":
        args.extend(["--benchmark-id", benchmark_id])
    if profile_id != "":
        args.extend(["--profile", profile_id])
    args.append(input_content)

    return ssgcommon.subprocess_check_output(args).decode("utf-8")
コード例 #4
0
def generate_role_for_input_content(input_content, benchmark_id, profile_id,
                                    template):
    """Returns remediation role for given input_content and profile_id
    combination. This function assumes only one Benchmark exists
    in given input_content!
    """

    args = [OSCAP_PATH, "xccdf", "generate", "fix"]
    # avoid validating the input over and over again for every profile
    args.append("--skip-valid")
    if benchmark_id != "":
        args.extend(["--benchmark-id", benchmark_id])
    if profile_id != "":
        args.extend(["--profile", profile_id])

    args.extend(["--template", template])
    args.append(input_content)

    return ssgcommon.subprocess_check_output(args).decode("utf-8")
コード例 #5
0
def generate_role_for_input_content(input_content, benchmark_id, profile_id,
                                    template):
    """Returns remediation role for given input_content and profile_id
    combination. This function assumes only one Benchmark exists
    in given input_content!
    """

    args = [OSCAP_PATH, "xccdf", "generate", "fix"]
    # avoid validating the input over and over again for every profile
    args.append("--skip-valid")
    if benchmark_id != "":
        args.extend(["--benchmark-id", benchmark_id])
    if profile_id != "":
        args.extend(["--profile", profile_id])

    args.extend(["--template", template])
    args.append(input_content)

    return ssgcommon.subprocess_check_output(args).decode("utf-8")