mobbdev 1.1.21 → 1.1.23

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.
@@ -8,13 +8,12 @@ declare enum AiBlameInferenceType {
8
8
  }
9
9
 
10
10
  type SanitizationCounts = {
11
- pii: {
11
+ detections: {
12
12
  total: number;
13
13
  high: number;
14
14
  medium: number;
15
15
  low: number;
16
16
  };
17
- secrets: number;
18
17
  };
19
18
 
20
19
  declare const PromptItemZ: z.ZodObject<{
@@ -190,9 +189,11 @@ type UploadAiBlameOptions = {
190
189
  model?: string[];
191
190
  toolName?: string[];
192
191
  blameType?: AiBlameInferenceType[];
192
+ sessionId?: string[];
193
193
  'ai-response-at'?: string[];
194
194
  'tool-name'?: string[];
195
195
  'blame-type'?: AiBlameInferenceType[];
196
+ 'session-id'?: string[];
196
197
  };
197
198
  declare function uploadAiBlameBuilder(args: Yargs.Argv<unknown>): Yargs.Argv<UploadAiBlameOptions>;
198
199
  type UploadAiBlameResult = {
@@ -208,6 +209,7 @@ declare function uploadAiBlameHandlerFromExtension(args: {
208
209
  tool: string;
209
210
  responseTime: string;
210
211
  blameType?: AiBlameInferenceType;
212
+ sessionId?: string;
211
213
  }): Promise<UploadAiBlameResult>;
212
214
  declare function uploadAiBlameHandler(args: UploadAiBlameOptions, exitOnError?: boolean): Promise<void>;
213
215
 
@@ -79,7 +79,7 @@ var init_FileUtils = __esm({
79
79
  import fs4 from "fs";
80
80
  import ignore from "ignore";
81
81
  import * as path5 from "path";
82
- import { simpleGit } from "simple-git";
82
+ import { simpleGit as simpleGit2 } from "simple-git";
83
83
  var init_GitService = __esm({
84
84
  "src/features/analysis/scm/services/GitService.ts"() {
85
85
  "use strict";
@@ -2375,6 +2375,9 @@ if (!semver.satisfies(process.version, packageJson.engines.node)) {
2375
2375
  process.exit(1);
2376
2376
  }
2377
2377
 
2378
+ // src/utils/gitUtils.ts
2379
+ import simpleGit from "simple-git";
2380
+
2378
2381
  // src/utils/index.ts
2379
2382
  var sleep = (ms = 2e3) => new Promise((r) => setTimeout(r, ms));
2380
2383
  var CliError = class extends Error {
@@ -5290,8 +5293,6 @@ async function uploadFile({
5290
5293
 
5291
5294
  // src/utils/sanitize-sensitive-data.ts
5292
5295
  import { OpenRedaction } from "@openredaction/openredaction";
5293
- import { spawn } from "child_process";
5294
- import { installGitleaks } from "gitleaks-secret-scanner/lib/installer.js";
5295
5296
  var openRedaction = new OpenRedaction({
5296
5297
  patterns: [
5297
5298
  // Core Personal Data
@@ -5379,63 +5380,6 @@ var openRedaction = new OpenRedaction({
5379
5380
  "CLIENT_ID"
5380
5381
  ]
5381
5382
  });
5382
- var gitleaksBinaryPath = null;
5383
- async function initializeGitleaks() {
5384
- try {
5385
- gitleaksBinaryPath = await installGitleaks({ version: "8.27.2" });
5386
- return gitleaksBinaryPath;
5387
- } catch {
5388
- return null;
5389
- }
5390
- }
5391
- var gitleaksInitPromise = initializeGitleaks();
5392
- async function detectSecretsWithGitleaks(text) {
5393
- const secrets = /* @__PURE__ */ new Set();
5394
- const binaryPath = gitleaksBinaryPath || await gitleaksInitPromise;
5395
- if (!binaryPath) {
5396
- return secrets;
5397
- }
5398
- return new Promise((resolve) => {
5399
- const gitleaks = spawn(
5400
- binaryPath,
5401
- [
5402
- "detect",
5403
- "--pipe",
5404
- "--no-banner",
5405
- "--exit-code",
5406
- "0",
5407
- "--report-format",
5408
- "json"
5409
- ],
5410
- {
5411
- stdio: ["pipe", "pipe", "ignore"]
5412
- }
5413
- );
5414
- let output = "";
5415
- gitleaks.stdout.on("data", (data) => {
5416
- output += data.toString();
5417
- });
5418
- gitleaks.on("close", () => {
5419
- try {
5420
- const findings = JSON.parse(output);
5421
- if (Array.isArray(findings)) {
5422
- for (const finding of findings) {
5423
- if (finding.Secret) {
5424
- secrets.add(finding.Secret);
5425
- }
5426
- }
5427
- }
5428
- } catch {
5429
- }
5430
- resolve(secrets);
5431
- });
5432
- gitleaks.on("error", () => {
5433
- resolve(secrets);
5434
- });
5435
- gitleaks.stdin.write(text);
5436
- gitleaks.stdin.end();
5437
- });
5438
- }
5439
5383
  function maskString(str, showStart = 2, showEnd = 2) {
5440
5384
  if (str.length <= showStart + showEnd) {
5441
5385
  return "*".repeat(str.length);
@@ -5444,8 +5388,7 @@ function maskString(str, showStart = 2, showEnd = 2) {
5444
5388
  }
5445
5389
  async function sanitizeDataWithCounts(obj) {
5446
5390
  const counts = {
5447
- pii: { total: 0, high: 0, medium: 0, low: 0 },
5448
- secrets: 0
5391
+ detections: { total: 0, high: 0, medium: 0, low: 0 }
5449
5392
  };
5450
5393
  const sanitizeString = async (str) => {
5451
5394
  let result = str;
@@ -5457,20 +5400,14 @@ async function sanitizeDataWithCounts(obj) {
5457
5400
  ...piiDetections.low
5458
5401
  ];
5459
5402
  for (const detection of allDetections) {
5460
- counts.pii.total++;
5461
- if (detection.severity === "high") counts.pii.high++;
5462
- else if (detection.severity === "medium") counts.pii.medium++;
5463
- else if (detection.severity === "low") counts.pii.low++;
5403
+ counts.detections.total++;
5404
+ if (detection.severity === "high") counts.detections.high++;
5405
+ else if (detection.severity === "medium") counts.detections.medium++;
5406
+ else if (detection.severity === "low") counts.detections.low++;
5464
5407
  const masked = maskString(detection.value);
5465
5408
  result = result.replaceAll(detection.value, masked);
5466
5409
  }
5467
5410
  }
5468
- const secrets = await detectSecretsWithGitleaks(result);
5469
- counts.secrets += secrets.size;
5470
- for (const secret of secrets) {
5471
- const masked = maskString(secret);
5472
- result = result.replaceAll(secret, masked);
5473
- }
5474
5411
  return result;
5475
5412
  };
5476
5413
  const sanitizeRecursive = async (data) => {
@@ -5581,7 +5518,8 @@ async function uploadAiBlameHandlerFromExtension(args) {
5581
5518
  model: [],
5582
5519
  toolName: [],
5583
5520
  aiResponseAt: [],
5584
- blameType: []
5521
+ blameType: [],
5522
+ sessionId: []
5585
5523
  };
5586
5524
  let promptsCounts;
5587
5525
  let inferenceCounts;
@@ -5614,6 +5552,9 @@ async function uploadAiBlameHandlerFromExtension(args) {
5614
5552
  uploadArgs.toolName.push(args.tool);
5615
5553
  uploadArgs.aiResponseAt.push(args.responseTime);
5616
5554
  uploadArgs.blameType.push(args.blameType || "CHAT" /* Chat */);
5555
+ if (args.sessionId) {
5556
+ uploadArgs.sessionId.push(args.sessionId);
5557
+ }
5617
5558
  await uploadAiBlameHandler(uploadArgs, false);
5618
5559
  });
5619
5560
  });
@@ -5631,6 +5572,7 @@ async function uploadAiBlameHandler(args, exitOnError = true) {
5631
5572
  const tools = args.toolName || args["tool-name"] || [];
5632
5573
  const responseTimes = args.aiResponseAt || args["ai-response-at"] || [];
5633
5574
  const blameTypes = args.blameType || args["blame-type"] || [];
5575
+ const sessionIds = args.sessionId || args["session-id"] || [];
5634
5576
  if (prompts.length !== inferences.length) {
5635
5577
  const errorMsg = "prompt and inference must have the same number of entries";
5636
5578
  console.error(chalk3.red(errorMsg));
@@ -5666,14 +5608,18 @@ async function uploadAiBlameHandler(args, exitOnError = true) {
5666
5608
  toolName: tools[i],
5667
5609
  blameType: blameTypes[i] || "CHAT" /* Chat */,
5668
5610
  computerName,
5669
- userName
5611
+ userName,
5612
+ sessionId: sessionIds[i]
5670
5613
  });
5671
5614
  }
5672
5615
  const authenticatedClient = await getAuthenticatedGQLClient({
5673
5616
  isSkipPrompts: true
5674
5617
  });
5618
+ const initSessions = sessions.map(
5619
+ ({ sessionId: _sessionId, ...rest }) => rest
5620
+ );
5675
5621
  const sanitizedSessions = await sanitizeData(
5676
- sessions
5622
+ initSessions
5677
5623
  );
5678
5624
  const initRes = await authenticatedClient.uploadAIBlameInferencesInitRaw({
5679
5625
  sessions: sanitizedSessions
@@ -5719,7 +5665,8 @@ async function uploadAiBlameHandler(args, exitOnError = true) {
5719
5665
  toolName: s.toolName,
5720
5666
  blameType: s.blameType,
5721
5667
  computerName: s.computerName,
5722
- userName: s.userName
5668
+ userName: s.userName,
5669
+ sessionId: s.sessionId
5723
5670
  };
5724
5671
  });
5725
5672
  const sanitizedFinalizeSessions = await sanitizeData(
package/dist/index.mjs CHANGED
@@ -9863,6 +9863,7 @@ var utils_exports = {};
9863
9863
  __export(utils_exports, {
9864
9864
  CliError: () => CliError,
9865
9865
  Spinner: () => Spinner,
9866
+ createGitWithLogging: () => createGitWithLogging,
9866
9867
  getDirName: () => getDirName,
9867
9868
  getModuleRootDir: () => getModuleRootDir,
9868
9869
  getTopLevelDirName: () => getTopLevelDirName,
@@ -9990,6 +9991,53 @@ if (!semver.satisfies(process.version, packageJson.engines.node)) {
9990
9991
  process.exit(1);
9991
9992
  }
9992
9993
 
9994
+ // src/utils/gitUtils.ts
9995
+ import simpleGit2 from "simple-git";
9996
+ var defaultLogger = {
9997
+ info: (data, msg) => {
9998
+ if (msg) {
9999
+ const sanitizedMsg = String(msg).replace(/\n|\r/g, "");
10000
+ console.log(`[GIT] ${sanitizedMsg}`, data);
10001
+ } else {
10002
+ console.log("[GIT]", data);
10003
+ }
10004
+ }
10005
+ };
10006
+ function createGitWithLogging(dirName, logger2 = defaultLogger) {
10007
+ return simpleGit2(dirName, {
10008
+ maxConcurrentProcesses: 6
10009
+ }).outputHandler((bin, stdout2, stderr2) => {
10010
+ const callID = Math.random();
10011
+ logger2.info({ callID, bin }, "Start git CLI call");
10012
+ const errChunks = [];
10013
+ const outChunks = [];
10014
+ let isStdoutClosed = false;
10015
+ let isStderrClosed = false;
10016
+ stderr2.on("data", (data) => errChunks.push(data.toString("utf8")));
10017
+ stdout2.on("data", (data) => outChunks.push(data.toString("utf8")));
10018
+ function logData() {
10019
+ if (!isStderrClosed || !isStdoutClosed) {
10020
+ return;
10021
+ }
10022
+ const logObj = {
10023
+ callID,
10024
+ bin,
10025
+ err: `${errChunks.join("").slice(0, 200)}...`,
10026
+ out: `${outChunks.join("").slice(0, 200)}...`
10027
+ };
10028
+ logger2.info(logObj, "git log output");
10029
+ }
10030
+ stderr2.on("close", () => {
10031
+ isStderrClosed = true;
10032
+ logData();
10033
+ });
10034
+ stdout2.on("close", () => {
10035
+ isStdoutClosed = true;
10036
+ logData();
10037
+ });
10038
+ });
10039
+ }
10040
+
9993
10041
  // src/utils/index.ts
9994
10042
  var sleep = (ms = 2e3) => new Promise((r) => setTimeout(r, ms));
9995
10043
  var CliError = class extends Error {
@@ -12159,7 +12207,7 @@ import AdmZip from "adm-zip";
12159
12207
  import Debug13 from "debug";
12160
12208
  import { globby } from "globby";
12161
12209
  import { isBinary as isBinary2 } from "istextorbinary";
12162
- import { simpleGit as simpleGit2 } from "simple-git";
12210
+ import { simpleGit as simpleGit3 } from "simple-git";
12163
12211
  import { parseStringPromise } from "xml2js";
12164
12212
  import { z as z28 } from "zod";
12165
12213
  var debug14 = Debug13("mobbdev:pack");
@@ -12187,7 +12235,7 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
12187
12235
  debug14("pack folder %s", srcDirPath);
12188
12236
  let git = void 0;
12189
12237
  try {
12190
- git = simpleGit2({
12238
+ git = simpleGit3({
12191
12239
  baseDir: srcDirPath,
12192
12240
  maxConcurrentProcesses: 1,
12193
12241
  trimmed: true
@@ -13579,8 +13627,6 @@ import z31 from "zod";
13579
13627
 
13580
13628
  // src/utils/sanitize-sensitive-data.ts
13581
13629
  import { OpenRedaction } from "@openredaction/openredaction";
13582
- import { spawn } from "child_process";
13583
- import { installGitleaks } from "gitleaks-secret-scanner/lib/installer.js";
13584
13630
  var openRedaction = new OpenRedaction({
13585
13631
  patterns: [
13586
13632
  // Core Personal Data
@@ -13668,63 +13714,6 @@ var openRedaction = new OpenRedaction({
13668
13714
  "CLIENT_ID"
13669
13715
  ]
13670
13716
  });
13671
- var gitleaksBinaryPath = null;
13672
- async function initializeGitleaks() {
13673
- try {
13674
- gitleaksBinaryPath = await installGitleaks({ version: "8.27.2" });
13675
- return gitleaksBinaryPath;
13676
- } catch {
13677
- return null;
13678
- }
13679
- }
13680
- var gitleaksInitPromise = initializeGitleaks();
13681
- async function detectSecretsWithGitleaks(text) {
13682
- const secrets = /* @__PURE__ */ new Set();
13683
- const binaryPath = gitleaksBinaryPath || await gitleaksInitPromise;
13684
- if (!binaryPath) {
13685
- return secrets;
13686
- }
13687
- return new Promise((resolve) => {
13688
- const gitleaks = spawn(
13689
- binaryPath,
13690
- [
13691
- "detect",
13692
- "--pipe",
13693
- "--no-banner",
13694
- "--exit-code",
13695
- "0",
13696
- "--report-format",
13697
- "json"
13698
- ],
13699
- {
13700
- stdio: ["pipe", "pipe", "ignore"]
13701
- }
13702
- );
13703
- let output = "";
13704
- gitleaks.stdout.on("data", (data) => {
13705
- output += data.toString();
13706
- });
13707
- gitleaks.on("close", () => {
13708
- try {
13709
- const findings = JSON.parse(output);
13710
- if (Array.isArray(findings)) {
13711
- for (const finding of findings) {
13712
- if (finding.Secret) {
13713
- secrets.add(finding.Secret);
13714
- }
13715
- }
13716
- }
13717
- } catch {
13718
- }
13719
- resolve(secrets);
13720
- });
13721
- gitleaks.on("error", () => {
13722
- resolve(secrets);
13723
- });
13724
- gitleaks.stdin.write(text);
13725
- gitleaks.stdin.end();
13726
- });
13727
- }
13728
13717
  function maskString(str, showStart = 2, showEnd = 2) {
13729
13718
  if (str.length <= showStart + showEnd) {
13730
13719
  return "*".repeat(str.length);
@@ -13733,8 +13722,7 @@ function maskString(str, showStart = 2, showEnd = 2) {
13733
13722
  }
13734
13723
  async function sanitizeDataWithCounts(obj) {
13735
13724
  const counts = {
13736
- pii: { total: 0, high: 0, medium: 0, low: 0 },
13737
- secrets: 0
13725
+ detections: { total: 0, high: 0, medium: 0, low: 0 }
13738
13726
  };
13739
13727
  const sanitizeString = async (str) => {
13740
13728
  let result = str;
@@ -13746,20 +13734,14 @@ async function sanitizeDataWithCounts(obj) {
13746
13734
  ...piiDetections.low
13747
13735
  ];
13748
13736
  for (const detection of allDetections) {
13749
- counts.pii.total++;
13750
- if (detection.severity === "high") counts.pii.high++;
13751
- else if (detection.severity === "medium") counts.pii.medium++;
13752
- else if (detection.severity === "low") counts.pii.low++;
13737
+ counts.detections.total++;
13738
+ if (detection.severity === "high") counts.detections.high++;
13739
+ else if (detection.severity === "medium") counts.detections.medium++;
13740
+ else if (detection.severity === "low") counts.detections.low++;
13753
13741
  const masked = maskString(detection.value);
13754
13742
  result = result.replaceAll(detection.value, masked);
13755
13743
  }
13756
13744
  }
13757
- const secrets = await detectSecretsWithGitleaks(result);
13758
- counts.secrets += secrets.size;
13759
- for (const secret of secrets) {
13760
- const masked = maskString(secret);
13761
- result = result.replaceAll(secret, masked);
13762
- }
13763
13745
  return result;
13764
13746
  };
13765
13747
  const sanitizeRecursive = async (data) => {
@@ -13870,7 +13852,8 @@ async function uploadAiBlameHandlerFromExtension(args) {
13870
13852
  model: [],
13871
13853
  toolName: [],
13872
13854
  aiResponseAt: [],
13873
- blameType: []
13855
+ blameType: [],
13856
+ sessionId: []
13874
13857
  };
13875
13858
  let promptsCounts;
13876
13859
  let inferenceCounts;
@@ -13903,6 +13886,9 @@ async function uploadAiBlameHandlerFromExtension(args) {
13903
13886
  uploadArgs.toolName.push(args.tool);
13904
13887
  uploadArgs.aiResponseAt.push(args.responseTime);
13905
13888
  uploadArgs.blameType.push(args.blameType || "CHAT" /* Chat */);
13889
+ if (args.sessionId) {
13890
+ uploadArgs.sessionId.push(args.sessionId);
13891
+ }
13906
13892
  await uploadAiBlameHandler(uploadArgs, false);
13907
13893
  });
13908
13894
  });
@@ -13920,6 +13906,7 @@ async function uploadAiBlameHandler(args, exitOnError = true) {
13920
13906
  const tools = args.toolName || args["tool-name"] || [];
13921
13907
  const responseTimes = args.aiResponseAt || args["ai-response-at"] || [];
13922
13908
  const blameTypes = args.blameType || args["blame-type"] || [];
13909
+ const sessionIds = args.sessionId || args["session-id"] || [];
13923
13910
  if (prompts.length !== inferences.length) {
13924
13911
  const errorMsg = "prompt and inference must have the same number of entries";
13925
13912
  console.error(chalk9.red(errorMsg));
@@ -13955,14 +13942,18 @@ async function uploadAiBlameHandler(args, exitOnError = true) {
13955
13942
  toolName: tools[i],
13956
13943
  blameType: blameTypes[i] || "CHAT" /* Chat */,
13957
13944
  computerName,
13958
- userName
13945
+ userName,
13946
+ sessionId: sessionIds[i]
13959
13947
  });
13960
13948
  }
13961
13949
  const authenticatedClient = await getAuthenticatedGQLClient({
13962
13950
  isSkipPrompts: true
13963
13951
  });
13952
+ const initSessions = sessions.map(
13953
+ ({ sessionId: _sessionId, ...rest }) => rest
13954
+ );
13964
13955
  const sanitizedSessions = await sanitizeData(
13965
- sessions
13956
+ initSessions
13966
13957
  );
13967
13958
  const initRes = await authenticatedClient.uploadAIBlameInferencesInitRaw({
13968
13959
  sessions: sanitizedSessions
@@ -14008,7 +13999,8 @@ async function uploadAiBlameHandler(args, exitOnError = true) {
14008
13999
  toolName: s.toolName,
14009
14000
  blameType: s.blameType,
14010
14001
  computerName: s.computerName,
14011
- userName: s.userName
14002
+ userName: s.userName,
14003
+ sessionId: s.sessionId
14012
14004
  };
14013
14005
  });
14014
14006
  const sanitizedFinalizeSessions = await sanitizeData(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.mjs",
@@ -68,7 +68,6 @@
68
68
  "debug": "4.4.3",
69
69
  "dotenv": "16.6.1",
70
70
  "extract-zip": "2.0.1",
71
- "gitleaks-secret-scanner": "1.2.2",
72
71
  "globby": "14.1.0",
73
72
  "graphql": "16.12.0",
74
73
  "graphql-request": "6.1.0",