@ethernity-cloud/sdk-js 1.5.5 → 1.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,10 @@ class TaskStatus {
17
17
  static CONFIG_ERROR = 32;
18
18
  static EXECUTION_TIMEOUT = 33; // Started but produced no result within the order duration.
19
19
  static ESR_GAS_LIMIT_EXCEEDED = 34; // ESR commits would exceed the per-order relayed-gas budget.
20
+ static SECURITY_VIOLATION = 35; // A state commit was authorized under a caller other than
21
+ // the task's submitter (the in-enclave ownership check was
22
+ // bypassed). Set by the securelock on a detected forged
23
+ // caller, and by the trustedzone re-adjudication.
20
24
  }
21
25
 
22
26
  module.exports = {
@@ -115,6 +115,36 @@ try {
115
115
  process.exit(1);
116
116
  }
117
117
 
118
+ // Safety lint: flag dynamic code execution -- especially of task input --
119
+ // before the image is sealed. A hard error only for the case that actually
120
+ // opens the enclave to a submitter (eval / Function of ___etny_data_set___);
121
+ // everything else is a warning. See payloadLint.mjs for scope + opt-out.
122
+ try {
123
+ const { analyze } = await import('../payloadLint.mjs');
124
+ const src = fs.readFileSync(backendFile, 'utf8');
125
+ const { findings, optedOut } = analyze(src, 'src/serverless/backend.js');
126
+ if (!optedOut) {
127
+ const warnings = findings.filter((f) => f.severity === 'warning');
128
+ const errors = findings.filter((f) => f.severity === 'error');
129
+ for (const f of warnings) {
130
+ console.warn(`WARNING: src/serverless/backend.js:${f.line}: ${f.message}`);
131
+ }
132
+ if (errors.length) {
133
+ console.error('');
134
+ console.error('ERROR: unsafe dynamic execution of task input in src/serverless/backend.js:');
135
+ for (const f of errors) console.error(` line ${f.line}: ${f.message}`);
136
+ console.error('');
137
+ console.error(' This would let a task submitter run arbitrary code inside your enclave');
138
+ console.error(' and reach other users\' state. Fix it, or if the input is genuinely');
139
+ console.error(' trusted, add `// ecld: allow-eval` on that line to acknowledge the risk.');
140
+ process.exit(1);
141
+ }
142
+ }
143
+ } catch (e) {
144
+ // The lint is best-effort; never block a build on the linter itself failing.
145
+ console.warn(`WARNING: payload safety lint skipped (${e && e.message ? e.message : e})`);
146
+ }
147
+
118
148
  console.log(`Creating destination directory: ${destDir}`);
119
149
  fs.mkdirSync(destDir, { recursive: true });
120
150