diff --git a/integrations/runzero/manifest.yaml b/integrations/runzero/manifest.yaml new file mode 100644 index 0000000..b294764 --- /dev/null +++ b/integrations/runzero/manifest.yaml @@ -0,0 +1,77 @@ +id: runzero +name: runZero +version: 1.0.0 +description: "runZero (API v1.0) — asset inventory and network visibility: search and read assets, search services, list sites, and list tasks. Bearer-token authentication; stdlib-only, no extra Python dependencies." +changelog: "1.0.0 — Initial release: search/get assets, search services, list sites, list tasks." +category: asset_management + +# Per-instance configuration. Auth header 'Authorization: Bearer ' (an +# organization or export API token). +config_schema: + properties: + base_url: + type: string + description: "runZero console URL" + default: "https://console.runzero.com" + token: + type: string + description: "Organization API token" + x-soar-sensitive: true + required: + - token + +commands: + - id: list_assets + name: runzero-list-assets + description: "Search assets." + risk: read + inputs_schema: + properties: + search: { type: string, description: "Search expression (e.g. 'os:windows' or an IP)" } + page: { type: number, description: "Page number (default 1)" } + required: [] + outputs_schema: { properties: {} } + - id: get_asset + name: runzero-get-asset + description: "Get a single asset by ID." + risk: read + inputs_schema: + properties: + asset_id: { type: string, description: "Asset ID" } + required: [asset_id] + outputs_schema: { properties: {} } + - id: list_services + name: runzero-list-services + description: "Search services." + risk: read + inputs_schema: + properties: + search: { type: string, description: "Search expression (e.g. 'port:22')" } + required: [] + outputs_schema: { properties: {} } + - id: list_sites + name: runzero-list-sites + description: "List sites." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } + - id: list_tasks + name: runzero-list-tasks + description: "List scan tasks." + risk: read + inputs_schema: + properties: + search: { type: string, description: "Optional search expression" } + required: [] + outputs_schema: { properties: {} } + + - id: test_connection + name: runzero-test-connection + description: "Verify the API token (used by the Test button)." + risk: read + inputs_schema: + properties: {} + required: [] + outputs_schema: { properties: {} } diff --git a/integrations/runzero/scripts/get_asset.py b/integrations/runzero/scripts/get_asset.py new file mode 100644 index 0000000..5b4061e --- /dev/null +++ b/integrations/runzero/scripts/get_asset.py @@ -0,0 +1,48 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return (str(cfg.get("base_url") or "https://console.runzero.com")).rstrip("/") + "/api/v1.0" + + +def request(method, path, cfg, params=None): + url = _base(cfg) + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"Authorization": "Bearer " + str(cfg.get("token", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + asset_id = inputs.get("asset_id") + if not asset_id: + raise Exception("asset_id is required") + q = lambda v: urllib.parse.quote(str(v), safe="") + return request("GET", "/org/assets/" + q(asset_id), cfg) + + +_run(main) diff --git a/integrations/runzero/scripts/list_assets.py b/integrations/runzero/scripts/list_assets.py new file mode 100644 index 0000000..7fd530c --- /dev/null +++ b/integrations/runzero/scripts/list_assets.py @@ -0,0 +1,46 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return (str(cfg.get("base_url") or "https://console.runzero.com")).rstrip("/") + "/api/v1.0" + + +def request(method, path, cfg, params=None): + url = _base(cfg) + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"Authorization": "Bearer " + str(cfg.get("token", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + search = inputs.get("search") + page = inputs.get("page") + return request("GET", "/org/assets", cfg, params={"search": search, "page": int(page or 1)}) + + +_run(main) diff --git a/integrations/runzero/scripts/list_services.py b/integrations/runzero/scripts/list_services.py new file mode 100644 index 0000000..344e5cb --- /dev/null +++ b/integrations/runzero/scripts/list_services.py @@ -0,0 +1,45 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return (str(cfg.get("base_url") or "https://console.runzero.com")).rstrip("/") + "/api/v1.0" + + +def request(method, path, cfg, params=None): + url = _base(cfg) + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"Authorization": "Bearer " + str(cfg.get("token", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + search = inputs.get("search") + return request("GET", "/org/services", cfg, params={"search": search}) + + +_run(main) diff --git a/integrations/runzero/scripts/list_sites.py b/integrations/runzero/scripts/list_sites.py new file mode 100644 index 0000000..95f43c4 --- /dev/null +++ b/integrations/runzero/scripts/list_sites.py @@ -0,0 +1,44 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return (str(cfg.get("base_url") or "https://console.runzero.com")).rstrip("/") + "/api/v1.0" + + +def request(method, path, cfg, params=None): + url = _base(cfg) + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"Authorization": "Bearer " + str(cfg.get("token", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + return request("GET", "/org/sites", cfg) + + +_run(main) diff --git a/integrations/runzero/scripts/list_tasks.py b/integrations/runzero/scripts/list_tasks.py new file mode 100644 index 0000000..075c65f --- /dev/null +++ b/integrations/runzero/scripts/list_tasks.py @@ -0,0 +1,45 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return (str(cfg.get("base_url") or "https://console.runzero.com")).rstrip("/") + "/api/v1.0" + + +def request(method, path, cfg, params=None): + url = _base(cfg) + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"Authorization": "Bearer " + str(cfg.get("token", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + search = inputs.get("search") + return request("GET", "/org/tasks", cfg, params={"search": search}) + + +_run(main) diff --git a/integrations/runzero/scripts/test_connection.py b/integrations/runzero/scripts/test_connection.py new file mode 100644 index 0000000..50d70b5 --- /dev/null +++ b/integrations/runzero/scripts/test_connection.py @@ -0,0 +1,45 @@ +import json, os, sys, urllib.parse, urllib.request, urllib.error + + +def _cfg(): + return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}")) + + +def _inputs(): + return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}")) + + +def _base(cfg): + return (str(cfg.get("base_url") or "https://console.runzero.com")).rstrip("/") + "/api/v1.0" + + +def request(method, path, cfg, params=None): + url = _base(cfg) + path + if params: + clean = {k: v for k, v in params.items() if v not in (None, "")} + if clean: + url += "?" + urllib.parse.urlencode(clean) + headers = {"Authorization": "Bearer " + str(cfg.get("token", "")), "Accept": "application/json"} + req = urllib.request.Request(url, headers=headers, method=method) + with urllib.request.urlopen(req, timeout=60) as r: + raw = r.read() + return json.loads(raw) if raw else {} + + +def _run(fn): + try: + print(json.dumps(fn(_cfg(), _inputs()))) + except urllib.error.HTTPError as e: + print(json.dumps({"error": "HTTP " + str(e.code), "detail": e.read().decode("utf-8", "replace")})) + sys.exit(1) + except Exception as e: + print(json.dumps({"error": str(e)})) + sys.exit(1) + + +def main(cfg, inputs): + request("GET", "/org/sites", cfg) + return {"ok": True} + + +_run(main)