@jupiterone/integration-sdk-cli 17.2.0 → 17.2.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupiterone/integration-sdk-cli",
3
- "version": "17.2.0",
3
+ "version": "17.2.1",
4
4
  "description": "The SDK for developing JupiterOne integrations",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -25,8 +25,8 @@
25
25
  "plop": "plop --plopfile dist/src/generator/newIntegration.js"
26
26
  },
27
27
  "dependencies": {
28
- "@jupiterone/integration-sdk-core": "^17.2.0",
29
- "@jupiterone/integration-sdk-runtime": "^17.2.0",
28
+ "@jupiterone/integration-sdk-core": "^17.2.1",
29
+ "@jupiterone/integration-sdk-runtime": "^17.2.1",
30
30
  "chalk": "^4",
31
31
  "commander": "^9.4.0",
32
32
  "ejs": "^3.1.9",
@@ -40,12 +40,11 @@
40
40
  "neo4j-driver": "^4.3.3",
41
41
  "plop": "^3.1.2",
42
42
  "runtypes": "5.1.0",
43
- "upath": "^1.2.0",
44
- "url-exists": "^1.0.3"
43
+ "upath": "^1.2.0"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@jupiterone/data-model": "^0.62.0",
48
- "@jupiterone/integration-sdk-private-test-utils": "^17.2.0",
47
+ "@jupiterone/integration-sdk-private-test-utils": "^17.2.1",
49
48
  "@pollyjs/adapter-node-http": "^6.0.5",
50
49
  "@pollyjs/core": "^6.0.5",
51
50
  "@pollyjs/persister-fs": "^6.0.5",
@@ -61,5 +60,5 @@
61
60
  "peerDependencies": {
62
61
  "@jupiterone/data-model": ">= 0.62.0"
63
62
  },
64
- "gitHead": "3c61544ad88f01c1c0f72d862040aee7f372e4dd"
63
+ "gitHead": "7a21455358e5eca047711830d9cd5376fd3ee6fb"
65
64
  }
@@ -9,7 +9,6 @@ export * from './validate-question-file';
9
9
  export * from './neo4j';
10
10
  export * from './visualize-dependencies';
11
11
  export * from './generate-integration-graph-schema';
12
- export * from './troubleshoot';
13
12
  export * from './generate-ingestion-sources-config';
14
13
  export * from './generate';
15
14
  export * from './bocchi';
package/src/index.ts CHANGED
@@ -13,7 +13,6 @@ import {
13
13
  visualizeDependencies,
14
14
  generateIntegrationGraphSchemaCommand,
15
15
  generateIngestionSourcesConfigCommand,
16
- troubleshootLocalExecution,
17
16
  generate,
18
17
  bocchi,
19
18
  } from './commands';
@@ -32,7 +31,6 @@ export function createCli() {
32
31
  .addCommand(visualizeDependencies())
33
32
  .addCommand(generateIntegrationGraphSchemaCommand())
34
33
  .addCommand(generateIngestionSourcesConfigCommand())
35
- .addCommand(troubleshootLocalExecution())
36
34
  .addCommand(generate())
37
35
  .addCommand(bocchi());
38
36
  }
@@ -1 +0,0 @@
1
- export declare function troubleshootLocalExecution(): import("commander").Command;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.troubleshootLocalExecution = troubleshootLocalExecution;
4
- const commander_1 = require("commander");
5
- const troubleshoot_1 = require("../troubleshoot");
6
- function troubleshootLocalExecution() {
7
- return (0, commander_1.createCommand)('troubleshoot')
8
- .description('troubleshoot common issues with local execution')
9
- .option('-p, --project-path <directory>', 'path to integration project directory', process.cwd())
10
- .action(async (options) => {
11
- await (0, troubleshoot_1.troubleshoot)(options);
12
- });
13
- }
14
- //# sourceMappingURL=troubleshoot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"troubleshoot.js","sourceRoot":"","sources":["../../../src/commands/troubleshoot.ts"],"names":[],"mappings":";;AAIA,gEAWC;AAfD,yCAA0C;AAE1C,kDAA+C;AAE/C,SAAgB,0BAA0B;IACxC,OAAO,IAAA,yBAAa,EAAC,cAAc,CAAC;SACjC,WAAW,CAAC,iDAAiD,CAAC;SAC9D,MAAM,CACL,gCAAgC,EAChC,uCAAuC,EACvC,OAAO,CAAC,GAAG,EAAE,CACd;SACA,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +0,0 @@
1
- export * from './troubleshoot';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./troubleshoot"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/troubleshoot/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -1 +0,0 @@
1
- export declare function troubleshoot(options: any): Promise<void>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.troubleshoot = troubleshoot;
27
- const log = __importStar(require("../log"));
28
- const os = __importStar(require("os"));
29
- const utils_1 = require("./utils");
30
- // Check items that our integrations aren't already checking or items
31
- // that would normally be checked or handled by the managed execution
32
- // in JupiterOne
33
- async function troubleshoot(options) {
34
- log.info(`Troubleshooting code found at ${options.projectPath}`);
35
- log.info(`Checking Operating System Information`);
36
- log.info(`OS Architecture: ${os.arch()}`);
37
- log.info(`OS Platform: ${os.platform()}`);
38
- log.info(`OS Version: ${os.version()}`);
39
- log.info(`Checking Node version: ${process.version}`);
40
- // Check versions of packages (SDK, graph project, ) and suggest that they upgrade if it is out of date
41
- (0, utils_1.getVersions)(options.projectPath);
42
- log.info(`Checking for Docker Info`);
43
- await (0, utils_1.executeWithLogging)('docker info');
44
- // Check authentication. If this fails, we will also check if it
45
- // might be due to missing or self signed certs
46
- await (0, utils_1.executeValidateAuthentication)(options.projectPath);
47
- }
48
- // TODO (adam-in-ict) In the future, possibly run this every time it is run outside the managed environment?
49
- // TODO (adam-in-ict) Should we add a preamble to every execution that shows SDK version and graph- project?
50
- //# sourceMappingURL=troubleshoot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"troubleshoot.js","sourceRoot":"","sources":["../../../src/troubleshoot/troubleshoot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWA,oCAkBC;AA7BD,4CAA8B;AAC9B,uCAAyB;AACzB,mCAIiB;AAEjB,qEAAqE;AACrE,qEAAqE;AACrE,gBAAgB;AACT,KAAK,UAAU,YAAY,CAAC,OAAO;IACxC,GAAG,CAAC,IAAI,CAAC,iCAAiC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAEjE,GAAG,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAClD,GAAG,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3C,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3C,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAEzC,GAAG,CAAC,IAAI,CAAC,0BAA0B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACtD,uGAAuG;IACvG,IAAA,mBAAW,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAEjC,GAAG,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACrC,MAAM,IAAA,0BAAkB,EAAC,aAAa,CAAC,CAAC;IAExC,iEAAiE;IACjE,+CAA+C;IAC/C,MAAM,IAAA,qCAA6B,EAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED,4GAA4G;AAE5G,4GAA4G"}
@@ -1,4 +0,0 @@
1
- export declare function executeWithLogging(command: string): Promise<void>;
2
- export declare function executeValidateAuthentication(directory: string): Promise<void>;
3
- export declare function endpointCheck(url: string): void;
4
- export declare function getVersions(path: string): void;
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.executeWithLogging = executeWithLogging;
30
- exports.executeValidateAuthentication = executeValidateAuthentication;
31
- exports.endpointCheck = endpointCheck;
32
- exports.getVersions = getVersions;
33
- const integration_sdk_runtime_1 = require("@jupiterone/integration-sdk-runtime");
34
- const child_process_1 = require("child_process");
35
- const log = __importStar(require("../log"));
36
- const path_1 = __importDefault(require("path"));
37
- const config_1 = require("../config");
38
- const url_exists_1 = __importDefault(require("url-exists"));
39
- const fs = __importStar(require("fs"));
40
- async function executeWithLogging(command) {
41
- return new Promise((resolve, reject) => {
42
- const childProcess = (0, child_process_1.exec)(command);
43
- if (childProcess.stdout) {
44
- childProcess.stdout.pipe(process.stdout);
45
- }
46
- childProcess.on('exit', () => {
47
- resolve();
48
- });
49
- childProcess.on('error', (err) => {
50
- reject(err);
51
- });
52
- });
53
- }
54
- async function executeValidateAuthentication(directory) {
55
- log.info(`Checking authentication using values in .env file`);
56
- try {
57
- const config = (0, integration_sdk_runtime_1.prepareLocalStepCollection)(await (0, config_1.loadConfig)(path_1.default.join(directory, 'src')));
58
- await Promise.resolve(`${`${directory}/src/index`}`).then(s => __importStar(require(s))).then(async ({ invocationConfig }) => {
59
- await invocationConfig.validateInvocation({
60
- instance: (0, integration_sdk_runtime_1.createIntegrationInstanceForLocalExecution)(config),
61
- });
62
- });
63
- }
64
- catch (err) {
65
- log.info(`Call to validateInvocation failed.`);
66
- log.info(JSON.stringify(err));
67
- if (err.endpoint) {
68
- endpointCheck(err.endpoint);
69
- }
70
- }
71
- }
72
- function endpointCheck(url) {
73
- log.info(`Checking availability of endpoint ${url}`);
74
- try {
75
- (0, url_exists_1.default)(url, function (err, exists) {
76
- if (exists) {
77
- log.info(`Endpoint can be successfully reached.`);
78
- }
79
- else {
80
- log.info(`Checking availability of endpoint with certificate verification disabled.`);
81
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
82
- (0, url_exists_1.default)(url, function (err, exists) {
83
- if (exists) {
84
- log.info(`Endpoint can be successfully reached only after disabling TLS certificate validation.`);
85
- }
86
- else {
87
- log.info(`Endpoint is unreachable`);
88
- }
89
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1';
90
- });
91
- }
92
- });
93
- }
94
- catch (err) {
95
- log.info(err);
96
- }
97
- }
98
- function getVersions(path) {
99
- log.info(`Checking versions from ${path}/package.json`);
100
- try {
101
- const packages = JSON.parse(fs.readFileSync(`${path}/package.json`, 'utf8'));
102
- log.info(`Main package name: ${packages.name}`);
103
- log.info(`Main package version: ${packages.version}`);
104
- if (packages.dependencies) {
105
- log.info(`Dependencies: ${JSON.stringify(packages.dependencies)}`);
106
- }
107
- if (packages.peerDependencies) {
108
- log.info(`Peer Dependencies: ${JSON.stringify(packages.peerDependencies)}`);
109
- }
110
- if (packages.devDependencies) {
111
- log.info(`Development Dependencies: ${JSON.stringify(packages.devDependencies)}`);
112
- }
113
- }
114
- catch (err) {
115
- log.info(`An error occurred when trying to read package information from ${path}/package.json`);
116
- }
117
- }
118
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/troubleshoot/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,gDAgBC;AAED,sEAqBC;AAED,sCA0BC;AAED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CAAC,YAAY,CAAC,GAAG,IAAI,eAAe,EAAE,MAAM,CAAC,CAChD,CAAC;QAEF,GAAG,CAAC,IAAI,CAAC,uBAAuB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,GAAG,CAAC,IAAI,CAAC,0BAA0B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACvD,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC1B,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YAC9B,GAAG,CAAC,IAAI,CACN,uBAAuB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CACnE,CAAC;QACJ,CAAC;QACD,IAAI,QAAQ,CAAC,eAAe,EAAE,CAAC;YAC7B,GAAG,CAAC,IAAI,CACN,8BAA8B,IAAI,CAAC,SAAS,CAC1C,QAAQ,CAAC,eAAe,CACzB,EAAE,CACJ,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CAAC,IAAI,CACN,kEAAkE,IAAI,eAAe,CACtF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,16 +0,0 @@
1
- import { createCommand } from 'commander';
2
-
3
- import { troubleshoot } from '../troubleshoot';
4
-
5
- export function troubleshootLocalExecution() {
6
- return createCommand('troubleshoot')
7
- .description('troubleshoot common issues with local execution')
8
- .option(
9
- '-p, --project-path <directory>',
10
- 'path to integration project directory',
11
- process.cwd(),
12
- )
13
- .action(async (options) => {
14
- await troubleshoot(options);
15
- });
16
- }
@@ -1 +0,0 @@
1
- export * from './troubleshoot';
@@ -1,34 +0,0 @@
1
- import * as log from '../log';
2
- import * as os from 'os';
3
- import {
4
- executeValidateAuthentication,
5
- executeWithLogging,
6
- getVersions,
7
- } from './utils';
8
-
9
- // Check items that our integrations aren't already checking or items
10
- // that would normally be checked or handled by the managed execution
11
- // in JupiterOne
12
- export async function troubleshoot(options) {
13
- log.info(`Troubleshooting code found at ${options.projectPath}`);
14
-
15
- log.info(`Checking Operating System Information`);
16
- log.info(`OS Architecture: ${os.arch()}`);
17
- log.info(`OS Platform: ${os.platform()}`);
18
- log.info(`OS Version: ${os.version()}`);
19
-
20
- log.info(`Checking Node version: ${process.version}`);
21
- // Check versions of packages (SDK, graph project, ) and suggest that they upgrade if it is out of date
22
- getVersions(options.projectPath);
23
-
24
- log.info(`Checking for Docker Info`);
25
- await executeWithLogging('docker info');
26
-
27
- // Check authentication. If this fails, we will also check if it
28
- // might be due to missing or self signed certs
29
- await executeValidateAuthentication(options.projectPath);
30
- }
31
-
32
- // TODO (adam-in-ict) In the future, possibly run this every time it is run outside the managed environment?
33
-
34
- // TODO (adam-in-ict) Should we add a preamble to every execution that shows SDK version and graph- project?
@@ -1,111 +0,0 @@
1
- import {
2
- createIntegrationInstanceForLocalExecution,
3
- prepareLocalStepCollection,
4
- } from '@jupiterone/integration-sdk-runtime';
5
- import { exec } from 'child_process';
6
- import * as log from '../log';
7
- import path from 'path';
8
- import { loadConfig } from '../config';
9
- import urlExists from 'url-exists';
10
- import * as fs from 'fs';
11
-
12
- export async function executeWithLogging(command: string) {
13
- return new Promise<void>((resolve, reject) => {
14
- const childProcess = exec(command);
15
-
16
- if (childProcess.stdout) {
17
- childProcess.stdout.pipe(process.stdout);
18
- }
19
-
20
- childProcess.on('exit', () => {
21
- resolve();
22
- });
23
-
24
- childProcess.on('error', (err) => {
25
- reject(err);
26
- });
27
- });
28
- }
29
-
30
- export async function executeValidateAuthentication(directory: string) {
31
- log.info(`Checking authentication using values in .env file`);
32
- try {
33
- const config = prepareLocalStepCollection(
34
- await loadConfig(path.join(directory, 'src')),
35
- );
36
-
37
- await import(`${directory}/src/index`).then(
38
- async ({ invocationConfig }) => {
39
- await invocationConfig.validateInvocation({
40
- instance: createIntegrationInstanceForLocalExecution(config),
41
- });
42
- },
43
- );
44
- } catch (err) {
45
- log.info(`Call to validateInvocation failed.`);
46
- log.info(JSON.stringify(err));
47
- if (err.endpoint) {
48
- endpointCheck(err.endpoint);
49
- }
50
- }
51
- }
52
-
53
- export function endpointCheck(url: string) {
54
- log.info(`Checking availability of endpoint ${url}`);
55
- try {
56
- urlExists(url, function (err, exists) {
57
- if (exists) {
58
- log.info(`Endpoint can be successfully reached.`);
59
- } else {
60
- log.info(
61
- `Checking availability of endpoint with certificate verification disabled.`,
62
- );
63
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
64
- urlExists(url, function (err, exists) {
65
- if (exists) {
66
- log.info(
67
- `Endpoint can be successfully reached only after disabling TLS certificate validation.`,
68
- );
69
- } else {
70
- log.info(`Endpoint is unreachable`);
71
- }
72
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = '1';
73
- });
74
- }
75
- });
76
- } catch (err) {
77
- log.info(err);
78
- }
79
- }
80
-
81
- export function getVersions(path: string) {
82
- log.info(`Checking versions from ${path}/package.json`);
83
-
84
- try {
85
- const packages = JSON.parse(
86
- fs.readFileSync(`${path}/package.json`, 'utf8'),
87
- );
88
-
89
- log.info(`Main package name: ${packages.name}`);
90
- log.info(`Main package version: ${packages.version}`);
91
- if (packages.dependencies) {
92
- log.info(`Dependencies: ${JSON.stringify(packages.dependencies)}`);
93
- }
94
- if (packages.peerDependencies) {
95
- log.info(
96
- `Peer Dependencies: ${JSON.stringify(packages.peerDependencies)}`,
97
- );
98
- }
99
- if (packages.devDependencies) {
100
- log.info(
101
- `Development Dependencies: ${JSON.stringify(
102
- packages.devDependencies,
103
- )}`,
104
- );
105
- }
106
- } catch (err) {
107
- log.info(
108
- `An error occurred when trying to read package information from ${path}/package.json`,
109
- );
110
- }
111
- }