apache / apache/cloudstack

Leading/trailing spaces are allowed in string fields for some API endpoints

Offen
#12,506 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
component:api type:improvement
Vorherrschende Sprache
Java
Sterne
3.1k
Forks
1.4k
Ø Merge
6 T. 19 Std.
Gemergte PRs (30 T.)
32

Beschreibung

### problem

Currently, some API endpoints allow saving string fields with leading or trailing spaces. This behavior can lead to inconsistent data and unexpected UI/API issues.

For example, when creating or updating certain resources (e.g. volumes, templates, ISOs), values with spaces at the beginning or end of the string are accepted and stored successfully, while they should instead be rejected with a validation error.

Here is the list of API endpoints where the issue occurs for the name and description fields:
- registerIso / updateIso
- createVolume / updateVolume / uploadVolume
- registerTemplate / updateTemplate
- updateNetwork / createNetwork / createNetworkACL / updateNetworkACLList
- createVPC / updateVPC
- createVpnCustomerGateway / createVpnGateway / createVpnCustomerGateway

Please also check other endpoints where this issue might occur, as similar validation problems may exist elsewhere.

### versions

CloudStack 4.20.2.0

### The steps to reproduce the bug

1. Call one of the affected endpoints (for example: ISO creation or update).
2. Provide string fields with leading or trailing spaces.
3. Observe that the request is accepted and the data is stored.

```
{
"listisosresponse": {
"count": 1,
"iso": [
{
"id": "fee7a4be-b9cd-41d9-81c9-e948332e605b",
"name": " test name ",
"displaytext": " text ",
"isready": true,
"url": "my_url",
....
}
]
}
}
```

### What to do about it?

The API should not allow leading or trailing spaces in string fields. It would be preferable to introduce this validation globally for all string fields across the API

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, die Validierung für die aufgeführten API-Einstiegspunkte nachzuverfolgen, und verwende registerIso oder updateIso, um die Akzeptanz führender und nachgestellter Leerzeichen zu reproduzieren. Prüfe die anderen benannten Volume-, Template-, Netzwerk-, VPC- und VPN-Endpunkte auf dasselbe Verhalten; als erledigt gilt die Aufgabe, wenn betroffene String-Felder solche Werte mit einem Validierungsfehler ablehnen, einschließlich aller zusätzlich gefundenen Endpunkte.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
api, backend, cloud
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.