Conditions | 6 |
Total Lines | 34 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | #!/usr/bin/env python |
||
13 | def main(): |
||
14 | """ |
||
15 | Walk through all known products in the ssg root specified in sys.argv[1], |
||
16 | and ensure that all ovals in all rule directories are parsable under |
||
17 | ssg.oval.parse_affected(...). |
||
18 | """ |
||
19 | |||
20 | if len(sys.argv) != 2: |
||
21 | print("Error! Must supply only path to root of ssg directory", |
||
22 | file=sys.stderr) |
||
23 | sys.exit(1) |
||
24 | |||
25 | ssg_root = sys.argv[1] |
||
26 | |||
27 | guide_dirs = set() |
||
28 | for product in ssg.constants.product_directories: |
||
29 | product_dir = os.path.join(ssg_root, product) |
||
30 | product_yaml_path = os.path.join(product_dir, "product.yml") |
||
31 | product_yaml = ssg.yaml.open_raw(product_yaml_path) |
||
32 | |||
33 | guide_dir = os.path.join(product_dir, product_yaml['benchmark_root']) |
||
34 | if guide_dir in guide_dirs: |
||
35 | continue |
||
36 | |||
37 | for rule_dir in ssg.rules.find_rule_dirs(guide_dir): |
||
38 | for oval in ssg.rules.get_rule_dir_ovals(rule_dir): |
||
39 | oval_contents = ssg.utils.read_file_list(oval) |
||
40 | results = ssg.oval.parse_affected(oval_contents) |
||
41 | |||
42 | assert len(results) == 3 |
||
43 | assert isinstance(results[0], int) |
||
44 | assert isinstance(results[1], int) |
||
45 | |||
46 | guide_dirs.add(guide_dir) |
||
47 | |||
51 |