Skip to content

Commit d1332f2

Browse files
Merge branch 'main' into ft/gitlab-compatible-user-scopes-vars
2 parents a3b27b8 + 45b822f commit d1332f2

File tree

68 files changed

+746
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+746
-324
lines changed

.github/workflows/code-build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ jobs:
6969
- [ ] test `gp open` and `gp preview`
7070
- [ ] test open in VS Code Desktop, check `gp open` and `gp preview` in task/user terminals
7171
- [ ] telemetry data like `vscode_extension_gallery` is collected in [Segment](https://app.segment.com/gitpod/sources/staging_trusted/debugger)
72+
- [ ] test using `ubuntu 18` is working well, [example repo](https://github.com/jeanp413/test-gp-prebuild/tree/jp/damaged-aardwolf)
7273
7374
### Preview status
7475
gitpod:summary

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</div>
1818

1919

20-
[Gitpod](https://www.gitpod.io)’s developer platform provides on-demand, pre-configured environments that automatically integrate into any tool, library, or dependency required for creating software. Gitpod workspaces are the fastest and most secure way to ship software and are as easy as adding a .gitpod.yml file to the root of any repository.
20+
[Gitpod](https://www.gitpod.io)’s developer platform provides on-demand, pre-configured environments that automatically integrate into any tool, library, or dependency required for creating software. Gitpod workspaces are the fastest and most secure way to ship software and are as easy as adding a `.gitpod.yml` file to the root of any repository.
2121

2222
📄 [Read Cloud Development Environment white paper](https://www.gitpod.io/whitepaper/cde)
2323

WORKSPACE.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ defaultArgs:
77
publishToNPM: true
88
publishToJBMarketplace: true
99
localAppVersion: unknown
10-
codeCommit: dbe6cce70f2466a5f716a17d4fccdf198ca6287f
11-
codeVersion: 1.93.1
10+
codeCommit: df9057e10ad761c6a8378b72b37554c1458256e3
11+
codeVersion: 1.94.2
1212
codeQuality: stable
1313
codeWebExtensionCommit: 7ff72a2938a7a06cbdf3964590f7e9b7525958f3
1414
xtermCommit: 8f10c5febf0162a3c2309076302f770fbad38fde
@@ -21,7 +21,7 @@ defaultArgs:
2121
webstormDownloadUrl: "https://download.jetbrains.com/webstorm/WebStorm-2024.2.3.tar.gz"
2222
riderDownloadUrl: "https://download.jetbrains.com/rider/JetBrains.Rider-2024.1.4.tar.gz"
2323
clionDownloadUrl: "https://download.jetbrains.com/cpp/CLion-2024.2.2.tar.gz"
24-
rustroverDownloadUrl: "https://download.jetbrains.com/rustrover/RustRover-2024.2.2.tar.gz"
24+
rustroverDownloadUrl: "https://download.jetbrains.com/rustrover/RustRover-2024.2.3.tar.gz"
2525
jbBackendVersion: "latest"
2626
dockerVersion: "20.10.24"
2727
dockerComposeVersion: "2.27.0-gitpod.0"

components/blobserve/leeway.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the GNU Affero General Public License (AGPL).
33
# See License.AGPL.txt in the project root for license information.
44

5-
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:28f57f6a9fb2478f3a3dd160794831bd0099ec92d0d7b81cd203fae67bcb5339
5+
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:4857dbc65f7dbf22dd662370a6b211621eba5550d276a9b2ad2596b666cbbdfe
66

77
# Ensure latest packages are present, like security updates.
88
RUN apk upgrade --no-cache \

components/content-service/leeway.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the GNU Affero General Public License (AGPL).
33
# See License.AGPL.txt in the project root for license information.
44

5-
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:28f57f6a9fb2478f3a3dd160794831bd0099ec92d0d7b81cd203fae67bcb5339
5+
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:4857dbc65f7dbf22dd662370a6b211621eba5550d276a9b2ad2596b666cbbdfe
66

77
# Ensure latest packages are present, like security updates.
88
RUN apk upgrade --no-cache \

components/dashboard/leeway.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the GNU Affero General Public License (AGPL).
33
# See License.AGPL.txt in the project root for license information.
44

5-
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:28f57f6a9fb2478f3a3dd160794831bd0099ec92d0d7b81cd203fae67bcb5339 as compress
5+
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:4857dbc65f7dbf22dd662370a6b211621eba5550d276a9b2ad2596b666cbbdfe as compress
66

77
RUN apk add brotli gzip
88

components/dashboard/src/components/podkit/combobox/Combobox.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ export const Combobox: FunctionComponent<ComboboxProps> = ({
8484

8585
const setActiveElement = useCallback(
8686
(element: string) => {
87+
if (!filteredOptions.find((el) => element === el.id)?.isSelectable) {
88+
return;
89+
}
8790
setSelectedElementTemp(element);
8891
const el = document.getElementById(element);
8992
el?.scrollIntoView({ block: "nearest" });
9093
},
91-
[setSelectedElementTemp],
94+
[filteredOptions],
9295
);
9396

9497
const handleOpenChange = useCallback(

components/dashboard/src/data/git-providers/unified-repositories-search-query.test.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { SuggestedRepository } from "@gitpod/public-api/lib/gitpod/v1/scm_pb";
8-
import { deduplicateAndFilterRepositories } from "./unified-repositories-search-query";
8+
import { deduplicateAndFilterRepositories, isValidGitUrl } from "./unified-repositories-search-query";
99

1010
function repo(name: string, project?: string): SuggestedRepository {
1111
return new SuggestedRepository({
@@ -95,3 +95,27 @@ test("it should return all repositories without duplicates when excludeProjects
9595
expect(deduplicated[0].repoName).toEqual("foo");
9696
expect(deduplicated[1].repoName).toEqual("bar");
9797
});
98+
99+
test("should perform weak validation for git URLs", () => {
100+
expect(isValidGitUrl("a:")).toEqual(false);
101+
expect(isValidGitUrl("a:b")).toEqual(false);
102+
expect(isValidGitUrl("https://b")).toEqual(false);
103+
expect(isValidGitUrl("https://b/repo.git")).toEqual(false);
104+
expect(isValidGitUrl("https://b.com/repo.git")).toEqual(true);
105+
expect(isValidGitUrl("[email protected]:")).toEqual(false);
106+
expect(isValidGitUrl("[email protected]:")).toEqual(false);
107+
expect(isValidGitUrl("[email protected]:22:")).toEqual(false);
108+
expect(isValidGitUrl("[email protected]:g/g")).toEqual(true);
109+
110+
// some "from the wild" cases
111+
expect(isValidGitUrl("https://github.com/gitpod-io/gitpod/pull/20281")).toEqual(true);
112+
expect(isValidGitUrl("https://gitlab.com/filiptronicek/gitpod.git")).toEqual(true);
113+
expect(isValidGitUrl("[email protected]:gitpod-io/gitpod.git")).toEqual(true);
114+
expect(isValidGitUrl("[email protected]:filiptronicek/gitpod.git")).toEqual(true);
115+
expect(isValidGitUrl("ssh://[email protected]:12345/~/repository.git")).toBe(true);
116+
expect(isValidGitUrl("https://bitbucket.gitpod-dev.com/scm/~geropl/test-user-repo.git")).toBe(true);
117+
expect(isValidGitUrl("git://gitlab.com/gitpod/spring-petclinic")).toBe(true);
118+
expect(isValidGitUrl("[email protected]:v3/services-azure/open-to-edit-project2/open-to-edit-project2")).toBe(
119+
true,
120+
);
121+
});

components/dashboard/src/data/git-providers/unified-repositories-search-query.ts

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useMemo } from "react";
1111
import { useListConfigurations } from "../configurations/configuration-queries";
1212
import type { UseInfiniteQueryResult } from "@tanstack/react-query";
1313
import { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";
14+
import { parseUrl } from "../../utils";
1415

1516
export const flattenPagedConfigurations = (
1617
data: UseInfiniteQueryResult<{ configurations: Configuration[] }>["data"],
@@ -125,17 +126,62 @@ export function deduplicateAndFilterRepositories(
125126
}
126127

127128
if (results.length === 0) {
128-
try {
129-
// If the searchString is a URL, and it's not present in the proposed results, "artificially" add it here.
130-
new URL(searchString);
129+
// If the searchString is a URL, and it's not present in the proposed results, "artificially" add it here.
130+
if (isValidGitUrl(searchString)) {
131+
console.log("It's valid man");
131132
results.push(
132133
new SuggestedRepository({
133134
url: searchString,
134135
}),
135136
);
136-
} catch {}
137+
}
138+
139+
console.log("Valid after man");
137140
}
138141

139142
// Limit what we show to 200 results
140143
return results.slice(0, 200);
141144
}
145+
146+
const ALLOWED_GIT_PROTOCOLS = ["ssh:", "git:", "http:", "https:"];
147+
/**
148+
* An opionated git URL validator
149+
*
150+
* Assumptions:
151+
* - Git hosts are not themselves TLDs (like .com) or reserved names like `localhost`
152+
* - Git clone URLs can operate over ssh://, git:// and http(s)://
153+
* - Git clone URLs (both SSH and HTTP ones) must have a nonempty path
154+
*/
155+
export const isValidGitUrl = (input: string): boolean => {
156+
const url = parseUrl(input);
157+
if (!url) {
158+
// SSH URLs with no protocol, such as [email protected]:gitpod-io/gitpod.git
159+
const sshMatch = input.match(/^\w+@([^:]+):(.+)$/);
160+
if (!sshMatch) return false;
161+
162+
const [, host, path] = sshMatch;
163+
164+
// Check if the path is not empty
165+
if (!path || path.trim().length === 0) return false;
166+
167+
if (path.includes(":")) return false;
168+
169+
return isHostValid(host);
170+
}
171+
172+
if (!url) return false;
173+
174+
if (!ALLOWED_GIT_PROTOCOLS.includes(url.protocol)) return false;
175+
if (url.pathname.length <= 1) return false; // make sure we have some path
176+
177+
return isHostValid(url.host);
178+
};
179+
180+
const isHostValid = (input?: string): boolean => {
181+
if (!input) return false;
182+
183+
const hostSegments = input.split(".");
184+
if (hostSegments.length < 2 || hostSegments.some((chunk) => chunk === "")) return false; // check that there are no consecutive periods as well as no leading or trailing ones
185+
186+
return true;
187+
};
10.3 KB
Loading

0 commit comments

Comments
 (0)