Skip to content

Commit d8e5a77

Browse files
committed
Let generic-worker verify run-task/fetch-content integrity
The decision task knows the contents of these scripts so it can pass their checksums to downstream tasks.
1 parent 5143893 commit d8e5a77

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/taskgraph/transforms/run/run_task.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import dataclasses
99
import os
10+
from pathlib import Path
1011

1112
from voluptuous import Any, Optional, Required
1213

@@ -25,6 +26,9 @@
2526
"powershell": ["powershell.exe", "-ExecutionPolicy", "Bypass"],
2627
}
2728

29+
RUN_TASK_PATH = Path(__file__).parent.parent.parent / "run-task" / "run-task"
30+
FETCH_CONTENT_PATH = Path(__file__).parent.parent.parent / "run-task" / "fetch-content"
31+
2832
run_task_schema = Schema(
2933
{
3034
Required("using"): "run-task",
@@ -169,10 +173,14 @@ def generic_worker_run_task(config, task, taskdesc):
169173
common_setup(config, task, taskdesc, command)
170174

171175
worker.setdefault("mounts", [])
176+
run_task_sha256 = hashlib.sha256(RUN_TASK_PATH.read_bytes()).hexdigest()
177+
fetch_content_sha256 = hashlib.sha256(FETCH_CONTENT_PATH.read_bytes()).hexdigest()
172178
worker["mounts"].append(
173179
{
174180
"content": {
175-
"url": script_url(config, "run-task"),
181+
"taskId": {"task-reference": "<decision>"},
182+
"artifact": "public/run-task",
183+
"sha256": run_task_sha256,
176184
},
177185
"file": "./run-task",
178186
}
@@ -181,7 +189,9 @@ def generic_worker_run_task(config, task, taskdesc):
181189
worker["mounts"].append(
182190
{
183191
"content": {
184-
"url": script_url(config, "fetch-content"),
192+
"taskId": {"task-reference": "<decision>"},
193+
"artifact": "public/fetch-content",
194+
"sha256": fetch_content_sha256,
185195
},
186196
"file": "./fetch-content",
187197
}

0 commit comments

Comments
 (0)