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

Fix issues reported by SonarCloud and add tests #617

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

Danielius1922
Copy link
Member

@Danielius1922 Danielius1922 commented Mar 15, 2024

Summary by CodeRabbit

  • New Features
    • Improved access control list functionality with enhanced permission evaluation.
    • Added functions for checking access control permissions based on security settings.
    • Centralized URI definitions for security resources.
  • Refactor
    • Restructured access control logic for better performance and understanding.
    • Introduced new functions for creating and checking security resources.
    • Split ownership functions for improved resource management.
  • Bug Fixes
    • Corrected URI inconsistencies and function calls for stability.
  • Documentation
    • Updated includes for "security/oc_acl_util_internal.h".
    • Added and modified security functions across files.
    • Refactored function structures for readability and maintenance.

Copy link

coderabbitai bot commented Mar 15, 2024

Walkthrough

The recent changes focus on enhancing access control mechanisms in the security components to improve security architecture. These modifications involve restructuring functions related to access control lists (ACLs), permission evaluation, and security state management. Additionally, a new file has been introduced to centralize ACL management and permission evaluation tasks, streamlining the overall security framework.

Changes

File(s) Change Summary
security/oc_acl.c, security/oc_acl_util.c - Restructured access control logic in oc_acl.c.
- Introduced new functionality in oc_acl_util.c for optimized permission evaluation.
- Centralized ACL management and permission evaluation tasks.
security/oc_acl_internal.h, security/oc_acl_util_internal.h - Added internal helpers inclusion and definitions for ACL resources.
- Removed/added functions for resource handling and permission checks.
security/oc_cred.c, security/oc_cred_internal.h - Updated URI definitions and resource creation logic in oc_cred.c.
- Introduced new functions for credential resource URI matching and ownership verification.
security/oc_doxm.c, security/oc_doxm_internal.h - Modified logic for peer verification and added ownership check functions in oc_doxm.c.
- Renamed resource creation function and introduced ownership verification in oc_doxm_internal.h.
security/oc_obt.c, security/oc_obt_otm_cert.c, security/oc_obt_otm_justworks.c, security/oc_obt_otm_randompin.c - Replaced hardcoded URIs with defined constants for various security requests.
- Improved code maintainability by centralizing URI definitions.
security/oc_pstat.c, security/oc_pstat_internal.h - Added headers and functions for enhanced device state management in oc_pstat.c.
- Introduced new functions for pstat resource creation and URI checking in oc_pstat_internal.h.
security/oc_roles.c, security/oc_roles_internal.h - Added a new function for roles resource URI matching and improved role removal comments.
- Introduced a macro for role ownership and enhanced role resource handling.
security/oc_security.c, security/oc_security_internal.h - Split oc_sec_self_own function into resource ownership and self-onboarding functions.
- Introduced oc_sec_own_resources for owning secure resources by UUID.
security/oc_svr.c - Modified resource creation to use specific functions instead of direct population.
- Enhanced security resource handling in oc_svr.c.
security/oc_tls.c, security/oc_tls_internal.h - Added a function for checking if a peer is a doc in oc_tls.c.
- Refactored oc_tls_uses_psk_cred for readability.
- Improved peer connection checks in oc_tls_internal.h.
port/esp32/main/CMakeLists.txt, port/linux/Makefile, port/openthread/Makefile, port/windows/vs2015/IoTivity-lite.vcxproj, port/windows/vs2015/IoTivity-lite.vcxproj.filters, port/android/Makefile, port/arduino/adapter/Makefile - Included oc_acl_util.c in security-related source files for builds with SECURE flag enabled.
- Updated platform-specific build configurations for security module inclusion.
port/unittest/clocktest.cpp - Converted seconds calculation data type to long for precision in clocktest.cpp.

Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a97b531 and 7bd262b.
Files selected for processing (55)
  • api/cloud/oc_cloud_rd.c (2 hunks)
  • api/oc_collection.c (1 hunks)
  • api/oc_core_res.c (6 hunks)
  • api/oc_core_res_internal.h (2 hunks)
  • api/oc_discovery.c (2 hunks)
  • api/oc_discovery_internal.h (1 hunks)
  • api/oc_enums_internal.h (1 hunks)
  • api/oc_etag.c (2 hunks)
  • api/oc_ri.c (1 hunks)
  • api/plgd/plgd_time.c (1 hunks)
  • api/plgd/plgd_time_internal.h (2 hunks)
  • api/unittest/etagtest.cpp (2 hunks)
  • docker/apps/Dockerfile.cloud-server (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug-clang (1 hunks)
  • include/oc_rep.h (1 hunks)
  • messaging/coap/observe.c (1 hunks)
  • port/android/Makefile (1 hunks)
  • port/arduino/adapter/Makefile (1 hunks)
  • port/esp32/main/CMakeLists.txt (1 hunks)
  • port/linux/Makefile (1 hunks)
  • port/openthread/Makefile (1 hunks)
  • port/unittest/clocktest.cpp (1 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj (2 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj.filters (2 hunks)
  • security/oc_acl.c (8 hunks)
  • security/oc_acl_internal.h (3 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/oc_acl_util_internal.h (1 hunks)
  • security/oc_cred.c (3 hunks)
  • security/oc_cred_internal.h (2 hunks)
  • security/oc_doxm.c (2 hunks)
  • security/oc_doxm_internal.h (2 hunks)
  • security/oc_obt.c (15 hunks)
  • security/oc_obt_otm_cert.c (8 hunks)
  • security/oc_obt_otm_justworks.c (8 hunks)
  • security/oc_obt_otm_randompin.c (8 hunks)
  • security/oc_pstat.c (5 hunks)
  • security/oc_pstat_internal.h (5 hunks)
  • security/oc_roles.c (2 hunks)
  • security/oc_roles_internal.h (2 hunks)
  • security/oc_security.c (1 hunks)
  • security/oc_security_internal.h (2 hunks)
  • security/oc_svr.c (1 hunks)
  • security/oc_tls.c (2 hunks)
  • security/oc_tls_internal.h (2 hunks)
  • security/unittest/acltest.cpp (6 hunks)
  • security/unittest/keypairtest.cpp (1 hunks)
  • security/unittest/obt_certstest.cpp (17 hunks)
  • security/unittest/pstattest.cpp (3 hunks)
  • security/unittest/rolestest.cpp (6 hunks)
  • tests/gtest/PKI.cpp (5 hunks)
  • tests/gtest/PKI.h (2 hunks)
  • util/oc_atomic.h (2 hunks)
  • util/unittest/memblocktest.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (37)
  • api/oc_core_res_internal.h
  • api/oc_discovery_internal.h
  • api/oc_enums_internal.h
  • api/plgd/plgd_time_internal.h
  • api/unittest/etagtest.cpp
  • docker/apps/Dockerfile.cloud-server
  • docker/apps/Dockerfile.cloud-server-debug
  • docker/apps/Dockerfile.cloud-server-debug-clang
  • include/oc_rep.h
  • port/android/Makefile
  • port/arduino/adapter/Makefile
  • port/esp32/main/CMakeLists.txt
  • port/linux/Makefile
  • port/openthread/Makefile
  • port/unittest/clocktest.cpp
  • port/windows/vs2015/IoTivity-lite.vcxproj
  • port/windows/vs2015/IoTivity-lite.vcxproj.filters
  • security/oc_acl_util_internal.h
  • security/oc_cred_internal.h
  • security/oc_doxm_internal.h
  • security/oc_obt_otm_cert.c
  • security/oc_obt_otm_justworks.c
  • security/oc_obt_otm_randompin.c
  • security/oc_roles.c
  • security/oc_roles_internal.h
  • security/oc_security.c
  • security/oc_security_internal.h
  • security/oc_svr.c
  • security/oc_tls_internal.h
  • security/unittest/keypairtest.cpp
  • security/unittest/obt_certstest.cpp
  • security/unittest/pstattest.cpp
  • security/unittest/rolestest.cpp
  • tests/gtest/PKI.cpp
  • tests/gtest/PKI.h
  • util/oc_atomic.h
  • util/unittest/memblocktest.cpp
Additional Context Used
AST-based Instructions (70)
api/cloud/oc_cloud_rd.c (1)

[warning] 267-267: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&partition, 0, sizeof(rd_links_partition_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_collection.c (4)

[warning] 818-818: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(oc_response_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 820-820: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 822-822: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&rest_request, 0, sizeof(oc_request_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 850-850: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&link_item, 0, sizeof(link_item));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_core_res.c (5)

[warning] 109-109: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(g_core_resources, 0, sizeof(g_core_resources));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 110-110: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(g_oc_device_info, 0, sizeof(g_oc_device_info));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 286-287: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(device, 0,
OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 296-296: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&device_info[device_count], 0, sizeof(oc_device_info_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 431-431: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&r->types, 0, sizeof(oc_string_array_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_discovery.c (5)

[warning] 728-728: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&rest_request, 0, sizeof(oc_request_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 730-730: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(oc_response_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 732-732: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1232-1232: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&uri, 0, sizeof(oc_string_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1329-1329: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&result, 0, sizeof(result));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_etag.c (6)

[warning] 248-248: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&etag_map, 0, sizeof(etag_map));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 524-524: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&request, 0, sizeof(request));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 526-526: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 571-571: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 589-589: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&result, 0, sizeof(result));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 644-644: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/oc_ri.c (7)

[warning] 772-772: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(aux_arr, 0, sizeof(aux_arr));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 830-830: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&handler, 0, sizeof(oc_request_handler_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1246-1246: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&result, 0, sizeof(result));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1686-1686: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(preparsed_request_obj, 0, sizeof(oc_ri_preparsed_request_obj_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1741-1741: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1745-1745: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_obj, 0, sizeof(response_obj));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1749-1749: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&request_obj, 0, sizeof(request_obj));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

api/plgd/plgd_time.c (2)

[warning] 518-518: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&pt, 0, sizeof(pt));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 540-540: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&pt, 0, sizeof(pt));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

messaging/coap/observe.c (16)

[warning] 807-807: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 845-845: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&request, 0, sizeof(request));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 847-847: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 849-849: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 923-923: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&request, 0, sizeof(request));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 925-925: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 927-927: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 998-998: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&request, 0, sizeof(request));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1144-1144: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1162-1162: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1199-1199: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1201-1201: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1363-1363: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1397-1397: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1548-1548: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response, 0, sizeof(response));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1550-1550: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&response_buffer, 0, sizeof(response_buffer));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_acl.c (4)

[warning] 582-582: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&subject, 0, sizeof(oc_ace_subject_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 600-600: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&g_aclist[device].rowneruuid, 0, sizeof(oc_uuid_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 649-649: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&subject, 0, sizeof(oc_ace_subject_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 848-848: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&_anon_clear, 0, sizeof(oc_ace_subject_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_acl_util.c (3)

[warning] 339-339: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&_auth_crypt, 0, sizeof(oc_ace_subject_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 357-357: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&_anon_clear, 0, sizeof(oc_ace_subject_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 388-388: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&subject, 0, sizeof(oc_ace_subject_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_cred.c (4)

[warning] 271-271: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&uuid, 0, sizeof(oc_uuid_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 301-301: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(g_devices[device].rowneruuid.id, 0, OC_UUID_ID_SIZE);
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 648-648: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&public_key, 0, sizeof(oc_string_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 668-668: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&subject, 0, sizeof(oc_uuid_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_doxm.c (3)

[warning] 256-256: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(doxm->devowneruuid.id, 0, sizeof(doxm->devowneruuid.id));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 257-257: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(doxm->rowneruuid.id, 0, sizeof(doxm->rowneruuid.id));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 690-690: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&decode, 0, sizeof(oc_doxm_decode_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_obt.c (2)

[warning] 573-573: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&di, 0, sizeof(oc_uuid_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1425-1425: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&subjectuuid, 0, sizeof(oc_uuid_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_pstat.c (3)

[warning] 76-76: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(g_pstat, 0, sizeof(g_pstat));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 291-291: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(ps->rowneruuid.id, 0, sizeof(ps->rowneruuid.id));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 494-494: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(ps, 0, sizeof(*ps));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/

security/oc_tls.c (5)

[warning] 1325-1325: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&crt, 0, sizeof(mbedtls_x509_crt));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1837-1837: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&wildcard_sub, 0, sizeof(oc_uuid_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 2018-2018: Avoid 'memset()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'memset_s()' instead.
Context: memset(&peer->timer, 0, sizeof(oc_tls_retry_timer_t));
Note: [CWE-14]: Compiler Removal of Code to Clear Buffers [OWASP A04:2021] Insecure Design [REFERENCES]
- https://cwe.mitre.org/data/definitions/14.html
- https://owasp.org/Top10/A02_2021-Cryptographic_Failures/


[warning] 1437-1437: Avoid 'strcpy()' or 'strncpy()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'strcpy_s()' instead.
Context: strncpy(credid_str, "any", sizeof(credid_str));
Note: [CWE-676]: Use of Potentially Dangerous Function [REFERENCES]
- https://cwe.mitre.org/data/definitions/676
- https://nvd.nist.gov/vuln/detail/CVE-2019-11365


[warning] 1453-1453: Avoid 'strcpy()' or 'strncpy()' function, it does not consider buffer boundaries and can lead to buffer overflows. Use 'strcpy_s()' instead.
Context: strncpy(credid_str, "any", sizeof(credid_str));
Note: [CWE-676]: Use of Potentially Dangerous Function [REFERENCES]
- https://cwe.mitre.org/data/definitions/676
- https://nvd.nist.gov/vuln/detail/CVE-2019-11365

Additional comments not posted (51)
security/oc_acl_internal.h (6)

22-29: Added multiple includes for internal helpers and other related functionalities. Ensure these headers are necessary to avoid unnecessary dependencies.


37-38: Added definitions for OCF_SEC_ACL_URI and OCF_SEC_ACL_RT. Confirm that these constants are used consistently across the project to avoid magic strings.


75-78: Added a new function oc_sec_ace_find_resource. Ensure that this function is thoroughly tested, especially since it involves resource matching which is critical for security.


85-86: Introduced oc_sec_acl_create_resource function. It's important to validate that this function handles all edge cases, particularly in error scenarios where resource creation might fail.


89-89: Added oc_sec_is_acl_resource_uri function. This function should be robust against various forms of URIs, including those with or without trailing slashes.


92-92: Introduced oc_sec_acl_is_owned_by function. It's crucial to ensure that ownership checks are secure and do not allow any bypasses or misinterpretations of UUIDs.

security/oc_pstat_internal.h (7)

22-22: Included headers for internal helpers and other functionalities. Verify that these are essential for the functionality of the updated code to maintain minimal coupling.


33-34: Definitions for OCF_SEC_PSTAT_URI and OCF_SEC_PSTAT_RT added. Ensure these constants are utilized consistently throughout the codebase.


36-36: Introduced oc_sec_pstat_create_resource function. Confirm that resource creation is handled safely and errors are managed appropriately.


39-41: Added oc_sec_is_pstat_resource_uri function. This function should robustly handle different URI formats and edge cases.


43-44: Introduced oc_sec_pstat_is_owned_by function. It is critical to ensure that the ownership verification is secure and correctly interprets UUIDs.


117-129: The function oc_sec_pstat_is_in_dos_state checks if the onboarding state property is in one of the DOS states. Ensure thread safety when accessing shared state, possibly through atomic operations or mutexes.


139-139: Ensure thread safety when accessing device states, possibly through atomic operations or mutexes.

api/cloud/oc_cloud_rd.c (2)

163-164: Replaced oc_sec_pstat_is_in_dos_state with oc_device_is_in_dos_state to check the device state. Verify that the new function covers all scenarios previously handled by the old function to maintain functional parity.


256-257: Similar to the previous comment, ensure that the replacement of the function does not omit any conditions that were previously checked.

api/oc_etag.c (2)

215-215: Replace direct URI comparison with a function call to enhance modularity.


443-443: Replace direct device state checking with a function call to enhance modularity.

security/oc_pstat.c (4)

22-25: Addition of headers oc_helpers_internal.h and oc_resource_internal.h is appropriate for the functionalities used in this file.


451-454: The function oc_sec_pstat_is_in_dos_state correctly checks the device operational state against a mask. This is a good use of bitmasking for state checks.


457-459: The function oc_device_is_in_dos_state is a good abstraction that enhances modularity by delegating the state check to oc_sec_pstat_is_in_dos_state.


811-817: The function oc_sec_pstat_create_resource correctly sets up a resource for the pstat endpoint. It properly configures the resource with the right properties and handlers.

api/oc_core_res.c (1)

90-94: Introduce new function oc_is_device_resource_uri to encapsulate URI checks.

This change improves readability and maintainability by centralizing URI checks into a single function, making the codebase cleaner and more modular.

api/plgd/plgd_time.c (1)

613-617: The implementation of plgd_is_time_resource_uri correctly checks if the given URI matches the time resource URI using oc_resource_match_uri. This is a straightforward and effective use of existing functionality.

api/oc_collection.c (1)

43-43: Added include directive for "security/oc_acl_util_internal.h".

Ensure that the new functions or data structures provided by this header are properly utilized in the file, if applicable.

security/unittest/acltest.cpp (8)

22-22: Consider organizing includes to separate standard libraries, project-specific libraries, and testing frameworks for better readability.


31-31: The inclusion of oc_acl_util_internal.h suggests new utility functions for ACL management. Ensure that these utilities are covered by unit tests to maintain robustness.


79-86: Initialization in SetUpTestCase includes critical operations like random initialization and conditional PKI setup. Ensure that these operations are paired with corresponding teardown steps to prevent resource leaks or state persistence between tests.


183-186: The test oc_sec_acl_add_bootstrap_acl checks the ACL addition but does not verify the cleanup or removal of the ACL entries. Adding such checks can prevent potential leaks or unintended access permissions persisting after tests.


191-212: Complex ACL update operations are performed here. It's crucial to ensure that these updates do not interfere with other tests by properly isolating them or cleaning up thoroughly in the teardown phase.


269-275: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [272-301]

This test case modifies the device state and checks ACL behaviors in different states. It's important to reset the device state after the test to avoid side effects on subsequent tests.


305-324: The test oc_sec_check_acl_FailInsecureDOC is critical for security. Ensure that all edge cases are considered, such as different endpoint configurations and error states.


848-916: The test oc_sec_check_acl_AccessToNonSVRByCryptConn manipulates ACL permissions dynamically. It's essential to verify that these changes are reverted at the end of the test to maintain test environment integrity.

api/oc_discovery.c (1)

1270-1274: LGTM! The function oc_is_wkcore_resource_uri correctly utilizes oc_resource_match_uri to check if the URI matches the well-known core URI.

security/oc_cred.c (5)

23-23: Added inclusion of "api/oc_resource_internal.h" is appropriate for the functionalities used in this file.


66-67: Using OCF_SEC_ROLE_OWNER constant for initializing g_allowed_roles enhances maintainability and reduces typo errors.


1592-1594: Ensure the updated URI for OCF_SEC_CRED resource creation is correctly implemented as per the project's URI design guidelines.

Verification successful

---



---


The URI for the OCF_SEC_CRED resource is correctly implemented as "/oic/sec/cred" in accordance with the project's URI design guidelines. The implementation is found in security/oc_cred_internal.h.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the updated URI in the resource creation function
ast-grep --lang c --pattern $'oc_core_populate_resource($$$, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_, $_)'

Length of output: 106



Script:

#!/bin/bash
# Search broadly for any function related to resource creation to verify the presence of `oc_core_populate_resource` or similar functions
rg --files-with-matches 'oc_core_populate_resource' | xargs cat

Length of output: 341579



Script:

#!/bin/bash
# Search for the function `oc_sec_cred_create_resource` to verify the updated URI
grep -r "oc_sec_cred_create_resource" .

Length of output: 238



Script:

#!/bin/bash
# Extract the implementation of `oc_sec_cred_create_resource` from `security/oc_cred.c`
cat ./security/oc_cred.c | grep -A 20 "oc_sec_cred_create_resource(size_t device)"

Length of output: 681



Script:

#!/bin/bash
# Search for the definition of the constant `OCF_SEC_CRED_URI`
grep -r "OCF_SEC_CRED_URI" .

Length of output: 1586


1597-1601: The implementation of oc_sec_is_cred_resource_uri correctly uses oc_resource_match_uri for URI matching, adhering to standard practices.


1603-1607: The function oc_sec_cred_is_owned_by correctly retrieves and compares UUIDs to check ownership, using established utility functions.

messaging/coap/observe.c (1)

79-79: Ensure that the newly included header file security/oc_acl_util_internal.h is properly utilized within the file.

This inclusion should align with the security enhancements mentioned in the PR objectives. Verify that the functions or definitions from this header are indeed used and necessary for the observe functionality.

api/oc_ri.c (1)

86-86: Ensure the new include directive is necessary and correctly placed.

The addition of #include "security/oc_acl_util_internal.h" should be validated to ensure that it is necessary for the functionalities used in this file. Check if the functions or types from this header are used within api/oc_ri.c.

security/oc_tls.c (2)

2730-2735: Refactor to use a switch statement for clarity and maintainability.


564-569: Add error handling for oc_tls_get_peer.

security/oc_obt.c (9)

874-874: The POST initialization and error handling are correctly implemented.


1072-1072: The POST initialization for OSCORE credentials is correctly implemented.


1143-1143: The POST initialization for OSCORE credentials is correctly implemented.


1558-1558: The POST initialization for credential provisioning is correctly implemented.


1610-1610: The POST initialization for credential provisioning is correctly implemented.


2057-2057: The POST initialization for trust anchor provisioning is correctly implemented.


2280-2280: The POST initialization for group OSCORE context provisioning is correctly implemented.


3102-3102: The DELETE initialization for credential deletion is correctly implemented.


3434-3434: The DELETE initialization for ACE deletion is correctly implemented.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ocf-conformance-test-tool
Copy link

🎉 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 (f57a3fe), label this PR with OCF Conformance Testing.

⚠️ Label is removed with every code change.

@Danielius1922
Copy link
Member Author

@coderabbitai create unit tests for util/oc_memb.c from this branch

Copy link

coderabbitai bot commented Mar 15, 2024

Tip

For best results, initiate chat on the files or code changes.

@Danielius1922, based on the content of util/oc_memb.c, here's a high-level outline for creating unit tests for this file. The file primarily consists of memory management functions for a custom memory block allocator. Key functions include oc_memb_init, _oc_memb_alloc, _oc_memb_free, oc_memb_inmemb, oc_memb_numfree, and oc_memb_set_buffers_avail_cb.

Unit Test Outline

  1. oc_memb_init

    • Test initializing a memory block structure with various num values (including 0) and verify that count and mem arrays are zero-initialized.
  2. _oc_memb_alloc

    • Test allocation from an initialized memory block structure with sufficient space.
    • Test allocation behavior when no blocks are available.
    • Test allocation with OC_DYNAMIC_ALLOCATION defined and undefined.
    • Verify that memory is zero-initialized upon allocation.
    • (If applicable) Test behavior with OC_MEMORY_TRACE defined.
  3. _oc_memb_free

    • Test freeing a previously allocated block and verify that it can be reallocated.
    • Test freeing a block not belonging to the memory block structure.
    • Test double-free prevention.
    • (If applicable) Test behavior with OC_MEMORY_TRACE defined.
  4. oc_memb_inmemb

    • Test with a pointer inside the memory block range.
    • Test with a pointer outside the memory block range.
  5. oc_memb_numfree

    • Test with various numbers of allocated and freed blocks to verify the correct count of free blocks.
  6. oc_memb_set_buffers_avail_cb

    • Test setting a callback and verify it's called appropriately during _oc_memb_free.

Additional Considerations

  • Mocking external dependencies, if any, to isolate tests.
  • Utilizing a testing framework consistent with the project's existing tests (e.g., CMocka, Unity).
  • Ensuring tests cover edge cases, such as boundary values and error conditions.

Given the complexity of writing unit tests and the need for a deep understanding of the project's testing conventions and setup, I recommend reviewing the project's documentation on testing, looking at existing tests for examples, and possibly consulting with the project maintainers or contributors for guidance on writing consistent and comprehensive tests.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Find and display the content of `util/oc_memb.c`
fd oc_memb.c util/ --exec cat {}

Length of output: 4588

@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from f57a3fe to e6a1160 Compare March 15, 2024 11:05
@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from e6a1160 to 3aa722b Compare March 15, 2024 11:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7a89f4c and 3aa722b.
Files selected for processing (9)
  • api/unittest/etagtest.cpp (2 hunks)
  • docker/apps/Dockerfile.cloud-server (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug-clang (1 hunks)
  • include/oc_rep.h (1 hunks)
  • port/unittest/clocktest.cpp (1 hunks)
  • security/unittest/keypairtest.cpp (1 hunks)
  • util/oc_atomic.h (2 hunks)
  • util/unittest/memblocktest.cpp (1 hunks)
Files skipped from review due to trivial changes (1)
  • docker/apps/Dockerfile.cloud-server-debug
Additional comments: 17
docker/apps/Dockerfile.cloud-server (2)
  • 1-1: Using a specific version of Alpine (3.19) instead of the latest version can ensure more predictable and stable builds by avoiding unexpected changes in the base image. However, it's important to periodically review and update this to benefit from security patches and new features.
  • 14-14: Adding comments to clarify the purpose of specific installations or configurations, such as enabling struct stat64, is a good practice for maintainability. It helps future developers understand the rationale behind certain decisions.
docker/apps/Dockerfile.cloud-server-debug-clang (2)
  • 6-7: Cleaning up packages after installation with apt-get clean is a good practice to reduce the image size. This step removes the package cache, which is not needed in the final image.
  • 9-11: Installing clang-15 and setting it as the default compiler using update-alternatives is a clear and effective way to ensure that the desired compiler version is used. This approach also makes it easier to update or change the compiler in the future if needed.
util/unittest/memblocktest.cpp (6)
  • 34-43: The test case Init correctly initializes a memory block and verifies its size and number of blocks based on the OC_DYNAMIC_ALLOCATION flag. This is a good practice to ensure that the initialization logic works as expected under different configurations.
  • 46-49: The test case Alloc_Fail properly handles the scenario where allocation should fail, i.e., when a null pointer is passed. This test ensures that the function behaves correctly in error conditions.
  • 65-68: The test case Dealloc_Fail correctly tests the scenario where deallocation should fail, i.e., when null pointers are passed. This ensures that the function behaves correctly in error conditions.
  • 70-90: The test case AllocExceedsLimit effectively tests the behavior of the allocation function when the limit of allocations is reached. It also correctly handles the difference in behavior based on the OC_DYNAMIC_ALLOCATION flag. This test ensures that the memory block management system correctly enforces limits on allocations.
  • 94-105: The test case Realloc is conditionally compiled for non-dynamic allocation scenarios and tests that a block can be reallocated after being freed. This ensures that the memory management system correctly handles block reuse. It's a good practice to include such conditionally compiled tests to cover different build configurations.
  • 107-122: The test case InBlock correctly verifies whether allocated blocks belong to specific memory blocks. This test is crucial for ensuring the integrity of the memory block management system, especially when multiple memory blocks are in use.
port/unittest/clocktest.cpp (1)
  • 72-72: Converting the seconds variable to a long type is a prudent change that ensures the variable can hold larger values, which might be necessary for certain platforms or scenarios. This change improves the robustness of the test.
util/oc_atomic.h (2)
  • 41-44: Converting macro definitions to typedefs for atomic integer types (OC_ATOMIC_INT8_T, OC_ATOMIC_UINT8_T, OC_ATOMIC_INT32_T, OC_ATOMIC_UINT32_T) enhances clarity and type safety. This is a positive change that makes the code more readable and maintainable.
  • 83-86: Repeating the conversion of macro definitions to typedefs for atomic integer types in the Windows-specific section of the code ensures consistency across different platforms. This is a good practice that maintains clarity and type safety across the codebase.
security/unittest/keypairtest.cpp (1)
  • 279-290: The modifications to the assertions within the generate_keypair lambda function, specifically adjusting the EXPECT_EQ and EXPECT_TRUE assertions, appear to streamline the test code and focus on the essential aspects of keypair generation and validation. Ensuring that the number of keypairs before and after the operation matches expected values is crucial for the integrity of the test.
api/unittest/etagtest.cpp (2)
  • 597-599: The simplification of the return statement in isETagStorageEmpty function looks good and should maintain the original functionality. It's a good practice to simplify code for readability and maintainability.
  • 687-687: Changing the parameter type to std::string_view in isPlatformResourceURI function is a good optimization to avoid unnecessary string copies. Just ensure that the lifetime of the passed string always exceeds the std::string_view to prevent dangling references.
include/oc_rep.h (1)
  • 1192-1200: The introduction of the typedef union oc_rep_value_t for the value field in the oc_rep_value struct is a positive change for readability and maintainability. Ensure that all parts of the project that interact with this struct are updated to use the new oc_rep_value_t type.
Verification successful

The examination of the occurrences of "oc_rep_value" in the project files indicates that the references are related to oc_rep_value_type_t, not direct uses of the old oc_rep_value union structure. This suggests that the project has been updated to use the new oc_rep_value_t typedef union as intended. The initial review comment is thus validated by the absence of direct references to the old union structure, indicating that the changes have been correctly propagated throughout the project.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for direct usage of the old `oc_rep_value` union to ensure they are updated.
rg --type c "oc_rep_value" --files-with-matches

Length of output: 144



Script:

#!/bin/bash
# Examine the occurrences of "oc_rep_value" in the listed files to understand their context.
for file in include/oc_rep.h api/oc_rep.c api/oc_rep_internal.h api/oc_rep_decode_json.c api/oc_rep_decode.c; do
    echo "Occurrences in $file:"
    rg "oc_rep_value" "$file"
    echo "-----"
done

Length of output: 2333

util/unittest/memblocktest.cpp Show resolved Hide resolved
@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from 3aa722b to b2470e9 Compare March 15, 2024 12:02
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7a89f4c and b2470e9.
Files selected for processing (25)
  • api/oc_collection.c (1 hunks)
  • api/oc_discovery.c (1 hunks)
  • api/oc_ri.c (1 hunks)
  • api/unittest/etagtest.cpp (2 hunks)
  • docker/apps/Dockerfile.cloud-server (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug-clang (1 hunks)
  • include/oc_rep.h (1 hunks)
  • messaging/coap/observe.c (1 hunks)
  • port/android/Makefile (1 hunks)
  • port/arduino/adapter/Makefile (1 hunks)
  • port/esp32/main/CMakeLists.txt (1 hunks)
  • port/linux/Makefile (1 hunks)
  • port/openthread/Makefile (1 hunks)
  • port/unittest/clocktest.cpp (1 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj (2 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj.filters (2 hunks)
  • security/oc_acl.c (2 hunks)
  • security/oc_acl_internal.h (2 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/oc_acl_util_internal.h (1 hunks)
  • security/unittest/acltest.cpp (1 hunks)
  • security/unittest/keypairtest.cpp (1 hunks)
  • util/oc_atomic.h (2 hunks)
  • util/unittest/memblocktest.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (9)
  • api/unittest/etagtest.cpp
  • docker/apps/Dockerfile.cloud-server
  • docker/apps/Dockerfile.cloud-server-debug
  • docker/apps/Dockerfile.cloud-server-debug-clang
  • include/oc_rep.h
  • port/unittest/clocktest.cpp
  • security/unittest/keypairtest.cpp
  • util/oc_atomic.h
  • util/unittest/memblocktest.cpp
Additional comments: 21
security/oc_acl_util_internal.h (1)
  • 32-33: The addition of the oc_sec_check_acl function declaration enhances ACL handling by providing a mechanism to check access permissions for a given method, resource, and endpoint. This is a positive change towards improving security.
port/openthread/Makefile (1)
  • 60-60: The inclusion of oc_acl_util.c in the SRC_COMMON list when the SECURE flag is enabled is a logical step towards enhancing security features. This ensures that ACL utility functionalities are available for security-related operations.
security/oc_acl_internal.h (1)
  • 74-77: The addition of the oc_sec_ace_find_resource function enhances ACL handling by providing a targeted mechanism to find resources within an ACE. This is a positive change towards improving security and resource management.
port/arduino/adapter/Makefile (1)
  • 42-42: The inclusion of oc_acl_util.c in the security sources list when the SECURE flag is enabled is a logical step towards enhancing security features. This ensures that ACL utility functionalities are available for security-related operations.
security/unittest/acltest.cpp (1)
  • 30-30: The inclusion of security/oc_acl_util_internal.h in the unit tests is a positive step towards enhancing testing coverage for ACL-related functionalities. This aligns with the PR's objectives of improving security and robustness.
port/esp32/main/CMakeLists.txt (1)
  • 188-188: The inclusion of oc_acl_util.c in the sources list when CONFIG_SECURE is enabled is a logical step towards enhancing security features. This ensures that ACL utility functionalities are available for security-related operations.
port/android/Makefile (1)
  • 272-272: The addition of oc_acl_util.c to the security-related source files in the Makefile is noted and appears correctly implemented. Ensure that oc_acl_util.c exists and contains no errors to prevent build issues.
security/oc_acl_util.c (1)
  • 1-492: The new file oc_acl_util.c introduces several functions for ACL management and checking. It's well-structured and follows the project's coding standards. However, ensure thorough testing, especially for the new logic introduced in functions like oc_sec_check_acl, to validate their correctness and robustness in various scenarios.
security/oc_acl.c (1)
  • 109-109: The function oc_sec_ace_find_resource has been modified or added. It's crucial to ensure that the logic for finding a resource within an ACE (Access Control Entry) correctly handles the href and wildcard parameters. This function appears to perform a detailed comparison, including handling cases where the href might not start with a / character and wildcard permissions. Ensure that all edge cases are covered, especially with wildcard permissions and partial matches of href.
port/windows/vs2015/IoTivity-lite.vcxproj (2)
  • 275-275: The inclusion of oc_acl_util_internal.h in the project file ensures that the security-related functionality is accessible during the build process. This is a positive change, enhancing the project's security capabilities.
  • 456-456: The addition of oc_acl_util.c to the compilation sources is crucial for implementing the security functionalities defined in the corresponding header file. This change is necessary for the completeness and functionality of the security features.
port/windows/vs2015/IoTivity-lite.vcxproj.filters (2)
  • 362-364: The addition of oc_acl_util.c to the Security filter is appropriate, as it aligns with the project's organizational structure, grouping related security functionalities together.
  • 730-732: Similarly, the inclusion of oc_acl_util_internal.h in the Security filter is consistent with the project's approach to organizing internal headers related to security features.
port/linux/Makefile (1)
  • 294-294: The addition of oc_acl_util.c to the list of security-related source files when the SECURE flag is enabled appears correct. Ensure that oc_acl_util.c integrates well with the existing security features and does not introduce any build issues or unhandled dependencies.
api/oc_collection.c (1)
  • 43-43: The addition of the include directive for "security/oc_acl_util_internal.h" within the #ifdef OC_SECURITY block seems appropriate, assuming there's a direct or indirect dependency on this header when the security feature is enabled. Ensure that the contents of this header are indeed utilized within this file or through included headers to justify its inclusion.
api/oc_discovery.c (4)
  • 51-51: The inclusion of "security/oc_acl_util_internal.h" suggests a dependency on ACL utilities within the discovery component. Please verify the necessity of this include directive, ensuring it's used within the file or indirectly influences the functionality in a manner not visible in the provided context.
  • 48-54: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1250]

Consider reviewing the discovery process for potential optimizations, particularly in reducing iterations over endpoints and resources, to improve response times and overall performance.

  • 48-54: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1250]

To enhance maintainability and readability, consider modularizing larger functions and further separating concerns within the code. This approach could simplify future modifications and improve the overall structure.

  • 48-54: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-1250]

Improving documentation and commenting, especially for complex sections of the code, could enhance understanding and adherence to best practices. Consider adding more detailed comments explaining the logic and decisions behind critical sections.

messaging/coap/observe.c (1)
  • 79-79: The inclusion of "security/oc_acl_util_internal.h" suggests enhancements or checks related to ACLs within the observe functionality. Ensure that the functions or definitions provided by this header are indeed utilized within this file to justify its inclusion.
api/oc_ri.c (1)
  • 86-86: Including "security/oc_acl_util_internal.h" is noted. Ensure that functions or definitions from this header are indeed utilized within api/oc_ri.c. Unnecessary includes should be avoided to keep the codebase clean and maintainable.

@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from b2470e9 to 1f4df38 Compare March 15, 2024 12:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7a89f4c and 1f4df38.
Files selected for processing (25)
  • api/oc_collection.c (1 hunks)
  • api/oc_discovery.c (1 hunks)
  • api/oc_ri.c (1 hunks)
  • api/unittest/etagtest.cpp (2 hunks)
  • docker/apps/Dockerfile.cloud-server (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug-clang (1 hunks)
  • include/oc_rep.h (1 hunks)
  • messaging/coap/observe.c (1 hunks)
  • port/android/Makefile (1 hunks)
  • port/arduino/adapter/Makefile (1 hunks)
  • port/esp32/main/CMakeLists.txt (1 hunks)
  • port/linux/Makefile (1 hunks)
  • port/openthread/Makefile (1 hunks)
  • port/unittest/clocktest.cpp (1 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj (2 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj.filters (2 hunks)
  • security/oc_acl.c (2 hunks)
  • security/oc_acl_internal.h (2 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/oc_acl_util_internal.h (1 hunks)
  • security/unittest/acltest.cpp (1 hunks)
  • security/unittest/keypairtest.cpp (1 hunks)
  • util/oc_atomic.h (2 hunks)
  • util/unittest/memblocktest.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (24)
  • api/oc_collection.c
  • api/oc_discovery.c
  • api/oc_ri.c
  • api/unittest/etagtest.cpp
  • docker/apps/Dockerfile.cloud-server
  • docker/apps/Dockerfile.cloud-server-debug
  • docker/apps/Dockerfile.cloud-server-debug-clang
  • include/oc_rep.h
  • messaging/coap/observe.c
  • port/android/Makefile
  • port/arduino/adapter/Makefile
  • port/esp32/main/CMakeLists.txt
  • port/linux/Makefile
  • port/openthread/Makefile
  • port/unittest/clocktest.cpp
  • port/windows/vs2015/IoTivity-lite.vcxproj
  • port/windows/vs2015/IoTivity-lite.vcxproj.filters
  • security/oc_acl_internal.h
  • security/oc_acl_util.c
  • security/oc_acl_util_internal.h
  • security/unittest/acltest.cpp
  • security/unittest/keypairtest.cpp
  • util/oc_atomic.h
  • util/unittest/memblocktest.cpp

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1f4df38 and d08f024.
Files selected for processing (3)
  • security/oc_acl.c (3 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/unittest/acltest.cpp (10 hunks)
Files skipped from review as they are similar to previous changes (2)
  • security/oc_acl.c
  • security/oc_acl_util.c
Additional comments: 13
security/unittest/acltest.cpp (13)
  • 30-36: The addition of include directives for internal and test-related headers enhances the test file's capability to perform more comprehensive tests by providing access to necessary internal functionalities and mock objects. This change aligns with the PR's objective to enhance project reliability through unit testing.
  • 63-68: The initialization in the SetUp method has been expanded to include the creation of security servers with oc_sec_svr_create(). This is a crucial step for setting up a proper testing environment for ACL tests, ensuring that the security components are initialized correctly before each test case runs. It's important to ensure that all resources initialized here are properly cleaned up in the TearDown method to prevent resource leaks.
  • 74-80: The cleanup in the TearDown method now includes oc_sec_svr_free() and oc_connectivity_shutdown(kDeviceID), which are essential for releasing resources allocated during the test setup. This ensures that each test case starts with a clean state and that there are no resource leaks. It's good practice to mirror the initialization steps in SetUp with corresponding cleanup steps in TearDown.
  • 131-170: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [102-180]

The test cases added for ACL functionalities, such as adding bootstrap ACLs, clearing ACLs, and verifying ACL checks under various conditions, significantly contribute to the project's testing framework. These tests cover crucial aspects of ACL management and validation, aligning with the PR's objective to enhance code reliability through thorough testing. It's important to ensure that these tests cover a wide range of scenarios, including edge cases, to fully validate the ACL functionalities.

  • 196-202: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [199-215]

The test case oc_sec_check_acl_in_RFOTM effectively tests ACL checks in the RFOTM (Request For Ownership Transfer Mode) state, covering scenarios with different permissions and resource access settings. This test case is particularly important for validating security behavior during the ownership transfer process. It's commendable that the test covers both positive and negative scenarios, ensuring a comprehensive validation of ACL checks in RFOTM.

  • 232-251: The test case oc_sec_check_acl_FailInsecureDOC is designed to verify that ACL checks fail for insecure Device Onboarding Client (DOC) connections in the RFOTM state. This test ensures that only secure connections are allowed for sensitive operations, aligning with security best practices. It's crucial to validate the setup and teardown of TLS peers within the test to ensure that the test environment accurately reflects the intended security conditions.
  • 255-268: The test case oc_sec_check_acl_AccessInRFOTM validates ACL checks for resources in the RFOTM state, focusing on the impact of the SetAccessInRFOTM function. This test case contributes to the thorough testing of ACL behavior in different device states, which is essential for ensuring the security and reliability of the system. It's important to cover various combinations of permissions to fully assess the ACL checks' behavior in RFOTM.
  • 272-289: The test case oc_sec_check_acl_FailNCRInNonRFNOP checks that Non-Configurable Resources (NCRs) cannot be accessed in non-RFNOP (Ready For Normal Operation) states. This test is crucial for validating the system's behavior in ensuring that sensitive resources are protected in states that are not ready for normal operation. It's important to test this behavior across all relevant device states to ensure comprehensive coverage.
  • 291-303: The test case oc_sec_check_acl_FailInsecureAccessToVerticalResource ensures that insecure access to vertical resources is correctly blocked in the RFNOP state. This test aligns with the objective of securing vertical resources by enforcing strict access controls. It's essential to validate that the test accurately identifies vertical resources and applies the correct ACL checks.
  • 305-328: The test case oc_sec_check_acl_DOCAccessToDCR validates that Device Onboarding Client (DOC) access to Device Configuration Resources (DCRs) is correctly handled in the RFOTM state. This test is important for ensuring that the system correctly manages access controls during the device onboarding process. It's crucial to ensure that the test setup accurately reflects the security conditions expected during DOC access to DCRs.
  • 330-345: The test case oc_sec_check_acl_GETinRFOTM verifies that core resources are accessible via GET requests in the RFOTM state. This test is essential for ensuring that the system behaves as expected during the ownership transfer process, allowing access to necessary resources. It's important to cover all core resources to ensure comprehensive testing of ACL checks in RFOTM.
  • 347-361: The test case oc_sec_check_acl_PriorToDOCAccessToDoxmInRFOTM ensures that access to the doxm resource is correctly handled prior to DOC access in the RFOTM state. This test is crucial for validating the system's behavior in managing access controls during sensitive stages of the device lifecycle. It's important to test various methods to fully assess access controls for the doxm resource.
  • 363-377: The test case oc_sec_check_acl_PriorToDOCGetAccessToPstatInRFOTM focuses on validating GET access to the pstat resource prior to DOC access in the RFOTM state. This test is important for ensuring that the system correctly manages access controls for critical resources during the device onboarding process. It's commendable that the test specifically targets GET access while also checking that other methods are correctly blocked.

@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from d08f024 to ff8b0d1 Compare March 15, 2024 15:59
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1f4df38 and ff8b0d1.
Files selected for processing (3)
  • security/oc_acl.c (3 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/unittest/acltest.cpp (10 hunks)
Files skipped from review as they are similar to previous changes (3)
  • security/oc_acl.c
  • security/oc_acl_util.c
  • security/unittest/acltest.cpp

@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from ff8b0d1 to e98425f Compare March 15, 2024 17:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1f4df38 and e98425f.
Files selected for processing (3)
  • security/oc_acl.c (3 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/unittest/acltest.cpp (10 hunks)
Files skipped from review as they are similar to previous changes (3)
  • security/oc_acl.c
  • security/oc_acl_util.c
  • security/unittest/acltest.cpp

@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from e98425f to 1aea124 Compare March 25, 2024 09:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 12011d3 and 1aea124.
Files selected for processing (36)
  • api/cloud/oc_cloud_rd.c (2 hunks)
  • api/oc_collection.c (1 hunks)
  • api/oc_core_res.c (1 hunks)
  • api/oc_discovery.c (1 hunks)
  • api/oc_etag.c (1 hunks)
  • api/oc_ri.c (1 hunks)
  • api/unittest/etagtest.cpp (2 hunks)
  • docker/apps/Dockerfile.cloud-server (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug (1 hunks)
  • docker/apps/Dockerfile.cloud-server-debug-clang (1 hunks)
  • include/oc_rep.h (1 hunks)
  • messaging/coap/observe.c (1 hunks)
  • port/android/Makefile (1 hunks)
  • port/arduino/adapter/Makefile (1 hunks)
  • port/esp32/main/CMakeLists.txt (1 hunks)
  • port/linux/Makefile (1 hunks)
  • port/openthread/Makefile (1 hunks)
  • port/unittest/clocktest.cpp (1 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj (2 hunks)
  • port/windows/vs2015/IoTivity-lite.vcxproj.filters (2 hunks)
  • security/oc_acl.c (3 hunks)
  • security/oc_acl_internal.h (2 hunks)
  • security/oc_acl_util.c (1 hunks)
  • security/oc_acl_util_internal.h (1 hunks)
  • security/oc_obt.c (1 hunks)
  • security/oc_obt_otm_cert.c (4 hunks)
  • security/oc_obt_otm_justworks.c (4 hunks)
  • security/oc_obt_otm_randompin.c (4 hunks)
  • security/oc_pstat.c (5 hunks)
  • security/oc_pstat_internal.h (5 hunks)
  • security/oc_svr.c (1 hunks)
  • security/unittest/acltest.cpp (10 hunks)
  • security/unittest/keypairtest.cpp (1 hunks)
  • security/unittest/pstattest.cpp (3 hunks)
  • util/oc_atomic.h (2 hunks)
  • util/unittest/memblocktest.cpp (1 hunks)
Files not reviewed due to errors (2)
  • (no review received)
  • (no review received)
Files skipped from review due to trivial changes (1)
  • security/oc_obt_otm_justworks.c
Additional comments: 81
docker/apps/Dockerfile.cloud-server-debug (1)
  • 17-17: Using WORKDIR before cloning libfaketime is a good practice as it avoids the need for cd commands and makes the Dockerfile more readable.
security/oc_acl_util_internal.h (1)
  • 1-39: The header file oc_acl_util_internal.h is well-structured and follows best practices for C header files, including include guards and conditional C++ linkage. The function declaration for oc_sec_check_acl is clear and appropriately documented.
docker/apps/Dockerfile.cloud-server (1)
  • 1-1: Switching to a specific version of Alpine (alpine:3.19) instead of using latest is a good practice for ensuring consistent and predictable builds.
docker/apps/Dockerfile.cloud-server-debug-clang (2)
  • 6-11: Refactoring the package installation to separate the installation of clang-15 and setting it as the default compiler is a clear and efficient approach. It improves readability and maintainability of the Dockerfile.
  • 23-26: Specifying CC=clang for the make command when installing libfaketime ensures that the correct compiler is used. This is a good practice when multiple compilers are available in the environment.
security/oc_svr.c (1)
  • 51-51: Replacing direct resource creation with a call to oc_sec_pstat_create_resource centralizes the logic for creating the OCF_SEC_PSTAT resource, which can improve maintainability and consistency across the codebase.
port/openthread/Makefile (1)
  • 60-60: Adding oc_acl_util.c to the SRC_COMMON list when the SECURE flag is set to 1 ensures that ACL utility functions are available for secure builds. This change aligns with the project's approach to conditional compilation based on security requirements.
security/oc_acl_internal.h (1)
  • 74-78: The addition of oc_sec_ace_find_resource function enhances the ACL module by providing a way to find resources within an ACE. This function could be crucial for fine-grained access control checks and should be thoroughly tested to ensure it behaves as expected.
Verification successful

The function oc_sec_ace_find_resource is correctly integrated and used across the project, specifically within the ACL module, to enhance access control checks by providing a mechanism to find resources within an ACE. The usage patterns observed in security/oc_acl_util.c and security/oc_acl.c confirm its role and importance in the project's ACL handling logic. This aligns with the initial review comment, affirming the function's addition and its expected behavior.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that oc_sec_ace_find_resource is used correctly across the project
rg "oc_sec_ace_find_resource" --type c

Length of output: 500

port/arduino/adapter/Makefile (1)
  • 42-42: Including oc_acl_util.c in the security source files for the Arduino adapter ensures that ACL utility functions are compiled into the security-enabled builds. This is a necessary step for supporting advanced security features on the Arduino platform.
util/unittest/memblocktest.cpp (2)
  • 1-124: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [163-164]

In the cloud_publish_resources function, the condition to check if the device is in the OC_DOS_RFNOP state has been updated to use oc_device_is_in_dos_state instead of oc_sec_pstat_is_in_dos_state. This change aligns with the PR objectives to replace the function calls as mentioned in the AI-generated summary. This update is consistent and correctly implements the intended functionality.

  • 1-124: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [256-257]

Similarly, in the cloud_delete_resources function, the condition to check if the device is in the OC_DOS_RFNOP state has been updated to use oc_device_is_in_dos_state instead of oc_sec_pstat_is_in_dos_state. This change is in line with the PR objectives and correctly applies the intended update.

security/oc_pstat_internal.h (5)
  • 22-22: The inclusion of oc_helpers_internal.h is a new addition to this file. This change is likely made to use utility functions or definitions provided by oc_helpers_internal.h within oc_pstat_internal.h. Ensure that the functions or definitions from oc_helpers_internal.h are indeed used in this file to justify the inclusion.
  • 33-34: The definitions for OCF_SEC_PSTAT_URI and OCF_SEC_PSTAT_RT are added to standardize the URI and resource type for the pstat resource. This is a good practice as it avoids hardcoding strings in multiple places, making the code more maintainable and less error-prone.
  • 37-37: The function oc_sec_pstat_create_resource is added to create a pstat resource for a given device. This addition seems to be part of the reorganization of the access control logic as mentioned in the PR objectives. Ensure that this function is implemented with proper error handling and security checks, especially considering its role in security configuration.
  • 41-41: The function oc_sec_is_pstat_resource_uri checks if a given URI matches the pstat resource URI. This utility function can simplify URI matching logic elsewhere in the codebase, contributing to cleaner and more readable code. Verify that it's used effectively where URI checks for the pstat resource are needed.
Verification successful

The function oc_sec_is_pstat_resource_uri is effectively used within the codebase, specifically in oc_acl_util.c, to simplify URI matching logic for the pstat resource, as intended. This contributes to cleaner and more readable code where URI checks for the pstat resource are needed.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usage of oc_sec_is_pstat_resource_uri to ensure it's effectively used
grep -r "oc_sec_is_pstat_resource_uri" security/

Length of output: 392

* 124-124: The function `oc_sec_pstat_is_in_dos_state` checks if the onboarding state property is in one of the DOS states. This function, along with `oc_device_is_in_dos_state`, provides a clearer and more direct way to query the device state, which is crucial for making security-related decisions. Ensure that these functions are used consistently across the codebase for checking DOS states.
Verification successful

The provided grep command and its output show that oc_sec_pstat_is_in_dos_state and oc_device_is_in_dos_state are used within the security/ directory, indicating a consistent usage pattern in this part of the codebase. To fully verify the comment regarding their consistent usage across the entire codebase, it would be beneficial to extend the search beyond the security/ directory. This will ensure that these functions are indeed used consistently everywhere they are needed for making security-related decisions.


The extended search across the entire codebase has revealed that oc_sec_pstat_is_in_dos_state and oc_device_is_in_dos_state are consistently used not only within the security/ directory but also in other parts of the codebase, such as ./api/cloud/oc_cloud_rd.c and ./api/oc_etag.c. This indicates a comprehensive and logical application of these functions for making security-related decisions, aligning with the guidance provided in the review comment. Therefore, the usage of these functions across the codebase supports the comment's assertion regarding their importance in querying the device state for security purposes.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Ensure consistent usage of oc_sec_pstat_is_in_dos_state and oc_device_is_in_dos_state across the codebase
grep -rE "oc_sec_pstat_is_in_dos_state|oc_device_is_in_dos_state" security/

Length of output: 640



Script:

#!/bin/bash
# Extend the search for oc_sec_pstat_is_in_dos_state and oc_device_is_in_dos_state across the entire codebase
grep -rE "oc_sec_pstat_is_in_dos_state|oc_device_is_in_dos_state" .

Length of output: 884

port/unittest/clocktest.cpp (1)
  • 72-72: The change to cast the result of the time difference calculation to a long type in the oc_clock_wait test function is appropriate. This ensures that the type of the variable seconds matches the expected type for the assertion that follows. This change improves type safety and clarity in the test.
security/unittest/pstattest.cpp (3)
  • 181-181: Replacing the hardcoded URI "/oic/sec/pstat" with the constant OCF_SEC_PSTAT_URI in the PostRequest_FailMethodNotAuthorized test case is a good practice. It ensures consistency and makes the code easier to maintain.
  • 197-197: Similarly, using the OCF_SEC_PSTAT_URI constant in the PutRequest_Fail test case instead of a hardcoded URI string is a positive change. It enhances code readability and maintainability.
  • 211-211: The use of OCF_SEC_PSTAT_URI in the DeleteRequest_Fail test case, replacing the hardcoded URI, follows the same pattern of improving code maintainability and consistency. This is a welcomed change.
util/oc_atomic.h (2)
  • 41-44: Converting macro definitions to typedefs for atomic integer types (OC_ATOMIC_INT8_T, OC_ATOMIC_UINT8_T, OC_ATOMIC_INT32_T, OC_ATOMIC_UINT32_T) is a positive change. It enhances type safety and readability of the code. This change aligns with best practices for defining atomic types.
  • 83-86: Similarly, for Windows platforms, converting macro definitions to typedefs for atomic integer types is a good practice. It ensures consistency across different platforms and improves the readability and maintainability of the code.
api/cloud/oc_cloud_rd.c (2)
  • 163-164: In the cloud_publish_resources function, the condition to check if the device is in the OC_DOS_RFNOP state has been updated to use oc_device_is_in_dos_state instead of oc_sec_pstat_is_in_dos_state. This change aligns with the PR objectives to replace the function calls as mentioned in the AI-generated summary. This update is consistent and correctly implements the intended functionality.
  • 256-257: Similarly, in the cloud_delete_resources function, the condition to check if the device is in the OC_DOS_RFNOP state has been updated to use oc_device_is_in_dos_state instead of oc_sec_pstat_is_in_dos_state. This change is in line with the PR objectives and correctly applies the intended update.
port/esp32/main/CMakeLists.txt (1)
  • 189-189: The addition of ${CMAKE_CURRENT_SOURCE_DIR}/../../../security/oc_acl_util.c under the CONFIG_SECURE flag is correctly implemented. Ensure that CONFIG_SECURE is consistently used and documented across the project. Also, verify if oc_acl_util.c has any other dependencies or requires additional configurations.
security/unittest/acltest.cpp (16)
  • 30-37: Added includes for internal security modules are appropriate for the expanded test coverage. Ensure these modules are only used for testing purposes and do not introduce unnecessary dependencies in the production code.
  • 61-103: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [47-72]

The modifications in the SetUp method, including the initialization of security modules and setting the log level to debug, are suitable for the intended test setup. However, consider resetting the log level back to its original state after tests to avoid affecting other tests or the production environment.

  • 77-83: In TearDown, resetting the log level to INFO is a good practice. Ensure that all resources initialized in SetUp are correctly freed or reset here to prevent resource leaks or interference with other tests.
  • 90-100: The method getSVRs is a useful addition for retrieving Secure Virtual Resources (SVRs) for testing. Ensure that the range of resources it iterates over (OCF_SEC_DOXM to OCF_D) correctly encompasses all SVRs intended for testing.
  • 117-120: The test oc_sec_acl_add_bootstrap_acl correctly checks the addition of a bootstrap ACL. Ensure that edge cases, such as adding a bootstrap ACL when one already exists, are also tested.
  • 146-185: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [130-154]

In the test oc_sec_acl_clear, the use of oc_sec_ace_update_res to set up test conditions is appropriate. However, consider adding comments to explain the purpose of each block within the test for clarity, especially for complex test setups.

  • 210-216: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [213-242]

The test oc_sec_check_acl_in_RFOTM introduces testing for security checks in different device states, which is crucial for ensuring the correct behavior of ACLs. Ensure that all relevant device states are covered and consider adding negative tests for comprehensive coverage.

  • 246-265: The test oc_sec_check_acl_FailInsecureDOC is important for verifying the behavior of ACL checks with insecure device ownership credentials. Ensure that the setup for the TLS peer and endpoint is correctly mimicking the intended insecure conditions.
Verification successful

The provided script outputs and context give us insight into how the oc_tls_add_or_get_peer and oc_sec_check_acl functions operate, as well as the conditions under which they are called within the test oc_sec_check_acl_FailInsecureDOC.

From the oc_tls.c file, we see that oc_tls_add_or_get_peer adds a new TLS peer based on the provided endpoint and role, with an emphasis on whether the peer was newly created or already existed. This function is crucial for establishing a secure or insecure connection, depending on the test scenario.

The oc_sec_check_acl function, as seen in oc_acl_util.c, performs access control checks based on the method, resource, and endpoint involved in the request. It includes checks for various device ownership states (DOS), whether the request is over a secured channel, and if the resource is a Device Configuration Resource (DCR), a Secure Virtual Resource (SVR), or a vertical resource. The function's logic is comprehensive, covering different scenarios including access during the RFOTM (Requesting Full Ownership Transfer Method) state and prior to Device Onboarding Completion (DOC).

The test oc_sec_check_acl_FailInsecureDOC specifically sets up a scenario where a TLS peer is added with the intention of mimicking insecure conditions by asserting that the endpoint is not secured (ASSERT_EQ(0, ep.flags & SECURED)). This setup, followed by the call to oc_sec_check_acl with the expectation of EXPECT_FALSE, aims to verify that access control correctly identifies and blocks insecure access attempts under specific conditions (in this case, likely during the RFOTM state or prior to DOC).

Given the detailed implementation of both oc_tls_add_or_get_peer and oc_sec_check_acl, and the specific assertions and expectations within the test oc_sec_check_acl_FailInsecureDOC, it can be inferred that the test is designed to accurately mimic and verify the behavior of ACL checks under insecure conditions as intended.

Therefore, based on the analysis of the provided context and the script outputs, the review comment regarding the verification of the test setup for mimicking insecure conditions in oc_sec_check_acl_FailInsecureDOC is consistent with the codebase and its intended functionality.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the setup for TLS peer and endpoint in oc_sec_check_acl_FailInsecureDOC correctly mimics insecure conditions.
# This script is a placeholder for the actual verification logic, which would depend on the project's documentation or source code structure.
echo "Verify the TLS peer and endpoint setup in oc_sec_check_acl_FailInsecureDOC."

Length of output: 160



Script:

#!/bin/bash
# Search for the implementation of oc_tls_add_or_get_peer and oc_sec_check_acl to understand their handling of security conditions.
rg "oc_tls_add_or_get_peer" -A 30
rg "oc_sec_check_acl" -A 30
# Additionally, look for any documentation or comments that define "insecure conditions".
rg "insecure conditions" -C 5

Length of output: 55854

* 267-282: The test `oc_sec_check_acl_AccessInRFOTM` correctly verifies ACL access in the RFOTM state. Ensure that the test setup accurately reflects the RFOTM state and that the resource setup is consistent with the intended test conditions. * 286-303: The test `oc_sec_check_acl_FailNCRInNonRFNOP` is crucial for ensuring that non-configured resources (NCRs) are not accessible in non-RFNOP states. Consider adding a brief comment explaining the significance of each state tested to enhance readability and maintainability. * 305-317: The test `oc_sec_check_acl_FailInsecureAccessToVerticalResource` ensures that insecure access to vertical resources is correctly handled. Verify that the definition of "vertical resource" in this context is consistent with the project's security model.
Verification successful

The definition of "vertical resource" within the project's security model is consistent across various parts of the codebase. Vertical resources are identified as custom resources specific to a device, subject to strict access control measures, and play a significant role in the project's ecosystem, including cloud registration and discovery. This understanding aligns with the project's security model as inferred from the code snippets provided in the shell script output. Therefore, the review comment is verified as the definition of "vertical resource" is consistent with the project's security model.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the definition of "vertical resource" in the context of the project's security model.
# This script is a placeholder for the actual verification logic, which would depend on the project's documentation or source code structure.
echo "Verify the definition of 'vertical resource' in oc_sec_check_acl_FailInsecureAccessToVerticalResource."

Length of output: 220



Script:

#!/bin/bash
# Search for mentions of "vertical resource" within the codebase to understand its definition and role in the security model.
rg "vertical resource" --context 5
# Additionally, search for documentation or comments that might explain the concept further.
rg "vertical resource" -tmd

Length of output: 5318

* 319-342: The test `oc_sec_check_acl_DOCAccessToDCR` effectively tests DOC (Device Ownership Credential) access to DCR (Device Configuration Resources). Ensure that the setup for the TLS peer and endpoint accurately represents secure DOC conditions. * 344-359: The test `oc_sec_check_acl_GETinRFOTM` is important for verifying GET access to core resources in RFOTM. Ensure that the selection of resources (`OCF_P`, `OCF_D`, `OCF_RES`) is comprehensive and relevant to the RFOTM state. * 361-375: The test `oc_sec_check_acl_PriorToDOCAccessToDoxmInRFOTM` correctly verifies access to the `doxm` resource prior to DOC in RFOTM. This is crucial for the device ownership transfer process. Ensure that the test accurately reflects the intended conditions for DOC access. * 377-392: The test `oc_sec_check_acl_PriorToDOCGetAccessToPstatInRFOTM` effectively tests GET access to `pstat` prior to DOC in RFOTM. Consider adding tests for other methods (POST, PUT, DELETE) to ensure comprehensive coverage of access controls. * 394-415: The test `oc_sec_check_acl_FailInsecureAccessToSecurityVerticalResource` ensures that insecure access to security vertical resources is correctly restricted. This is a critical aspect of the security model. Verify that all relevant SVRs and device states are covered in the test.
Verification successful

The provided script output contains extensive references to the handling of SVRs (Security Vertical Resources) and device states within the codebase. The references span across various files and contexts, including unit tests, security implementations, cloud interactions, and more. This information is crucial for verifying the coverage of SVRs and device states in the test oc_sec_check_acl_FailInsecureAccessToSecurityVerticalResource.

Analysis of Script Output:

  1. SVRs Identification and Handling:

    • The function oc_core_is_SVR is used across multiple files to identify SVRs. This function checks if a given resource is an SVR based on the device ID.
    • The unit test file unittest/acltest.cpp specifically tests the handling of SVRs in various device states, including the test in question.
  2. Device States Coverage:

    • The device states OC_DOS_RFPRO, OC_DOS_RFNOP, and OC_DOS_SRESET are explicitly tested in the unit test oc_sec_check_acl_FailInsecureAccessToSecurityVerticalResource, as seen in the provided code snippet.
    • The script output also shows various parts of the codebase reacting to different device states, indicating a comprehensive handling of device states across the project.
  3. Relevance to Security Model:

    • The handling of SVRs and device states is closely tied to the security model of the system. The tests and code snippets ensure that SVRs are appropriately restricted based on the device's state, aligning with security requirements.

Conclusion:

The script output provides evidence that the test oc_sec_check_acl_FailInsecureAccessToSecurityVerticalResource and related code adequately cover the handling of SVRs and relevant device states (OC_DOS_RFPRO, OC_DOS_RFNOP, and OC_DOS_SRESET). This coverage is crucial for maintaining the security model's integrity, ensuring that SVRs are protected against unauthorized access in sensitive device states.

Given the detailed references to SVRs and device states handling in the provided script output, it can be concluded that the test and related codebase sections comprehensively cover the necessary aspects of SVRs and device states as per the security model requirements.

**Final Tag: **

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that all relevant SVRs and device states are covered in oc_sec_check_acl_FailInsecureAccessToSecurityVerticalResource.
# This script is a placeholder for the actual verification logic, which would depend on the project's documentation or source code structure.
echo "Verify SVRs and device states coverage in oc_sec_check_acl_FailInsecureAccessToSecurityVerticalResource."

Length of output: 218



Script:

#!/bin/bash
# Search for definitions or listings of SVRs in the codebase.
rg "oc_core_is_SVR" --context 5
# Search for definitions or usages of device states to ensure coverage.
rg "OC_DOS_" --context 5

Length of output: 78682

port/android/Makefile (1)
  • 272-272: The addition of oc_acl_util.c to the SRC list under the SECURE condition seems appropriate, assuming oc_acl_util.c is indeed part of the security features. Please ensure that its inclusion is necessary and correct for builds where SECURE is enabled.
security/unittest/keypairtest.cpp (1)
  • 279-290: The modifications to EXPECT statements by removing concatenated error messages simplify the code. However, please consider the impact on the clarity of test failures. Ensure that test names and any additional context or comments are sufficient to understand failures without these detailed messages.
security/oc_obt_otm_cert.c (2)
  • 79-79: The replacement of the hardcoded URI with OCF_SEC_PSTAT_URI macro enhances maintainability and consistency. Good job on this improvement.
  • 247-247: The use of OCF_SEC_PSTAT_URI macro here is consistent with the previous change and continues to improve code maintainability. Well done.
security/oc_acl_util.c (1)
  • 1-1: Updating the copyright information to include "plgd.dev s.r.o." for the year 2024 is appropriate and keeps the file's metadata current.
security/oc_obt_otm_randompin.c (3)
  • 79-79: Using OCF_SEC_PSTAT_URI constant instead of a hardcoded URI string improves maintainability and consistency. Good change.
  • 247-247: This change aligns with the previous one, consistently using OCF_SEC_PSTAT_URI for URI references. Well done.
  • 425-425: Consistent use of OCF_SEC_PSTAT_URI across the file is a good practice for maintainability. Approved.
api/oc_etag.c (1)
  • 444-444: Replacing oc_sec_pstat_is_in_dos_state with oc_device_is_in_dos_state could streamline device state checking. Ensure that the new function accurately reflects the intended state checks and does not introduce regressions.
Verification successful

The provided output from the oc_pstat.c file reveals the implementation details of the oc_device_is_in_dos_state function. This function checks if a device is in a specific Device Onboarding State (DOS) by comparing the device's current state against a provided mask. The function utilizes the oc_sec_pstat_is_in_dos_state function, which operates on a oc_sec_pstat_t structure representing the persistent state of security resources for a device. The oc_device_is_in_dos_state function effectively abstracts the process of checking the device's state, making it easier to use across different parts of the codebase, such as in cloud and ETag functionalities.

Given the context and the implementation details, it's clear that the replacement of oc_sec_pstat_is_in_dos_state with oc_device_is_in_dos_state in the oc_etag.c file is intended to streamline the process of checking the device's state. This change leverages a more direct and possibly more readable approach to perform the state check, which could improve code maintainability and readability without altering the underlying logic of state checking.

Considering the usage of oc_device_is_in_dos_state in multiple parts of the codebase and its implementation, it can be inferred that the function accurately reflects the intended state checks. Therefore, the change in the oc_etag.c file is consistent with the goal of streamlining device state checking, and there's no indication that it introduces regressions or deviates from the intended functionality.

Based on the analysis, the review comment is verified as the change seems appropriate for the intended purpose, and the function oc_device_is_in_dos_state is implemented in a way that supports the described functionality.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that oc_device_is_in_dos_state correctly handles device state checks
grep -R "oc_device_is_in_dos_state" .

Length of output: 456



Script:

#!/bin/bash
# View the implementation of oc_device_is_in_dos_state in oc_pstat.c
cat ./security/oc_pstat.c

Length of output: 21221

security/oc_pstat.c (6)
  • 22-25: The addition of #include "api/oc_resource_internal.h" is necessary for the newly introduced functions that deal with resource URIs. This change seems appropriate and necessary for the functionality being introduced.
  • 449-452: The modification of oc_sec_pstat_is_in_dos_state to take a const oc_sec_pstat_t *ps as input instead of a device index is a good practice. It makes the function more flexible and reusable by directly working with the oc_sec_pstat_t structure. This change enhances the modularity and maintainability of the code.
  • 454-457: The addition of oc_device_is_in_dos_state function is a logical extension to the existing functionality, providing a convenient way to check the device state using the device index. This function complements the modified oc_sec_pstat_is_in_dos_state function and improves the API's usability.
  • 671-679: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [674-692]

The refactoring of get_pstat and post_pstat functions into pstat_resource_get and pstat_resource_post is a positive change. It aligns the function names with the naming conventions used throughout the codebase, improving consistency and readability. Additionally, this change makes the purpose of these functions clearer to new readers or contributors to the codebase.

  • 806-812: The addition of oc_sec_pstat_create_resource function is crucial for initializing the /oic/sec/pstat resource. This function encapsulates the resource creation process, making the code more modular and easier to maintain. The use of OC_IF_RW | OC_IF_BASELINE and OC_DISCOVERABLE | OC_OBSERVABLE flags correctly sets the interface and properties of the pstat resource, aligning with the security requirements.
  • 815-818: The introduction of oc_sec_is_pstat_resource_uri function is a good practice for checking if a given URI corresponds to the pstat resource. This function enhances the code's modularity by abstracting the URI check, making it reusable across different parts of the codebase where such a check is needed.
api/oc_core_res.c (1)
  • 736-736: The change to use oc_sec_is_pstat_resource_uri in oc_core_get_resource_type_by_uri for checking if a URI corresponds to the pstat resource is a positive improvement. It leverages the newly introduced function to make the URI check more modular and maintainable. This change ensures that the logic for identifying the pstat resource URI is centralized, reducing the risk of inconsistencies and errors.
security/oc_acl.c (6)
  • 23-35: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [30-44]

Consider verifying the upper limit of oc_core_get_num_devices() to prevent potential excessive memory allocation in oc_sec_acl_init. Additionally, it's crucial to handle the case where calloc fails to allocate memory, which currently leads to a call to oc_abort("Insufficient memory"). While this may be an intended behavior, ensuring graceful error handling and recovery in low-memory situations could enhance the robustness of the system.

  • 23-35: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [70-79]

The get_new_aceid function generates a unique ACE identifier using a loop that could potentially become infinite if all possible IDs are taken. Consider adding a maximum attempt counter to this loop to prevent an infinite loop scenario, ensuring the function exits after a reasonable number of attempts even if a unique ID cannot be found.

  • 100-106: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [103-134]

The logic within oc_sec_ace_find_resource is sound, effectively handling both explicit resource identifiers and wildcard resources. However, the function's complexity and multiple exit points could benefit from a refactor to improve readability and maintainability. Consider simplifying the logic or breaking it down into smaller, more focused functions.

  • 23-35: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [234-345]

The oc_sec_encode_acl function's serialization logic is comprehensive, effectively covering various subject types and resource specifications. However, its length and complexity could impact maintainability. Consider refactoring this function into smaller, more manageable pieces or extracting parts of the logic into separate functions to enhance readability and maintainability.

  • 23-35: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1035-1048]

The memory management logic within oc_sec_acl_free is correctly implemented, ensuring that allocated ACL resources are properly freed, preventing memory leaks. This function appropriately handles the conditional freeing of the ACL list based on OC_DYNAMIC_ALLOCATION, demonstrating good practice in resource management.

  • 23-35: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1050-1057]

The implementation of oc_sec_acl_default effectively clears ACL entries and resets the owner UUID for a given device, aligning with the intended functionality for initializing or resetting ACL settings to their defaults. This straightforward approach is appropriate for the task at hand.

port/windows/vs2015/IoTivity-lite.vcxproj (2)
  • 275-275: The addition of oc_acl_util_internal.h to the project file is noted. Ensure that the file path is consistent with the project's directory structure and that the file is correctly placed in the specified directory.
  • 456-456: The inclusion of oc_acl_util.c in the project file is appropriate for integrating its functionalities into the build. As with the header file, please verify that the file path aligns with the project's directory structure and that the file is correctly placed.
port/windows/vs2015/IoTivity-lite.vcxproj.filters (2)
  • 362-364: The addition of oc_acl_util.c to the Security filter is correctly done and aligns with the project's structure for organizing security-related files.
  • 730-732: The inclusion of oc_acl_util_internal.h in the Security filter is appropriate and follows the conventions for organizing internal security-related header files.
api/oc_collection.c (1)
  • 43-43: The addition of #include "security/oc_acl_util_internal.h" within the #ifdef OC_SECURITY block suggests new dependencies on ACL utility functions. Ensure that this inclusion is necessary and correctly enhances the security features as intended by the PR objectives.
api/oc_discovery.c (5)
  • 51-51: The inclusion of "security/oc_acl_util_internal.h" suggests that ACL utility functions or definitions from this header are used within oc_discovery.c. Ensure that the functions or definitions provided by this header are indeed utilized within this file. If this inclusion is primarily for indirect dependencies, consider documenting this explicitly near the include directive for clarity and maintainability.
Verification successful

Given the output, there's no direct evidence of the usage of entities from "security/oc_acl_util_internal.h" within oc_discovery.c, based solely on the string "oc_acl_util". However, this does not conclusively prove the header is unnecessary, as it might contain macros, type definitions, or indirectly used entities that don't explicitly include "oc_acl_util" in their names. To further investigate, we should examine the contents of "oc_acl_util_internal.h" for potentially relevant entities (like macros or type definitions) and then search for their usage in "oc_discovery.c".


To conclusively determine the necessity of including "security/oc_acl_util_internal.h" in oc_discovery.c, we need to search for the usage of the function oc_sec_check_acl and the types oc_method_t, oc_resource_t, and oc_endpoint_t within oc_discovery.c. This will help us understand if the inclusion is justified by direct or indirect usage of these entities.


The search results indicate that oc_discovery.c makes use of the types oc_endpoint_t and oc_resource_t extensively. These types are related to the function oc_sec_check_acl, which is defined in the included header "security/oc_acl_util_internal.h". Notably, there is a direct call to oc_sec_check_acl within oc_discovery.c, specifically in a context that checks access control lists (ACLs) for resources, which justifies the inclusion of "security/oc_acl_util_internal.h".

Given this evidence, the inclusion of "security/oc_acl_util_internal.h" in oc_discovery.c is justified due to the direct usage of the oc_sec_check_acl function and the related types oc_endpoint_t and oc_resource_t. This confirms the necessity of the include directive for the functionality implemented in oc_discovery.c.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the usage of entities from oc_acl_util_internal.h within oc_discovery.c
rg "oc_acl_util" api/oc_discovery.c

Length of output: 78



Script:

#!/bin/bash
# Examine the contents of oc_acl_util_internal.h for entities that could be used in oc_discovery.c
cat security/oc_acl_util_internal.h

Length of output: 1206



Script:

#!/bin/bash
# Search for the usage of oc_sec_check_acl and related types in oc_discovery.c
rg "oc_sec_check_acl|oc_method_t|oc_resource_t|oc_endpoint_t" api/oc_discovery.c

Length of output: 2793

* 51-51: Including `"security/oc_acl_util_internal.h"` adds specific ACL utility functions or definitions to this file. It's important to ensure that these utilities are indeed used within `oc_discovery.c`. If the inclusion is for indirect dependencies or macro definitions, consider adding a comment near the include directive to clarify its purpose for future maintainability. * 48-54: > 📝 **NOTE** > This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1085-1113]

In the discovery_resource_get function, there's a conditional compilation block for OC_SPEC_VER_OIC that handles discovery requests specifically for OIC 1.1.0. Ensure that this version-specific handling is still relevant and correctly implemented. Additionally, verify that the security checks (e.g., for OC_SECURITY) and the logic for determining the response based on the interface mask are correctly applied and cover all necessary cases.

Verification successful

The review comment is verified. The version-specific handling for OIC 1.1.0 is correctly implemented and relevant, as evidenced by the presence of code blocks enclosed in #ifdef OC_SPEC_VER_OIC. Additionally, security checks related to discovery requests are correctly applied throughout the discovery process, as indicated by the usage of OC_SECURITY in various parts of the code. These findings confirm that the discovery_resource_get function includes appropriate version-specific handling and security checks as described.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the version-specific handling for OIC 1.1.0 is correctly implemented and relevant.
grep -A 10 "OC_SPEC_VER_OIC" api/oc_discovery.c
# Check for security checks related to discovery requests.
grep -A 20 "OC_SECURITY" api/oc_discovery.c

Length of output: 12384

* 48-54: > 📝 **NOTE** > This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1155-1216]

The discovery_encode function handles encoding of discovery responses for different interfaces. It's crucial to ensure that the encoding process is efficient and that the code is maintainable. Specifically, review the handling of the OC_IF_B interface for batch support and verify that the encoding for each interface type is correctly implemented according to the specifications. Additionally, consider if there are opportunities to refactor the code for better readability and maintainability, especially in handling the different interface types.

Consider refactoring the discovery_encode function to improve readability and maintainability. One approach could be to separate the encoding logic for each interface type into separate helper functions. This would make the code easier to understand and maintain, especially as new interface types may be added in the future.

  • 48-54: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1085-1113]

Within the discovery_resource_get function, there's conditional logic for OC_SECURITY that may affect how discovery requests are handled, especially in secure contexts. It's important to ensure that these security checks are correctly implemented and that they adequately protect against unauthorized access to discovery information. Review the security logic to confirm that it aligns with the project's security policies and best practices.

Verification successful

The grep output confirms the implementation of security checks within the api/oc_discovery.c file, specifically in relation to handling discovery requests in secure contexts. The file includes conditional compilation blocks for OC_SECURITY, indicating comprehensive security-related logic. This includes filtering resources based on security policies, handling secure batch interface requests, and more specific functionalities like handling secure device UUIDs (SDUUID) and secure discovery interfaces (SDI). These implementations align with the concerns for adequately protecting against unauthorized access to discovery information, confirming that the security logic is correctly implemented and aligns with the project's security policies and best practices.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check for correct implementation of security checks in relation to discovery requests.
grep -A 20 "OC_SECURITY" api/oc_discovery.c

Length of output: 11098

api/unittest/etagtest.cpp (3)
  • 687-687: The change to isPlatformResourceURI function signature from const std::string& to std::string_view is modern and efficient. Ensure all calls to this function have been updated accordingly.
Verification successful

The calls to isPlatformResourceURI within etagtest.cpp appear to have been updated to be compatible with the new function signature that uses std::string_view. There's no evidence of misuse or compatibility issues based on the provided context.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for calls to `isPlatformResourceURI` to ensure they are compatible with the new signature.
rg --type cpp "isPlatformResourceURI"

Length of output: 255

* 597-599: The refactoring in `isETagStorageEmpty` to simplify the return statement improves readability. Ensure the simplified logic accurately reflects the intended behavior. * 687-687: Ensure that the updated usage of `isPlatformResourceURI` throughout the codebase correctly handles the new `std::string_view` parameter without introducing lifetime issues.
messaging/coap/observe.c (2)
  • 79-79: Including "security/oc_acl_util_internal.h" introduces tighter coupling between the CoAP observe functionality and the security layer. Ensure that this dependency is necessary and justified, considering the potential impact on modularity and maintainability.
  • 79-79: The addition of "security/oc_acl_util_internal.h" suggests enhancements or dependencies related to access control. Verify that the newly introduced functions or data structures from this header are properly utilized, especially in terms of security checks or permissions validation.
api/oc_ri.c (2)
  • 86-86: The inclusion of "security/oc_acl_util_internal.h" is noted. Ensure that functions or definitions from this header are indeed utilized within api/oc_ri.c. If not, consider removing this include directive to avoid unnecessary dependencies.
  • 86-86: Given the addition of "security/oc_acl_util_internal.h", verify that functions or definitions from this header are indeed utilized within api/oc_ri.c. If there are no usages found, consider removing this include directive to streamline dependencies and reduce potential for unused code inclusion.
security/oc_obt.c (1)
  • 874-874: The update to use OCF_SEC_PSTAT_URI instead of a hardcoded string for initiating a POST request is a good practice. It enhances maintainability and readability.

docker/apps/Dockerfile.cloud-server-debug Show resolved Hide resolved
docker/apps/Dockerfile.cloud-server Show resolved Hide resolved
@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch 8 times, most recently from 9748d71 to b01ba1c Compare April 16, 2024 13:05
@Danielius1922 Danielius1922 marked this pull request as ready for review April 16, 2024 13:09
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 37

Actionable comments outside the diff hunks (37)
security/oc_pstat.c (3)

Line range hint 76-76: Replace memset with memset_s to ensure buffer boundaries are respected, mitigating potential buffer overflow risks.

-  memset(g_pstat, 0, sizeof(g_pstat));
+  memset_s(g_pstat, sizeof(g_pstat), 0, sizeof(g_pstat));

Line range hint 291-291: Replace memset with memset_s in the oc_pstat_handle_state function to prevent potential buffer overflow issues.

-  memset(ps->rowneruuid.id, 0, sizeof(ps->rowneruuid.id));
+  memset_s(ps->rowneruuid.id, sizeof(ps->rowneruuid.id), 0, sizeof(ps->rowneruuid.id));

Line range hint 494-494: Replace memset with memset_s in the oc_sec_pstat_clear function to enhance security by respecting buffer boundaries.

-  memset(ps, 0, sizeof(*ps));
+  memset_s(ps, sizeof(*ps), 0, sizeof(*ps));
api/oc_core_res.c (3)

Line range hint 109-110: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

-  memset(g_core_resources, 0, sizeof(g_core_resources));
-  memset(g_oc_device_info, 0, sizeof(g_oc_device_info));
+  memset_s(g_core_resources, sizeof(g_core_resources), 0, sizeof(g_core_resources));
+  memset_s(g_oc_device_info, sizeof(g_oc_device_info), 0, sizeof(g_oc_device_info));

Line range hint 286-296: Replace memset with memset_s in dynamic allocation scenarios to ensure buffer boundaries are respected, preventing potential buffer overflows.

-  memset(device, 0, OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t));
-  memset(&device_info[device_count], 0, sizeof(oc_device_info_t));
+  memset_s(device, OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t), 0, OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t));
+  memset_s(&device_info[device_count], sizeof(oc_device_info_t), 0, sizeof(oc_device_info_t));

Line range hint 431-431: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

-  memset(&r->types, 0, sizeof(oc_string_array_t));
+  memset_s(&r->types, sizeof(oc_string_array_t), 0, sizeof(oc_string_array_t));
security/oc_doxm.c (2)

Line range hint 256-257: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

-  memset(doxm->devowneruuid.id, 0, sizeof(doxm->devowneruuid.id));
-  memset(doxm->rowneruuid.id, 0, sizeof(doxm->rowneruuid.id));
+  memset_s(doxm->devowneruuid.id, sizeof(doxm->devowneruuid.id), 0, sizeof(doxm->devowneruuid.id));
+  memset_s(doxm->rowneruuid.id, sizeof(doxm->rowneruuid.id), 0, sizeof(doxm->rowneruuid.id));

Line range hint 690-690: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

-  memset(&decode, 0, sizeof(oc_doxm_decode_t));
+  memset_s(&decode, sizeof(oc_doxm_decode_t), 0, sizeof(oc_doxm_decode_t));
api/plgd/plgd_time.c (2)

Line range hint 518-518: Consider replacing memset with memset_s to ensure buffer boundaries are respected and enhance security.

- memset(&pt, 0, sizeof(pt));
+ memset_s(&pt, sizeof(pt), 0, sizeof(pt));

Line range hint 540-540: Consider replacing memset with memset_s to ensure buffer boundaries are respected and enhance security.

- memset(&pt, 0, sizeof(pt));
+ memset_s(&pt, sizeof(pt), 0, sizeof(pt));
security/oc_acl.c (1)

Line range hint 582-582: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security against potential buffer overflows.

- memset(&subject, 0, sizeof(oc_ace_subject_t));
+ memset_s(&subject, sizeof(oc_ace_subject_t), 0, sizeof(oc_ace_subject_t));
api/oc_collection.c (4)

Line range hint 818-818: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&response, 0, sizeof(oc_response_t));
+ memset_s(&response, sizeof(oc_response_t), 0, sizeof(oc_response_t));

This change addresses potential buffer overflow issues by ensuring that the size of the buffer is explicitly considered.


Line range hint 820-820: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
+ memset_s(&response_buffer, sizeof(oc_response_buffer_t), 0, sizeof(oc_response_buffer_t));

This change addresses potential buffer overflow issues by ensuring that the size of the buffer is explicitly considered.


Line range hint 822-822: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&rest_request, 0, sizeof(oc_request_t));
+ memset_s(&rest_request, sizeof(oc_request_t), 0, sizeof(oc_request_t));

This change addresses potential buffer overflow issues by ensuring that the size of the buffer is explicitly considered.


Line range hint 850-850: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&link_item, 0, sizeof(link_item));
+ memset_s(&link_item, sizeof(link_item), 0, sizeof(link_item));

This change addresses potential buffer overflow issues by ensuring that the size of the buffer is explicitly considered.

security/oc_cred.c (4)

Line range hint 271-271: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

- memset(&uuid, 0, sizeof(oc_uuid_t));
+ memset_s(&uuid, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Line range hint 301-301: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

- memset(g_devices[device].rowneruuid.id, 0, OC_UUID_ID_SIZE);
+ memset_s(g_devices[device].rowneruuid.id, OC_UUID_ID_SIZE, 0, OC_UUID_ID_SIZE);

Line range hint 648-648: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

- memset(&public_key, 0, sizeof(oc_string_t));
+ memset_s(&public_key, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Line range hint 668-668: Replace memset with memset_s to ensure buffer boundaries are respected, preventing potential buffer overflows.

- memset(&subject, 0, sizeof(oc_uuid_t));
+ memset_s(&subject, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));
messaging/coap/observe.c (4)

Line range hint 807-807: Replace memset with memset_s.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

The use of memset can potentially lead to security vulnerabilities due to compiler optimizations that may remove these calls. Using memset_s, which is designed to be more secure against such optimizations, is recommended.


Line range hint 845-845: Replace memset with memset_s.

- memset(&request, 0, sizeof(request));
+ memset_s(&request, sizeof(request), 0, sizeof(request));

Similar to previous comments, replace memset with memset_s to enhance security by preventing potential buffer overflows and ensuring that the memory clearing is not optimized away by the compiler.


Line range hint 847-847: Replace memset with memset_s.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Continue replacing memset with memset_s for the reasons mentioned earlier, enhancing the security of the code.


Line range hint 849-849: Replace memset with memset_s.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Ensure that buffer clearing operations are secure and not subject to compiler optimizations that could remove them.

api/oc_ri.c (7)

Line range hint 772-772: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(aux_arr, 0, sizeof(aux_arr));
+ memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));

Line range hint 830-830: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&handler, 0, sizeof(oc_request_handler_t));
+ memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));

Line range hint 1246-1246: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&result, 0, sizeof(result));
+ memset_s(&result, sizeof(result), 0, sizeof(result));

Line range hint 1686-1686: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing 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));

Line range hint 1741-1741: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 1745-1745: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_obj, 0, sizeof(response_obj));
+ memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));

Line range hint 1749-1749: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&request_obj, 0, sizeof(request_obj));
+ memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));
security/oc_tls.c (5)

Line range hint 1325-1325: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&crt, 0, sizeof(mbedtls_x509_crt));
+  memset_s(&crt, sizeof(mbedtls_x509_crt), 0, sizeof(mbedtls_x509_crt));

Line range hint 1837-1837: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&wildcard_sub, 0, sizeof(oc_uuid_t));
+  memset_s(&wildcard_sub, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Line range hint 2018-2018: Replace memset with memset_s to ensure buffer boundaries are respected.

-  memset(&peer->timer, 0, sizeof(oc_tls_retry_timer_t));
+  memset_s(&peer->timer, sizeof(oc_tls_retry_timer_t), 0, sizeof(oc_tls_retry_timer_t));

Line range hint 1437-1437: Replace strncpy with strcpy_s to ensure buffer boundaries are respected.

-  strncpy(credid_str, "any", sizeof(credid_str));
+  strcpy_s(credid_str, sizeof(credid_str), "any");

Line range hint 1453-1453: Replace strncpy with strcpy_s to ensure buffer boundaries are respected.

-  strncpy(credid_str, "any", sizeof(credid_str));
+  strcpy_s(credid_str, sizeof(credid_str), "any");
security/oc_obt.c (2)

Line range hint 573-573: Replace memset with memset_s to enhance security.

- memset(&di, 0, sizeof(oc_uuid_t));
+ memset_s(&di, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Using memset_s instead of memset can help prevent potential buffer overflow issues and enhance the security of the code.


Line range hint 1425-1425: Use memset_s instead of memset for better security practices.

- memset(&subjectuuid, 0, sizeof(oc_uuid_t));
+ memset_s(&subjectuuid, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Replacing memset with memset_s provides a safer alternative that considers buffer boundaries, reducing the risk of buffer overflows.

security/oc_tls.c Show resolved Hide resolved
port/esp32/main/CMakeLists.txt Show resolved Hide resolved
security/oc_tls.c Show resolved Hide resolved
security/oc_obt_otm_justworks.c Show resolved Hide resolved
security/oc_obt_otm_justworks.c Show resolved Hide resolved
api/oc_core_res_internal.h Show resolved Hide resolved
security/oc_security.c Show resolved Hide resolved
security/oc_pstat_internal.h Show resolved Hide resolved
security/oc_pstat_internal.h Show resolved Hide resolved
tests/gtest/PKI.h Show resolved Hide resolved
@Danielius1922 Danielius1922 added the OCF Conformance Testing OCF Conformance Testing required label Apr 16, 2024
@Danielius1922 Danielius1922 force-pushed the adam/bugfix/sc-fixes-15 branch from b01ba1c to 7bd262b Compare April 16, 2024 14:33
@ocf-conformance-test-tool ocf-conformance-test-tool bot removed the OCF Conformance Testing OCF Conformance Testing required label Apr 16, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Actionable comments outside the diff hunks (53)
api/cloud/oc_cloud_rd.c (1)

Line range hint 267-267: Avoid using memset() as it does not consider buffer boundaries and can lead to buffer overflows. Use memset_s() instead to enhance security.

- memset(&partition, 0, sizeof(rd_links_partition_t));
+ memset_s(&partition, sizeof(rd_links_partition_t), 0, sizeof(rd_links_partition_t));
api/oc_etag.c (5)

Line range hint 248-248: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(&etag_map, 0, sizeof(etag_map));
+  memset_s(&etag_map, sizeof(etag_map), 0, sizeof(etag_map));

Line range hint 524-526: Consider replacing memset with memset_s in multiple instances to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(&request, 0, sizeof(request));
+  memset_s(&request, sizeof(request), 0, sizeof(request));
-  memset(&response, 0, sizeof(response));
+  memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 571-571: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(&response_buffer, 0, sizeof(response_buffer));
+  memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 589-589: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(&result, 0, sizeof(result));
+  memset_s(&result, sizeof(result), 0, sizeof(result));

Line range hint 644-644: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(&response_buffer, 0, sizeof(response_buffer));
+  memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));
security/oc_pstat.c (3)

Line range hint 76-76: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(g_pstat, 0, sizeof(g_pstat));
+  memset_s(g_pstat, sizeof(g_pstat), 0, sizeof(g_pstat));

Line range hint 291-291: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(ps->rowneruuid.id, 0, sizeof(ps->rowneruuid.id));
+  memset_s(ps->rowneruuid.id, sizeof(ps->rowneruuid.id), 0, sizeof(ps->rowneruuid.id));

Line range hint 494-494: Consider replacing memset with memset_s to ensure buffer boundaries are respected and to prevent potential buffer overflows.

-  memset(ps, 0, sizeof(*ps));
+  memset_s(ps, sizeof(*ps), 0, sizeof(*ps));
api/oc_core_res.c (5)

Line range hint 109-109: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(g_core_resources, 0, sizeof(g_core_resources));
+ memset_s(g_core_resources, sizeof(g_core_resources), 0, sizeof(g_core_resources));

Line range hint 110-110: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(g_oc_device_info, 0, sizeof(g_oc_device_info));
+ memset_s(g_oc_device_info, sizeof(g_oc_device_info), 0, sizeof(g_oc_device_info));

Line range hint 286-287: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(device, 0, OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t));
+ memset_s(device, OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t), 0, OC_NUM_CORE_LOGICAL_DEVICE_RESOURCES * sizeof(oc_resource_t));

Line range hint 296-296: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&device_info[device_count], 0, sizeof(oc_device_info_t));
+ memset_s(&device_info[device_count], sizeof(oc_device_info_t), 0, sizeof(oc_device_info_t));

Line range hint 431-431: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&r->types, 0, sizeof(oc_string_array_t));
+ memset_s(&r->types, sizeof(oc_string_array_t), 0, sizeof(oc_string_array_t));
api/plgd/plgd_time.c (2)

Line range hint 518-518: Replace memset with memset_s to ensure buffer boundaries are considered, enhancing security against potential buffer overflows.

-  memset(&pt, 0, sizeof(pt));
+  memset_s(&pt, sizeof(pt), 0, sizeof(pt));

Line range hint 540-540: Replace memset with memset_s to ensure buffer boundaries are considered, enhancing security against potential buffer overflows.

-  memset(&pt, 0, sizeof(pt));
+  memset_s(&pt, sizeof(pt), 0, sizeof(pt));
security/oc_acl.c (4)

Line range hint 582-582: Replace memset() with memset_s() to ensure buffer boundaries are considered, preventing potential buffer overflows.

- memset(&subject, 0, sizeof(oc_ace_subject_t));
+ memset_s(&subject, sizeof(oc_ace_subject_t), 0, sizeof(oc_ace_subject_t));

Line range hint 600-600: Replace memset() with memset_s() to ensure buffer boundaries are considered, preventing potential buffer overflows.

- memset(&g_aclist[device].rowneruuid, 0, sizeof(oc_uuid_t));
+ memset_s(&g_aclist[device].rowneruuid, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Line range hint 649-649: Replace memset() with memset_s() to ensure buffer boundaries are considered, preventing potential buffer overflows.

- memset(&subject, 0, sizeof(oc_ace_subject_t));
+ memset_s(&subject, sizeof(oc_ace_subject_t), 0, sizeof(oc_ace_subject_t));

Line range hint 848-848: Replace memset() with memset_s() to ensure buffer boundaries are considered, preventing potential buffer overflows.

- memset(&_anon_clear, 0, sizeof(oc_ace_subject_t));
+ memset_s(&_anon_clear, sizeof(oc_ace_subject_t), 0, sizeof(oc_ace_subject_t));
api/oc_collection.c (4)

Line range hint 818-818: Replace memset() with memset_s() to ensure buffer boundaries are respected and prevent potential buffer overflows.

- memset(&response, 0, sizeof(oc_response_t));
+ memset_s(&response, sizeof(oc_response_t), 0, sizeof(oc_response_t));

Line range hint 820-820: Replace memset() with memset_s() to ensure buffer boundaries are respected and prevent potential buffer overflows.

- memset(&response_buffer, 0, sizeof(oc_response_buffer_t));
+ memset_s(&response_buffer, sizeof(oc_response_buffer_t), 0, sizeof(oc_response_buffer_t));

Line range hint 822-822: Replace memset() with memset_s() to ensure buffer boundaries are respected and prevent potential buffer overflows.

- memset(&rest_request, 0, sizeof(oc_request_t));
+ memset_s(&rest_request, sizeof(oc_request_t), 0, sizeof(oc_request_t));

Line range hint 850-850: Replace memset() with memset_s() to ensure buffer boundaries are respected and prevent potential buffer overflows.

- memset(&link_item, 0, sizeof(link_item));
+ memset_s(&link_item, sizeof(link_item), 0, sizeof(link_item));
security/oc_cred.c (4)

Line range hint 271-271: Replace memset with memset_s to enhance security by ensuring buffer boundaries are respected.

- memset(&uuid, 0, sizeof(oc_uuid_t));
+ memset_s(&uuid, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Line range hint 301-301: Replace memset with memset_s to enhance security by ensuring buffer boundaries are respected.

- memset(g_devices[device].rowneruuid.id, 0, OC_UUID_ID_SIZE);
+ memset_s(g_devices[device].rowneruuid.id, OC_UUID_ID_SIZE, 0, OC_UUID_ID_SIZE);

Line range hint 648-648: Replace memset with memset_s to enhance security by ensuring buffer boundaries are respected.

- memset(&public_key, 0, sizeof(oc_string_t));
+ memset_s(&public_key, sizeof(oc_string_t), 0, sizeof(oc_string_t));

Line range hint 668-668: Replace memset with memset_s to enhance security by ensuring buffer boundaries are respected.

- memset(&subject, 0, sizeof(oc_uuid_t));
+ memset_s(&subject, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));
messaging/coap/observe.c (16)

Line range hint 807-807: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 845-845: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&request, 0, sizeof(request));
+ memset_s(&request, sizeof(request), 0, sizeof(request));

Line range hint 847-847: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 849-849: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 923-923: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&request, 0, sizeof(request));
+ memset_s(&request, sizeof(request), 0, sizeof(request));

Line range hint 925-925: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 927-927: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 998-998: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&request, 0, sizeof(request));
+ memset_s(&request, sizeof(request), 0, sizeof(request));

Line range hint 1144-1144: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 1162-1162: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 1199-1199: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 1201-1201: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 1363-1363: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

Line range hint 1397-1397: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 1548-1548: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response, 0, sizeof(response));
+ memset_s(&response, sizeof(response), 0, sizeof(response));

Line range hint 1550-1550: Replace memset with memset_s to ensure buffer boundaries are respected, enhancing security.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));
api/oc_ri.c (7)

Line range hint 772-772: Replace memset with memset_s for safer memory initialization.

- memset(aux_arr, 0, sizeof(aux_arr));
+ memset_s(aux_arr, sizeof(aux_arr), 0, sizeof(aux_arr));

This change ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.


Line range hint 830-830: Replace memset with memset_s for safer memory initialization.

- memset(&handler, 0, sizeof(oc_request_handler_t));
+ memset_s(&handler, sizeof(oc_request_handler_t), 0, sizeof(oc_request_handler_t));

This change ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.


Line range hint 1246-1246: Replace memset with memset_s for safer memory initialization.

- memset(&result, 0, sizeof(result));
+ memset_s(&result, sizeof(result), 0, sizeof(result));

This change ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.


Line range hint 1686-1686: Replace memset with memset_s for safer memory initialization.

- 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 ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.


Line range hint 1741-1741: Replace memset with memset_s for safer memory initialization.

- memset(&response_buffer, 0, sizeof(response_buffer));
+ memset_s(&response_buffer, sizeof(response_buffer), 0, sizeof(response_buffer));

This change ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.


Line range hint 1745-1745: Replace memset with memset_s for safer memory initialization.

- memset(&response_obj, 0, sizeof(response_obj));
+ memset_s(&response_obj, sizeof(response_obj), 0, sizeof(response_obj));

This change ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.


Line range hint 1749-1749: Replace memset with memset_s for safer memory initialization.

- memset(&request_obj, 0, sizeof(request_obj));
+ memset_s(&request_obj, sizeof(request_obj), 0, sizeof(request_obj));

This change ensures that the buffer boundaries are respected, preventing potential buffer overflow issues.

security/oc_obt.c (2)

Line range hint 573-573: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&di, 0, sizeof(oc_uuid_t));
+ memset_s(&di, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

Line range hint 1425-1425: Replace memset with memset_s to ensure buffer boundaries are respected.

- memset(&subjectuuid, 0, sizeof(oc_uuid_t));
+ memset_s(&subjectuuid, sizeof(oc_uuid_t), 0, sizeof(oc_uuid_t));

@@ -106,7 +101,7 @@ get_new_aceid(size_t device)
return aceid;
}

static oc_ace_res_t *
oc_ace_res_t *
Copy link

Choose a reason for hiding this comment

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

Given the complexity of access control logic and the critical role it plays in security, it's essential to have comprehensive unit tests covering various scenarios, including different types of subjects (UUID, role, connection type), permissions, and resource specifications (specific resources, wildcards). This will help ensure that the access control logic behaves as expected across a wide range of cases.

Would you like assistance in creating a detailed test plan or implementing unit tests for these changes?

security/unittest/acltest.cpp Show resolved Hide resolved
security/oc_acl_util.c Show resolved Hide resolved
security/oc_acl_util.c Show resolved Hide resolved
security/oc_acl_util.c Show resolved Hide resolved
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
76.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@Danielius1922 Danielius1922 merged commit 603de5a into master Apr 16, 2024
123 of 124 checks passed
@Danielius1922 Danielius1922 deleted the adam/bugfix/sc-fixes-15 branch April 16, 2024 16:59
@github-actions github-actions bot locked and limited conversation to collaborators Apr 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant