Skip to content

Commit f759627

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 f759627

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/taskgraph/transforms/run/run_task.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"""
77

88
import dataclasses
9+
import hashlib
910
import os
11+
from pathlib import Path
1012

1113
from voluptuous import Any, Optional, Required
1214

@@ -25,6 +27,9 @@
2527
"powershell": ["powershell.exe", "-ExecutionPolicy", "Bypass"],
2628
}
2729

30+
RUN_TASK_PATH = Path(__file__).parent.parent.parent / "run-task" / "run-task"
31+
FETCH_CONTENT_PATH = Path(__file__).parent.parent.parent / "run-task" / "fetch-content"
32+
2833
run_task_schema = Schema(
2934
{
3035
Required("using"): "run-task",
@@ -169,10 +174,14 @@ def generic_worker_run_task(config, task, taskdesc):
169174
common_setup(config, task, taskdesc, command)
170175

171176
worker.setdefault("mounts", [])
177+
run_task_sha256 = hashlib.sha256(RUN_TASK_PATH.read_bytes()).hexdigest()
178+
fetch_content_sha256 = hashlib.sha256(FETCH_CONTENT_PATH.read_bytes()).hexdigest()
172179
worker["mounts"].append(
173180
{
174181
"content": {
175-
"url": script_url(config, "run-task"),
182+
"taskId": {"task-reference": "<decision>"},
183+
"artifact": "public/run-task",
184+
"sha256": run_task_sha256,
176185
},
177186
"file": "./run-task",
178187
}
@@ -181,7 +190,9 @@ def generic_worker_run_task(config, task, taskdesc):
181190
worker["mounts"].append(
182191
{
183192
"content": {
184-
"url": script_url(config, "fetch-content"),
193+
"taskId": {"task-reference": "<decision>"},
194+
"artifact": "public/fetch-content",
195+
"sha256": fetch_content_sha256,
185196
},
186197
"file": "./fetch-content",
187198
}

0 commit comments

Comments
 (0)