n8n-nodes-soar 0.1.15 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/common/asset.js +141 -0
  2. package/dist/common/collector.js +32 -0
  3. package/dist/common/connectionType.js +15 -0
  4. package/dist/common/executor/docker.executor.js +97 -0
  5. package/dist/common/executor/executor.js +48 -0
  6. package/dist/common/executor/k8s.executor.js +190 -0
  7. package/dist/common/runner/container.runner.js +174 -0
  8. package/dist/common/runner/priority.js +44 -0
  9. package/dist/common/runner/priority.runner.js +38 -0
  10. package/dist/common/runner/runner.js +57 -0
  11. package/dist/credentials/Docker/Docker.credentials.js +149 -0
  12. package/dist/credentials/Docker/docker.svg +7 -0
  13. package/dist/credentials/{FofaCredentials.credentials.js → FofaApi/FofaApi.credentials.js} +5 -5
  14. package/dist/credentials/Kubernetes/Kubernetes.credentials.js +82 -0
  15. package/dist/credentials/Kubernetes/k8s.svg +1 -0
  16. package/dist/nodes/Asset/SplitAsset/SplitAsset.node.js +110 -0
  17. package/dist/nodes/Asset/SplitAsset/split.svg +13 -0
  18. package/dist/nodes/Collector/Collector.node.js +123 -0
  19. package/dist/nodes/Executor/DockerExecutor/DockerExecutor.node.js +59 -0
  20. package/dist/nodes/Executor/DockerExecutor/docker.svg +7 -0
  21. package/dist/nodes/Executor/KubernetesExecutor/KubernetesExecutor.node.js +59 -0
  22. package/dist/nodes/Executor/KubernetesExecutor/k8s.svg +1 -0
  23. package/dist/nodes/Fofa/Fofa.node.js +20 -7
  24. package/dist/nodes/Katana/Katana.node.js +1 -1
  25. package/dist/nodes/Nuclei/Nuclei.node.js +1 -1
  26. package/dist/nodes/Runner/Dns/Dns.node.js +199 -0
  27. package/dist/nodes/Runner/Dns/script.js +81 -0
  28. package/dist/nodes/Runner/Httpx/Httpx.node.js +830 -0
  29. package/dist/nodes/Runner/Httpx/httpx.svg +3 -0
  30. package/dist/nodes/Runner/Katana/Katana.node.js +521 -0
  31. package/dist/nodes/Runner/Katana/a.json +30 -0
  32. package/dist/nodes/Runner/Katana/katana.svg +3 -0
  33. package/dist/nodes/Runner/Masscan/Masscan.node.js +151 -0
  34. package/dist/nodes/Runner/Masscan/masscan.svg +70 -0
  35. package/dist/nodes/{Naabu → Runner/Naabu}/Naabu.node.js +86 -48
  36. package/dist/nodes/Runner/Naabu/naabu.svg +3 -0
  37. package/dist/nodes/Runner/Nuclei/Nuclei.node.js +1057 -0
  38. package/dist/nodes/Runner/Nuclei/a.json +48 -0
  39. package/dist/nodes/Runner/Nuclei/nuclei.svg +3 -0
  40. package/dist/nodes/Runner/Priority/Priority.node.js +110 -0
  41. package/dist/nodes/Runner/PriorityAdd/PriorityAdd.node.js +97 -0
  42. package/dist/nodes/Runner/Router/SwitchRouter/SwitchRouter.node.js +101 -0
  43. package/dist/nodes/{Subfinder → Runner/Subfinder}/Subfinder.node.js +74 -43
  44. package/dist/nodes/Runner/Subfinder/subfinder.svg +3 -0
  45. package/dist/nodes/Runner/Unauthor/Unauthor.node.js +169 -0
  46. package/dist/nodes/Unauthor/Unauthor.node.js +24 -18
  47. package/package.json +63 -59
  48. package/dist/nodes/Cdncheck/Cdncheck.node.json +0 -9
  49. package/dist/nodes/Fofa/Fofa.node.json +0 -9
  50. package/dist/nodes/Httpx/Httpx.node.json +0 -9
  51. package/dist/nodes/Naabu/Naabu.node.json +0 -9
  52. package/dist/nodes/Subfinder/Subfinder.node.json +0 -9
  53. package/dist/utils/executor.js +0 -233
  54. package/dist/utils/interface.js +0 -4
  55. package/dist/utils/runner/docker.runner.js +0 -72
  56. package/dist/utils/runner/k8s.runner.js +0 -167
  57. package/dist/utils/runner/runner.js +0 -11
  58. /package/dist/credentials/{fofa.svg → FofaApi/fofa.svg} +0 -0
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ Asset: function() {
13
+ return Asset;
14
+ },
15
+ Basic: function() {
16
+ return Basic;
17
+ },
18
+ MissingPropertyError: function() {
19
+ return MissingPropertyError;
20
+ }
21
+ });
22
+ const _classtransformer = require("class-transformer");
23
+ require("reflect-metadata");
24
+ function _define_property(obj, key, value) {
25
+ if (key in obj) {
26
+ Object.defineProperty(obj, key, {
27
+ value: value,
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true
31
+ });
32
+ } else {
33
+ obj[key] = value;
34
+ }
35
+ return obj;
36
+ }
37
+ class Basic {
38
+ constructor(){
39
+ _define_property(this, "ip", void 0);
40
+ _define_property(this, "domain", void 0);
41
+ _define_property(this, "port", void 0);
42
+ _define_property(this, "protocol", void 0);
43
+ }
44
+ }
45
+ class MissingPropertyError extends Error {
46
+ constructor(property, asset){
47
+ super(`Missing property: ${property} on ${JSON.stringify((0, _classtransformer.instanceToPlain)(asset))}`);
48
+ }
49
+ }
50
+ class Asset {
51
+ getDomain() {
52
+ if (!this.basic.domain) {
53
+ throw new MissingPropertyError("basic.domain", this);
54
+ }
55
+ return this.basic.domain;
56
+ }
57
+ getHost() {
58
+ if (!(this.basic.domain || this.basic.ip)) {
59
+ throw new MissingPropertyError("basic.host", this);
60
+ }
61
+ return this.basic.domain || this.basic.ip || "";
62
+ }
63
+ getPort() {
64
+ if (!this.basic.port) {
65
+ throw new MissingPropertyError("basic.port", this);
66
+ }
67
+ return this.basic.port;
68
+ }
69
+ getHostAndPort() {
70
+ return `${this.getHost()}:${this.getPort()}`;
71
+ }
72
+ clone(patch) {
73
+ return (0, _classtransformer.plainToInstance)(Asset, Object.assign({}, this, patch));
74
+ }
75
+ splitBySubdomains() {
76
+ if (this.subdomains?.length) {
77
+ return [
78
+ this,
79
+ ...this.subdomains.map((n)=>{
80
+ return (0, _classtransformer.plainToInstance)(Asset, {
81
+ basic: {
82
+ host: n
83
+ },
84
+ metadata: this.metadata
85
+ });
86
+ })
87
+ ];
88
+ } else {
89
+ return [
90
+ this
91
+ ];
92
+ }
93
+ }
94
+ splitByDnsRecords() {
95
+ if (this.dnsRecord && Object.keys(this.dnsRecord).length) {
96
+ return [
97
+ ...this.dnsRecord?.A ?? [],
98
+ ...this.dnsRecord?.AAAA ?? []
99
+ ].map((n)=>{
100
+ return (0, _classtransformer.plainToInstance)(Asset, {
101
+ basic: {
102
+ domain: this.basic.domain,
103
+ ip: n
104
+ },
105
+ metadata: this.metadata
106
+ });
107
+ });
108
+ } else {
109
+ return [
110
+ this
111
+ ];
112
+ }
113
+ }
114
+ splitByPorts() {
115
+ if (this.ports?.length) {
116
+ return this.ports.map((n)=>{
117
+ return (0, _classtransformer.plainToInstance)(Asset, {
118
+ basic: {
119
+ domain: this.basic.domain,
120
+ port: n.port,
121
+ protocol: n.protocol
122
+ },
123
+ metadata: this.metadata
124
+ });
125
+ });
126
+ } else {
127
+ return [
128
+ this
129
+ ];
130
+ }
131
+ }
132
+ constructor(){
133
+ _define_property(this, "basic", new Basic());
134
+ _define_property(this, "subdomains", void 0);
135
+ _define_property(this, "dnsRecord", void 0);
136
+ _define_property(this, "ports", void 0);
137
+ _define_property(this, "metadata", void 0);
138
+ _define_property(this, "response", void 0);
139
+ _define_property(this, "success", false);
140
+ }
141
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Collector", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Collector;
9
+ }
10
+ });
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
24
+ class Collector {
25
+ setExecutor(executor) {
26
+ this.executor = executor;
27
+ }
28
+ constructor(){
29
+ _define_property(this, "executor", void 0);
30
+ //
31
+ }
32
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "NodeConnectionType", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return NodeConnectionType;
9
+ }
10
+ });
11
+ var NodeConnectionType;
12
+ (function(NodeConnectionType) {
13
+ NodeConnectionType["Runner"] = "runner";
14
+ NodeConnectionType["Executor"] = "executor";
15
+ })(NodeConnectionType || (NodeConnectionType = {}));
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "DockerExecutor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DockerExecutor;
9
+ }
10
+ });
11
+ const _stream = require("stream");
12
+ const _dockerode = /*#__PURE__*/ _interop_require_default(require("dockerode"));
13
+ const _n8nworkflow = require("n8n-workflow");
14
+ const _executor = require("./executor");
15
+ function _define_property(obj, key, value) {
16
+ if (key in obj) {
17
+ Object.defineProperty(obj, key, {
18
+ value: value,
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true
22
+ });
23
+ } else {
24
+ obj[key] = value;
25
+ }
26
+ return obj;
27
+ }
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ class DockerExecutor extends _executor.Executor {
34
+ async __run(cmd, image, env) {
35
+ let stdout = "";
36
+ let stderr = "";
37
+ const outStream = new _stream.Writable({
38
+ write (chunk, encoding, done) {
39
+ stdout += chunk.toString();
40
+ done();
41
+ }
42
+ });
43
+ const errStream = new _stream.Writable({
44
+ write (chunk, encoding, done) {
45
+ stderr += chunk.toString();
46
+ done();
47
+ }
48
+ });
49
+ await this.docker.pull(image);
50
+ let container;
51
+ const containers = (await this.docker.listContainers({
52
+ filters: '{"label": ["managed-by=n8n-nodes-soar"]}'
53
+ })).filter((n)=>n.Image === image);
54
+ if (containers.length === 0) {
55
+ this.func.logger.info(`Boot new container for image ${image}`);
56
+ container = await this.docker.createContainer({
57
+ Image: image,
58
+ Cmd: [
59
+ "sleep",
60
+ "infinity"
61
+ ],
62
+ Labels: {
63
+ "managed-by": "n8n-nodes-soar"
64
+ }
65
+ });
66
+ await container.start();
67
+ } else {
68
+ container = this.docker.getContainer(containers[0].Id);
69
+ }
70
+ this.func.logger.debug(`Running ${cmd.join(" ")}`);
71
+ const exec = await container.exec({
72
+ AttachStderr: true,
73
+ AttachStdout: true,
74
+ Env: Object.entries(env || {}).map(([key, value])=>`${key}=${value}`),
75
+ Tty: false,
76
+ Cmd: cmd
77
+ });
78
+ const pipe = await exec.start({});
79
+ this.docker.modem.demuxStream(pipe, outStream, errStream);
80
+ await new Promise((resolve)=>{
81
+ pipe.on("end", resolve);
82
+ });
83
+ if (stderr !== "") {
84
+ throw new _n8nworkflow.NodeOperationError(this.func.getNode(), new Error(stderr));
85
+ }
86
+ this.func.logger.debug(`Result ${stdout}`);
87
+ return JSON.parse(stdout);
88
+ }
89
+ constructor(credentials, func){
90
+ super(func);
91
+ _define_property(this, "docker", void 0);
92
+ if (credentials === undefined) {
93
+ throw new _n8nworkflow.NodeOperationError(func.getNode(), new Error("No credentials got returned!"));
94
+ }
95
+ this.docker = new _dockerode.default(credentials);
96
+ }
97
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Executor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Executor;
9
+ }
10
+ });
11
+ const _connectionType = require("../connectionType");
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
25
+ class Executor {
26
+ async run(cmd, image, env) {
27
+ const { index } = this.func.addInputData(_connectionType.NodeConnectionType.Executor, [
28
+ [
29
+ {
30
+ json: {
31
+ cmd,
32
+ image,
33
+ env
34
+ }
35
+ }
36
+ ]
37
+ ]);
38
+ const resp = await this.__run(cmd, image, env);
39
+ this.func.addOutputData(_connectionType.NodeConnectionType.Executor, index, [
40
+ this.func.helpers.returnJsonArray(resp)
41
+ ]);
42
+ return resp;
43
+ }
44
+ constructor(func){
45
+ _define_property(this, "func", void 0);
46
+ this.func = func;
47
+ }
48
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "K8sExecutor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return K8sExecutor;
9
+ }
10
+ });
11
+ const _stream = require("stream");
12
+ const _clientnode = /*#__PURE__*/ _interop_require_wildcard(require("@kubernetes/client-node"));
13
+ const _n8nworkflow = require("n8n-workflow");
14
+ const _executor = require("./executor");
15
+ function _define_property(obj, key, value) {
16
+ if (key in obj) {
17
+ Object.defineProperty(obj, key, {
18
+ value: value,
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true
22
+ });
23
+ } else {
24
+ obj[key] = value;
25
+ }
26
+ return obj;
27
+ }
28
+ function _getRequireWildcardCache(nodeInterop) {
29
+ if (typeof WeakMap !== "function") return null;
30
+ var cacheBabelInterop = new WeakMap();
31
+ var cacheNodeInterop = new WeakMap();
32
+ return (_getRequireWildcardCache = function(nodeInterop) {
33
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
34
+ })(nodeInterop);
35
+ }
36
+ function _interop_require_wildcard(obj, nodeInterop) {
37
+ if (!nodeInterop && obj && obj.__esModule) {
38
+ return obj;
39
+ }
40
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
41
+ return {
42
+ default: obj
43
+ };
44
+ }
45
+ var cache = _getRequireWildcardCache(nodeInterop);
46
+ if (cache && cache.has(obj)) {
47
+ return cache.get(obj);
48
+ }
49
+ var newObj = {
50
+ __proto__: null
51
+ };
52
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
53
+ for(var key in obj){
54
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
55
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
56
+ if (desc && (desc.get || desc.set)) {
57
+ Object.defineProperty(newObj, key, desc);
58
+ } else {
59
+ newObj[key] = obj[key];
60
+ }
61
+ }
62
+ }
63
+ newObj.default = obj;
64
+ if (cache) {
65
+ cache.set(obj, newObj);
66
+ }
67
+ return newObj;
68
+ }
69
+ class K8sExecutor extends _executor.Executor {
70
+ async __run(cmd, image, env) {
71
+ const kc = this.kubeConfig;
72
+ const k8sCoreApi = kc.makeApiClient(_clientnode.CoreV1Api);
73
+ const pods = (await k8sCoreApi.listNamespacedPod("default", undefined, undefined, undefined, undefined, "managed-by=n8n-nodes-soar")).body.items.filter((n)=>(n.status?.phase === "Running" || n.status?.phase === "Pending") && n.spec?.containers[0].image === image);
74
+ let pod = undefined;
75
+ const namespace = "default";
76
+ if (pods.length > 0) {
77
+ pod = pods[0];
78
+ } else {
79
+ const podName = `n8n-soar-pod-${Date.now()}`;
80
+ const podSpec = {
81
+ metadata: {
82
+ name: podName,
83
+ labels: {
84
+ "managed-by": "n8n-nodes-soar"
85
+ }
86
+ },
87
+ spec: {
88
+ restartPolicy: "Always",
89
+ containers: [
90
+ {
91
+ name: "main-container",
92
+ image,
93
+ imagePullPolicy: "Always",
94
+ args: [
95
+ "sleep",
96
+ "infinity"
97
+ ],
98
+ lifecycle: {}
99
+ }
100
+ ]
101
+ }
102
+ };
103
+ this.func.logger.debug("Creating pod " + JSON.stringify(podSpec));
104
+ const resp = await k8sCoreApi.createNamespacedPod(namespace, podSpec);
105
+ pod = resp.body;
106
+ }
107
+ const name = pod.metadata?.name;
108
+ if (!name) {
109
+ throw new Error("Pod name not set!");
110
+ }
111
+ // if is in initial
112
+ if (pod.status?.phase === "Pending") {
113
+ while(true){
114
+ const pod = (await k8sCoreApi.readNamespacedPod(name, namespace)).body;
115
+ if (pod.status?.phase === "Running") {
116
+ break;
117
+ }
118
+ await new Promise((resolve)=>setTimeout(resolve, 1000));
119
+ }
120
+ }
121
+ // exec into pod and get stdout/stderr
122
+ const exec = new _clientnode.Exec(kc);
123
+ const stdout = new _stream.Writable();
124
+ let stdoutString = "";
125
+ stdout._write = (chunk, encoding, next)=>{
126
+ stdoutString += chunk.toString();
127
+ next();
128
+ };
129
+ const stderr = new _stream.Writable();
130
+ let stderrString = "";
131
+ stderr._write = (chunk, encoding, next)=>{
132
+ stderrString += chunk.toString();
133
+ next();
134
+ };
135
+ this.func.logger.debug(`Running ${cmd.join(" ")}`);
136
+ await new Promise(async (resolve, reject)=>{
137
+ exec.exec(namespace, name, "main-container", [
138
+ "env",
139
+ ...Object.entries(env || {}).flatMap(([k, v])=>[
140
+ "-e",
141
+ `${k}=${v}`
142
+ ]),
143
+ ...cmd
144
+ ], stdout, stderr, null, false, (s)=>{
145
+ switch(s.status){
146
+ case "Failure":
147
+ reject(s.message);
148
+ break;
149
+ case "Success":
150
+ resolve(undefined);
151
+ break;
152
+ }
153
+ }).catch(reject);
154
+ });
155
+ stderrString;
156
+ if (stderrString !== "") {
157
+ throw new _n8nworkflow.NodeOperationError(this.func.getNode(), new Error(stderrString));
158
+ }
159
+ this.func.logger.debug(`Result ${stdoutString}`);
160
+ return JSON.parse(stdoutString);
161
+ }
162
+ constructor(credentials, func){
163
+ super(func);
164
+ _define_property(this, "kubeConfig", void 0);
165
+ if (credentials === undefined) {
166
+ throw new _n8nworkflow.NodeOperationError(func.getNode(), new Error("No credentials got returned!"));
167
+ }
168
+ const kubeConfig = new _clientnode.KubeConfig();
169
+ switch(credentials.loadFrom){
170
+ case "automatic":
171
+ kubeConfig.loadFromDefault();
172
+ break;
173
+ case "file":
174
+ if (typeof credentials.filePath !== "string" || credentials.filePath === "") {
175
+ throw new _n8nworkflow.NodeOperationError(func.getNode(), new Error("File path not set!"));
176
+ }
177
+ kubeConfig.loadFromFile(credentials.filePath);
178
+ break;
179
+ case "content":
180
+ if (typeof credentials.content !== "string" || credentials.content === "") {
181
+ throw new _n8nworkflow.NodeOperationError(func.getNode(), new Error("Content not set!"));
182
+ }
183
+ kubeConfig.loadFromString(credentials.content);
184
+ break;
185
+ default:
186
+ throw new _n8nworkflow.NodeOperationError(func.getNode(), new Error("Load from value not set!"));
187
+ }
188
+ this.kubeConfig = kubeConfig;
189
+ }
190
+ }
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ ContainerRunner: function() {
13
+ return ContainerRunner;
14
+ },
15
+ IMAGE: function() {
16
+ return IMAGE;
17
+ },
18
+ injectCommonProperties: function() {
19
+ return injectCommonProperties;
20
+ }
21
+ });
22
+ const _n8nworkflow = require("n8n-workflow");
23
+ const _runner = require("./runner");
24
+ const IMAGE = {
25
+ DEFAULT: "registry.yoshino-s.xyz/yoshino-s/soar-image:dev",
26
+ SCRIPT: "registry.yoshino-s.xyz/yoshino-s/soar-image/script:dev"
27
+ };
28
+ const injectCommonProperties = (p)=>{
29
+ return [
30
+ ...p,
31
+ {
32
+ displayName: "Advanced Config",
33
+ name: "advanced",
34
+ type: "fixedCollection",
35
+ default: {},
36
+ typeOptions: {
37
+ multipleValues: true
38
+ },
39
+ options: [
40
+ {
41
+ name: "envs",
42
+ displayName: "Envs",
43
+ values: [
44
+ {
45
+ displayName: "Key",
46
+ name: "key",
47
+ type: "string",
48
+ default: ""
49
+ },
50
+ {
51
+ displayName: "Value",
52
+ name: "value",
53
+ type: "string",
54
+ default: ""
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ name: "Files",
60
+ displayName: "Files",
61
+ values: [
62
+ {
63
+ displayName: "Name",
64
+ name: "name",
65
+ type: "string",
66
+ default: ""
67
+ },
68
+ {
69
+ displayName: "Content",
70
+ name: "content",
71
+ type: "string",
72
+ default: ""
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ displayName: "Collect Files",
78
+ name: "collectFiles",
79
+ values: [
80
+ {
81
+ displayName: "Name",
82
+ name: "name",
83
+ type: "string",
84
+ default: ""
85
+ }
86
+ ]
87
+ }
88
+ ]
89
+ }
90
+ ];
91
+ };
92
+ class ContainerRunner extends _runner.Runner {
93
+ collectGeneratedOptions(extraArgParameters) {
94
+ const cmdline = [];
95
+ for (const parameter of extraArgParameters){
96
+ const value = this.func.getNodeParameter(parameter, this.itemIndex, null);
97
+ if (!value) continue;
98
+ if (typeof value === "string") {
99
+ cmdline.push(parameter, value);
100
+ } else if (Array.isArray(value)) {
101
+ value.forEach((v)=>{
102
+ if (typeof v === "string") {
103
+ cmdline.push(v);
104
+ } else {
105
+ const { key, value } = v;
106
+ if (value) {
107
+ cmdline.push(key, value);
108
+ } else {
109
+ cmdline.push(key);
110
+ }
111
+ }
112
+ });
113
+ }
114
+ }
115
+ return cmdline;
116
+ }
117
+ options(assets) {
118
+ assets;
119
+ const options = {
120
+ envs: {},
121
+ files: {},
122
+ collectFiles: []
123
+ };
124
+ const _env = this.func.getNodeParameter("advanced.envs", this.itemIndex, []);
125
+ options.envs = Object.fromEntries(_env.map(({ key, value })=>[
126
+ key,
127
+ value
128
+ ]));
129
+ const _files = this.func.getNodeParameter("advanced.files", this.itemIndex, []);
130
+ options.files = Object.fromEntries(_files.map(({ name, content })=>[
131
+ name,
132
+ content
133
+ ]));
134
+ const _collectFiles = this.func.getNodeParameter("advanced.collectFiles", this.itemIndex, []);
135
+ options.collectFiles = _collectFiles.map(({ name })=>name);
136
+ return options;
137
+ }
138
+ async __run(collector, assets) {
139
+ if (collector.executor === undefined) {
140
+ throw new _n8nworkflow.NodeOperationError(this.func.getNode(), "Executor is not set");
141
+ }
142
+ const options = this.options(assets);
143
+ const cmd = this.cmd(assets);
144
+ let cmdline = [
145
+ "/usr/local/bin/runner"
146
+ ];
147
+ if (options.files) {
148
+ for (const [key, value] of Object.entries(options.files)){
149
+ cmdline.push("--files", `${key}:${value}`);
150
+ }
151
+ }
152
+ if (options.collectFiles) {
153
+ for (const key of options.collectFiles){
154
+ cmdline.push("--collect-files", key);
155
+ }
156
+ }
157
+ if (options.ignoreStdout) {
158
+ cmdline.push("--ignore-stdout");
159
+ }
160
+ if (options.ignoreStderr) {
161
+ cmdline.push("--ignore-stderr");
162
+ }
163
+ cmdline.push("--");
164
+ cmdline = cmdline.concat(cmd);
165
+ const { stdout, stderr, error, files: resultFiles } = await collector.executor.run(cmdline, options.image ?? IMAGE.DEFAULT, options.envs);
166
+ if (error) {
167
+ throw new _n8nworkflow.NodeOperationError(this.func.getNode(), new Error(error));
168
+ }
169
+ if (stderr) {
170
+ this.func.logger.warn(stderr);
171
+ }
172
+ return this.process(assets, stdout, resultFiles ?? {});
173
+ }
174
+ }