Skip to content

Instantly share code, notes, and snippets.

@conorsch
Created March 17, 2021 22:27
Show Gist options
  • Save conorsch/261d71988744d6cab91ed0c502df8e11 to your computer and use it in GitHub Desktop.
Save conorsch/261d71988744d6cab91ed0c502df8e11 to your computer and use it in GitHub Desktop.
def test_spectre_meltdown_checker(host):
"""
Runs the "spectre-meltdown-checker" script to evaluate
vulnerability for CPU side-channel attacks.
"""
if not host.exists("/usr/bin/spectre-meltdown-checker"):
warnings.warn("Installing spectre-meltdown-checker to run CPU tests")
with host.sudo():
host.run("apt-get install -y spectre-meltdown-checker")
try:
with host.sudo():
stdout = host.check_output("spectre-meltdown-checker --batch json")
results = json.loads(stdout)
for result in results:
assert result["VULNERABLE"] == False
finally:
host.run("apt-get remove -y spectre-meltdown-checker")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment