Skip to content

Commit 447398b

Browse files
committed
measured boot: move to new failure architecture
Currently only has one event id. If necessary can be extended such that policies can generate their own event ids. Part of enhancement proposal keylime/enhancements#48 Signed-off-by: Thore Sommer <[email protected]>
1 parent aa91d02 commit 447398b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

keylime/measured_boot.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from keylime import config
1212
from keylime import keylime_logging
13-
13+
from keylime.failure import Failure, Component
1414
logger = keylime_logging.init_logging('measured_boot')
1515

1616
def read_mb_refstate(mb_path=None):
@@ -61,20 +61,23 @@ def get_policy(mb_refstate_str):
6161

6262
return mb_policy, mb_refstate_data
6363

64-
def evaluate_policy(mb_policy, mb_refstate_data, mb_measurement_data, pcrsInQuote, pcrPrefix, agent_id):
64+
def evaluate_policy(mb_policy, mb_refstate_data, mb_measurement_data, pcrsInQuote, pcrPrefix, agent_id) -> Failure:
65+
failure = Failure(Component.MEASURED_BOOT)
6566
missing = list(set(config.MEASUREDBOOT_PCRS).difference(pcrsInQuote))
6667
if len(missing) > 0:
6768
logger.error("%sPCRs specified for measured boot not in quote: %s", pcrPrefix, missing)
68-
return False
69+
failure.add_event("missing_pcrs", {"context": "PCRs are missing in quote", "data": missing}, True)
6970
try:
7071
reason = mb_policy.evaluate(mb_refstate_data, mb_measurement_data)
7172
except Exception as exn:
7273
reason= "policy evaluation failed: %s"%(str(exn))
7374
if reason:
7475
logger.error("Boot attestation failed for agent %s, configured policy %s, refstate=%s, reason=%s",
7576
agent_id, config.MEASUREDBOOT_POLICYNAME, json.dumps(mb_refstate_data), reason)
76-
return False
77-
return True
77+
failure.add_event("policy",
78+
{"context": "Boot attestation failed", "policy": config.MEASUREDBOOT_POLICYNAME,
79+
"refstate": mb_refstate_data, "reason": reason}, True)
80+
return failure
7881

7982
def main():
8083
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)