Example #1
0
def any_test_transformation_tree_to_Json_for_JsTree(
        src, test_data_src, rule_id):
    test_data = any_get_test_data_json(test_data_src)

    parser = XmlParser(get_src(src))
    oval_tree = parser.get_oval_tree(rule_id)

    assert oval_tree.node_id == rule_id
    out_data = Converter(oval_tree).to_js_tree_dict()
    assert out_data == test_data
from oval_graph.xml_parser import XmlParser
import time

rule = 'xccdf_org.ssgproject.content_rule_enable_fips_mode'
src = 'tests/test_data/[email protected]'

print("Benchmark xml to oval_tree")
print("Start process rule: ", rule)
print("report-xml: ", src)
start_time = time.time()

xml_parser = XmlParser(src)
oval_tree = xml_parser.get_oval_tree(rule)

print(
    "rule xccdf_org.ssgproject.content_rule_enable_fips_mode --- %s seconds ---"
    % (time.time() - start_time))

print("Start process all rules")
print("report-xml: ", src)
start_time_all_rules = time.time()

xml_parser_all_rules = XmlParser(src)
try:
    for rule in xml_parser_all_rules.used_rules:
        oval_tree = xml_parser_all_rules.get_oval_tree(rule['id_rule'])
    print("%d rules --- %s seconds ---" % (len(
        xml_parser_all_rules.used_rules), time.time() - start_time_all_rules))
except AttributeError:
    for rule in xml_parser_all_rules.get_used_rules():
        oval_tree = xml_parser_all_rules.get_oval_tree(rule['id_rule'])
Example #3
0
from oval_graph.xml_parser import XmlParser
import time

rule = 'xccdf_org.ssgproject.content_rule_enable_fips_mode'
src = 'tests/test_data/[email protected]'

print("Benchmark xml to oval_tree")
print("Start process rule: ", rule)
print("report-xml: ", src)
start_time = time.time()

xml_parser = XmlParser(src)
oval_tree = xml_parser.get_oval_tree(rule)

print(
    "rule xccdf_org.ssgproject.content_rule_enable_fips_mode --- %s seconds ---"
    % (time.time() - start_time))

print("Start process all rules")
print("report-xml: ", src)
start_time_all_rules = time.time()

xml_parser_all_rules = XmlParser(src)

for rule in xml_parser_all_rules.used_rules:
    oval_tree = xml_parser_all_rules.get_oval_tree(rule)
print(
    "%d rules --- %s seconds ---" %
    (len(xml_parser_all_rules.used_rules), time.time() - start_time_all_rules))
Example #4
0
def any_test_parsing_and_evaluate_scan_rule(src, rule_id, result):
    parser = XmlParser(get_src(src))
    oval_tree = parser.get_oval_tree(rule_id)
    any_test_treeEvaluation(oval_tree, result)