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

Add validation for null props inside objects inside arrays. #4896

Merged
merged 7 commits into from
May 4, 2021

Conversation

vadim-kovalyov
Copy link
Contributor

@vadim-kovalyov vadim-kovalyov commented Apr 23, 2021

Add validation for null props inside objects inside arrays.

Since IoT Hub does not support patch operations on arrays (if you want to update array, you need to replace it), they don't allow null values or null properties inside arrays. EdgeHub, on the other hand, allows that. So, validation can pass on the EdgeHub side, but the update will be rejected by the hub. This situation allows for sending bad payloads, that blocks any further twin updates unless bad property is removed/cleared.

{
if (currentDepth > TwinPropertyMaxDepth)
{
throw new InvalidOperationException($"Nested depth of twin property exceeds {TwinPropertyMaxDepth}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this applicable to arrays as well? Have you confirmed with IoTHub behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is true for all json type fields then can we just move it out of the destructure ifs and put a single if depth check at the top of this fn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyanzebra, this is true for arrays and objects only. But you might have a point, so I moved that into a func to avoid duplications.

@varunpuranik, as discussed offline with the hub folks, I believe we need to keep nested arrays validaion.

varunpuranik
varunpuranik previously approved these changes Apr 27, 2021
@kodiakhq kodiakhq bot merged commit f96961f into Azure:master May 4, 2021
vadim-kovalyov added a commit to vadim-kovalyov/iotedge that referenced this pull request May 4, 2021
Add validation for null props inside objects inside arrays.
kodiakhq bot pushed a commit that referenced this pull request May 5, 2021
…4941)

Add validation for null props inside objects inside arrays.

Since IoT Hub does not support patch operations on arrays (if you want to update array, you need to replace it), they don't allow null values or null properties inside arrays. EdgeHub, on the other hand, allows that. So, validation can pass on the EdgeHub side, but the update will be rejected by the hub. This situation allows for sending bad payloads, that blocks any further twin updates unless bad property is removed/cleared.
yophilav added a commit to yophilav/iotedge that referenced this pull request May 12, 2021
Update test

rusting

rusting

Style

Style C#

parsing

Parsing with test

Add validation for null props inside objects inside arrays. (Azure#4896) (Azure#4941)

Add validation for null props inside objects inside arrays.

Since IoT Hub does not support patch operations on arrays (if you want to update array, you need to replace it), they don't allow null values or null properties inside arrays. EdgeHub, on the other hand, allows that. So, validation can pass on the EdgeHub side, but the update will be rejected by the hub. This situation allows for sending bad payloads, that blocks any further twin updates unless bad property is removed/cleared.
yophilav pushed a commit to yophilav/iotedge that referenced this pull request May 13, 2021
…) (Azure#4941)

Add validation for null props inside objects inside arrays.

Since IoT Hub does not support patch operations on arrays (if you want to update array, you need to replace it), they don't allow null values or null properties inside arrays. EdgeHub, on the other hand, allows that. So, validation can pass on the EdgeHub side, but the update will be rejected by the hub. This situation allows for sending bad payloads, that blocks any further twin updates unless bad property is removed/cleared.
vipeller pushed a commit to vipeller/iotedge that referenced this pull request May 26, 2021
kodiakhq bot pushed a commit that referenced this pull request May 26, 2021
#5034)

…#4941)

Since IoT Hub does not support patch operations on arrays (if you want to update array, you need to replace it), they don't allow null values or null properties inside arrays. EdgeHub, on the other hand, allows that. So, validation can pass on the EdgeHub side, but the update will be rejected by the hub. This situation allows for sending bad payloads, that blocks any further twin updates unless bad property is removed/cleared.
ggjjj pushed a commit to ggjjj/iotedge that referenced this pull request Jul 22, 2021
Add validation for null props inside objects inside arrays.
damonbarry pushed a commit to damonbarry/iotedge that referenced this pull request Apr 15, 2022
Add validation for null props inside objects inside arrays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants