Skip to content

Conversation

@rcasallas-silabs
Copy link
Contributor

Summary

Adds a wrapper to the AccessControl, so virtual ACL entries may be automatically added by the Groupcast cluster, without affecting the actual ACL entries managed by the Access Control cluster.

Related issues

Testing

Readability checklist

The checklist below will help the reviewer finish PR review in time and keep the
code readable:

  • PR title is
    descriptive
  • Apply the
    “When in Rome…”
    rule (coding style)
  • PR size is short
  • Try to avoid "squashing" and "force-update" in commit history
  • CI time didn't increase

See: Pull Request Guidelines

Copilot AI review requested due to automatic review settings November 20, 2025 17:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an experimental groupcast access control feature by implementing a wrapper around the existing AccessControl system. The wrapper allows virtual ACL entries to be automatically managed by the Groupcast cluster without modifying the ACL entries handled by the Access Control cluster.

Key changes:

  • Adds a new PersistentArray template class for managing persistent storage of array data
  • Implements GroupcastAccessControlDelegate to manage groupcast-specific ACL entries
  • Introduces ExtendedAccessControlDelegate to combine primary and secondary access control delegates

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/lib/support/PersistentArray.h New template class for persistent array storage with serialization support
src/lib/support/DefaultStorageKeyAllocator.h Adds storage key allocation for groupcast access control data
src/app/server/Server.h Integrates extended access control delegate into server initialization
src/app/server/Server.cpp Declares static instance of ExtendedAccessControlDelegate
src/access/examples/GroupcastAccessControlDelegate.h Header defining interface for groupcast access control
src/access/examples/GroupcastAccessControlDelegate.cpp Implementation of groupcast-specific access control delegate
src/access/examples/ExtendedAccessControlDelegate.h Header for delegate that combines primary and secondary access controls
src/access/examples/ExtendedAccessControlDelegate.cpp Implementation of the extended access control wrapper
src/access/ExtendedAccessControlDelegate.h Duplicate header file for extended access control delegate
src/access/ExtendedAccessControlDelegate.cpp Duplicate implementation file for extended access control delegate
src/access/BUILD.gn Updates build configuration to include new delegate files
Comments suppressed due to low confidence (1)

src/lib/support/PersistentArray.h:1

  • The equality operator should return true when fabric indices are equal, not when they are different. Change != to ==.
/*


virtual CHIP_ERROR Next(Entry & entry) override
{
if(mIndex < sList.Count()) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Missing space after if keyword. Should be if (mIndex < sList.Count()).

Suggested change
if(mIndex < sList.Count()) {
if (mIndex < sList.Count()) {

Copilot uses AI. Check for mistakes.
Comment on lines +459 to +461
// FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
FabricIndex fabric_index = 1;
// FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Hardcoded fabric index value needs to be replaced with proper fabric index handling. This appears in multiple methods (GetEntryCount, CreateEntry, ReadEntry, UpdateEntry, DeleteEntry).

Copilot uses AI. Check for mistakes.

AccessControl::Delegate * GetAccessControlDelegate(PersistentStorageDelegate *storage) {
static AccessControlDelegate sDelegate;
if(storage) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Missing space after if keyword. Should be if (storage).

Suggested change
if(storage) {
if (storage) {

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +23
if(mFirst) {
mFirst->Release();
}
if(mSecond) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Missing space after if keyword. Should be if (mFirst) and if (mSecond).

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +34
if(CHIP_NO_ERROR == mError) {
mError = mFirst->Next(entry);
}
if(mSecond && (CHIP_ERROR_SENTINEL == mError)) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Missing space after if keyword. Should be if (CHIP_NO_ERROR == mError) and if (mSecond && (CHIP_ERROR_SENTINEL == mError)).

Copilot uses AI. Check for mistakes.
// Capabilities
CHIP_ERROR ExtendedAccessControlDelegate::GetMaxEntriesPerFabric(size_t & value) const
{
ChipLogDetail(DeviceLayer, "~~~ ExtendedAccessControlDelegate::GetMaxEntriesPerFabric: #%p/%p\n", mPrimary, mSecondary);
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Debug logging statements should be removed or converted to proper debug macros before merging experimental code.

Suggested change
ChipLogDetail(DeviceLayer, "~~~ ExtendedAccessControlDelegate::GetMaxEntriesPerFabric: #%p/%p\n", mPrimary, mSecondary);

Copilot uses AI. Check for mistakes.
// Iteration
CHIP_ERROR ExtendedAccessControlDelegate::Entries(AccessControl::EntryIterator & iterator, const FabricIndex * fabricIndex) const {
VerifyOrReturnError(nullptr != mPrimary || nullptr != mSecondary, CHIP_ERROR_INCORRECT_STATE);
ChipLogDetail(DeviceLayer, "~~~ ExtendedAccessControlDelegate::Entries: #%p/%p\n", mPrimary, mSecondary);
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Debug logging statements should be removed or converted to proper debug macros before merging experimental code.

Suggested change
ChipLogDetail(DeviceLayer, "~~~ ExtendedAccessControlDelegate::Entries: #%p/%p\n", mPrimary, mSecondary);

Copilot uses AI. Check for mistakes.
entry.subject_count = 0;
memset(entry.subjects, 0x00, sizeof(entry.subjects));
entry.target_count = 0;
for(size_t i=0; i < kMaxTargets; i++) {
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Missing spaces around operators. Should be for (size_t i = 0; i < kMaxTargets; i++).

Suggested change
for(size_t i=0; i < kMaxTargets; i++) {
for (size_t i = 0; i < kMaxTargets; i++) {

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +65
"examples/ExtendedAccessControlDelegate.cpp",
"examples/ExtendedAccessControlDelegate.h",
"examples/GroupcastAccessControlDelegate.cpp",
"examples/GroupcastAccessControlDelegate.h",
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Files are duplicated in both src/access/examples/ and src/access/ directories. These duplicate files (ExtendedAccessControlDelegate.h/cpp) should be consolidated to a single location.

Copilot uses AI. Check for mistakes.
ReturnErrorOnFailure(this->Load());
for (size_t i = this->mCount; (this->mCount > 0) && (i > 0); --i)
{
return Remove(i - 1);
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The loop will only execute once due to the unconditional return statement inside. The return should be changed to ReturnErrorOnFailure(Remove(i - 1)); to continue removing all entries.

Suggested change
return Remove(i - 1);
ReturnErrorOnFailure(Remove(i - 1));

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

PR #42066: Size comparison from ee2ab5e to acd89dd

Increases above 0.2%:

platform target config section ee2ab5e acd89dd change % change
realtek light-switch-app rtl8777g FLASH 709256 715368 6112 0.9
RAM 107148 111052 3904 3.6
lighting-app rtl8777g FLASH 757960 764080 6120 0.8
RAM 127296 131192 3896 3.1
stm32 light STM32WB5MM-DK FLASH 470592 475124 4532 1.0
RAM 141352 145244 3892 2.8
Full report (3 builds for realtek, stm32)
platform target config section ee2ab5e acd89dd change % change
realtek light-switch-app rtl8777g FLASH 709256 715368 6112 0.9
RAM 107148 111052 3904 3.6
lighting-app rtl8777g FLASH 757960 764080 6120 0.8
RAM 127296 131192 3896 3.1
stm32 light STM32WB5MM-DK FLASH 470592 475124 4532 1.0
RAM 141352 145244 3892 2.8

}


void ExtendedAccessControlDelegate::Release() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Extended should be renamed to Auxiliary everywhere

Comment on lines +134 to +140
AccessControl::EntryIterator first;
ReturnErrorOnFailure(mPrimary->Entries(first, fabricIndex)); // TODO: OPTIONAL fabricIndex
AccessControl::EntryIterator::Delegate *it1 = &first.GetDelegate();
// Secondary
AccessControl::EntryIterator second;
ReturnErrorOnFailure(mSecondary->Entries(second, fabricIndex));
AccessControl::EntryIterator::Delegate *it2 = &second.GetDelegate();
Copy link
Contributor

Choose a reason for hiding this comment

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

What difference between primary and secondary?

}

// Groupcast
static StorageKeyName GroupcastAccess(chip::FabricIndex fabric) { return StorageKeyName::Formatted("f/%x/ga", fabric); }
Copy link
Contributor

Choose a reason for hiding this comment

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

What is stored there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants