-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity_controller.ex
More file actions
31 lines (26 loc) · 780 Bytes
/
Copy pathsecurity_controller.ex
File metadata and controls
31 lines (26 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# SPDX-License-Identifier: MPL-2.0
defmodule StapelnWeb.SecurityController do
use StapelnWeb, :controller
alias Stapeln.Security
def start(conn, params) do
command = Map.get(params, "command", "ambush")
target = Map.get(params, "target", "/bin/true")
schedule = Map.get(params, "schedule", "one-off")
with {:ok, state} <- Security.delegate_trace(command, target, schedule) do
json(conn, state)
else
{:error, reason, fallback} ->
conn
|> put_status(:conflict)
|> json(%{error: reason, info: fallback})
end
end
def stop(conn, _params) do
with {:ok, state} <- Security.stop_trace() do
json(conn, state)
end
end
def status(conn, _params) do
json(conn, Security.trace_status())
end
end