-
Notifications
You must be signed in to change notification settings - Fork 66
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
discovery: allow to ignore resource in batch notification #623
Conversation
WalkthroughThe updates across various API components focus on enhancing response handling, resource discovery, and testing frameworks. Key changes include improved decision-making in response processing, support checks for batch responses, and extended testing capabilities with new classes and methods for dynamic resources and batch discovery scenarios. These changes aim to refine functionality and expand testing coverage for more robust software behavior. Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (9)
Files skipped from review as they are similar to previous changes (6)
Additional Context UsedAST-based Instructions (15)
Additional comments not posted (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
🎉 Thank you for your code contribution! To guarantee the change/addition is conformant to the OCF Specification, we would like to ask you to execute OCF Conformance Testing of your change ☝️ when your work is ready to be reviewed. ℹ️ To verify your latest change (cccfd14), label this PR with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Actionable comments outside the diff hunks (3)
api/oc_discovery.c (3)
Line range hint
728-732
: Replacememset
withmemset_s
to enhance security.The use of
memset
for clearing structures likeoc_request_t
,oc_response_t
, andoc_response_buffer_t
can potentially lead to buffer overflows. Replace these withmemset_s
which is safer as it considers buffer boundaries.- memset(&rest_request, 0, sizeof(oc_request_t)); - memset(&response, 0, sizeof(oc_response_t)); - memset(&response_buffer, 0, sizeof(oc_response_buffer_t)); + memset_s(&rest_request, sizeof(oc_request_t), 0, sizeof(oc_request_t)); + memset_s(&response, sizeof(oc_response_t), 0, sizeof(oc_response_t)); + memset_s(&response_buffer, sizeof(oc_response_buffer_t), 0, sizeof(oc_response_buffer_t));
Line range hint
1242-1242
: Replacememset
withmemset_s
to prevent potential buffer overflows.The use of
memset
to clear theoc_string_t
structure can lead to buffer overflows. Usememset_s
instead for enhanced safety.- memset(&uri, 0, sizeof(oc_string_t)); + memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));
Line range hint
1339-1339
: Replacememset
withmemset_s
to ensure buffer safety.The use of
memset
to clear theoc_rep_parse_result_t
structure can lead to buffer overflows. Replace it withmemset_s
to ensure buffer boundaries are respected.- memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result));
cccfd14
to
5ce7882
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Actionable comments outside the diff hunks (1)
api/oc_discovery.c (1)
Line range hint
758-762
: Replacememset
withmemset_s
to ensure buffer safety.- memset(&rest_request, 0, sizeof(oc_request_t)); - memset(&response, 0, sizeof(oc_response_t)); - memset(&response_buffer, 0, sizeof(oc_response_buffer_t)); + memset_s(&rest_request, sizeof(oc_request_t), 0, sizeof(oc_request_t)); + memset_s(&response, sizeof(oc_response_t), 0, sizeof(oc_response_t)); + memset_s(&response_buffer, sizeof(oc_response_buffer_t), 0, sizeof(oc_response_buffer_t));Using
memset_s
instead ofmemset
can help prevent potential buffer overflows and ensure that the memory clearing is not optimized away by the compiler, which can happen withmemset
in certain optimization levels.
5ce7882
to
a211487
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Actionable comments outside the diff hunks (5)
api/oc_server_api.c (3)
Line range hint
74-74
: Replacememset
withmemset_s
to enhance security by preventing potential buffer overflows.- memset(&cfg.ports, 0, sizeof(cfg.ports)); + memset_s(&cfg.ports, sizeof(cfg.ports), 0, sizeof(cfg.ports));
Line range hint
341-341
: Replacememset
withmemset_s
in theoc_populate_resource_object
function to prevent potential buffer overflows.- memset(&resource->name, 0, sizeof(oc_string_t)); + memset_s(&resource->name, sizeof(oc_string_t), 0, sizeof(oc_string_t));
Line range hint
347-347
: Replacememset
withmemset_s
to secure the initialization ofoc_string_array_t
types.- memset(&resource->types, 0, sizeof(oc_string_array_t)); + memset_s(&resource->types, sizeof(oc_string_array_t), 0, sizeof(oc_string_array_t));api/oc_discovery.c (2)
Line range hint
1251-1251
: Replacememset
withmemset_s
for theuri
variable to enhance security.- memset(&uri, 0, sizeof(oc_string_t)); + memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));This change ensures that the buffer boundaries are respected, reducing the risk of buffer overflow.
Line range hint
1348-1348
: Usememset_s
instead ofmemset
to clear theresult
structure.- memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result));This modification is recommended to prevent potential buffer overflow issues by considering the size of the buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Actionable comments outside the diff hunks (7)
api/oc_ri.c (7)
Line range hint
773-773
: Replacememset
withmemset_s
to enhance security.- memset(aux_arr, 0, sizeof(aux_arr)); + memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
Line range hint
831-831
: Replacememset
withmemset_s
to enhance security.- memset(&handler, 0, sizeof(oc_request_handler_t)); + memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
Line range hint
1247-1247
: Replacememset
withmemset_s
to enhance security.- memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
Line range hint
1697-1697
: Replacememset
withmemset_s
to enhance security.- memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t)); + memset_s(preparsed_request_obj, sizeof(oc_ri_preparsed_request_obj_t), 0, sizeof(oc_ri_preparsed_request_obj_t));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
Line range hint
1752-1752
: Replacememset
withmemset_s
to enhance security.- memset(&response_buffer, 0, sizeof(response_buffer)); + memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
Line range hint
1756-1756
: Replacememset
withmemset_s
to enhance security.- memset(&response_obj, 0, sizeof(response_obj)); + memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
Line range hint
1760-1760
: Replacememset
withmemset_s
to enhance security.- memset(&request_obj, 0, sizeof(request_obj)); + memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));This change prevents potential buffer overflow issues by ensuring the buffer boundaries are respected.
fbd4696
to
00e7195
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Actionable comments outside the diff hunks (3)
api/oc_discovery.c (2)
Line range hint
1259-1259
: Replacememset
withmemset_s
to ensure buffer boundaries are respected.- memset(&uri, 0, sizeof(oc_string_t)); + memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));Using
memset_s
helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.
Line range hint
1356-1356
: Replacememset
withmemset_s
to ensure buffer boundaries are respected.- memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result));Using
memset_s
helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.api/oc_ri.c (1)
Line range hint
773-773
: Replacememset
withmemset_s
to enhance security.- memset(aux_arr, 0, sizeof(aux_arr)); + memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr)); - memset(&handler, 0, sizeof(oc_request_handler_t)); + memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t)); - memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result)); - memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t)); + memset_s(preparsed_request_obj, sizeof(oc_ri_preparsed_request_obj_t), 0, sizeof(oc_ri_preparsed_request_obj_t)); - memset(&response_buffer, 0, sizeof(response_buffer)); + memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer)); - memset(&response_obj, 0, sizeof(response_obj)); + memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj)); - memset(&request_obj, 0, sizeof(request_obj)); + memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));Consider replacing
memset
withmemset_s
in the specified lines to prevent potential buffer overflow issues and enhance the security of the code.Also applies to: 831-831, 1247-1247, 1697-1697, 1752-1752, 1756-1756, 1760-1760
Use OC_IGNORE response code to ignore resource in batch responses or notifications.
00e7195
to
1005f48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Actionable comments outside the diff hunks (12)
api/oc_server_api.c (3)
Line range hint
74-74
: Consider replacingmemset
withmemset_s
to ensure safe operations that respect buffer boundaries.- memset(&cfg.ports, 0, sizeof(cfg.ports)); + memset_s(&cfg.ports, sizeof(cfg.ports), 0, sizeof(cfg.ports));
Line range hint
341-341
: Consider replacingmemset
withmemset_s
to ensure safe operations that respect buffer boundaries.- memset(&resource->name, 0, sizeof(oc_string_t)); + memset_s(&resource->name, sizeof(oc_string_t), 0, sizeof(oc_string_t));
Line range hint
347-347
: Consider replacingmemset
withmemset_s
to ensure safe operations that respect buffer boundaries.- memset(&resource->types, 0, sizeof(oc_string_array_t)); + memset_s(&resource->types, sizeof(oc_string_array_t), 0, sizeof(oc_string_array_t));api/oc_discovery.c (2)
Line range hint
1259-1259
: Replacememset
withmemset_s
to ensure buffer boundaries are respected.- memset(&uri, 0, sizeof(oc_string_t)); + memset_s(&uri, sizeof(oc_string_t), 0, sizeof(oc_string_t));Using
memset_s
helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.
Line range hint
1356-1356
: Replacememset
withmemset_s
to ensure buffer boundaries are respected.- memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result));Using
memset_s
helps prevent potential buffer overflow issues by ensuring that the size of the buffer is considered during the operation.api/oc_ri.c (7)
Line range hint
773-773
: Replacememset
withmemset_s
to ensure buffer safety.- memset(aux_arr, 0, sizeof(aux_arr)); + memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Line range hint
831-831
: Replacememset
withmemset_s
to ensure buffer safety.- memset(&handler, 0, sizeof(oc_request_handler_t)); + memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Line range hint
1247-1247
: Replacememset
withmemset_s
to ensure buffer safety.- memset(&result, 0, sizeof(result)); + memset_s(&result, sizeof(result), 0, sizeof(result));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Line range hint
1697-1697
: Replacememset
withmemset_s
to ensure buffer safety.- memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t)); + memset_s(preparsed_request_obj, sizeof(oc_ri_preparsed_request_obj_t), 0, sizeof(oc_ri_preparsed_request_obj_t));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Line range hint
1752-1752
: Replacememset
withmemset_s
to ensure buffer safety.- memset(&response_buffer, 0, sizeof(response_buffer)); + memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Line range hint
1756-1756
: Replacememset
withmemset_s
to ensure buffer safety.- memset(&response_obj, 0, sizeof(response_obj)); + memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Line range hint
1760-1760
: Replacememset
withmemset_s
to ensure buffer safety.- memset(&request_obj, 0, sizeof(request_obj)); + memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));This change helps prevent potential buffer overflow issues by ensuring that the buffer boundaries are respected.
Quality Gate passedIssues Measures |
Use OC_IGNORE response code to ignore resource in batch notification.
Summary by CodeRabbit
New Features
Bug Fixes
Tests