Skip to content

Commit

Permalink
[python] Restore old trusted files syntax support
Browse files Browse the repository at this point in the history
"sgx.trusted_files.key = value" syntax is deprecated, but still
supported.

Signed-off-by: Borys Popławski <borysp@invisiblethingslab.com>
  • Loading branch information
boryspoplawski committed Oct 3, 2021
1 parent 8209523 commit 601fb00
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions python/graminelibos/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import hashlib
import pathlib
import sys

import toml

Expand Down Expand Up @@ -82,15 +83,31 @@ def __init__(self, manifest_str):
loader = manifest.setdefault('loader', {})
loader.setdefault('preload', '')

# TODO: uncomment once we drop the old syntax support completely.
#if not isinstance(sgx['trusted_files'], list):
# raise ValueError("Unsupported trusted files syntax, more info: " +
# "https://gramine.readthedocs.io/en/latest/manifest-syntax.html#trusted-files")

# Current toml versions (< 1.0) do not support non-homogeneous arrays
trusted_files = []
for tf in sgx['trusted_files']:
if isinstance(tf, dict):
trusted_files.append(tf)
elif isinstance(tf, str):
append_tf(trusted_files, tf, None)
else:
raise ValueError(f'Unknown trusted file format: {tf!r}')
if isinstance(sgx['trusted_files'], dict):
# Old, deprecated syntax "sgx.trusted_files.key = value".
print("This trusted files syntax is deprecated, please move to the new one: " +
"https://gramine.readthedocs.io/en/latest/manifest-syntax.html#trusted-files",
file=sys.stderr)
for _, tf in sgx['trusted_files'].items():
if isinstance(tf, str):
append_tf(trusted_files, tf, None)
else:
raise ValueError(f'Unknown trusted file format: {tf!r}')
else:
for tf in sgx['trusted_files']:
if isinstance(tf, dict) and 'uri' in tf:
trusted_files.append(tf)
elif isinstance(tf, str):
append_tf(trusted_files, tf, None)
else:
raise ValueError(f'Unknown trusted file format: {tf!r}')

sgx['trusted_files'] = trusted_files

Expand Down

0 comments on commit 601fb00

Please sign in to comment.