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

Device auto-provision and auto-create may use invalid device id #3608

Closed
harism opened this issue Jan 20, 2024 · 3 comments · Fixed by #3641
Closed

Device auto-provision and auto-create may use invalid device id #3608

harism opened this issue Jan 20, 2024 · 3 comments · Fixed by #3641

Comments

@harism
Copy link
Contributor

harism commented Jan 20, 2024

It seems possible that gateway device auto-provision and certificate based device auto-create may create a device with invalid device id. Invalid in a sense that you cannot access that device id using Device Registry API in any way.

Would it be better to add similar validation for auto-provision and auto-create as Device Registry HTTP calls have to ensure it the created device or gateway has always valid device id which works with Device Registry API calls also?

To test this:

  1. Create an auto-provisioning gateway with http-credentials
  2. Send PUT /telemetry/{tenant_id}/**invalid to http-adapter with previous step gateway credentials
  3. Device with **invalid -device id is created which is inaccessible with Device Registry API
@harism harism changed the title Device auto-provisionin and auto-create may use invalid device id Device auto-provision and auto-create may use invalid device id Jan 20, 2024
@sophokles73
Copy link
Contributor

Would it be better to add similar validation for auto-provision and auto-create as Device Registry HTTP calls have to ensure it the created device or gateway has always valid device id which works with Device Registry API calls also?

I guess the check, if it is currently missing, should be added to the component that both the Registry Management API endpoint as well as the (adapter facing) AMQP based service Device Registration endpoint are using.

@harism
Copy link
Contributor Author

harism commented Jan 27, 2024

Ok, I could make a PR for this change for evaluation for its need. There is configurable validator already in device registry for device and tenant ids but it seems to be in use only for incoming HTTP requests parameters unless I'm mistaken. It should be somewhat straightforward to bring same validator into use for automated device creation paths also.

@harism
Copy link
Contributor Author

harism commented Apr 14, 2024

Sorry for the long delay but now finally I had time to look at this again, and there is one question I'd like to clarify first before starting any actual implementation;

The current deviceId regexp pattern is defined in the property hono.registry.http.deviceIdPattern and now I would need to extend its use and bring a properties object containing it ServiceConfigProperties into use for AMQP or more specifically the EdgeDeviceAutoProvisioner class's use. It depends a bit also on how early the deviceId check is wanted to be made as part of device assertion.

And the question is how would you like to see this property hono.registry.http.deviceIdPattern handled now if its use gets extended above default HTTP device create only?

harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 2, 2024
harism added a commit to harism/hono that referenced this issue Jun 13, 2024
harism added a commit to harism/hono that referenced this issue Jun 21, 2024
harism added a commit to harism/hono that referenced this issue Jun 22, 2024
harism added a commit to harism/hono that referenced this issue Jun 22, 2024
harism added a commit to harism/hono that referenced this issue Jun 22, 2024
harism added a commit to harism/hono that referenced this issue Jun 23, 2024
harism added a commit to harism/hono that referenced this issue Jun 23, 2024
harism added a commit to harism/hono that referenced this issue Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants