Skip to content

Commit 63da37f

Browse files
Release/sdk v2.0.0 beta.11 (#391)
## [2.0.0-beta.11] ### Added - Added `allowDebug` option for `protectData` to allow using the protected data in TEE debug apps (default `false`)
2 parents 3a3b3b3 + 8dc71a0 commit 63da37f

File tree

15 files changed

+599
-183
lines changed

15 files changed

+599
-183
lines changed

packages/sdk/.drone.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,36 @@ steps:
226226
depends_on:
227227
- sms
228228

229+
- name: sms-debug
230+
image: iexechub/iexec-sms:7.1.0
231+
detach: true
232+
environment:
233+
TZ: Europe/Paris
234+
IEXEC_SMS_BLOCKCHAIN_NODE_ADDRESS: http://bellecour-fork:8545
235+
IEXEC_HUB_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f'
236+
IEXEC_TEE_WORKER_PRE_COMPUTE_IMAGE: docker.io/iexechub/tee-worker-pre-compute:7.1.0-sconify-5.3.15-debug
237+
IEXEC_TEE_WORKER_PRE_COMPUTE_FINGERPRINT: 9f0f782d6edc611baa23ca0978f555ee58ea70e092640c961e75c25e9e4b0f22
238+
IEXEC_TEE_WORKER_PRE_COMPUTE_HEAP_SIZE_GB: 4
239+
IEXEC_TEE_WORKER_POST_COMPUTE_IMAGE: docker.io/iexechub/tee-worker-post-compute:7.1.1-sconify-5.3.15-debug
240+
IEXEC_TEE_WORKER_POST_COMPUTE_FINGERPRINT: face1376b97131e2dc75a556381d47a2e03bed9e1bc11e462471f99d1eefae50
241+
IEXEC_TEE_WORKER_POST_COMPUTE_HEAP_SIZE_GB: 4
242+
IEXEC_IGNORED_SGX_ADVISORIES: INTEL-SA-00161,INTEL-SA-00289,INTEL-SA-00334,INTEL-SA-00381,INTEL-SA-00389,INTEL-SA-00220,INTEL-SA-00270,INTEL-SA-00293,INTEL-SA-00320,INTEL-SA-00329,INTEL-SA-00477
243+
IEXEC_SCONE_TOLERATED_INSECURE_OPTIONS: debug-mode,hyperthreading,outdated-tcb
244+
IEXEC_SMS_DISPLAY_DEBUG_SESSION: 'true'
245+
IEXEC_SCONE_CAS_HOST: foo
246+
IEXEC_SMS_IMAGE_LAS_IMAGE: foo
247+
expose:
248+
- 13300
249+
depends_on:
250+
- bellecour-fork-healthy
251+
252+
- name: sms-debug-healthy
253+
image: bash
254+
commands:
255+
- while ! nc -z sms-debug 13300 ; do sleep 1 ; done && echo "sms-debug ready"
256+
depends_on:
257+
- sms-debug
258+
229259
- name: result-proxy
230260
image: iexechub/iexec-result-proxy:7.1.0
231261
detach: true
@@ -329,6 +359,7 @@ steps:
329359
depends_on:
330360
- bellecour-fork-healthy
331361
- sms-healthy
362+
- sms-debug-healthy
332363
- result-proxy-healthy
333364
- market-api-healthy
334365
- ipfs-healthy

packages/sdk/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## Next
5+
## [2.0.0-beta.11] (2025-01-29)
6+
7+
### Added
8+
9+
- Added `allowDebug` option for `protectData` to allow using the protected data in TEE debug apps (default `false`)
610

711
### Changed
812

packages/sdk/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iexec/dataprotector",
3-
"version": "2.0.0-beta.10",
3+
"version": "2.0.0-beta.11",
44
"description": "This product enables users to confidentially store data–such as mail address, documents, personal information ...",
55
"type": "module",
66
"types": "dist/src/index.d.ts",

packages/sdk/src/config/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export const DEFAULT_SHARING_CONTRACT_ADDRESS =
1515
export const DEFAULT_SUBGRAPH_URL =
1616
'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector-v2';
1717

18+
export const DEFAULT_DEBUG_SMS_URL =
19+
'https://sms.scone-debug.v8-bellecour.iex.ec';
20+
1821
export const WORKERPOOL_ADDRESS = 'prod-v8-bellecour.main.pools.iexec.eth';
1922

2023
export const SCONE_TAG = ['tee', 'scone'];

packages/sdk/src/lib/IExecDataProtectorModule.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { GraphQLClient } from 'graphql-request';
33
import { IExec } from 'iexec';
44
import {
55
DEFAULT_CONTRACT_ADDRESS,
6+
DEFAULT_DEBUG_SMS_URL,
67
DEFAULT_IEXEC_IPFS_NODE,
78
DEFAULT_IPFS_GATEWAY,
89
DEFAULT_SHARING_CONTRACT_ADDRESS,
@@ -27,6 +28,8 @@ abstract class IExecDataProtectorModule {
2728

2829
protected iexec: IExec;
2930

31+
protected iexecDebug: IExec;
32+
3033
constructor(
3134
ethProvider?:
3235
| AbstractProvider
@@ -46,6 +49,14 @@ abstract class IExecDataProtectorModule {
4649
...options?.iexecOptions,
4750
}
4851
);
52+
this.iexecDebug = new IExec(
53+
{ ethProvider: ethProvider || 'bellecour' },
54+
{
55+
ipfsGatewayURL: ipfsGateway,
56+
...options?.iexecOptions,
57+
smsURL: options?.iexecOptions?.smsDebugURL || DEFAULT_DEBUG_SMS_URL,
58+
}
59+
);
4960
} catch (e) {
5061
throw new Error(`Unsupported ethProvider, ${e.message}`);
5162
}

packages/sdk/src/lib/dataProtectorCore/IExecDataProtectorCore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class IExecDataProtectorCore extends IExecDataProtectorModule {
3636
ipfsNode: this.ipfsNode,
3737
ipfsGateway: this.ipfsGateway,
3838
iexec: this.iexec,
39+
iexecDebug: this.iexecDebug,
3940
});
4041
}
4142

packages/sdk/src/lib/dataProtectorCore/protectData.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111
handleIfProtocolError,
1212
WorkflowError,
1313
} from '../../utils/errors.js';
14-
import { getLogger } from '../../utils/logger.js';
1514
import { getEventFromLogs } from '../../utils/getEventFromLogs.js';
15+
import { getLogger } from '../../utils/logger.js';
1616
import {
1717
stringSchema,
1818
throwIfMissing,
@@ -30,6 +30,7 @@ import {
3030
import {
3131
DataProtectorContractConsumer,
3232
IExecConsumer,
33+
IExecDebugConsumer,
3334
} from '../types/internalTypes.js';
3435
import { getDataProtectorCoreContract } from './smartContract/getDataProtectorCoreContract.js';
3536

@@ -39,13 +40,16 @@ export type ProtectData = typeof protectData;
3940

4041
export const protectData = async ({
4142
iexec = throwIfMissing(),
43+
iexecDebug = throwIfMissing(),
4244
dataprotectorContractAddress,
4345
name = DEFAULT_DATA_NAME,
4446
ipfsNode,
4547
ipfsGateway,
48+
allowDebug = false,
4649
data,
4750
onStatusUpdate = () => {},
4851
}: IExecConsumer &
52+
IExecDebugConsumer &
4953
DataProtectorContractConsumer &
5054
IpfsNodeAndGateway &
5155
ProtectDataParams): Promise<ProtectedDataWithSecretProps> => {
@@ -244,6 +248,35 @@ export const protectData = async ({
244248
},
245249
});
246250

251+
if (allowDebug === true) {
252+
// share secret with scone debug SMS
253+
vOnStatusUpdate({
254+
title: 'PUSH_SECRET_TO_DEBUG_SMS',
255+
isDone: false,
256+
payload: {
257+
teeFramework: 'scone',
258+
},
259+
});
260+
await iexecDebug.dataset
261+
.pushDatasetSecret(protectedDataAddress, encryptionKey, {
262+
teeFramework: 'scone',
263+
})
264+
.catch((e: Error) => {
265+
handleIfProtocolError(e);
266+
throw new WorkflowError({
267+
message: 'Failed to push protected data encryption key',
268+
errorCause: e,
269+
});
270+
});
271+
vOnStatusUpdate({
272+
title: 'PUSH_SECRET_TO_DEBUG_SMS',
273+
isDone: true,
274+
payload: {
275+
teeFramework: 'scone',
276+
},
277+
});
278+
}
279+
247280
return {
248281
name,
249282
address: protectedDataAddress,

packages/sdk/src/lib/types/commonTypes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,14 @@ export type DataProtectorConfigOptions = {
6969
* Options specific to iExec integration.
7070
* If not provided, default iexec options will be used.
7171
*/
72-
iexecOptions?: IExecConfigOptions;
72+
iexecOptions?: IExecConfigOptionsExtended;
7373
};
7474

75+
interface IExecConfigOptionsExtended extends IExecConfigOptions {
76+
// adds smsDebugURL to possible options, used ton configure an IExec debug instance seamlessly (no JS doc test purpose only)
77+
smsDebugURL?: string;
78+
}
79+
7580
// ---------------------ProtectedData Schema Types------------------------------------
7681
export type MimeType =
7782
| 'application/octet-stream'

packages/sdk/src/lib/types/coreTypes.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export type ProtectDataStatuses =
4040
| 'ENCRYPT_FILE'
4141
| 'UPLOAD_ENCRYPTED_FILE'
4242
| 'DEPLOY_PROTECTED_DATA'
43-
| 'PUSH_SECRET_TO_SMS';
43+
| 'PUSH_SECRET_TO_SMS'
44+
| 'PUSH_SECRET_TO_DEBUG_SMS';
4445

4546
export type OneProtectDataStatus = {
4647
title: ProtectDataStatuses;
@@ -61,6 +62,16 @@ export type ProtectDataParams = {
6162
*/
6263
name?: string;
6364

65+
/**
66+
* allow to use the protected data in TEE debug apps (default `false`)
67+
*
68+
* ⚠️ TEE debug apps runs in enclave simulation mode which does not prevent the worker host to inspect data or temper the app output.
69+
* You should never set this parameter to `true` with real data, use it for development purpose only.
70+
*
71+
* setting this parameter to `true` adds a signature request to the protectData workflow, this signature is used to push the protected data encryption key to the debug Secret Management System
72+
*/
73+
allowDebug?: boolean;
74+
6475
/**
6576
* Callback function that will get called at each step of the process
6677
*/

0 commit comments

Comments
 (0)