-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhandler_database.yaml
More file actions
57 lines (51 loc) · 2.4 KB
/
Copy pathhandler_database.yaml
File metadata and controls
57 lines (51 loc) · 2.4 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Language: Benthos YAML, Project: DatAasee, License: MIT, Author: Christian Himpe
processor_resources:
- label: 'handler_database'
switch:
- check: 'metadata("language").or("").length() > 256 || metadata("query").or("").length() > 4096'
processors:
- mapping: |
meta status = "414"
root.errors = [{"title": "Request Error: Request-Uri Too Long",
"detail": "Query parameter exceeds 4KiB or other parameters exceed 256B"}]
- check: 'metadata("query").or("").string().trim() == ""'
processors:
- mapping: |
meta status = "400"
root.errors = [{"title": "Request Error: Bad Request",
"detail": "Invalid query string."}]
- check: '!metadata("language").or("sql").string().trim().re_match("^(?i)(sql|mongo|opencypher|graphql|redis)?$")'
processors:
- mapping: |
meta status = "400"
root.errors = [{"title": "Request Error: Bad Request",
"detail": "Unknown query language."}]
- processors:
- mapping: |
meta language = metadata("language").or("sql").string().trim().lowercase().not_empty().catch("sql")
meta query = metadata("query").string().trim()
- label: 'handler_database__arcadedb_query_custom'
arcadedb:
host: '${DB_HOST}'
port: ${DB_PORT} # yamllint disable-line rule:quoted-strings
endpoint: 'query'
database: '${DB_NAME}'
username: '${DB_USER}'
password: '${DB_PASS}'
silent: true
request: |
root.language = metadata("language")
root.limit = 100
root.command = metadata("query")
response: |
if this.result != null {
root.result = this.result.array()
meta params = "?language=" + metadata("language") + "&query=" + metadata("query").escape_url_query()
} else {
meta status = "400"
root.errors = [{"title": this.error,
"detail": this.detail}]
}
root.data.type = "data"
root.data.id = timestamp_unix().string()
root.data.attributes = this.with("result")