Skip to content

Commit 49604b5

Browse files
authored
Fix false positive in scs-0101-fips-test (#1225)
Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent e722038 commit 49604b5

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

Tests/iaas/scs_0101_entropy/entropy_check.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,28 +127,28 @@ def compute_scs_0101_rngd(collected_vm_output, image_name):
127127
def compute_scs_0101_fips_test(collected_vm_output, image_name):
128128
"""This test ensures that the 'fips test' via `rngtest` is passed on a test VM."""
129129
lines = collected_vm_output['fips-test']
130-
try:
131-
fips_data = '\n'.join(lines)
132-
failure_re = re.search(r'failures:\s\d+', fips_data, flags=re.MULTILINE)
133-
if failure_re:
134-
fips_failures = failure_re.string[failure_re.regs[0][0]:failure_re.regs[0][1]].split(" ")[1]
135-
if int(fips_failures) <= 3:
136-
return True # strict test passed
137-
logger.info(
138-
f"VM '{image_name}' didn't pass the strict FIPS 140-2 testing. "
139-
f"Expected a maximum of 3 failures, got {fips_failures}."
140-
)
141-
if int(fips_failures) <= 5:
142-
return True # lenient test passed
143-
logger.error(
144-
f"VM '{image_name}' didn't pass the FIPS 140-2 testing. "
145-
f"Expected a maximum of 5 failures, got {fips_failures}."
146-
)
147-
else:
148-
logger.error(f"VM '{image_name}': failed to determine fips failures")
149-
logger.debug(f"stderr following:\n{fips_data}")
150-
except BaseException:
151-
logger.critical(f"Couldn't check VM '{image_name}' requirements", exc_info=True)
130+
fips_data = '\n'.join(lines)
131+
failure_re = re.search(r'failures:\s\d+', fips_data, flags=re.MULTILINE)
132+
if not failure_re:
133+
# It seems possible that 'failures: 0' is just omitted, and we could check for
134+
# 'successes: 1000' to verify that, but I have observed this only once in many
135+
# many runs over multiple years. I'm inclined to label this 'inconclusive'
136+
# instead of making the code more complex and risking false certainty.
137+
logger.debug(f"failed to determine fips failures; stderr following:\n{fips_data}")
138+
raise RuntimeError(f"VM '{image_name}': failed to determine fips failures")
139+
fips_failures = failure_re.string[failure_re.regs[0][0]:failure_re.regs[0][1]].split(" ")[1]
140+
if int(fips_failures) <= 3:
141+
return True # strict test passed
142+
logger.info(
143+
f"VM '{image_name}' didn't pass the strict FIPS 140-2 testing. "
144+
f"Expected a maximum of 3 failures, got {fips_failures}."
145+
)
146+
if int(fips_failures) <= 5:
147+
return True # lenient test passed
148+
logger.error(
149+
f"VM '{image_name}' didn't pass the FIPS 140-2 testing. "
150+
f"Expected a maximum of 5 failures, got {fips_failures}."
151+
)
152152
return False # any unsuccessful path should end up here
153153

154154

0 commit comments

Comments
 (0)