mobbdev 0.0.115 → 0.0.118

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 (2) hide show
  1. package/dist/index.mjs +40 -25
  2. package/package.json +11 -11
package/dist/index.mjs CHANGED
@@ -593,9 +593,9 @@ function createWSClient(options) {
593
593
  webSocketImpl: options.websocket || WebSocket,
594
594
  connectionParams: () => {
595
595
  return {
596
- headers: {
596
+ headers: options.type === "apiKey" ? {
597
597
  [API_KEY_HEADER_NAME]: options.apiKey
598
- }
598
+ } : { authorization: `Bearer ${options.token}` }
599
599
  };
600
600
  }
601
601
  });
@@ -699,13 +699,14 @@ var REPORT_STATE_CHECK_DELAY = 5 * 1e3;
699
699
  var GQLClient = class {
700
700
  constructor(args) {
701
701
  __publicField(this, "_client");
702
- __publicField(this, "_apiKey");
703
702
  __publicField(this, "_clientSdk");
704
- const { apiKey } = args;
705
- this._apiKey = apiKey;
706
- debug3(`init with apiKey ${apiKey}`);
703
+ __publicField(this, "_auth");
704
+ debug3(`init with ${args}`);
705
+ this._auth = args;
707
706
  this._client = new GraphQLClient(API_URL, {
708
- headers: { [API_KEY_HEADER_NAME]: apiKey || "" },
707
+ headers: args.type === "apiKey" ? { [API_KEY_HEADER_NAME]: args.apiKey || "" } : {
708
+ Authorization: `Bearer ${args.token}`
709
+ },
709
710
  requestMiddleware: (request) => {
710
711
  const requestId = uuidv4();
711
712
  debug3(
@@ -805,10 +806,12 @@ var GQLClient = class {
805
806
  const filters = hunks.map((hunk) => {
806
807
  const filter = {
807
808
  path: { _eq: hunk.path },
808
- _or: hunk.ranges.map(({ endLine, startLine }) => ({
809
- startLine: { _gte: startLine, _lte: endLine },
810
- endLine: { _gte: startLine, _lte: endLine }
811
- }))
809
+ _or: hunk.ranges.flatMap(({ endLine, startLine }) => {
810
+ return [
811
+ { startLine: { _gte: startLine, _lte: endLine } },
812
+ { endLine: { _gte: startLine, _lte: endLine } }
813
+ ];
814
+ })
812
815
  };
813
816
  return filter;
814
817
  });
@@ -925,8 +928,13 @@ var GQLClient = class {
925
928
  resolve(data);
926
929
  }
927
930
  },
928
- {
929
- apiKey: this._apiKey,
931
+ this._auth.type === "apiKey" ? {
932
+ apiKey: this._auth.apiKey,
933
+ type: "apiKey",
934
+ timeoutInMs: params.timeoutInMs
935
+ } : {
936
+ token: this._auth.token,
937
+ type: "token",
930
938
  timeoutInMs: params.timeoutInMs
931
939
  }
932
940
  );
@@ -4336,7 +4344,7 @@ async function handleFinishedAnalysis({
4336
4344
  ${patch}
4337
4345
  \`\`\``;
4338
4346
  const fixPageLink = `[Learn more and fine tune the fix](${fixUrl})`;
4339
- await scm.updatePrComment(
4347
+ return await scm.updatePrComment(
4340
4348
  {
4341
4349
  body: `${title}
4342
4350
  ${subTitle}
@@ -4444,6 +4452,9 @@ function endsWithAny(str, suffixes) {
4444
4452
  return str.endsWith(suffix);
4445
4453
  });
4446
4454
  }
4455
+ function _get_manifest_files_suffixes() {
4456
+ return ["package.json"];
4457
+ }
4447
4458
  async function pack(srcDirPath, vulnFiles) {
4448
4459
  debug6("pack folder %s", srcDirPath);
4449
4460
  const filepaths = await globby("**", {
@@ -4457,6 +4468,7 @@ async function pack(srcDirPath, vulnFiles) {
4457
4468
  debug6("compressing files");
4458
4469
  for (const filepath of filepaths) {
4459
4470
  const absFilepath = path4.join(srcDirPath, filepath.toString());
4471
+ vulnFiles = vulnFiles.concat(_get_manifest_files_suffixes());
4460
4472
  if (!endsWithAny(
4461
4473
  absFilepath.toString().replaceAll(path4.win32.sep, path4.posix.sep),
4462
4474
  vulnFiles
@@ -4821,7 +4833,7 @@ async function uploadFile({
4821
4833
  }
4822
4834
 
4823
4835
  // src/features/analysis/index.ts
4824
- var { CliError: CliError2, Spinner: Spinner2, keypress: keypress2, getDirName: getDirName2 } = utils_exports;
4836
+ var { CliError: CliError2, Spinner: Spinner2, keypress: keypress2 } = utils_exports;
4825
4837
  var webLoginUrl = `${WEB_APP_URL}/cli-login`;
4826
4838
  async function downloadRepo({
4827
4839
  repoUrl,
@@ -4865,9 +4877,6 @@ var LOGIN_CHECK_DELAY = 5 * 1e3;
4865
4877
  var MOBB_LOGIN_REQUIRED_MSG = `\u{1F513} Login to Mobb is Required, you will be redirected to our login page, once the authorization is complete return to this prompt, ${chalk4.bgBlue(
4866
4878
  "press any key to continue"
4867
4879
  )};`;
4868
- var tmpObj = tmp2.dirSync({
4869
- unsafeCleanup: true
4870
- });
4871
4880
  var getReportUrl = ({
4872
4881
  organizationId,
4873
4882
  projectId,
@@ -4875,7 +4884,7 @@ var getReportUrl = ({
4875
4884
  }) => `${WEB_APP_URL}/organization/${organizationId}/project/${projectId}/report/${fixReportId}`;
4876
4885
  var debug10 = Debug11("mobbdev:index");
4877
4886
  var packageJson = JSON.parse(
4878
- fs3.readFileSync(path6.join(getDirName2(), "../package.json"), "utf8")
4887
+ fs3.readFileSync(path6.join(getDirName(), "../package.json"), "utf8")
4879
4888
  );
4880
4889
  if (!semver.satisfies(process.version, packageJson.engines.node)) {
4881
4890
  throw new CliError2(
@@ -4885,8 +4894,11 @@ if (!semver.satisfies(process.version, packageJson.engines.node)) {
4885
4894
  var config2 = new Configstore(packageJson.name, { apiToken: "" });
4886
4895
  debug10("config %o", config2);
4887
4896
  async function runAnalysis(params, options) {
4897
+ const tmpObj = tmp2.dirSync({
4898
+ unsafeCleanup: true
4899
+ });
4888
4900
  try {
4889
- await _scan(
4901
+ return await _scan(
4890
4902
  {
4891
4903
  ...params,
4892
4904
  dirname: tmpObj.name
@@ -4943,7 +4955,8 @@ async function _scan(params, { skipPrompts = false } = {}) {
4943
4955
  const { createSpinner: createSpinner4 } = Spinner2({ ci });
4944
4956
  skipPrompts = skipPrompts || ci;
4945
4957
  let gqlClient = new GQLClient({
4946
- apiKey: apiKey || config2.get("apiToken")
4958
+ apiKey: apiKey || config2.get("apiToken"),
4959
+ type: "apiKey"
4947
4960
  });
4948
4961
  await handleMobbLogin();
4949
4962
  const { projectId, organizationId } = await gqlClient.getOrgAndProjectId(mobbProjectName);
@@ -5077,6 +5090,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
5077
5090
  text: "\u{1F575}\uFE0F\u200D\u2642\uFE0F Generating fixes..."
5078
5091
  });
5079
5092
  await askToOpenAnalysis();
5093
+ return reportUploadInfo.fixReportId;
5080
5094
  async function getReport(scanner2) {
5081
5095
  const reportPath2 = path6.join(dirname, "report.json");
5082
5096
  switch (scanner2) {
@@ -5168,7 +5182,7 @@ async function _scan(params, { skipPrompts = false } = {}) {
5168
5182
  });
5169
5183
  throw new CliError2();
5170
5184
  }
5171
- gqlClient = new GQLClient({ apiKey: newApiToken });
5185
+ gqlClient = new GQLClient({ apiKey: newApiToken, type: "apiKey" });
5172
5186
  if (await gqlClient.verifyToken()) {
5173
5187
  debug10("set api token %s", newApiToken);
5174
5188
  config2.set("apiToken", newApiToken);
@@ -5314,13 +5328,13 @@ async function _scan(params, { skipPrompts = false } = {}) {
5314
5328
  text: "\u{1F575}\uFE0F\u200D\u2642\uFE0F Generating fixes..."
5315
5329
  });
5316
5330
  await askToOpenAnalysis();
5331
+ return reportUploadInfo.fixReportId;
5317
5332
  }
5318
5333
  }
5319
5334
 
5320
5335
  // src/commands/index.ts
5321
5336
  import chalkAnimation from "chalk-animation";
5322
5337
  import Configstore2 from "configstore";
5323
- var { getDirName: getDirName3 } = utils_exports;
5324
5338
  async function review(params, { skipPrompts = true } = {}) {
5325
5339
  const {
5326
5340
  repo,
@@ -5378,13 +5392,14 @@ async function analyze({
5378
5392
  );
5379
5393
  }
5380
5394
  var packageJson2 = JSON.parse(
5381
- fs4.readFileSync(path7.join(getDirName3(), "../package.json"), "utf8")
5395
+ fs4.readFileSync(path7.join(getDirName(), "../package.json"), "utf8")
5382
5396
  );
5383
5397
  var config3 = new Configstore2(packageJson2.name, { apiToken: "" });
5384
5398
  async function addScmToken(addScmTokenOptions) {
5385
5399
  const { apiKey, token, organization, scmType, url, username, refreshToken } = addScmTokenOptions;
5386
5400
  const gqlClient = new GQLClient({
5387
- apiKey: apiKey || config3.get("apiToken")
5401
+ apiKey: apiKey || config3.get("apiToken"),
5402
+ type: "apiKey"
5388
5403
  });
5389
5404
  if (!scmType) {
5390
5405
  throw new CliError(errorMessages.invalidScmType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.115",
3
+ "version": "0.0.118",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",
@@ -43,11 +43,11 @@
43
43
  "dotenv": "16.4.5",
44
44
  "extract-zip": "2.0.1",
45
45
  "globby": "13.2.2",
46
- "graphql": "16.8.1",
46
+ "graphql": "16.8.2",
47
47
  "graphql-request": "5.0.0",
48
48
  "graphql-tag": "2.12.6",
49
- "graphql-ws": "5.14.3",
50
- "inquirer": "9.2.7",
49
+ "graphql-ws": "5.16.0",
50
+ "inquirer": "9.2.23",
51
51
  "isomorphic-ws": "5.0.0",
52
52
  "istextorbinary": "6.0.0",
53
53
  "libsodium-wrappers": "0.7.13",
@@ -57,22 +57,22 @@
57
57
  "open": "8.4.2",
58
58
  "parse-diff": "0.11.1",
59
59
  "semver": "7.6.2",
60
- "simple-git": "3.24.0",
60
+ "simple-git": "3.25.0",
61
61
  "snyk": "1.1118.0",
62
62
  "supports-color": "9.4.0",
63
63
  "tar": "6.2.1",
64
64
  "tmp": "0.2.3",
65
65
  "undici": "6.7.0",
66
- "uuid": "9.0.1",
66
+ "uuid": "10.0.0",
67
67
  "ws": "8.10.0",
68
68
  "yargs": "17.7.2",
69
69
  "zod": "3.23.8"
70
70
  },
71
71
  "devDependencies": {
72
- "@graphql-codegen/cli": "2.16.5",
73
- "@graphql-codegen/typescript": "2.7.2",
72
+ "@graphql-codegen/cli": "3.3.1",
73
+ "@graphql-codegen/typescript": "3.0.4",
74
74
  "@graphql-codegen/typescript-graphql-request": "4.5.8",
75
- "@graphql-codegen/typescript-operations": "2.5.5",
75
+ "@graphql-codegen/typescript-operations": "3.0.4",
76
76
  "@octokit/request-error": "3.0.3",
77
77
  "@octokit/types": "13.5.0",
78
78
  "@types/adm-zip": "0.5.0",
@@ -89,10 +89,10 @@
89
89
  "@typescript-eslint/eslint-plugin": "5.44.0",
90
90
  "@typescript-eslint/parser": "5.44.0",
91
91
  "eslint": "8.56.0",
92
- "eslint-plugin-import": "2.27.5",
92
+ "eslint-plugin-import": "2.29.1",
93
93
  "eslint-plugin-prettier": "5.1.3",
94
94
  "eslint-plugin-simple-import-sort": "10.0.0",
95
- "prettier": "3.3.1",
95
+ "prettier": "3.3.2",
96
96
  "tsup": "7.2.0",
97
97
  "typescript": "4.9.5",
98
98
  "vitest": "0.34.6"