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

Service path levels with 0 length should not be allowed #4495

Closed
fgalan opened this issue Jan 29, 2024 · 1 comment
Closed

Service path levels with 0 length should not be allowed #4495

fgalan opened this issue Jan 29, 2024 · 1 comment

Comments

@fgalan
Copy link
Member

fgalan commented Jan 29, 2024

From https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#entity-service-path

50 maximum characters in each level (1 char is minimum), only alphanumeric and underscore allowed

However, Orion allows creating service path with 0 length levels, eg:

$ curl localhost:1026/v2/entities -vvvv -s -S -H 'Content-Type: application/json' -H 'fiware-servicepath: //detecciondeplagas' -d @- <<EOF
{
  "id": "Room2",
  "type": "Room",
  "temperature": {
    "value": 23,
    "type": "Float"
  },
  "pressure": {
    "value": 720,
    "type": "Integer"
  }
}
EOF

*   Trying 127.0.0.1:1026...
* Connected to localhost (127.0.0.1) port 1026 (#0)
> POST /v2/entities HTTP/1.1
> Host: localhost:1026
> User-Agent: curl/7.88.1
> Accept: */*
> Content-Type: application/json
> fiware-servicepath: //detecciondeplagas
> Content-Length: 148
> 
< HTTP/1.1 201 Created
< Date: Mon, 29 Jan 2024 15:15:25 GMT
< Fiware-Correlator: 3a970da4-beb9-11ee-85a1-080027cd35f1
< Location: /v2/entities/Room2?type=Room
< Content-Length: 0
< 
* Connection #0 to host localhost left intact
@ArqamFarooqui110719
Copy link
Contributor

PR #4503
This PR fixes servicepath levels with zero length, i.e. available in initial part (1st level) of servicepath only (e.g. fiware-servicepath: //det), because servicepath levels with zero length, i.e. available in 2nd level or further level of servicepath (e.g. fiware-servicepath: /a///det), are already restricted by following code in servicePathCheck() function src/lib/rest/rest.cpp file:

    if (compV[ix].c_str()[0] == 0)
    {
      OrionError oe(SccBadRequest, "empty component in ServicePath");
      ciP->answer = oe.setStatusCodeAndSmartRender(ciP->apiVersion, &(ciP->httpStatusCode));
      return 3;
    }

@fgalan fgalan added this to the 3.12.0 milestone Feb 14, 2024
@fgalan fgalan closed this as completed Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants