mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-15 11:28:09 +00:00
expose supervisor tasks that are fully self-contained fuzzing tasks in the service (#474)
Exposes the functionality added in #454 to the service & CLI. Fixes #439
This commit is contained in:
@ -1378,10 +1378,7 @@ Each event will be submitted via HTTP POST to the user provided URL.
|
|||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"type",
|
"type",
|
||||||
"duration",
|
"duration"
|
||||||
"target_exe",
|
|
||||||
"target_env",
|
|
||||||
"target_options"
|
|
||||||
],
|
],
|
||||||
"title": "TaskDetails",
|
"title": "TaskDetails",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
@ -2761,10 +2758,7 @@ Each event will be submitted via HTTP POST to the user provided URL.
|
|||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"type",
|
"type",
|
||||||
"duration",
|
"duration"
|
||||||
"target_exe",
|
|
||||||
"target_env",
|
|
||||||
"target_options"
|
|
||||||
],
|
],
|
||||||
"title": "TaskDetails",
|
"title": "TaskDetails",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
|
@ -92,6 +92,25 @@ def check_containers(definition: TaskDefinition, config: TaskConfig) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def check_target_exe(config: TaskConfig, definition: TaskDefinition) -> None:
|
||||||
|
if config.task.target_exe is None:
|
||||||
|
if TaskFeature.target_exe in definition.features:
|
||||||
|
raise TaskConfigError("missing target_exe")
|
||||||
|
|
||||||
|
if TaskFeature.target_exe_optional in definition.features:
|
||||||
|
return
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
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`" % (
|
||||||
|
config.task.target_exe,
|
||||||
|
container.name,
|
||||||
|
)
|
||||||
|
LOGGER.warning(err)
|
||||||
|
|
||||||
|
|
||||||
def check_config(config: TaskConfig) -> None:
|
def check_config(config: TaskConfig) -> None:
|
||||||
if config.task.type not in TASK_DEFINITIONS:
|
if config.task.type not in TASK_DEFINITIONS:
|
||||||
raise TaskConfigError("unsupported task type: %s" % config.task.type.name)
|
raise TaskConfigError("unsupported task type: %s" % config.task.type.name)
|
||||||
@ -132,14 +151,7 @@ def check_config(config: TaskConfig) -> None:
|
|||||||
else:
|
else:
|
||||||
raise TaskConfigError("either the vm or pool must be specified")
|
raise TaskConfigError("either the vm or pool must be specified")
|
||||||
|
|
||||||
if TaskFeature.target_exe in definition.features:
|
check_target_exe(config, definition)
|
||||||
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`" % (
|
|
||||||
config.task.target_exe,
|
|
||||||
container.name,
|
|
||||||
)
|
|
||||||
LOGGER.warning(err)
|
|
||||||
|
|
||||||
if TaskFeature.generator_exe in definition.features:
|
if TaskFeature.generator_exe in definition.features:
|
||||||
container = [x for x in config.containers if x.type == ContainerType.tools][0]
|
container = [x for x in config.containers if x.type == ContainerType.tools][0]
|
||||||
@ -253,6 +265,12 @@ def build_task_config(
|
|||||||
if TaskFeature.target_exe in definition.features:
|
if TaskFeature.target_exe in definition.features:
|
||||||
config.target_exe = "setup/%s" % task_config.task.target_exe
|
config.target_exe = "setup/%s" % task_config.task.target_exe
|
||||||
|
|
||||||
|
if (
|
||||||
|
TaskFeature.target_exe_optional in definition.features
|
||||||
|
and task_config.task.target_exe
|
||||||
|
):
|
||||||
|
config.target_exe = "setup/%s" % task_config.task.target_exe
|
||||||
|
|
||||||
if TaskFeature.target_env in definition.features:
|
if TaskFeature.target_env in definition.features:
|
||||||
config.target_env = task_config.task.target_env or EMPTY_DICT
|
config.target_env = task_config.task.target_env or EMPTY_DICT
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ TASK_DEFINITIONS = {
|
|||||||
),
|
),
|
||||||
ContainerDefinition(
|
ContainerDefinition(
|
||||||
type=ContainerType.tools,
|
type=ContainerType.tools,
|
||||||
compare=Compare.Equal,
|
compare=Compare.AtMost,
|
||||||
value=1,
|
value=1,
|
||||||
permissions=[ContainerPermission.Read, ContainerPermission.List],
|
permissions=[ContainerPermission.Read, ContainerPermission.List],
|
||||||
),
|
),
|
||||||
@ -252,6 +252,36 @@ TASK_DEFINITIONS = {
|
|||||||
ContainerPermission.List,
|
ContainerPermission.List,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
ContainerDefinition(
|
||||||
|
type=ContainerType.unique_reports,
|
||||||
|
compare=Compare.AtMost,
|
||||||
|
value=1,
|
||||||
|
permissions=[
|
||||||
|
ContainerPermission.Write,
|
||||||
|
ContainerPermission.Read,
|
||||||
|
ContainerPermission.List,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ContainerDefinition(
|
||||||
|
type=ContainerType.reports,
|
||||||
|
compare=Compare.AtMost,
|
||||||
|
value=1,
|
||||||
|
permissions=[
|
||||||
|
ContainerPermission.Write,
|
||||||
|
ContainerPermission.Read,
|
||||||
|
ContainerPermission.List,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ContainerDefinition(
|
||||||
|
type=ContainerType.no_repro,
|
||||||
|
compare=Compare.AtMost,
|
||||||
|
value=1,
|
||||||
|
permissions=[
|
||||||
|
ContainerPermission.Write,
|
||||||
|
ContainerPermission.Read,
|
||||||
|
ContainerPermission.List,
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
monitor_queue=None,
|
monitor_queue=None,
|
||||||
),
|
),
|
||||||
|
@ -828,19 +828,8 @@ class Tasks(Endpoint):
|
|||||||
lambda: [str(x.job_id) for x in self.onefuzz.jobs.list()],
|
lambda: [str(x.job_id) for x in self.onefuzz.jobs.list()],
|
||||||
)
|
)
|
||||||
|
|
||||||
if target_env is None:
|
|
||||||
target_env = {}
|
|
||||||
if tags is None:
|
if tags is None:
|
||||||
tags = {}
|
tags = {}
|
||||||
if target_options is None:
|
|
||||||
target_options = []
|
|
||||||
if supervisor_options is None:
|
|
||||||
supervisor_options = []
|
|
||||||
if supervisor_env is None:
|
|
||||||
supervisor_env = {}
|
|
||||||
|
|
||||||
if prereq_tasks is None:
|
|
||||||
prereq_tasks = []
|
|
||||||
|
|
||||||
containers_submit = []
|
containers_submit = []
|
||||||
for (container_type, container) in containers:
|
for (container_type, container) in containers:
|
||||||
|
@ -274,7 +274,7 @@ class TopCache:
|
|||||||
type=task.config.task.type,
|
type=task.config.task.type,
|
||||||
pool=task.config.pool.pool_name if task.config.pool else "",
|
pool=task.config.pool.pool_name if task.config.pool else "",
|
||||||
state=task.state,
|
state=task.state,
|
||||||
target=task.config.task.target_exe.replace("setup/", "", 0),
|
target=(task.config.task.target_exe or "").replace("setup/", "", 0),
|
||||||
containers=task.config.containers,
|
containers=task.config.containers,
|
||||||
end_time=task.end_time,
|
end_time=task.end_time,
|
||||||
)
|
)
|
||||||
@ -285,7 +285,7 @@ class TopCache:
|
|||||||
task_id=event.task_id,
|
task_id=event.task_id,
|
||||||
type=event.config.task.type,
|
type=event.config.task.type,
|
||||||
pool=event.config.pool.pool_name if event.config.pool else "",
|
pool=event.config.pool.pool_name if event.config.pool else "",
|
||||||
target=event.config.task.target_exe.replace("setup/", "", 0),
|
target=(event.config.task.target_exe or "").replace("setup/", "", 0),
|
||||||
containers=event.config.containers,
|
containers=event.config.containers,
|
||||||
state=TaskState.init,
|
state=TaskState.init,
|
||||||
)
|
)
|
||||||
|
@ -57,6 +57,7 @@ class TaskFeature(Enum):
|
|||||||
stats_file = "stats_file"
|
stats_file = "stats_file"
|
||||||
stats_format = "stats_format"
|
stats_format = "stats_format"
|
||||||
target_exe = "target_exe"
|
target_exe = "target_exe"
|
||||||
|
target_exe_optional = "target_exe_optional"
|
||||||
target_env = "target_env"
|
target_env = "target_env"
|
||||||
target_options = "target_options"
|
target_options = "target_options"
|
||||||
analyzer_exe = "analyzer_exe"
|
analyzer_exe = "analyzer_exe"
|
||||||
|
@ -142,9 +142,9 @@ class ReproConfig(BaseModel):
|
|||||||
class TaskDetails(BaseModel):
|
class TaskDetails(BaseModel):
|
||||||
type: TaskType
|
type: TaskType
|
||||||
duration: int
|
duration: int
|
||||||
target_exe: str
|
target_exe: Optional[str]
|
||||||
target_env: Dict[str, str]
|
target_env: Optional[Dict[str, str]]
|
||||||
target_options: List[str]
|
target_options: Optional[List[str]]
|
||||||
target_workers: Optional[int]
|
target_workers: Optional[int]
|
||||||
target_options_merge: Optional[bool]
|
target_options_merge: Optional[bool]
|
||||||
check_asan_log: Optional[bool]
|
check_asan_log: Optional[bool]
|
||||||
|
Reference in New Issue
Block a user