always set SignalR events at the end of handlers (#445)

Addresses an issue where events meant for SignalR do not get sent to the service when an App Service instance spins down before a timer event fires.
This commit is contained in:
bmc-msft
2021-01-21 05:31:02 -05:00
committed by GitHub
parent f3d81566e3
commit b499b9b17d
55 changed files with 708 additions and 414 deletions

View File

@ -10,6 +10,7 @@ from onefuzztypes.requests import CanScheduleRequest
from onefuzztypes.responses import CanSchedule from onefuzztypes.responses import CanSchedule
from ..onefuzzlib.endpoint_authorization import call_if_agent from ..onefuzzlib.endpoint_authorization import call_if_agent
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Node from ..onefuzzlib.pools import Node
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.tasks.main import Task from ..onefuzzlib.tasks.main import Task
@ -42,7 +43,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return ok(CanSchedule(allowed=allowed, work_stopped=work_stopped)) return ok(CanSchedule(allowed=allowed, work_stopped=work_stopped))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"POST": post} methods = {"POST": post}
method = methods[req.method] method = methods[req.method]
return call_if_agent(req, method) result = call_if_agent(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,20 +1,26 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"post" "post"
], ],
"route": "agents/can_schedule" "route": "agents/can_schedule"
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
} }

View File

@ -9,6 +9,7 @@ from onefuzztypes.requests import NodeCommandDelete, NodeCommandGet
from onefuzztypes.responses import BoolResult, PendingNodeCommand from onefuzztypes.responses import BoolResult, PendingNodeCommand
from ..onefuzzlib.endpoint_authorization import call_if_agent from ..onefuzzlib.endpoint_authorization import call_if_agent
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import NodeMessage from ..onefuzzlib.pools import NodeMessage
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -42,7 +43,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"DELETE": delete, "GET": get} methods = {"DELETE": delete, "GET": get}
method = methods[req.method] method = methods[req.method]
return call_if_agent(req, method) result = call_if_agent(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get", "get",
"post", "post",
"delete" "delete"
], ],
"route": "agents/commands" "route": "agents/commands"
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
} }

View File

@ -18,6 +18,7 @@ from onefuzztypes.responses import BoolResult
from ..onefuzzlib.agent_events import on_state_update, on_worker_event from ..onefuzzlib.agent_events import on_state_update, on_worker_event
from ..onefuzzlib.endpoint_authorization import call_if_agent from ..onefuzzlib.endpoint_authorization import call_if_agent
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -71,7 +72,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"POST": post} methods = {"POST": post}
method = methods[req.method] method = methods[req.method]
return call_if_agent(req, method) result = call_if_agent(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,20 +1,26 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"post" "post"
], ],
"route": "agents/events" "route": "agents/events"
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -17,6 +17,7 @@ from ..onefuzzlib.azure.creds import get_instance_url
from ..onefuzzlib.azure.queue import get_queue_sas from ..onefuzzlib.azure.queue import get_queue_sas
from ..onefuzzlib.azure.storage import StorageType from ..onefuzzlib.azure.storage import StorageType
from ..onefuzzlib.endpoint_authorization import call_if_agent from ..onefuzzlib.endpoint_authorization import call_if_agent
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Node, NodeMessage, NodeTasks, Pool from ..onefuzzlib.pools import Node, NodeMessage, NodeTasks, Pool
from ..onefuzzlib.request import not_ok, ok, parse_uri from ..onefuzzlib.request import not_ok, ok, parse_uri
@ -116,7 +117,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return create_registration_response(node.machine_id, pool) return create_registration_response(node.machine_id, pool)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"POST": post, "GET": get} methods = {"POST": post, "GET": get}
method = methods[req.method] method = methods[req.method]
return call_if_agent(req, method) result = call_if_agent(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get", "get",
"post", "post",
"delete" "delete"
], ],
"route": "agents/registration" "route": "agents/registration"
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
} }

View File

@ -21,6 +21,7 @@ from ..onefuzzlib.azure.containers import (
) )
from ..onefuzzlib.azure.storage import StorageType from ..onefuzzlib.azure.storage import StorageType
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -89,7 +90,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=delete_container(request.name, StorageType.corpus))) return ok(BoolResult(result=delete_container(request.name, StorageType.corpus)))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -16,6 +16,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -14,6 +14,7 @@ from ..onefuzzlib.azure.containers import (
) )
from ..onefuzzlib.azure.storage import StorageType from ..onefuzzlib.azure.storage import StorageType
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import not_ok, parse_uri, redirect from ..onefuzzlib.request import not_ok, parse_uri, redirect
@ -46,7 +47,13 @@ def get(req: func.HttpRequest) -> func.HttpResponse:
) )
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get} methods = {"GET": get}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,19 +1,25 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get" "get"
] ]
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -14,12 +14,13 @@ from ..onefuzzlib.azure.creds import (
get_instance_id, get_instance_id,
get_subscription, get_subscription,
) )
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import ok from ..onefuzzlib.request import ok
from ..onefuzzlib.versions import versions from ..onefuzzlib.versions import versions
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
return ok( response = ok(
Info( Info(
resource_group=get_base_resource_group(), resource_group=get_base_resource_group(),
region=get_base_region(), region=get_base_region(),
@ -30,3 +31,9 @@ def main(req: func.HttpRequest) -> func.HttpResponse:
insights_instrumentation_key=get_insights_instrumentation_key(), insights_instrumentation_key=get_insights_instrumentation_key(),
) )
) )
events = get_events()
if events:
dashboard.set(events)
return response

View File

@ -1,19 +1,25 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get" "get"
] ]
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -8,6 +8,7 @@ from onefuzztypes.job_templates import JobTemplateRequest
from onefuzztypes.models import Error from onefuzztypes.models import Error
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.job_templates.templates import JobTemplateIndex from ..onefuzzlib.job_templates.templates import JobTemplateIndex
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.user_credentials import parse_jwt_token from ..onefuzzlib.user_credentials import parse_jwt_token
@ -34,7 +35,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return ok(job) return ok(job)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post} methods = {"GET": get, "POST": post}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -15,6 +15,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -14,6 +14,7 @@ from onefuzztypes.models import Error
from onefuzztypes.responses import BoolResult from onefuzztypes.responses import BoolResult
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.job_templates.templates import JobTemplateIndex from ..onefuzzlib.job_templates.templates import JobTemplateIndex
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -61,7 +62,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=entry is not None)) return ok(BoolResult(result=entry is not None))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -17,6 +17,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -9,6 +9,7 @@ from onefuzztypes.models import Error, JobConfig, JobTaskInfo
from onefuzztypes.requests import JobGet, JobSearch from onefuzztypes.requests import JobGet, JobSearch
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.jobs import Job from ..onefuzzlib.jobs import Job
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.tasks.main import Task from ..onefuzzlib.tasks.main import Task
@ -74,7 +75,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(job) return ok(job)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -16,6 +16,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -22,4 +22,4 @@
"hubName": "dashboard" "hubName": "dashboard"
} }
] ]
} }

View File

@ -10,6 +10,7 @@ from onefuzztypes.requests import NodeGet, NodeSearch, NodeUpdate
from onefuzztypes.responses import BoolResult from onefuzztypes.responses import BoolResult
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Node, NodeTasks from ..onefuzzlib.pools import Node, NodeTasks
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -100,7 +101,13 @@ def patch(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "PATCH": patch, "DELETE": delete, "POST": post} methods = {"GET": get, "PATCH": patch, "DELETE": delete, "POST": post}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get", "get",
"patch", "patch",
"delete", "delete",
"post" "post"
] ]
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -9,6 +9,8 @@ from onefuzztypes.models import Error
from onefuzztypes.requests import NodeAddSshKey from onefuzztypes.requests import NodeAddSshKey
from onefuzztypes.responses import BoolResult from onefuzztypes.responses import BoolResult
from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Node from ..onefuzzlib.pools import Node
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -31,8 +33,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
if req.method == "POST": methods = {"POST": post}
return post(req) method = methods[req.method]
else: result = call_if_user(req, method)
raise Exception("invalid method")
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,20 +1,26 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"post" "post"
], ],
"route": "node/add_ssh_key" "route": "node/add_ssh_key"
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -10,6 +10,7 @@ from onefuzztypes.models import Error
from onefuzztypes.requests import NotificationCreate, NotificationGet from onefuzztypes.requests import NotificationCreate, NotificationGet
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.notifications.main import Notification from ..onefuzzlib.notifications.main import Notification
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -49,7 +50,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(entry) return ok(entry)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -16,6 +16,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -22,6 +22,7 @@ from ..onefuzzlib.azure.queue import get_queue_sas
from ..onefuzzlib.azure.storage import StorageType from ..onefuzzlib.azure.storage import StorageType
from ..onefuzzlib.azure.vmss import list_available_skus from ..onefuzzlib.azure.vmss import list_available_skus
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Pool from ..onefuzzlib.pools import Pool
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -131,7 +132,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get", "get",
"post", "post",
"delete", "delete",
"patch" "patch"
] ]
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -12,6 +12,7 @@ from onefuzztypes.requests import ProxyCreate, ProxyDelete, ProxyGet, ProxyReset
from onefuzztypes.responses import BoolResult, ProxyGetResult from onefuzztypes.responses import BoolResult, ProxyGetResult
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Scaleset from ..onefuzzlib.pools import Scaleset
from ..onefuzzlib.proxy import Proxy from ..onefuzzlib.proxy import Proxy
from ..onefuzzlib.proxy_forward import ProxyForward from ..onefuzzlib.proxy_forward import ProxyForward
@ -114,7 +115,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete, "PATCH": patch} methods = {"GET": get, "POST": post, "DELETE": delete, "PATCH": patch}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get", "get",
"post", "post",
"delete", "delete",
"patch" "patch"
] ]
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -1,18 +1,18 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "proxy", "queueName": "proxy",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
] ]
} }

View File

@ -1,18 +1,18 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "file-changes", "queueName": "file-changes",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
] ]
} }

View File

@ -1,18 +1,18 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "node-heartbeat", "queueName": "node-heartbeat",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
] ]
} }

View File

@ -1,18 +1,18 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "task-heartbeat", "queueName": "task-heartbeat",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
] ]
} }

View File

@ -1,18 +1,18 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "update-queue", "queueName": "update-queue",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
] ]
} }

View File

@ -7,10 +7,15 @@ import json
import azure.functions as func import azure.functions as func
from ..onefuzzlib.events import get_events
from ..onefuzzlib.webhooks import WebhookMessageLog, WebhookMessageQueueObj from ..onefuzzlib.webhooks import WebhookMessageLog, WebhookMessageQueueObj
def main(msg: func.QueueMessage) -> None: def main(msg: func.QueueMessage, dashboard: func.Out[str]) -> None:
body = msg.get_body() body = msg.get_body()
obj = WebhookMessageQueueObj.parse_obj(json.loads(body)) obj = WebhookMessageQueueObj.parse_obj(json.loads(body))
WebhookMessageLog.process_from_queue(obj) WebhookMessageLog.process_from_queue(obj)
events = get_events()
if events:
dashboard.set(events)

View File

@ -1,12 +1,18 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"name": "msg", "name": "msg",
"type": "queueTrigger", "type": "queueTrigger",
"direction": "in", "direction": "in",
"queueName": "webhooks", "queueName": "webhooks",
"connection": "AzureWebJobsStorage" "connection": "AzureWebJobsStorage"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -9,6 +9,7 @@ from onefuzztypes.models import Error, ReproConfig
from onefuzztypes.requests import ReproGet from onefuzztypes.requests import ReproGet
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.repro import Repro from ..onefuzzlib.repro import Repro
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.user_credentials import parse_jwt_token from ..onefuzzlib.user_credentials import parse_jwt_token
@ -73,7 +74,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(vm) return ok(vm)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -16,6 +16,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -17,6 +17,7 @@ from onefuzztypes.responses import BoolResult
from ..onefuzzlib.azure.creds import get_base_region, get_regions from ..onefuzzlib.azure.creds import get_base_region, get_regions
from ..onefuzzlib.azure.vmss import list_available_skus from ..onefuzzlib.azure.vmss import list_available_skus
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Pool, Scaleset from ..onefuzzlib.pools import Pool, Scaleset
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -143,7 +144,13 @@ def patch(req: func.HttpRequest) -> func.HttpResponse:
return ok(scaleset) return ok(scaleset)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete, "PATCH": patch} methods = {"GET": get, "POST": post, "DELETE": delete, "PATCH": patch}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -1,22 +1,28 @@
{ {
"scriptFile": "__init__.py", "scriptFile": "__init__.py",
"bindings": [ "bindings": [
{ {
"authLevel": "anonymous", "authLevel": "anonymous",
"type": "httpTrigger", "type": "httpTrigger",
"direction": "in", "direction": "in",
"name": "req", "name": "req",
"methods": [ "methods": [
"get", "get",
"post", "post",
"delete", "delete",
"patch" "patch"
] ]
}, },
{ {
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
} },
] {
} "type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
]
}

View File

@ -3,7 +3,6 @@
# Copyright (c) Microsoft Corporation. # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License. # Licensed under the MIT License.
# import logging
import azure.functions as func import azure.functions as func
from onefuzztypes.enums import ErrorCode, JobState from onefuzztypes.enums import ErrorCode, JobState
from onefuzztypes.models import Error, TaskConfig from onefuzztypes.models import Error, TaskConfig
@ -11,6 +10,7 @@ from onefuzztypes.requests import TaskGet, TaskSearch
from onefuzztypes.responses import BoolResult from onefuzztypes.responses import BoolResult
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.jobs import Job from ..onefuzzlib.jobs import Job
from ..onefuzzlib.pools import NodeTasks from ..onefuzzlib.pools import NodeTasks
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
@ -99,7 +99,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(task) return ok(task)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete} methods = {"GET": get, "POST": post, "DELETE": delete}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -17,6 +17,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -8,12 +8,13 @@ import logging
import azure.functions as func import azure.functions as func
from onefuzztypes.enums import VmState from onefuzztypes.enums import VmState
from ..onefuzzlib.events import get_events
from ..onefuzzlib.pools import Scaleset from ..onefuzzlib.pools import Scaleset
from ..onefuzzlib.proxy import Proxy from ..onefuzzlib.proxy import Proxy
from ..onefuzzlib.webhooks import WebhookMessageLog from ..onefuzzlib.webhooks import WebhookMessageLog
def main(mytimer: func.TimerRequest) -> None: # noqa: F841 def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa: F841
for proxy in Proxy.search(): for proxy in Proxy.search():
if not proxy.is_used(): if not proxy.is_used():
logging.info("stopping proxy") logging.info("stopping proxy")
@ -33,3 +34,7 @@ def main(mytimer: func.TimerRequest) -> None: # noqa: F841
log_entry.event_id, log_entry.event_id,
) )
log_entry.delete() log_entry.delete()
events = get_events()
if events:
dashboard.set(events)

View File

@ -1,11 +1,17 @@
{ {
"bindings": [ "bindings": [
{ {
"direction": "in", "direction": "in",
"name": "mytimer", "name": "mytimer",
"schedule": "1.00:00:00", "schedule": "1.00:00:00",
"type": "timerTrigger" "type": "timerTrigger"
} },
], {
"scriptFile": "__init__.py" "type": "signalR",
} "direction": "out",
"name": "dashboard",
"hubName": "dashboard"
}
],
"scriptFile": "__init__.py"
}

View File

@ -1,17 +1,17 @@
{ {
"bindings": [ "bindings": [
{ {
"direction": "in", "direction": "in",
"name": "mytimer", "name": "mytimer",
"schedule": "00:00:30", "schedule": "00:00:30",
"type": "timerTrigger" "type": "timerTrigger"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
], ],
"scriptFile": "__init__.py" "scriptFile": "__init__.py"
} }

View File

@ -14,4 +14,4 @@
} }
], ],
"scriptFile": "__init__.py" "scriptFile": "__init__.py"
} }

View File

@ -1,17 +1,17 @@
{ {
"bindings": [ "bindings": [
{ {
"direction": "in", "direction": "in",
"name": "mytimer", "name": "mytimer",
"schedule": "00:00:15", "schedule": "00:00:15",
"type": "timerTrigger" "type": "timerTrigger"
}, },
{ {
"type": "signalR", "type": "signalR",
"direction": "out", "direction": "out",
"name": "dashboard", "name": "dashboard",
"hubName": "dashboard" "hubName": "dashboard"
} }
], ],
"scriptFile": "__init__.py" "scriptFile": "__init__.py"
} }

View File

@ -16,6 +16,7 @@ from onefuzztypes.requests import (
from onefuzztypes.responses import BoolResult from onefuzztypes.responses import BoolResult
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.webhooks import Webhook from ..onefuzzlib.webhooks import Webhook
@ -105,7 +106,13 @@ def delete(req: func.HttpRequest) -> func.HttpResponse:
return ok(BoolResult(result=True)) return ok(BoolResult(result=True))
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"GET": get, "POST": post, "DELETE": delete, "PATCH": patch} methods = {"GET": get, "POST": post, "DELETE": delete, "PATCH": patch}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -17,6 +17,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -10,6 +10,7 @@ from onefuzztypes.models import Error
from onefuzztypes.requests import WebhookGet from onefuzztypes.requests import WebhookGet
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.webhooks import Webhook, WebhookMessageLog from ..onefuzzlib.webhooks import Webhook, WebhookMessageLog
@ -28,7 +29,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return ok(logs) return ok(logs)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"POST": post} methods = {"POST": post}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -15,6 +15,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }

View File

@ -10,6 +10,7 @@ from onefuzztypes.models import Error
from onefuzztypes.requests import WebhookGet from onefuzztypes.requests import WebhookGet
from ..onefuzzlib.endpoint_authorization import call_if_user from ..onefuzzlib.endpoint_authorization import call_if_user
from ..onefuzzlib.events import get_events
from ..onefuzzlib.request import not_ok, ok, parse_request from ..onefuzzlib.request import not_ok, ok, parse_request
from ..onefuzzlib.webhooks import Webhook from ..onefuzzlib.webhooks import Webhook
@ -29,7 +30,13 @@ def post(req: func.HttpRequest) -> func.HttpResponse:
return ok(ping) return ok(ping)
def main(req: func.HttpRequest) -> func.HttpResponse: def main(req: func.HttpRequest, dashboard: func.Out[str]) -> func.HttpResponse:
methods = {"POST": post} methods = {"POST": post}
method = methods[req.method] method = methods[req.method]
return call_if_user(req, method) result = call_if_user(req, method)
events = get_events()
if events:
dashboard.set(events)
return result

View File

@ -15,6 +15,12 @@
"type": "http", "type": "http",
"direction": "out", "direction": "out",
"name": "$return" "name": "$return"
},
{
"type": "signalR",
"direction": "out",
"name": "dashboard",
"hubName": "dashboard"
} }
] ]
} }