@molecule/api-git-provider-gitlab 1.0.3 → 1.0.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,WAAW,EAGZ,MAAM,4BAA4B,CAAA;AAwCnC,2BAA2B;AAC3B,eAAO,MAAM,QAAQ,EAAE,WAmEtB,CAAA"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,WAAW,EAGZ,MAAM,4BAA4B,CAAA;AAuDnC,2BAA2B;AAC3B,eAAO,MAAM,QAAQ,EAAE,WAoEtB,CAAA"}
package/dist/provider.js CHANGED
@@ -30,6 +30,20 @@ const normalize = (project) => {
30
30
  description: project.description ?? null,
31
31
  };
32
32
  };
33
+ /**
34
+ * Validates a (possibly user-supplied) host before it is interpolated into
35
+ * an API base URL. Fails closed: anything carrying URL structure — path
36
+ * separators, query strings, fragments, userinfo (`token@host`), scheme
37
+ * separators — is rejected, so the bearer-token-bearing request can never
38
+ * be reshaped to an attacker-chosen path or credential-prefixed URL.
39
+ * Allowed: hostname letters/digits/dots/hyphens plus an optional port.
40
+ */
41
+ const assertValidHost = (host) => {
42
+ if (!/^[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?(?::\d{1,5})?$/.test(host)) {
43
+ throw new Error(`Invalid git provider host: ${JSON.stringify(host)}`);
44
+ }
45
+ return host;
46
+ };
33
47
  /** The GitLab provider. */
34
48
  export const provider = {
35
49
  id: 'gitlab',
@@ -54,6 +68,7 @@ export const provider = {
54
68
  apiBaseForHost(host) {
55
69
  // Uniform for gitlab.com and self-hosted alike — unlike GitHub, there is no
56
70
  // separate API host.
71
+ assertValidHost(host);
57
72
  return `https://${host}/api/v4`;
58
73
  },
59
74
  apiHeaders(token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-git-provider-gitlab",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Git hosting provider for GitLab (gitlab.com) — OAuth endpoints, token auth shape, repository listing and lookup.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,11 +33,11 @@
33
33
  "directory": "packages/api/bonds/git-provider/gitlab"
34
34
  },
35
35
  "devDependencies": {
36
- "@molecule/api-git-provider": "1.0.3",
36
+ "@molecule/api-git-provider": "1.0.4",
37
37
  "@molecule/api-http": "1.0.1",
38
38
  "@types/node": "26.1.2",
39
39
  "typescript": "6.0.3",
40
- "vitest": "4.1.10"
40
+ "vitest": "4.1.11"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@molecule/api-git-provider": "^1.0.2",