* [pdm-devel] [PATCH datacenter-manager 0/2] validate remote hostname
@ 2025-12-19 12:37 Shannon Sterz
2025-12-19 12:37 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: node url list: validate list of endpoints Shannon Sterz
2025-12-19 12:37 ` [pdm-devel] [PATCH datacenter-manager 2/2] api types: node url: validate hostname Shannon Sterz
0 siblings, 2 replies; 3+ messages in thread
From: Shannon Sterz @ 2025-12-19 12:37 UTC (permalink / raw)
To: pdm-devel
previously the endpoints list in the ui did not validate user input,
nor did the api when updating a remote. this could lead to an issue
where a user could configure a remote in a way that made it impossible
for pdm to connect to it. this series fixes that.
changes since v1:
* add validation to the correct place, thanks @ Dominik Csapak
Shannon Sterz (2):
ui: node url list: validate list of endpoints
api types: node url: validate hostname
lib/pdm-api-types/src/lib.rs | 3 +++
lib/pdm-api-types/src/remotes.rs | 5 ++++-
ui/src/remotes/node_url_list.rs | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] [PATCH datacenter-manager 1/2] ui: node url list: validate list of endpoints
2025-12-19 12:37 [pdm-devel] [PATCH datacenter-manager 0/2] validate remote hostname Shannon Sterz
@ 2025-12-19 12:37 ` Shannon Sterz
2025-12-19 12:37 ` [pdm-devel] [PATCH datacenter-manager 2/2] api types: node url: validate hostname Shannon Sterz
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2025-12-19 12:37 UTC (permalink / raw)
To: pdm-devel
otherwise user can manually edit these fields. when adding a remote
through a wizzard the api will return an error that the value doesn't
match the validation regex instantly. hence, there it is mostly a ux
issue.
when editing a remote, however, the api doesn't validate the url. so
adding, for a example a protocol (e.g. "https://") to the hostname/ip
field, will lead to connection errors when looking at the remote's
overview.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
lib/pdm-api-types/src/lib.rs | 3 +++
ui/src/remotes/node_url_list.rs | 2 ++
2 files changed, 5 insertions(+)
diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
index 5daaa3f..d4cc7ef 100644
--- a/lib/pdm-api-types/src/lib.rs
+++ b/lib/pdm-api-types/src/lib.rs
@@ -137,6 +137,9 @@ pub const HOST_PORT_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&HOST_POR
pub const HOST_OPTIONAL_PORT_FORMAT: ApiStringFormat =
ApiStringFormat::Pattern(&HOST_OPTIONAL_PORT_REGEX);
pub const HTTP_URL_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&HTTP_URL_REGEX);
+pub const HOST_OPTIONAL_PORT_SCHEMA: Schema = StringSchema::new("A host with an optional port.")
+ .format(&HOST_OPTIONAL_PORT_FORMAT)
+ .schema();
pub const DAILY_DURATION_FORMAT: ApiStringFormat =
ApiStringFormat::VerifyFn(|s| parse_daily_duration(s).map(drop));
diff --git a/ui/src/remotes/node_url_list.rs b/ui/src/remotes/node_url_list.rs
index 89999ef..c558022 100644
--- a/ui/src/remotes/node_url_list.rs
+++ b/ui/src/remotes/node_url_list.rs
@@ -16,6 +16,7 @@ use pwt::{css, prelude::*};
use proxmox_yew_comp::{SchemaValidation, Status};
use pdm_api_types::remotes::NodeUrl;
+use pdm_api_types::HOST_OPTIONAL_PORT_SCHEMA;
use proxmox_schema::property_string::PropertyString;
use proxmox_schema::api_types::CERT_FINGERPRINT_SHA256_SCHEMA;
@@ -254,6 +255,7 @@ fn columns(ctx: &ManagedFieldContext<PdmNodeUrlField>) -> Rc<Vec<DataTableHeader
Field::new()
.on_change(link.callback(move |value| Msg::UpdateHostname(index, value)))
.required(true)
+ .schema(HOST_OPTIONAL_PORT_SCHEMA)
.value(item.data.hostname.clone())
.into()
}
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pdm-devel] [PATCH datacenter-manager 2/2] api types: node url: validate hostname
2025-12-19 12:37 [pdm-devel] [PATCH datacenter-manager 0/2] validate remote hostname Shannon Sterz
2025-12-19 12:37 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: node url list: validate list of endpoints Shannon Sterz
@ 2025-12-19 12:37 ` Shannon Sterz
1 sibling, 0 replies; 3+ messages in thread
From: Shannon Sterz @ 2025-12-19 12:37 UTC (permalink / raw)
To: pdm-devel
otherwise, it is possible to set values via the api when updating a
remote that won't work. for example, adding a protocol like "https://"
to the beginning of a remote's hostname will break attempts at
connecting to it.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
lib/pdm-api-types/src/remotes.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/pdm-api-types/src/remotes.rs b/lib/pdm-api-types/src/remotes.rs
index f69609c..b226d19 100644
--- a/lib/pdm-api-types/src/remotes.rs
+++ b/lib/pdm-api-types/src/remotes.rs
@@ -8,7 +8,7 @@ use proxmox_schema::{api, ApiType, Schema, StringSchema, Updater};
use proxmox_section_config::typed::ApiSectionDataEntry;
use proxmox_section_config::{SectionConfig, SectionConfigPlugin};
-use crate::Authid;
+use crate::{Authid, HOST_OPTIONAL_PORT_FORMAT};
pub const REMOTE_ID_SCHEMA: Schema = StringSchema::new("Remote ID.")
.format(&crate::PROXMOX_SAFE_ID_FORMAT)
@@ -18,6 +18,9 @@ pub const REMOTE_ID_SCHEMA: Schema = StringSchema::new("Remote ID.")
#[api(
properties: {
+ hostname: {
+ format: &HOST_OPTIONAL_PORT_FORMAT,
+ },
"fingerprint": {
type: String,
format: &crate::FINGERPRINT_SHA256_FORMAT,
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-19 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-19 12:37 [pdm-devel] [PATCH datacenter-manager 0/2] validate remote hostname Shannon Sterz
2025-12-19 12:37 ` [pdm-devel] [PATCH datacenter-manager 1/2] ui: node url list: validate list of endpoints Shannon Sterz
2025-12-19 12:37 ` [pdm-devel] [PATCH datacenter-manager 2/2] api types: node url: validate hostname Shannon Sterz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox