Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

expose supervisor tasks that are fully self-contained fuzzing tasks in the service #474

Merged
5 commits merged into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions docs/webhook_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,7 @@ Each event will be submitted via HTTP POST to the user provided URL.
},
"required": [
"type",
"duration",
"target_exe",
"target_env",
"target_options"
"duration"
],
"title": "TaskDetails",
"type": "object"
Expand Down Expand Up @@ -2761,10 +2758,7 @@ Each event will be submitted via HTTP POST to the user provided URL.
},
"required": [
"type",
"duration",
"target_exe",
"target_env",
"target_options"
"duration"
],
"title": "TaskDetails",
"type": "object"
Expand Down
34 changes: 26 additions & 8 deletions src/api-service/__app__/onefuzzlib/tasks/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
if config.task.type not in TASK_DEFINITIONS:
raise TaskConfigError("unsupported task type: %s" % config.task.type.name)
Expand Down Expand Up @@ -132,14 +151,7 @@ def check_config(config: TaskConfig) -> None:
else:
raise TaskConfigError("either the vm or pool must be specified")

if TaskFeature.target_exe in definition.features:
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)
check_target_exe(config, definition)

if TaskFeature.generator_exe in definition.features:
container = [x for x in config.containers if x.type == ContainerType.tools][0]
Expand Down Expand Up @@ -253,6 +265,12 @@ def build_task_config(
if TaskFeature.target_exe in definition.features:
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:
config.target_env = task_config.task.target_env or EMPTY_DICT

Expand Down
32 changes: 31 additions & 1 deletion src/api-service/__app__/onefuzzlib/tasks/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
),
ContainerDefinition(
type=ContainerType.tools,
compare=Compare.Equal,
compare=Compare.AtMost,
value=1,
permissions=[ContainerPermission.Read, ContainerPermission.List],
),
Expand All @@ -252,6 +252,36 @@
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,
),
Expand Down
11 changes: 0 additions & 11 deletions src/cli/onefuzz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,19 +828,8 @@ def create(
lambda: [str(x.job_id) for x in self.onefuzz.jobs.list()],
)

if target_env is None:
target_env = {}
if tags is None:
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 = []
for (container_type, container) in containers:
Expand Down
4 changes: 2 additions & 2 deletions src/cli/onefuzz/status/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def add_task(self, task: Task) -> None:
type=task.config.task.type,
pool=task.config.pool.pool_name if task.config.pool else "",
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,
end_time=task.end_time,
)
Expand All @@ -285,7 +285,7 @@ def task_created(self, event: EventTaskCreated) -> None:
task_id=event.task_id,
type=event.config.task.type,
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,
state=TaskState.init,
)
Expand Down
1 change: 1 addition & 0 deletions src/pytypes/onefuzztypes/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class TaskFeature(Enum):
stats_file = "stats_file"
stats_format = "stats_format"
target_exe = "target_exe"
target_exe_optional = "target_exe_optional"
target_env = "target_env"
target_options = "target_options"
analyzer_exe = "analyzer_exe"
Expand Down
6 changes: 3 additions & 3 deletions src/pytypes/onefuzztypes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def check_duration(cls, value: int) -> int:
class TaskDetails(BaseModel):
type: TaskType
duration: int
target_exe: str
target_env: Dict[str, str]
target_options: List[str]
target_exe: Optional[str]
target_env: Optional[Dict[str, str]]
target_options: Optional[List[str]]
target_workers: Optional[int]
target_options_merge: Optional[bool]
check_asan_log: Optional[bool]
Expand Down