require target_exe to be a canonicalized relative path (#613)

This commit is contained in:
bmc-msft 2021-03-02 19:06:02 -05:00 committed by GitHub
parent 4489036d9f
commit 04fc41597e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,9 @@
# Licensed under the MIT License.
import logging
import ntpath
import os
import posixpath
from typing import Dict, List, Optional
from uuid import UUID
@ -102,6 +104,16 @@ def check_target_exe(config: TaskConfig, definition: TaskDefinition) -> None:
return
# Azure Blob Store uses virtualized directory structures. As such, we need
# the paths to already be canonicalized. As an example, accessing the blob
# store path "./foo" generates an exception, but "foo" and "foo/bar" do
# not.
if (
posixpath.relpath(config.task.target_exe) != config.task.target_exe
or ntpath.relpath(config.task.target_exe) != config.task.target_exe
):
raise TaskConfigError("target_exe must be a canonicalized relative path")
container = [x for x in config.containers if x.type == ContainerType.setup][0]
if not blob_exists(container.name, config.task.target_exe, StorageType.corpus):
err = "target_exe `%s` does not exist in the setup container `%s`" % (