mobbdev 0.0.94 → 0.0.96

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 +25 -10
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1724,9 +1724,10 @@ var GitlabAuthResultZ = z4.object({
1724
1724
 
1725
1725
  // src/features/analysis/scm/gitlab/gitlab.ts
1726
1726
  var EnvVariablesZod2 = z5.object({
1727
- GITLAB_API_TOKEN: z5.string().optional()
1727
+ GITLAB_API_TOKEN: z5.string().optional(),
1728
+ BROKERED_HOSTS: z5.string().toLowerCase().transform((x) => x.split(",").map((url) => url.trim(), [])).default("")
1728
1729
  });
1729
- var { GITLAB_API_TOKEN } = EnvVariablesZod2.parse(process.env);
1730
+ var { GITLAB_API_TOKEN, BROKERED_HOSTS } = EnvVariablesZod2.parse(process.env);
1730
1731
  function removeTrailingSlash2(str) {
1731
1732
  return str.trim().replace(/\/+$/, "");
1732
1733
  }
@@ -1985,14 +1986,23 @@ async function getGitlabBlameRanges({ ref, gitlabUrl, path: path9 }, options) {
1985
1986
  function initGitlabFetchMock() {
1986
1987
  const globalFetch = global.fetch;
1987
1988
  function myFetch(input, init) {
1988
- const stack = new Error().stack;
1989
- const parts = stack?.split("at ");
1990
- if (parts?.length && parts?.length >= 3 && parts[2]?.startsWith("defaultRequestHandler (") && parts[2]?.includes("/@gitbeaker/rest/dist/index.js") && (/^https?:\/\/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\//i.test(
1991
- input?.url
1992
- ) || "GITLAB_INTERNAL_DEV_HOST" in process.env && process.env["GITLAB_INTERNAL_DEV_HOST"] && input?.url?.startsWith(process.env["GITLAB_INTERNAL_DEV_HOST"]))) {
1993
- const dispatcher = new ProxyAgent(
1994
- process.env["GIT_PROXY_HOST"] || "http://tinyproxy:8888"
1989
+ let urlParsed = null;
1990
+ try {
1991
+ urlParsed = input?.url ? new URL(input?.url) : null;
1992
+ } catch (err) {
1993
+ console.log(
1994
+ `this block is used for unit tests only. URL ${input?.url} starts from local directory`
1995
1995
  );
1996
+ }
1997
+ if (urlParsed && BROKERED_HOSTS.includes(
1998
+ `${urlParsed.protocol?.toLowerCase()}//${urlParsed.host?.toLowerCase()}`
1999
+ )) {
2000
+ const dispatcher = new ProxyAgent({
2001
+ uri: process.env["GIT_PROXY_HOST"] || "http://tinyproxy:8888",
2002
+ requestTls: {
2003
+ rejectUnauthorized: false
2004
+ }
2005
+ });
1996
2006
  return globalFetch(input, { dispatcher });
1997
2007
  }
1998
2008
  return globalFetch(input, init);
@@ -2083,6 +2093,10 @@ var SubmitFixesResponseMessageZ = z6.discriminatedUnion("type", [
2083
2093
  ]);
2084
2094
 
2085
2095
  // src/features/analysis/scm/scmSubmit/index.ts
2096
+ var EnvVariablesZod3 = z7.object({
2097
+ BROKERED_HOSTS: z7.string().toLowerCase().transform((x) => x.split(",").map((url) => url.trim(), [])).default("")
2098
+ });
2099
+ var { BROKERED_HOSTS: BROKERED_HOSTS2 } = EnvVariablesZod3.parse(process.env);
2086
2100
  var isValidBranchName = async (branchName) => {
2087
2101
  const git = simpleGit2();
2088
2102
  try {
@@ -2573,7 +2587,8 @@ var GitlabSCMLib = class extends SCMLib {
2573
2587
  }
2574
2588
  }
2575
2589
  getDownloadUrl(sha) {
2576
- const repoName = this.url?.split("/")[-1];
2590
+ const urlSplit = this.url?.split("/") || [];
2591
+ const repoName = urlSplit[urlSplit?.length - 1];
2577
2592
  return `${this.url}/-/archive/${sha}/${repoName}-${sha}.zip`;
2578
2593
  }
2579
2594
  async _getUsernameForAuthUrl() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.94",
3
+ "version": "0.0.96",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "https://github.com/mobb-dev/bugsy",
6
6
  "main": "dist/index.js",
@@ -62,7 +62,7 @@
62
62
  "uuid": "9.0.1",
63
63
  "ws": "8.10.0",
64
64
  "yargs": "17.7.2",
65
- "zod": "3.22.4"
65
+ "zod": "3.22.5"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@octokit/plugin-rest-endpoint-methods": "7.0.1",