Compare commits

..

3 Commits

Author SHA1 Message Date
Guillaume BOURGEOIS 54b077bfc9 feat(confluence): new Confluence runbook/knowledge integration
Confluence REST API, 6 commands: CQL search, get page, create/update page,
list spaces. Basic (email + API token) auth, stdlib-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 15:23:56 +02:00
Guillaume BOURGEOIS 6d38896892 feat(dropbox): new Dropbox file/evidence integration
Dropbox API v2, 5 commands: search, get metadata, list folder, create shared
link. Bearer-token auth, stdlib-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 15:23:56 +02:00
Guillaume BOURGEOIS 223dfd34e3 feat(box): new Box file/evidence integration
Box Content API v2, 6 commands: search, get file/folder info, list folder
items, create shared link. Bearer-token auth, stdlib-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-12 15:23:56 +02:00
20 changed files with 1147 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
id: box
name: Box
version: 1.0.0
description: "Box (Content API v2) — evidence and file handling: search files, read file/folder metadata, list a folder's items, and create a shared link. Bearer-token authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: search, get file/folder info, list folder items, create shared link."
category: productivity
# Per-instance configuration. Auth header 'Authorization: Bearer <access_token>'.
config_schema:
properties:
access_token:
type: string
description: "Box access token (developer token or OAuth2/JWT-issued token)"
x-soar-sensitive: true
required:
- access_token
commands:
- id: search
name: box-search
description: "Search for files and folders by keyword."
risk: read
inputs_schema:
properties:
query: { type: string, description: "Search query" }
limit: { type: number, description: "Max results (default 30)" }
required: [query]
outputs_schema: { properties: {} }
- id: get_file_info
name: box-get-file-info
description: "Get a file's metadata."
risk: read
inputs_schema:
properties:
file_id: { type: string, description: "File ID" }
required: [file_id]
outputs_schema: { properties: {} }
- id: get_folder_info
name: box-get-folder-info
description: "Get a folder's metadata."
risk: read
inputs_schema:
properties:
folder_id: { type: string, description: "Folder ID (0 = root)" }
required: [folder_id]
outputs_schema: { properties: {} }
- id: list_folder_items
name: box-list-folder-items
description: "List the items inside a folder."
risk: read
inputs_schema:
properties:
folder_id: { type: string, description: "Folder ID (0 = root)" }
limit: { type: number, description: "Max items (default 100)" }
required: [folder_id]
outputs_schema: { properties: {} }
- id: create_shared_link
name: box-create-shared-link
description: "Create a shared link for a file."
inputs_schema:
properties:
file_id: { type: string, description: "File ID" }
access: { type: string, description: "open, company, or collaborators (default company)" }
required: [file_id]
outputs_schema: { properties: {} }
- id: test_connection
name: box-test-connection
description: "Verify the access token (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,58 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.box.com/2.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def request(method, path, cfg, body=None, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": "Bearer " + str(cfg.get("access_token", "")), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
file_id = inputs.get("file_id")
if not file_id:
raise Exception("file_id is required")
access = inputs.get("access")
return request(
"PUT",
"/files/" + q(file_id),
cfg,
body={"shared_link": {"access": (access or "company")}},
params={"fields": "shared_link"},
)
_run(main)
+51
View File
@@ -0,0 +1,51 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.box.com/2.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def request(method, path, cfg, body=None, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": "Bearer " + str(cfg.get("access_token", "")), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
file_id = inputs.get("file_id")
if not file_id:
raise Exception("file_id is required")
return request("GET", "/files/" + q(file_id), cfg)
_run(main)
@@ -0,0 +1,51 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.box.com/2.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def request(method, path, cfg, body=None, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": "Bearer " + str(cfg.get("access_token", "")), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
folder_id = inputs.get("folder_id")
if not folder_id:
raise Exception("folder_id is required")
return request("GET", "/folders/" + q(folder_id), cfg)
_run(main)
@@ -0,0 +1,52 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.box.com/2.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def request(method, path, cfg, body=None, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": "Bearer " + str(cfg.get("access_token", "")), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
folder_id = inputs.get("folder_id")
if not folder_id:
raise Exception("folder_id is required")
limit = inputs.get("limit")
return request("GET", "/folders/" + q(folder_id) + "/items", cfg, params={"limit": int(limit or 100)})
_run(main)
+49
View File
@@ -0,0 +1,49 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.box.com/2.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def request(method, path, cfg, body=None, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": "Bearer " + str(cfg.get("access_token", "")), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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):
query = inputs.get("query")
if not query:
raise Exception("query is required")
limit = inputs.get("limit")
return request("GET", "/search", cfg, params={"query": query, "limit": int(limit or 30)})
_run(main)
@@ -0,0 +1,46 @@
import json, os, sys, urllib.parse, urllib.request, urllib.error
BASE = "https://api.box.com/2.0"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def request(method, path, cfg, body=None, params=None):
url = BASE + path
if params:
clean = {k: v for k, v in params.items() if v not in (None, "")}
if clean:
url += "?" + urllib.parse.urlencode(clean)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": "Bearer " + str(cfg.get("access_token", "")), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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):
resp = request("GET", "/users/me", cfg)
return {"ok": True, "login": resp.get("login")}
_run(main)
+86
View File
@@ -0,0 +1,86 @@
id: confluence
name: Confluence
version: 1.0.0
description: "Atlassian Confluence (REST API) — runbook and knowledge handling: search content (CQL), read a page, create and update pages, and list spaces. Basic (email + API token) authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: search content, get page, create/update page, list spaces."
category: productivity
# Per-instance configuration. HTTP Basic auth with an email + API token (Cloud)
# or username + password (Server/DC).
config_schema:
properties:
base_url:
type: string
description: "Confluence base URL (e.g. https://your.atlassian.net/wiki)"
email:
type: string
description: "Account email (Cloud) or username (Server)"
api_token:
type: string
description: "API token (Cloud) or password (Server)"
x-soar-sensitive: true
required:
- base_url
- email
- api_token
commands:
- id: search
name: confluence-search
description: "Search content using CQL."
risk: read
inputs_schema:
properties:
cql: { type: string, description: "CQL query (e.g. text ~ \"phishing runbook\")" }
limit: { type: number, description: "Max results (default 25)" }
required: [cql]
outputs_schema: { properties: {} }
- id: get_page
name: confluence-get-page
description: "Get a page by ID (with body)."
risk: read
inputs_schema:
properties:
page_id: { type: string, description: "Page (content) ID" }
required: [page_id]
outputs_schema: { properties: {} }
- id: create_page
name: confluence-create-page
description: "Create a page in a space."
inputs_schema:
properties:
space_key: { type: string, description: "Space key" }
title: { type: string, description: "Page title" }
body: { type: string, description: "Page body (storage/HTML format)" }
parent_id: { type: string, description: "Optional parent page ID" }
required: [space_key, title, body]
outputs_schema: { properties: {} }
- id: update_page
name: confluence-update-page
description: "Update a page's title/body (increments the version)."
inputs_schema:
properties:
page_id: { type: string, description: "Page ID" }
title: { type: string, description: "New title" }
body: { type: string, description: "New body (storage/HTML)" }
version: { type: number, description: "New version number (current version + 1)" }
required: [page_id, title, body, version]
outputs_schema: { properties: {} }
- id: list_spaces
name: confluence-list-spaces
description: "List spaces."
risk: read
inputs_schema:
properties:
limit: { type: number, description: "Max spaces (default 25)" }
required: []
outputs_schema: { properties: {} }
- id: test_connection
name: confluence-test-connection
description: "Verify connectivity and credentials (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,75 @@
import json, os, sys, base64, 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", "")).rstrip("/") + "/rest/api"
def _auth(cfg):
raw = str(cfg.get("email", "")) + ":" + str(cfg.get("api_token", ""))
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
def request(method, path, cfg, body=None, 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)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": _auth(cfg), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
space_key = inputs.get("space_key")
if not space_key:
raise Exception("space_key is required")
title = inputs.get("title")
if not title:
raise Exception("title is required")
body = inputs.get("body")
if not body:
raise Exception("body is required")
parent_id = inputs.get("parent_id")
page = {
"type": "page",
"title": title,
"space": {"key": space_key},
"body": {"storage": {"value": body, "representation": "storage"}},
}
if parent_id not in (None, ""):
page["ancestors"] = [{"id": parent_id}]
return request("POST", "/content", cfg, body=page)
_run(main)
@@ -0,0 +1,58 @@
import json, os, sys, base64, 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", "")).rstrip("/") + "/rest/api"
def _auth(cfg):
raw = str(cfg.get("email", "")) + ":" + str(cfg.get("api_token", ""))
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
def request(method, path, cfg, body=None, 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)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": _auth(cfg), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
page_id = inputs.get("page_id")
if not page_id:
raise Exception("page_id is required")
return request("GET", "/content/" + q(page_id), cfg, params={"expand": "body.storage,version,space"})
_run(main)
@@ -0,0 +1,56 @@
import json, os, sys, base64, 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", "")).rstrip("/") + "/rest/api"
def _auth(cfg):
raw = str(cfg.get("email", "")) + ":" + str(cfg.get("api_token", ""))
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
def request(method, path, cfg, body=None, 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)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": _auth(cfg), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
limit = inputs.get("limit")
return request("GET", "/space", cfg, params={"limit": int(limit or 25)})
_run(main)
+59
View File
@@ -0,0 +1,59 @@
import json, os, sys, base64, 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", "")).rstrip("/") + "/rest/api"
def _auth(cfg):
raw = str(cfg.get("email", "")) + ":" + str(cfg.get("api_token", ""))
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
def request(method, path, cfg, body=None, 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)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": _auth(cfg), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
cql = inputs.get("cql")
if not cql:
raise Exception("cql is required")
limit = inputs.get("limit")
return request("GET", "/content/search", cfg, params={"cql": cql, "limit": int(limit or 25)})
_run(main)
@@ -0,0 +1,56 @@
import json, os, sys, base64, 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", "")).rstrip("/") + "/rest/api"
def _auth(cfg):
raw = str(cfg.get("email", "")) + ":" + str(cfg.get("api_token", ""))
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
def request(method, path, cfg, body=None, 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)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": _auth(cfg), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
request("GET", "/space", cfg, params={"limit": 1})
return {"ok": True}
_run(main)
@@ -0,0 +1,78 @@
import json, os, sys, base64, 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", "")).rstrip("/") + "/rest/api"
def _auth(cfg):
raw = str(cfg.get("email", "")) + ":" + str(cfg.get("api_token", ""))
return "Basic " + base64.b64encode(raw.encode("utf-8")).decode("utf-8")
def request(method, path, cfg, body=None, 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)
data = json.dumps(body).encode("utf-8") if body is not None else None
headers = {"Authorization": _auth(cfg), "Accept": "application/json"}
if data is not None:
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, 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)
q = lambda v: urllib.parse.quote(str(v), safe="")
def main(cfg, inputs):
page_id = inputs.get("page_id")
if not page_id:
raise Exception("page_id is required")
title = inputs.get("title")
if not title:
raise Exception("title is required")
body = inputs.get("body")
if not body:
raise Exception("body is required")
version = inputs.get("version")
if version in (None, ""):
raise Exception("version is required")
return request(
"PUT",
"/content/" + q(page_id),
cfg,
body={
"type": "page",
"title": title,
"version": {"number": int(version)},
"body": {"storage": {"value": body, "representation": "storage"}},
},
)
_run(main)
+63
View File
@@ -0,0 +1,63 @@
id: dropbox
name: Dropbox
version: 1.0.0
description: "Dropbox (API v2) — evidence and file handling: search files, get file/folder metadata, list a folder, and create a shared link. Bearer-token authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: search, get metadata, list folder, create shared link."
category: productivity
# Per-instance configuration. Auth header 'Authorization: Bearer <access_token>'.
config_schema:
properties:
access_token:
type: string
description: "Dropbox access token"
x-soar-sensitive: true
required:
- access_token
commands:
- id: search
name: dropbox-search
description: "Search files and folders by keyword."
risk: read
inputs_schema:
properties:
query: { type: string, description: "Search query" }
max_results: { type: number, description: "Max results (default 20)" }
required: [query]
outputs_schema: { properties: {} }
- id: get_metadata
name: dropbox-get-metadata
description: "Get metadata for a file or folder by path."
risk: read
inputs_schema:
properties:
path: { type: string, description: "Path (e.g. /Evidence/report.pdf)" }
required: [path]
outputs_schema: { properties: {} }
- id: list_folder
name: dropbox-list-folder
description: "List the contents of a folder."
risk: read
inputs_schema:
properties:
path: { type: string, description: "Folder path ('' or '/' for root)" }
required: []
outputs_schema: { properties: {} }
- id: create_shared_link
name: dropbox-create-shared-link
description: "Create a shared link for a file or folder."
inputs_schema:
properties:
path: { type: string, description: "Path to share" }
required: [path]
outputs_schema: { properties: {} }
- id: test_connection
name: dropbox-test-connection
description: "Verify the access token (used by the Test button)."
risk: read
inputs_schema:
properties: {}
required: []
outputs_schema: { properties: {} }
@@ -0,0 +1,45 @@
import json, os, sys, urllib.request, urllib.error
API = "https://api.dropboxapi.com/2"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def rpc(path, cfg, body):
data = json.dumps(body).encode("utf-8")
headers = {
"Authorization": "Bearer " + str(cfg.get("access_token", "")),
"Content-Type": "application/json",
"Accept": "application/json",
}
req = urllib.request.Request(API + path, data=data, headers=headers, method="POST")
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):
path = inputs.get("path")
if not path:
raise Exception("path is required")
return rpc("/sharing/create_shared_link_with_settings", cfg, {"path": path})
_run(main)
@@ -0,0 +1,45 @@
import json, os, sys, urllib.request, urllib.error
API = "https://api.dropboxapi.com/2"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def rpc(path, cfg, body):
data = json.dumps(body).encode("utf-8")
headers = {
"Authorization": "Bearer " + str(cfg.get("access_token", "")),
"Content-Type": "application/json",
"Accept": "application/json",
}
req = urllib.request.Request(API + path, data=data, headers=headers, method="POST")
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):
path = inputs.get("path")
if not path:
raise Exception("path is required")
return rpc("/files/get_metadata", cfg, {"path": path})
_run(main)
@@ -0,0 +1,44 @@
import json, os, sys, urllib.request, urllib.error
API = "https://api.dropboxapi.com/2"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def rpc(path, cfg, body):
data = json.dumps(body).encode("utf-8")
headers = {
"Authorization": "Bearer " + str(cfg.get("access_token", "")),
"Content-Type": "application/json",
"Accept": "application/json",
}
req = urllib.request.Request(API + path, data=data, headers=headers, method="POST")
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):
# Dropbox root is the empty string "", not "/".
path = inputs.get("path") or ""
return rpc("/files/list_folder", cfg, {"path": path})
_run(main)
+47
View File
@@ -0,0 +1,47 @@
import json, os, sys, urllib.request, urllib.error
API = "https://api.dropboxapi.com/2"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def rpc(path, cfg, body):
data = json.dumps(body).encode("utf-8")
headers = {
"Authorization": "Bearer " + str(cfg.get("access_token", "")),
"Content-Type": "application/json",
"Accept": "application/json",
}
req = urllib.request.Request(API + path, data=data, headers=headers, method="POST")
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):
query = inputs.get("query")
if not query:
raise Exception("query is required")
max_results = inputs.get("max_results")
max_results = int(max_results or 20)
return rpc("/files/search_v2", cfg, {"query": query, "options": {"max_results": max_results}})
_run(main)
@@ -0,0 +1,54 @@
import json, os, sys, urllib.request, urllib.error
API = "https://api.dropboxapi.com/2"
def _cfg():
return json.loads(os.environ.get("INTEGRATION_SECRETS", "{}"))
def _inputs():
return json.loads(os.environ.get("INTEGRATION_INPUTS", "{}"))
def rpc(path, cfg, body):
data = json.dumps(body).encode("utf-8")
headers = {
"Authorization": "Bearer " + str(cfg.get("access_token", "")),
"Content-Type": "application/json",
"Accept": "application/json",
}
req = urllib.request.Request(API + path, data=data, headers=headers, method="POST")
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):
# get_current_account needs a JSON null body, not an empty dict.
req = urllib.request.Request(
API + "/users/get_current_account",
data=b"null",
headers={
"Authorization": "Bearer " + str(cfg.get("access_token", "")),
"Content-Type": "application/json",
},
method="POST",
)
with urllib.request.urlopen(req, timeout=60) as r:
r.read()
return {"ok": True}
_run(main)