Skip to content

Commit d2c2d59

Browse files
authored
policy match, client timeout config value validation (#135)
1 parent 9e85253 commit d2c2d59

File tree

9 files changed

+31
-10
lines changed

9 files changed

+31
-10
lines changed

.github/workflows/onmergerelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Setup Python
4343
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
4444
with:
45-
python-version: '3.8.10'
45+
python-version: '3.9'
4646

4747
- name: Install Poetry
4848
run: pip install poetry==1.7.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The Python client currently supports the following TEEs:
2525

2626
## System requirement
2727

28-
- Python 3.8 or newer.
28+
- Python 3.9 or newer.
2929
- Ubuntu 22.04 with *kernel 6.7 or later,* or Ubuntu 24.04. Support for the ConfigFS-TSM subsystem is required for Intel TDX attestation.
3030

3131
## Installation

inteltrustauthorityclient/cli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For more information, see [GPU Remote Attestation](https://docs.trustauthority.i
1313

1414
The following prerequisites must be installed on the CVM (Confidential VM with Intel TDX):
1515

16-
- Use **Python 3.8 or newer**.
16+
- Use **Python 3.9 or newer**.
1717
- Ubuntu 22.04 with *kernel 6.7 or later,* or Ubuntu 24.04. Support for the ConfigFS-TSM subsystem is required for Intel TDX attestation.
1818
- NVIDIA H100 GPU
1919
- [NVIDIA Attestation SDK v1.4.0](https://github.com/NVIDIA/nvtrust/releases/tag/v1.4.0) installed in the guest TD. NVIDIA Attestation SDK v2.x is _not_ supported.

inteltrustauthorityclient/connector/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,13 @@ def validate_apikey(api_key):
139139
return True
140140
except binascii.Error as exc:
141141
log.error(f"Error in apikey validation :{exc}, API key must be a valid Base64 Encoded string")
142+
143+
def validate_policymustmatch(policy_must_match):
144+
# policy_must_match should be a boolean value
145+
if policy_must_match is None:
146+
return False
147+
if isinstance(policy_must_match, str):
148+
if policy_must_match.lower() in {"true", "false"}:
149+
return True if policy_must_match.lower() == "true" else False
150+
log.error("Unsupported Policy Must Match value provided, supported values are true/false")
151+
return -1

inteltrustauthorityclient/examples/sgx_sample_app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Begin by copying the Intel Trust Authority Client for Python repository to a loc
160160

161161
#### Prerequisites
162162

163-
- Python 3.8 or later
163+
- Python 3.9 or later
164164
- Poetry. You can install **poetry** using the command `pip3 install --no-cache-dir poetry`.
165165
- An Intel SGX host with the Intel SGX driver.
166166
- A subscription to Intel Trust Authority. If you don't have a subscription, you can find out how to get one at [Intel Trust Authority](https://trustauthority.intel.com).

inteltrustauthorityclient/examples/sgx_sample_app/sgx_sample_app.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,17 @@ def main():
155155
"CLIENT_TIMEOUT_SEC is not provided. Hence, setting to default value."
156156
)
157157
timeout_second = const.DEFAULT_CLIENT_TIMEOUT_SEC
158+
else:
159+
if not timeout_second.isnumeric():
160+
log.error("Invalid CLIENT_TIMEOUT_SEC format: CLIENT_TIMEOUT_SEC must be an Integer.")
161+
exit(1)
158162

159163
token_signing_algorithm = os.getenv("TOKEN_SIGNING_ALGORITHM")
160164
policy_must_match = os.getenv("POLICY_MUST_MATCH")
161-
if policy_must_match is not None and policy_must_match.lower() in {"true", "false"}:
162-
policy_must_match = True if policy_must_match.lower() == "true" else False
165+
policy_must_match = config.validate_policymustmatch(policy_must_match)
166+
if policy_must_match == -1:
167+
exit(1)
168+
163169
# enclave related work
164170
enclave_path = "./minimal-enclave/enclave.signed.so"
165171
eid = create_sgx_enclave(enclave_path)

inteltrustauthorityclient/examples/tdx_sample_app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ If the sample application runs successfully, the attestation token returned from
158158

159159
#### Prerequisites
160160

161-
- Python 3.8 or later
161+
- Python 3.9 or later
162162
- Poetry. Install **poetry** using the command `pip3 install --no-cache-dir poetry`.
163163
- An Intel TDX TD VM running on a local Intel TDX host or as a confidential VM in the cloud.
164164
- A subscription to Intel Trust Authority. If you don't have a subscription, you can find out how to get one at [Intel Trust Authority](https://trustauthority.intel.com).

inteltrustauthorityclient/examples/tdx_sample_app/tdx_sample_app.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ def main():
101101
"CLIENT_TIMEOUT_SEC is not provided. Hence, setting to default value."
102102
)
103103
timeout_second = const.DEFAULT_CLIENT_TIMEOUT_SEC
104+
else:
105+
if not timeout_second.isnumeric():
106+
log.error("Invalid CLIENT_TIMEOUT_SEC format: CLIENT_TIMEOUT_SEC must be an Integer.")
107+
exit(1)
104108

105109
token_signing_algorithm = os.getenv("TOKEN_SIGNING_ALGORITHM")
106110
policy_must_match = os.getenv("POLICY_MUST_MATCH")
107-
if policy_must_match is not None and policy_must_match.lower() in {"true", "false"}:
108-
policy_must_match = True if policy_must_match.lower() == "true" else False
111+
policy_must_match = config.validate_policymustmatch(policy_must_match)
112+
if policy_must_match == -1:
113+
exit(1)
109114

110115
try:
111116
# Populate config object

inteltrustauthorityclient/nvgpu/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For more information, see [GPU Remote Attestation](https://docs.trustauthority.i
1414

1515
The following prerequisites must be installed on the CVM (Confidential VM with Intel TDX):
1616

17-
- Use **Python 3.8 or newer**.
17+
- Use **Python 3.9 or newer**.
1818
- Ubuntu 22.04 with *kernel 6.7 or later,* or Ubuntu 24.04. Support for the ConfigFS-TSM subsystem is required for Intel TDX attestation.
1919
- NVIDIA H100 GPU
2020
- NVIDIA Management Library (NVML). Install NVML by running the following command on the CVM after Python is installed: `pip install nvidia-ml-py`.

0 commit comments

Comments
 (0)