-
-
Notifications
You must be signed in to change notification settings - Fork 395
feat: Add configurable SSH port for source control providers and SSH … #1028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ public function clone(Site $site, ?string $path = null): void | |
| 'path' => $path ?? $site->path, | ||
| 'branch' => $site->branch, | ||
| 'key' => $site->getSshKeyName(), | ||
| 'port' => $site->sourceControl?->provider()?->getSshPort() ?? 22, | ||
|
||
| ]), | ||
| 'clone-repository', | ||
| $site->id | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,4 +70,9 @@ public function getBranches(string $repo, bool $useCache = true): array | |||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| return []; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| public function getSshPort(): ?int | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| return (int) $this->sourceControl->port ?: ((int) ($this->sourceControl->provider_data['port'] ?? null) ?: null); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| return (int) $this->sourceControl->port ?: ((int) ($this->sourceControl->provider_data['port'] ?? null) ?: null); | |
| $port = $this->sourceControl->port; | |
| if ($port === null && isset($this->sourceControl->provider_data['port'])) { | |
| $port = $this->sourceControl->provider_data['port']; | |
| } | |
| if ($port === null) { | |
| return null; | |
| } | |
| $port = (int) $port; | |
| if ($port < 1 || $port > 65535) { | |
| return null; | |
| } | |
| return $port; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,14 +38,15 @@ public function createRules(array $input): array | |||||
| 'url:http,https', | ||||||
| 'ends_with:/', | ||||||
| ], | ||||||
| 'port' => 'nullable|integer', | ||||||
|
||||||
| 'port' => 'nullable|integer', | |
| 'port' => 'nullable|integer|min:1|max:65535', |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,6 +64,6 @@ public function deleteDeployKey(string $keyId, string $repo): void; | |||||||||||||
| public function getWebhookBranch(array $payload): string; | ||||||||||||||
|
|
||||||||||||||
| public function getRepos(bool $useCache = true): array; | ||||||||||||||
|
|
||||||||||||||
| public function getBranches(string $repo, bool $useCache = true): array; | ||||||||||||||
|
||||||||||||||
| public function getBranches(string $repo, bool $useCache = true): array; | |
| public function getBranches(string $repo, bool $useCache = true): array; | |
| } | |
| interface SshAwareSourceControlProvider extends SourceControlProvider | |
| { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||
| <?php | ||||||
|
|
||||||
| use Illuminate\Database\Migrations\Migration; | ||||||
| use Illuminate\Database\Schema\Blueprint; | ||||||
| use Illuminate\Support\Facades\Schema; | ||||||
|
|
||||||
| return new class extends Migration { | ||||||
| public function up(): void | ||||||
| { | ||||||
| Schema::table('source_controls', function (Blueprint $table): void { | ||||||
| $table->unsignedInteger('port')->nullable()->after('url'); | ||||||
|
||||||
| $table->unsignedInteger('port')->nullable()->after('url'); | |
| $table->unsignedSmallInteger('port')->nullable()->after('url'); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,29 +1,30 @@ | ||||||
| echo "Host {{ $host }}-{{ $key }} | ||||||
| Hostname {{ $host }} | ||||||
| IdentityFile=~/.ssh/{{ $key }}" >> ~/.ssh/config | ||||||
| Hostname {{ $host }} | ||||||
| Port {{ $port }} | ||||||
| IdentityFile=~/.ssh/{{ $key }}" >> ~/.ssh/config | ||||||
|
||||||
| IdentityFile=~/.ssh/{{ $key }}" >> ~/.ssh/config | |
| IdentityFile ~/.ssh/{{ $key }}" >> ~/.ssh/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
portis persisted from user input but there is no base validation for it. For non-Gitlab providers,providerRules()won't includeport, yet this code will still store the value (including negatives / >65535), which can later break SSH cloning. Add a shared validation rule forport(e.g. nullable|integer|min:1|max:65535) invalidate()or only allow persisting it when the active provider explicitly supports it.