Skip to content
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

added check of host value during daemon registration #159

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Service/DaemonConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public function __construct(
}

public function registerDaemonConfig(array $params): ?DaemonConfig {
$bad_patterns = ['http', 'https', 'tcp', 'udp', 'ssh'];
$docker_host = (string)$params['host'];
foreach ($bad_patterns as $bad_pattern) {
if (str_starts_with($docker_host, $bad_pattern . '://')) {
$this->logger->error('Failed to register daemon configuration. `host` must not include a protocol.');
return null;
}
}
try {
$daemonConfig = $this->mapper->insert(new DaemonConfig([
'name' => $params['name'],
Expand Down
23 changes: 21 additions & 2 deletions src/components/DaemonConfig/RegisterDaemonConfigModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,17 @@
<NcInputField
id="daemon-host"
:value.sync="host"
:placeholder="t('app_api', 'Daemon host (e.g. /var/run/docker.sock, https://proxy-domain.com:2375)')"
:aria-label="t('app_api', 'Daemon host (e.g. /var/run/docker.sock, https://proxy-domain.com:2375)')" />
:placeholder="t('app_api', 'Daemon host (e.g. /var/run/docker.sock, proxy-domain.com:2375)')"
:aria-label="t('app_api', 'Daemon host (e.g. /var/run/docker.sock, proxy-domain.com:2375)')"
:helper-text="daemonHostHelperText" />
</div>
<div v-if="acceptsDeployId !== 'manual-install'" class="external-label">
<label for="nextcloud-url">{{ t('app_api', 'Nextcloud url') }}</label>
<NcInputField
id="nextcloud-url"
:value.sync="nextcloud_url"
:placeholder="t('app_api', 'Nextcloud url')"
:aria-label="t('app_api', 'Nextcloud url')" />
</div>
<NcCheckboxRadioSwitch
v-if="acceptsDeployId !== 'manual-install'"
Expand Down Expand Up @@ -175,6 +184,16 @@ export default {
registerInOneClickLoading: false,
}
},
computed: {
daemonHostHelperText() {
if (this.protocol === 'unix-socket') {
return t('app_api', 'Unix socket path (e.g. /var/run/docker.sock)')
} else if (['http', 'https'].includes(this.protocol)) {
return t('app_api', 'Host with port (e.g. proxy-domain.com:2375)')
}
return ''
},
},
watch: {
acceptsDeployId(newAcceptsDeployId) {
if (newAcceptsDeployId === 'manual-install') {
Expand Down
Loading