mobbdev 0.0.77 → 0.0.80

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 +62 -39
  2. package/package.json +15 -15
package/dist/index.mjs CHANGED
@@ -991,46 +991,67 @@ import { Octokit } from "octokit";
991
991
  import { z as z3 } from "zod";
992
992
 
993
993
  // src/features/analysis/scm/urlParser.ts
994
- var pathnameParsingMap = {
995
- "dev.azure.com": (pathname) => {
996
- if (pathname.length < 2)
997
- return null;
998
- return {
999
- organization: pathname[0],
1000
- repoName: pathname[pathname.length - 1],
1001
- projectName: pathname[1]
1002
- };
1003
- },
1004
- "gitlab.com": (pathname) => {
1005
- if (pathname.length < 2)
1006
- return null;
1007
- return {
1008
- organization: pathname[0],
1009
- repoName: pathname[pathname.length - 1],
1010
- projectName: void 0
1011
- };
1012
- },
1013
- "github.com": (pathname) => {
1014
- if (pathname.length !== 2)
1015
- return null;
1016
- return {
1017
- organization: pathname[0],
1018
- repoName: pathname[1],
1019
- projectName: void 0
1020
- };
994
+ function getRepoInfo(pathname, hostname) {
995
+ const hostnameParts = hostname.split(".");
996
+ if (hostnameParts.length === 3 && hostnameParts[1] === "visualstudio" && hostnameParts[2] === "com") {
997
+ if (pathname.length === 2 && pathname[0] === "_git") {
998
+ return {
999
+ organization: hostnameParts[0],
1000
+ projectName: pathname[1],
1001
+ repoName: pathname[1]
1002
+ };
1003
+ }
1004
+ if (pathname.length === 3 && pathname[1] === "_git") {
1005
+ return {
1006
+ organization: hostnameParts[0],
1007
+ projectName: pathname[0],
1008
+ repoName: pathname[2]
1009
+ };
1010
+ }
1021
1011
  }
1022
- };
1012
+ if (hostname === "dev.azure.com") {
1013
+ if (pathname.length === 3 && pathname[1] === "_git") {
1014
+ return {
1015
+ organization: pathname[0],
1016
+ projectName: pathname[2],
1017
+ repoName: pathname[2]
1018
+ };
1019
+ }
1020
+ if (pathname.length === 4 && pathname[2] === "_git") {
1021
+ return {
1022
+ organization: pathname[0],
1023
+ projectName: pathname[1],
1024
+ repoName: pathname[3]
1025
+ };
1026
+ }
1027
+ }
1028
+ if (hostname === "github.com") {
1029
+ if (pathname.length === 2) {
1030
+ return {
1031
+ organization: pathname[0],
1032
+ projectName: void 0,
1033
+ repoName: pathname[1]
1034
+ };
1035
+ }
1036
+ }
1037
+ if (hostname === "gitlab.com") {
1038
+ if (pathname.length >= 2) {
1039
+ return {
1040
+ organization: pathname[0],
1041
+ projectName: void 0,
1042
+ repoName: pathname[pathname.length - 1]
1043
+ };
1044
+ }
1045
+ }
1046
+ return null;
1047
+ }
1023
1048
  var NAME_REGEX = /[a-z0-9\-_.+]+/i;
1024
1049
  var parseScmURL = (scmURL) => {
1025
1050
  try {
1026
1051
  const url = new URL(scmURL);
1027
1052
  const hostname = url.hostname.toLowerCase();
1028
- if (!(hostname in pathnameParsingMap))
1029
- return null;
1030
1053
  const projectPath = url.pathname.substring(1).replace(/.git$/i, "");
1031
- const repo = pathnameParsingMap[hostname](
1032
- projectPath.split("/")
1033
- );
1054
+ const repo = getRepoInfo(projectPath.split("/"), hostname);
1034
1055
  if (!repo)
1035
1056
  return null;
1036
1057
  const { organization, repoName, projectName } = repo;
@@ -1039,7 +1060,7 @@ var parseScmURL = (scmURL) => {
1039
1060
  if (!organization.match(NAME_REGEX) || !repoName.match(NAME_REGEX))
1040
1061
  return null;
1041
1062
  return {
1042
- hostname: url.hostname,
1063
+ hostname,
1043
1064
  organization,
1044
1065
  projectPath,
1045
1066
  repoName,
@@ -1860,13 +1881,15 @@ function getScmLibTypeFromUrl(url) {
1860
1881
  if (!url) {
1861
1882
  return void 0;
1862
1883
  }
1863
- if (url.toLowerCase().startsWith("https://gitlab.com/")) {
1884
+ const urlObject = new URL(url);
1885
+ const hostname = urlObject.hostname;
1886
+ if (hostname === "gitlab.com") {
1864
1887
  return "GITLAB" /* GITLAB */;
1865
1888
  }
1866
- if (url.toLowerCase().startsWith("https://github.com/")) {
1889
+ if (hostname === "github.com") {
1867
1890
  return "GITHUB" /* GITHUB */;
1868
1891
  }
1869
- if (url.toLowerCase().startsWith("https://dev.azure.com/")) {
1892
+ if (hostname === "dev.azure.com" || hostname.endsWith(".visualstudio.com")) {
1870
1893
  return "ADO" /* ADO */;
1871
1894
  }
1872
1895
  return void 0;
@@ -1973,7 +1996,7 @@ var SCMLib = class {
1973
1996
  }) {
1974
1997
  let trimmedUrl = void 0;
1975
1998
  if (url) {
1976
- trimmedUrl = url.trim().replace(/\/$/, "");
1999
+ trimmedUrl = url.trim().replace(/\/$/, "").replace(/.git$/i, "");
1977
2000
  }
1978
2001
  try {
1979
2002
  if ("GITHUB" /* GITHUB */ === scmType) {
@@ -3089,7 +3112,7 @@ async function getAdoReferenceData({
3089
3112
  function parseAdoOwnerAndRepo(adoUrl) {
3090
3113
  adoUrl = removeTrailingSlash3(adoUrl);
3091
3114
  const parsingResult = parseScmURL(adoUrl);
3092
- if (!parsingResult || parsingResult.hostname !== "dev.azure.com") {
3115
+ if (!parsingResult || parsingResult.hostname !== "dev.azure.com" && !parsingResult.hostname.endsWith(".visualstudio.com")) {
3093
3116
  throw new InvalidUrlPatternError(`invalid ADO repo URL: ${adoUrl}`);
3094
3117
  }
3095
3118
  const { organization, repoName, projectName, projectPath, pathElements } = parsingResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.77",
3
+ "version": "0.0.80",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "@octokit/request-error": "3.0.3",
32
32
  "@types/libsodium-wrappers": "0.7.13",
33
33
  "adm-zip": "0.5.10",
34
- "axios": "1.6.5",
34
+ "axios": "1.6.7",
35
35
  "azure-devops-node-api": "12.1.0",
36
36
  "chalk": "5.3.0",
37
37
  "chalk-animation": "2.0.3",
@@ -48,34 +48,34 @@
48
48
  "istextorbinary": "6.0.0",
49
49
  "libsodium-wrappers": "0.7.13",
50
50
  "nanospinner": "1.1.0",
51
- "node-fetch": "3.3.1",
51
+ "node-fetch": "3.3.2",
52
52
  "octokit": "2.0.14",
53
53
  "open": "8.4.2",
54
54
  "parse-diff": "0.11.1",
55
- "semver": "7.5.0",
55
+ "semver": "7.5.4",
56
56
  "simple-git": "3.19.1",
57
57
  "snyk": "1.1118.0",
58
58
  "supports-color": "9.4.0",
59
59
  "tar": "6.2.0",
60
60
  "tmp": "0.2.1",
61
- "uuid": "9.0.0",
61
+ "uuid": "9.0.1",
62
62
  "ws": "8.10.0",
63
63
  "yargs": "17.7.2",
64
- "zod": "3.22.3"
64
+ "zod": "3.22.4"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@octokit/plugin-rest-endpoint-methods": "7.0.1",
68
68
  "@octokit/request-error": "3.0.3",
69
69
  "@octokit/types": "12.4.0",
70
70
  "@types/adm-zip": "0.5.0",
71
- "@types/chalk-animation": "1.6.1",
72
- "@types/configstore": "6.0.0",
73
- "@types/debug": "4.1.8",
74
- "@types/inquirer": "9.0.3",
75
- "@types/semver": "7.5.0",
76
- "@types/tar": "^6.1.6",
71
+ "@types/chalk-animation": "1.6.3",
72
+ "@types/configstore": "6.0.2",
73
+ "@types/debug": "4.1.12",
74
+ "@types/inquirer": "9.0.7",
75
+ "@types/semver": "7.5.6",
76
+ "@types/tar": "6.1.11",
77
77
  "@types/tmp": "0.2.3",
78
- "@types/uuid": "9.0.1",
78
+ "@types/uuid": "9.0.8",
79
79
  "@types/ws": "8.5.3",
80
80
  "@types/yargs": "17.0.24",
81
81
  "@typescript-eslint/eslint-plugin": "5.44.0",
@@ -86,8 +86,8 @@
86
86
  "eslint-plugin-simple-import-sort": "10.0.0",
87
87
  "prettier": "2.8.4",
88
88
  "tsup": "7.2.0",
89
- "typescript": "4.9.3",
90
- "vitest": "0.26.2"
89
+ "typescript": "4.9.5",
90
+ "vitest": "0.34.6"
91
91
  },
92
92
  "engines": {
93
93
  "node": ">=12.20.0"