Skip to content

Commit eb27383

Browse files
authored
Merge pull request #2317 from Mab879/fix_2309
Make autotailor use correct XML namespaces
2 parents 31f4b06 + 90a5870 commit eb27383

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

tests/utils/autotailor_integration_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www
2121
assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www_rule_R2"]/result[text()="pass"]'
2222
assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www_rule_R3"]/result[text()="pass"]'
2323
assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www_rule_R4"]/result[text()="notselected"]'
24+
grep "xccdf-1.2:" $tailoring
2425

2526
# select additional rules R3, R4
2627
python3 $autotailor --id-namespace "com.example.www" --select R3 --select R4 $ds $original_profile > $tailoring
@@ -136,4 +137,4 @@ assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www
136137
# use JSON tailoring (P11) with a new profile from the command line
137138
python3 $autotailor --id-namespace "com.example.www" --json-tailoring $json_tailoring --tailored-profile-id=CMDL_P --select R3 $ds $original_profile > $tailoring
138139
$OSCAP xccdf eval --profile CMDL_P --progress --tailoring-file $tailoring --results $result $ds
139-
assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www_rule_R3"]/result[text()="pass"]'
140+
assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www_rule_R3"]/result[text()="pass"]'

utils/autotailor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import json
2929

3030

3131
NS = "http://checklists.nist.gov/xccdf/1.2"
32+
NS_PREFIX = "xccdf-1.2"
3233
DEFAULT_PROFILE_SUFFIX = "_customized"
3334
DEFAULT_REVERSE_DNS = "org.ssgproject.content"
3435
ROLES = ["full", "unscored", "unchecked"]
@@ -440,6 +441,8 @@ if __name__ == "__main__":
440441
parser = get_parser()
441442
args = parser.parse_args()
442443

444+
ET.register_namespace(NS_PREFIX, NS)
445+
443446
if not args.profile and not args.json_tailoring:
444447
parser.error("one of the following arguments has to be provided: "
445448
"BASE_PROFILE_ID or --json-tailoring JSON_TAILORING_FILENAME")

0 commit comments

Comments
 (0)