@sw-tsdk/plugin-connector 3.9.2 → 3.11.2

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 (50) hide show
  1. package/README.md +84 -35
  2. package/lib/commands/action/run/local.js +1 -1
  3. package/lib/commands/action/run/local.js.map +1 -1
  4. package/lib/commands/connector/create/openapi.js +48 -30
  5. package/lib/commands/connector/create/openapi.js.map +1 -1
  6. package/lib/commands/migrator/convert.d.ts +25 -0
  7. package/lib/commands/migrator/convert.js +224 -0
  8. package/lib/commands/migrator/convert.js.map +1 -0
  9. package/lib/commands/migrator/export.d.ts +13 -0
  10. package/lib/commands/migrator/export.js +121 -0
  11. package/lib/commands/migrator/export.js.map +1 -0
  12. package/lib/common.js +1 -0
  13. package/lib/common.js.map +1 -1
  14. package/lib/templates/migrator-runners/image.png +0 -0
  15. package/lib/templates/migrator-runners/plugin_override.txt +34 -0
  16. package/lib/templates/migrator-runners/runner_override.txt +22 -0
  17. package/lib/templates/migrator-runners/script_override.txt +31 -0
  18. package/lib/templates/python_312_definition/template/connector/config/actions/example.yaml +40 -0
  19. package/lib/templates/python_312_definition/template/connector/config/assets/example.yaml +27 -0
  20. package/lib/templates/python_312_definition/template/data/asset.json +1 -0
  21. package/lib/templates/python_312_definition/template/docs/CHANGELOG.md.t +7 -0
  22. package/lib/templates/python_312_definition/template/docs/README.md +38 -0
  23. package/lib/templates/python_312_definition/template/requirements.txt +0 -0
  24. package/lib/templates/python_312_definition/template_src/connector/config/actions/example.yaml +40 -0
  25. package/lib/templates/python_312_definition/template_src/connector/config/assets/example.yaml +27 -0
  26. package/lib/templates/python_312_definition/template_src/connector/src/runner_override.py +11 -0
  27. package/lib/templates/python_312_definition/template_src/data/asset.json +1 -0
  28. package/lib/templates/python_312_definition/template_src/docs/CHANGELOG.md.t +7 -0
  29. package/lib/templates/python_312_definition/template_src/docs/README.md +38 -0
  30. package/lib/templates/python_312_definition/template_src/requirements.txt +0 -0
  31. package/lib/transformers/base-transformer.d.ts +6 -0
  32. package/lib/transformers/base-transformer.js +54 -0
  33. package/lib/transformers/base-transformer.js.map +1 -0
  34. package/lib/transformers/connector-generator.d.ts +18 -0
  35. package/lib/transformers/connector-generator.js +327 -0
  36. package/lib/transformers/connector-generator.js.map +1 -0
  37. package/lib/transformers/forked-plugin-transformer.d.ts +4 -0
  38. package/lib/transformers/forked-plugin-transformer.js +16 -0
  39. package/lib/transformers/forked-plugin-transformer.js.map +1 -0
  40. package/lib/transformers/index.d.ts +3 -0
  41. package/lib/transformers/index.js +17 -0
  42. package/lib/transformers/index.js.map +1 -0
  43. package/lib/transformers/script-transformer.d.ts +5 -0
  44. package/lib/transformers/script-transformer.js +16 -0
  45. package/lib/transformers/script-transformer.js.map +1 -0
  46. package/lib/types/migrator-types.d.ts +59 -0
  47. package/lib/types/migrator-types.js +18 -0
  48. package/lib/types/migrator-types.js.map +1 -0
  49. package/oclif.manifest.json +133 -2
  50. package/package.json +13 -6
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTransformer = void 0;
4
+ const script_transformer_1 = require("./script-transformer");
5
+ const forked_plugin_transformer_1 = require("./forked-plugin-transformer");
6
+ const migrator_types_1 = require("../types/migrator-types");
7
+ function getTransformer(jsonFileContent) {
8
+ if (jsonFileContent?.Action?.ForkedFromPackage) {
9
+ return new forked_plugin_transformer_1.ForkedPluginTransformer();
10
+ }
11
+ if (jsonFileContent?.Action?.Script) {
12
+ return new script_transformer_1.ScriptTransformer();
13
+ }
14
+ throw new migrator_types_1.UnsupportedTransformerError();
15
+ }
16
+ exports.getTransformer = getTransformer;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AACtD,2EAAmE;AACnE,4DAAmE;AAEnE,SAAgB,cAAc,CAAC,eAAoB;IACjD,IAAI,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE;QAC9C,OAAO,IAAI,mDAAuB,EAAE,CAAA;KACrC;IAED,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE;QACnC,OAAO,IAAI,sCAAiB,EAAE,CAAA;KAC/B;IAED,MAAM,IAAI,4CAA2B,EAAE,CAAA;AACzC,CAAC;AAVD,wCAUC"}
@@ -0,0 +1,5 @@
1
+ import { TransformationResult } from '../types/migrator-types';
2
+ import { BaseTransformer } from './base-transformer';
3
+ export declare class ScriptTransformer extends BaseTransformer {
4
+ transform(jsonFileContent: any): TransformationResult;
5
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScriptTransformer = void 0;
4
+ const base_transformer_1 = require("./base-transformer");
5
+ class ScriptTransformer extends base_transformer_1.BaseTransformer {
6
+ transform(jsonFileContent) {
7
+ const commonFields = this.parseCommonFields(jsonFileContent);
8
+ return {
9
+ ...commonFields,
10
+ type: 'script',
11
+ dependencies: [],
12
+ };
13
+ }
14
+ }
15
+ exports.ScriptTransformer = ScriptTransformer;
16
+ //# sourceMappingURL=script-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-transformer.js","sourceRoot":"","sources":["../../src/transformers/script-transformer.ts"],"names":[],"mappings":";;;AACA,yDAAkD;AAElD,MAAa,iBAAkB,SAAQ,kCAAe;IAC7C,SAAS,CAAC,eAAoB;QACnC,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAA;QAC5D,OAAO;YACL,GAAG,YAAY;YACf,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,EAAE;SACjB,CAAA;IACH,CAAC;CACF;AATD,8CASC"}
@@ -0,0 +1,59 @@
1
+ export interface ConnectorMigrationConfig {
2
+ name: string;
3
+ vendor: string;
4
+ product: string;
5
+ description: string;
6
+ template: string;
7
+ author: string;
8
+ authorEmail: string;
9
+ homepage: string;
10
+ }
11
+ export declare const pythonVersionMap: {
12
+ readonly python3: "python_39_definition";
13
+ readonly python39: "python_39_definition";
14
+ readonly python310: "python_310_definition";
15
+ readonly python311: "python_311_definition";
16
+ readonly python312: "python_312_definition";
17
+ };
18
+ export type PythonVersionKey = keyof typeof pythonVersionMap;
19
+ export interface AppTasks {
20
+ pythonDirName: PythonVersionKey;
21
+ pythonDefinition: string;
22
+ appFolderPath: string;
23
+ connectorName: string;
24
+ taskFilePaths: string[];
25
+ }
26
+ export interface TransformationResult {
27
+ exportName: string;
28
+ exportUid: string;
29
+ type: 'script' | 'plugin';
30
+ dependencies: string[];
31
+ description: string;
32
+ family: string;
33
+ base64Image: string;
34
+ pythonVersion: string;
35
+ actionName: string;
36
+ script: string;
37
+ forkedName: string;
38
+ inputs: {
39
+ Key: string;
40
+ Creds: boolean;
41
+ Example: [];
42
+ Title: string;
43
+ ValueType: string;
44
+ }[];
45
+ outputs: {
46
+ Key: string;
47
+ Example: [];
48
+ Title: string;
49
+ ValueType: string;
50
+ Description: string;
51
+ }[];
52
+ vendor: string;
53
+ version: string;
54
+ author: string;
55
+ error?: string;
56
+ }
57
+ export declare class UnsupportedTransformerError extends Error {
58
+ constructor();
59
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedTransformerError = exports.pythonVersionMap = void 0;
4
+ // folder names the export tool creates : python versions supported by the tsdk
5
+ exports.pythonVersionMap = {
6
+ python3: 'python_39_definition',
7
+ python39: 'python_39_definition',
8
+ python310: 'python_310_definition',
9
+ python311: 'python_311_definition',
10
+ python312: 'python_312_definition',
11
+ };
12
+ class UnsupportedTransformerError extends Error {
13
+ constructor() {
14
+ super('Unsupported transformer');
15
+ }
16
+ }
17
+ exports.UnsupportedTransformerError = UnsupportedTransformerError;
18
+ //# sourceMappingURL=migrator-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrator-types.js","sourceRoot":"","sources":["../../src/types/migrator-types.ts"],"names":[],"mappings":";;;AAWA,+EAA+E;AAClE,QAAA,gBAAgB,GAAG;IAC9B,OAAO,EAAE,sBAAsB;IAC/B,QAAQ,EAAE,sBAAsB;IAChC,SAAS,EAAE,uBAAuB;IAClC,SAAS,EAAE,uBAAuB;IAClC,SAAS,EAAE,uBAAuB;CAC1B,CAAA;AAiCV,MAAa,2BAA4B,SAAQ,KAAK;IACpD;QACE,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAClC,CAAC;CACF;AAJD,kEAIC"}
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.9.2",
2
+ "version": "3.11.2",
3
3
  "commands": {
4
4
  "action:add": {
5
5
  "id": "action:add",
@@ -1003,6 +1003,136 @@
1003
1003
  },
1004
1004
  "args": {}
1005
1005
  },
1006
+ "migrator:convert": {
1007
+ "id": "migrator:convert",
1008
+ "description": "Convert scripts and forked plugins from Swimlane V10x to connectors.",
1009
+ "strict": true,
1010
+ "pluginName": "@sw-tsdk/plugin-connector",
1011
+ "pluginAlias": "@sw-tsdk/plugin-connector",
1012
+ "pluginType": "core",
1013
+ "aliases": [],
1014
+ "flags": {
1015
+ "fromDirectory": {
1016
+ "name": "fromDirectory",
1017
+ "type": "option",
1018
+ "char": "f",
1019
+ "description": "Root directory of the 10X export.",
1020
+ "multiple": false,
1021
+ "default": "./"
1022
+ },
1023
+ "toDirectory": {
1024
+ "name": "toDirectory",
1025
+ "type": "option",
1026
+ "char": "t",
1027
+ "description": "Root directory of the destination repository.",
1028
+ "multiple": false,
1029
+ "default": "./connectors"
1030
+ },
1031
+ "vendor": {
1032
+ "name": "vendor",
1033
+ "type": "option",
1034
+ "description": "Vendor (e.g. CrowdStrike)",
1035
+ "multiple": false
1036
+ },
1037
+ "product": {
1038
+ "name": "product",
1039
+ "type": "option",
1040
+ "description": "Product (e.g. Falcon)",
1041
+ "multiple": false
1042
+ },
1043
+ "description": {
1044
+ "name": "description",
1045
+ "type": "option",
1046
+ "description": "Description (e.g. CrowdStrike Host Query API)",
1047
+ "multiple": false
1048
+ },
1049
+ "author": {
1050
+ "name": "author",
1051
+ "type": "option",
1052
+ "description": "Connector Author",
1053
+ "multiple": false
1054
+ },
1055
+ "authorEmail": {
1056
+ "name": "authorEmail",
1057
+ "type": "option",
1058
+ "description": "Connector Author Email",
1059
+ "multiple": false
1060
+ },
1061
+ "homepage": {
1062
+ "name": "homepage",
1063
+ "type": "option",
1064
+ "description": "Connector Author Support URL",
1065
+ "multiple": false
1066
+ },
1067
+ "help": {
1068
+ "name": "help",
1069
+ "type": "boolean",
1070
+ "char": "h",
1071
+ "description": "Show CLI help.",
1072
+ "allowNo": false
1073
+ }
1074
+ },
1075
+ "args": {}
1076
+ },
1077
+ "migrator:export": {
1078
+ "id": "migrator:export",
1079
+ "description": "Use to export python scripts from a Swimlane instance",
1080
+ "strict": true,
1081
+ "pluginName": "@sw-tsdk/plugin-connector",
1082
+ "pluginAlias": "@sw-tsdk/plugin-connector",
1083
+ "pluginType": "core",
1084
+ "aliases": [],
1085
+ "flags": {
1086
+ "log-level": {
1087
+ "name": "log-level",
1088
+ "type": "option",
1089
+ "hidden": true,
1090
+ "multiple": false,
1091
+ "options": [
1092
+ "debug"
1093
+ ]
1094
+ },
1095
+ "mongoConnectionString": {
1096
+ "name": "mongoConnectionString",
1097
+ "type": "option",
1098
+ "char": "c",
1099
+ "description": "Mongo Connection String",
1100
+ "multiple": false,
1101
+ "default": ""
1102
+ },
1103
+ "databaseName": {
1104
+ "name": "databaseName",
1105
+ "type": "option",
1106
+ "char": "d",
1107
+ "description": "Database Name",
1108
+ "multiple": false,
1109
+ "default": "Swimlane"
1110
+ },
1111
+ "outputFile": {
1112
+ "name": "outputFile",
1113
+ "type": "option",
1114
+ "char": "o",
1115
+ "description": "Output file",
1116
+ "multiple": false,
1117
+ "default": "scripts.zip"
1118
+ },
1119
+ "tlsAllowInvalidCertificates": {
1120
+ "name": "tlsAllowInvalidCertificates",
1121
+ "type": "boolean",
1122
+ "char": "i",
1123
+ "description": "Allow invalid certificates",
1124
+ "allowNo": false
1125
+ },
1126
+ "help": {
1127
+ "name": "help",
1128
+ "type": "boolean",
1129
+ "char": "h",
1130
+ "description": "Show CLI help.",
1131
+ "allowNo": false
1132
+ }
1133
+ },
1134
+ "args": {}
1135
+ },
1006
1136
  "playbook:create": {
1007
1137
  "id": "playbook:create",
1008
1138
  "description": "Scaffold a new playbook",
@@ -1874,7 +2004,8 @@
1874
2004
  "node_20",
1875
2005
  "python_39_definition",
1876
2006
  "python_310_definition",
1877
- "python_311_definition"
2007
+ "python_311_definition",
2008
+ "python_312_definition"
1878
2009
  ]
1879
2010
  },
1880
2011
  "compile-override": {
package/package.json CHANGED
@@ -6,13 +6,16 @@
6
6
  "dependencies": {
7
7
  "@apidevtools/json-schema-ref-parser": "10.1.0",
8
8
  "@oclif/core": "2.8.5",
9
- "@sw-tsdk/common": "^3.9.2",
10
- "@sw-tsdk/connector": "^3.9.2",
11
- "@sw-tsdk/core": "^3.9.2",
12
- "@sw-tsdk/docker": "^3.9.2",
9
+ "@sw-tsdk/common": "^3.11.2",
10
+ "@sw-tsdk/connector": "^3.11.2",
11
+ "@sw-tsdk/core": "^3.11.2",
12
+ "@sw-tsdk/docker": "^3.11.2",
13
13
  "@swimlane/connector-interfaces": "1.11.0",
14
14
  "@swimlane/cosign": "1.4.1",
15
15
  "@swimlane/docker-reference": "2.0.1",
16
+ "@types/adm-zip": "^0.5.7",
17
+ "adm-zip": "0.5.1",
18
+ "archiver": "^7.0.1",
16
19
  "fs-extra": "11.1.1",
17
20
  "handlebars": "4.7.7",
18
21
  "inquirer": "8.2.2",
@@ -21,6 +24,7 @@
21
24
  "json-schema-faker": "0.5.0-rcv.46",
22
25
  "json-schema-typed": "7.0.3",
23
26
  "listr2": "6.6.0",
27
+ "mongodb": "^6.13.1",
24
28
  "noop-stream": "1.0.0",
25
29
  "npmlog": "7.0.1",
26
30
  "semver": "7.5.2",
@@ -73,6 +77,9 @@
73
77
  },
74
78
  "description": {
75
79
  "description": "Local description commands"
80
+ },
81
+ "migrator": {
82
+ "description": "Local migrator commands"
76
83
  }
77
84
  }
78
85
  },
@@ -95,6 +102,6 @@
95
102
  "posttest": "yarn lint",
96
103
  "dev:setup": "npm link"
97
104
  },
98
- "version": "3.9.2",
99
- "gitHead": "cd2fcf6dc457eb607ed0655689f26d3730190e9b"
105
+ "version": "3.11.2",
106
+ "gitHead": "6d49f5984522f27b6d8de39625a0db4735bc03ec"
100
107
  }