@agimon-ai/po-workflow 0.0.0-alpha.106 → 0.0.0-alpha.108

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.
@@ -7415,6 +7415,36 @@ function failedExecution(error) {
7415
7415
  stop: async () => void 0
7416
7416
  };
7417
7417
  }
7418
+ const INPUT_TEMPLATE = /(?:\$\{\{|\{\{)[^}]*\binputs(?:\.|\[|\s)/u;
7419
+ const ENV_TEMPLATE = /(?:\$\{\{|\{\{)[^}]*\benv\.([^.}\s]+)/gu;
7420
+ /** Whether `value` expands an input into its text, directly or through an env key in `tainted`. */
7421
+ function expandsInput(value, tainted) {
7422
+ const text = JSON.stringify(value ?? null);
7423
+ return INPUT_TEMPLATE.test(text) || [...text.matchAll(ENV_TEMPLATE)].some((match) => tainted.has(match[1] ?? ""));
7424
+ }
7425
+ /**
7426
+ * Refuses a child job whose shell text would carry an input: a `run` that expands `inputs.*`, or
7427
+ * an `env.*` key whose job or step value does. Env values reach a command as its process
7428
+ * environment, never as command text, so an input there is safe until a `run` expands it.
7429
+ */
7430
+ function assertStaticChildShell(definition) {
7431
+ const jobTainted = /* @__PURE__ */ new Set();
7432
+ for (const [key, value] of Object.entries(definition.env ?? {})) if (expandsInput(value, jobTainted)) jobTainted.add(key);
7433
+ const check = (steps) => {
7434
+ for (const step of steps) {
7435
+ if (step.parallel) check(step.parallel);
7436
+ if (step.run === void 0) continue;
7437
+ const tainted = new Set(jobTainted);
7438
+ for (const [key, value] of Object.entries(step.env ?? {})) if (expandsInput(value, jobTainted)) tainted.add(key);
7439
+ if (expandsInput(step.run, tainted)) throw new Error("Child script inputs must arrive on stdin, never through shell interpolation.");
7440
+ }
7441
+ };
7442
+ check([
7443
+ ...definition.preJob?.steps ?? [],
7444
+ ...definition.steps,
7445
+ ...definition.postJob?.steps ?? []
7446
+ ]);
7447
+ }
7418
7448
  /**
7419
7449
  * Runs workflow steps inside Po instead of a shell.
7420
7450
  *
@@ -7437,21 +7467,7 @@ function createStepExecutor(dependencies) {
7437
7467
  const runtime = dependencies.runtime;
7438
7468
  const workflow = child.context.config.workflow;
7439
7469
  const parser = new WorkflowParserService(runtime);
7440
- const staticShell = (steps) => {
7441
- for (const step of steps) {
7442
- if (step.parallel) staticShell(step.parallel);
7443
- if (step.run !== void 0 && /(?:\$\{\{|\{\{)[^}]*\binputs(?:\.|\[|\s)/u.test(JSON.stringify({
7444
- run: step.run,
7445
- env: step.env,
7446
- jobEnv: child.definition.env
7447
- }))) throw new Error("Child script inputs must arrive on stdin, never through shell interpolation.");
7448
- }
7449
- };
7450
- staticShell([
7451
- ...child.definition.preJob?.steps ?? [],
7452
- ...child.definition.steps,
7453
- ...child.definition.postJob?.steps ?? []
7454
- ]);
7470
+ assertStaticChildShell(child.definition);
7455
7471
  const usages = [];
7456
7472
  const evidence = [];
7457
7473
  const logger = {
@@ -13576,4 +13592,4 @@ Object.defineProperty(exports, "workflowShellOutput", {
13576
13592
  }
13577
13593
  });
13578
13594
 
13579
- //# sourceMappingURL=RecoverWorkflowService-D3FAo5TS.cjs.map
13595
+ //# sourceMappingURL=RecoverWorkflowService-2WMhxaZd.cjs.map