Skip to content

Commit ad92b52

Browse files
committed
Fix empty value handling in get_variable_values
If an XCCDF Value doesn't have any value but has a selector, we should use the actual selector name. It seems the variable name holding the selector name was accidentally quoted so instead of the actual selector name we got "selector" literally.
1 parent 7a233f5 commit ad92b52

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

build-scripts/generate_profile_remediations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_variable_values(variable):
129129
if selector is None:
130130
selector = DEFAULT_SELECTOR
131131
if value.text is None:
132-
values["selector"] = ""
132+
values[selector] = ""
133133
else:
134134
values[selector] = value.text
135135
return values

tests/unit/build-scripts/test_generate_profile_remediations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,9 @@ def test_get_variable_values_empty_text():
256256
)
257257
variable = ET.fromstring(xml)
258258
result = gpr.get_variable_values(variable)
259-
# When value.text is None, the code sets values["selector"] = ""
260-
assert "selector" in result
259+
# When value.text is None, the code sets values[selector] = ""
260+
assert "empty" in result
261+
assert result["empty"] == ""
261262

262263

263264
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)