mobbdev 1.1.4 → 1.1.6

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.
@@ -4120,10 +4120,10 @@ function detectAdoUrl(args) {
4120
4120
  const hostnameParts = hostname.split(".");
4121
4121
  const adoCloudHostname = new URL(scmCloudUrl.Ado).hostname;
4122
4122
  const prefixPath = pathname.at(0)?.toLowerCase() === ADO_PREFIX_PATH ? ADO_PREFIX_PATH : "";
4123
- const normilizedPath = prefixPath ? pathname.slice(1) : pathname;
4123
+ const normalizedPath = prefixPath ? pathname.slice(1) : pathname;
4124
4124
  if (hostnameParts.length === 3 && hostnameParts[1] === "visualstudio" && hostnameParts[2] === "com") {
4125
- if (normilizedPath.length === 2 && normilizedPath[0] === "_git") {
4126
- const [_git, projectName] = normilizedPath;
4125
+ if (normalizedPath.length === 2 && normalizedPath[0] === "_git") {
4126
+ const [_git, projectName] = normalizedPath;
4127
4127
  const [organization] = hostnameParts;
4128
4128
  return {
4129
4129
  scmType: "Ado" /* Ado */,
@@ -4134,8 +4134,8 @@ function detectAdoUrl(args) {
4134
4134
  prefixPath
4135
4135
  };
4136
4136
  }
4137
- if (normilizedPath.length === 3 && normilizedPath[1] === "_git") {
4138
- const [projectName, _git, repoName] = normilizedPath;
4137
+ if (normalizedPath.length === 3 && normalizedPath[1] === "_git") {
4138
+ const [projectName, _git, repoName] = normalizedPath;
4139
4139
  const [organization] = hostnameParts;
4140
4140
  return {
4141
4141
  scmType: "Ado" /* Ado */,
@@ -4147,9 +4147,9 @@ function detectAdoUrl(args) {
4147
4147
  }
4148
4148
  }
4149
4149
  if (hostname === adoCloudHostname || scmType === "Ado" /* Ado */) {
4150
- if (normilizedPath[normilizedPath.length - 2] === "_git") {
4151
- if (normilizedPath.length === 3) {
4152
- const [organization, _git, repoName] = normilizedPath;
4150
+ if (normalizedPath[normalizedPath.length - 2] === "_git") {
4151
+ if (normalizedPath.length === 3) {
4152
+ const [organization, _git, repoName] = normalizedPath;
4153
4153
  return {
4154
4154
  scmType: "Ado" /* Ado */,
4155
4155
  organization,
@@ -4159,8 +4159,8 @@ function detectAdoUrl(args) {
4159
4159
  prefixPath
4160
4160
  };
4161
4161
  }
4162
- if (normilizedPath.length === 4) {
4163
- const [organization, projectName, _git, repoName] = normilizedPath;
4162
+ if (normalizedPath.length === 4) {
4163
+ const [organization, projectName, _git, repoName] = normalizedPath;
4164
4164
  return {
4165
4165
  scmType: "Ado" /* Ado */,
4166
4166
  organization,
package/dist/index.mjs CHANGED
@@ -5409,10 +5409,10 @@ function detectAdoUrl(args) {
5409
5409
  const hostnameParts = hostname.split(".");
5410
5410
  const adoCloudHostname = new URL(scmCloudUrl.Ado).hostname;
5411
5411
  const prefixPath = pathname.at(0)?.toLowerCase() === ADO_PREFIX_PATH ? ADO_PREFIX_PATH : "";
5412
- const normilizedPath = prefixPath ? pathname.slice(1) : pathname;
5412
+ const normalizedPath = prefixPath ? pathname.slice(1) : pathname;
5413
5413
  if (hostnameParts.length === 3 && hostnameParts[1] === "visualstudio" && hostnameParts[2] === "com") {
5414
- if (normilizedPath.length === 2 && normilizedPath[0] === "_git") {
5415
- const [_git, projectName] = normilizedPath;
5414
+ if (normalizedPath.length === 2 && normalizedPath[0] === "_git") {
5415
+ const [_git, projectName] = normalizedPath;
5416
5416
  const [organization] = hostnameParts;
5417
5417
  return {
5418
5418
  scmType: "Ado" /* Ado */,
@@ -5423,8 +5423,8 @@ function detectAdoUrl(args) {
5423
5423
  prefixPath
5424
5424
  };
5425
5425
  }
5426
- if (normilizedPath.length === 3 && normilizedPath[1] === "_git") {
5427
- const [projectName, _git, repoName] = normilizedPath;
5426
+ if (normalizedPath.length === 3 && normalizedPath[1] === "_git") {
5427
+ const [projectName, _git, repoName] = normalizedPath;
5428
5428
  const [organization] = hostnameParts;
5429
5429
  return {
5430
5430
  scmType: "Ado" /* Ado */,
@@ -5436,9 +5436,9 @@ function detectAdoUrl(args) {
5436
5436
  }
5437
5437
  }
5438
5438
  if (hostname === adoCloudHostname || scmType === "Ado" /* Ado */) {
5439
- if (normilizedPath[normilizedPath.length - 2] === "_git") {
5440
- if (normilizedPath.length === 3) {
5441
- const [organization, _git, repoName] = normilizedPath;
5439
+ if (normalizedPath[normalizedPath.length - 2] === "_git") {
5440
+ if (normalizedPath.length === 3) {
5441
+ const [organization, _git, repoName] = normalizedPath;
5442
5442
  return {
5443
5443
  scmType: "Ado" /* Ado */,
5444
5444
  organization,
@@ -5448,8 +5448,8 @@ function detectAdoUrl(args) {
5448
5448
  prefixPath
5449
5449
  };
5450
5450
  }
5451
- if (normilizedPath.length === 4) {
5452
- const [organization, projectName, _git, repoName] = normilizedPath;
5451
+ if (normalizedPath.length === 4) {
5452
+ const [organization, projectName, _git, repoName] = normalizedPath;
5453
5453
  return {
5454
5454
  scmType: "Ado" /* Ado */,
5455
5455
  organization,
@@ -5519,7 +5519,98 @@ function getRepoInfo(args) {
5519
5519
  }
5520
5520
  return null;
5521
5521
  }
5522
+ function parseSshUrl(scmURL, scmType) {
5523
+ const sshMatch = scmURL.match(/^git@([^:]+):(.+?)(?:\.git)?$/);
5524
+ if (!sshMatch) return null;
5525
+ const hostname = sshMatch[1];
5526
+ const pathPart = sshMatch[2];
5527
+ if (!hostname || !pathPart) return null;
5528
+ const normalizedHostname = hostname.toLowerCase();
5529
+ let projectPath = pathPart;
5530
+ if (normalizedHostname === "ssh.dev.azure.com" && projectPath.startsWith("v3/")) {
5531
+ projectPath = projectPath.substring(3);
5532
+ }
5533
+ const pathElements = projectPath.split("/");
5534
+ if (normalizedHostname === "ssh.dev.azure.com") {
5535
+ if (pathElements.length === 3) {
5536
+ const [organization2, projectName, repoName2] = pathElements;
5537
+ if (organization2?.match(NAME_REGEX) && projectName && repoName2?.match(NAME_REGEX)) {
5538
+ return {
5539
+ scmType: "Ado" /* Ado */,
5540
+ hostname: normalizedHostname,
5541
+ organization: organization2,
5542
+ projectName: z12.string().parse(projectName),
5543
+ repoName: repoName2,
5544
+ projectPath,
5545
+ protocol: "ssh:",
5546
+ pathElements,
5547
+ prefixPath: ""
5548
+ };
5549
+ }
5550
+ }
5551
+ return null;
5552
+ }
5553
+ const repo = getRepoInfo({
5554
+ pathname: pathElements,
5555
+ hostname: normalizedHostname,
5556
+ scmType
5557
+ });
5558
+ if (!repo) {
5559
+ const knownHosts2 = [
5560
+ new URL(scmCloudUrl.GitHub).hostname,
5561
+ new URL(scmCloudUrl.GitLab).hostname,
5562
+ new URL(scmCloudUrl.Bitbucket).hostname,
5563
+ new URL(scmCloudUrl.Ado).hostname,
5564
+ "ssh.dev.azure.com"
5565
+ // ADO SSH host
5566
+ ];
5567
+ if (knownHosts2.includes(normalizedHostname)) {
5568
+ return null;
5569
+ }
5570
+ const filteredPathElements = pathElements.filter(Boolean);
5571
+ if (filteredPathElements.length < 2) {
5572
+ return null;
5573
+ }
5574
+ const organization2 = filteredPathElements[0] || "";
5575
+ const repoName2 = filteredPathElements[filteredPathElements.length - 1] || "";
5576
+ return {
5577
+ scmType: "Unknown",
5578
+ hostname: normalizedHostname,
5579
+ organization: organization2,
5580
+ projectPath,
5581
+ repoName: repoName2,
5582
+ protocol: "ssh:",
5583
+ pathElements: filteredPathElements
5584
+ };
5585
+ }
5586
+ const { organization, repoName } = repo;
5587
+ if (!organization || !repoName) return null;
5588
+ if (!organization.match(NAME_REGEX) || !repoName.match(NAME_REGEX))
5589
+ return null;
5590
+ const res = {
5591
+ hostname: normalizedHostname,
5592
+ organization,
5593
+ projectPath,
5594
+ repoName,
5595
+ protocol: "ssh:",
5596
+ pathElements
5597
+ };
5598
+ if (repo.scmType === "Ado" /* Ado */) {
5599
+ return {
5600
+ projectName: repo.projectName,
5601
+ prefixPath: repo.prefixPath,
5602
+ scmType: repo.scmType,
5603
+ ...res
5604
+ };
5605
+ }
5606
+ return {
5607
+ scmType: repo.scmType,
5608
+ ...res
5609
+ };
5610
+ }
5522
5611
  var parseScmURL = (scmURL, scmType) => {
5612
+ const sshResult = parseSshUrl(scmURL, scmType);
5613
+ if (sshResult) return sshResult;
5523
5614
  try {
5524
5615
  const url = new URL(scmURL);
5525
5616
  const hostname = url.hostname.toLowerCase();
@@ -5529,7 +5620,32 @@ var parseScmURL = (scmURL, scmType) => {
5529
5620
  hostname,
5530
5621
  scmType
5531
5622
  });
5532
- if (!repo) return null;
5623
+ if (!repo) {
5624
+ const knownHosts2 = [
5625
+ new URL(scmCloudUrl.GitHub).hostname,
5626
+ new URL(scmCloudUrl.GitLab).hostname,
5627
+ new URL(scmCloudUrl.Bitbucket).hostname,
5628
+ new URL(scmCloudUrl.Ado).hostname
5629
+ ];
5630
+ if (knownHosts2.includes(hostname)) {
5631
+ return null;
5632
+ }
5633
+ const pathElements = projectPath.split("/").filter(Boolean);
5634
+ if (pathElements.length < 2) {
5635
+ return null;
5636
+ }
5637
+ const organization2 = pathElements[0] || "";
5638
+ const repoName2 = pathElements[pathElements.length - 1] || "";
5639
+ return {
5640
+ scmType: "Unknown",
5641
+ hostname,
5642
+ organization: organization2,
5643
+ projectPath,
5644
+ repoName: repoName2,
5645
+ protocol: url.protocol,
5646
+ pathElements
5647
+ };
5648
+ }
5533
5649
  const { organization, repoName } = repo;
5534
5650
  if (!organization || !repoName) return null;
5535
5651
  if (!organization.match(NAME_REGEX) || !repoName.match(NAME_REGEX))
@@ -11589,7 +11705,16 @@ async function pack(srcDirPath, vulnFiles, isIncludeAllFiles = false) {
11589
11705
  debug15("ignoring %s because the size is > 5MB", filepath);
11590
11706
  continue;
11591
11707
  }
11592
- const data = git ? await git.showBuffer([`HEAD:./${filepath}`]) : fs8.readFileSync(absFilepath);
11708
+ let data;
11709
+ if (git) {
11710
+ try {
11711
+ data = await git.showBuffer([`HEAD:./${filepath}`]);
11712
+ } catch {
11713
+ data = fs8.readFileSync(absFilepath);
11714
+ }
11715
+ } else {
11716
+ data = fs8.readFileSync(absFilepath);
11717
+ }
11593
11718
  if (isBinary2(null, data)) {
11594
11719
  debug15("ignoring %s because is seems to be a binary file", filepath);
11595
11720
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
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",