Attribute ai_tools Windows rows from ProfileList, not the directory owner - #51083
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #51083 +/- ##
==========================================
+ Coverage 68.56% 68.65% +0.08%
==========================================
Files 3993 3994 +1
Lines 257379 257558 +179
Branches 13684 13684
==========================================
+ Hits 176484 176821 +337
+ Misses 65189 65018 -171
- Partials 15706 15719 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f8652f5 to
819e23e
Compare
…wner Resolves #51061 A profile directory's security-descriptor OWNER is an ACL field naming whoever administers the object, not the profile's user — on an administrator's profile it is commonly BUILTIN\Administrators. That put the group SID S-1-5-32-544 in uid and left username blank on every user-scoped row. Enumerate HKLM\...\ProfileList instead, which is where Windows records which account a profile belongs to, so a home arrives with its SID already attached. The key is admin-only-writable, preserving the anti-spoofing property the owner read was chosen for. The owner read stays as a fallback for homes the key does not record, now gated on the SID naming a user account so a group or well-known SID reports empty rather than a misleading value.
819e23e to
4e346da
Compare
WalkthroughThe homes package now centralizes path validation and deduplication. Platform-recorded homes are added before scanned directories. Unix ownership returns UID and best-effort username values. Windows discovery reads ProfileList entries, filters user SIDs and local paths, expands and canonicalizes paths, and verifies on-disk directories. Windows tests cover ownership attribution, profile validation, SID filtering, redirected profiles, unresolved accounts, and verification order. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
orbit/pkg/table/ai_tools/internal/homes/homes_windows_test.go (1)
204-219: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: cover the lowercase drive letter branch.
isLocalDriveAbsaccepts both'A'..'Z'and'a'..'z'. The rejection cases here and the accepted paths inTestProfileHomesall use an uppercase drive letter, so the lowercase half of that condition is never exercised. A single accepted entry withc:\Users\xpkoawould pin the branch.💚 Proposed addition
func TestProfileHomesRejectsNonLocalPaths(t *testing.T) { lookup := accountLookup(map[string]string{sidLocalUser: "xpkoa"}) + // A lowercase drive letter is a valid local path. + checkProfileHomes(t, []profileEntry{{SID: sidLocalUser, Path: `c:\Users\xpkoa`}}, + lookup, diskAlwaysConsistent, []Home{{UID: sidLocalUser, Username: "xpkoa", Dir: `c:\Users\xpkoa`}}) + for _, path := range []string{🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@orbit/pkg/table/ai_tools/internal/homes/homes_windows_test.go` around lines 204 - 219, Add a lowercase-drive accepted case to TestProfileHomes, using c:\Users\xpkoa for the local user entry, so the lowercase branch of isLocalDriveAbs is exercised while preserving the existing assertions and test structure.orbit/pkg/table/ai_tools/internal/homes/owner_windows.go (1)
103-119: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: express
userAccountForSIDthroughresolveUserAccount.Both functions run the same two steps: the
isNonUserSIDvalue gate, thenLookupAccount("")with aSidTypeUsercheck. The only difference is the treatment of a failed lookup, anduserAccountForSIDmaps that tofalse, which equalsres != resolvedUser. One implementation removes the risk that the two gates drift apart later.♻️ Proposed consolidation
func userAccountForSID(sid *windows.SID) (string, bool) { - if isNonUserSID(sid.String()) { - return "", false - } - account, _, accType, err := sid.LookupAccount("") - if err != nil || accType != windows.SidTypeUser { - return "", false - } - return account, true + account, res := resolveUserAccount(sid.String()) + return account, res == resolvedUser }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@orbit/pkg/table/ai_tools/internal/homes/owner_windows.go` around lines 103 - 119, Optionally consolidate userAccountForSID with resolveUserAccount by reusing resolveUserAccount’s non-user SID gate and account lookup/type validation, mapping unresolved results to an empty account and false. Preserve userAccountForSID’s bare account-name return contract and avoid duplicating the validation logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@orbit/pkg/table/ai_tools/internal/homes/homes_windows_test.go`:
- Around line 204-219: Add a lowercase-drive accepted case to TestProfileHomes,
using c:\Users\xpkoa for the local user entry, so the lowercase branch of
isLocalDriveAbs is exercised while preserving the existing assertions and test
structure.
In `@orbit/pkg/table/ai_tools/internal/homes/owner_windows.go`:
- Around line 103-119: Optionally consolidate userAccountForSID with
resolveUserAccount by reusing resolveUserAccount’s non-user SID gate and account
lookup/type validation, mapping unresolved results to an empty account and
false. Preserve userAccountForSID’s bare account-name return contract and avoid
duplicating the validation logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ddf86a4f-e3dc-4594-95f7-84980adc7a5d
⛔ Files ignored due to path filters (1)
orbit/pkg/table/ai_tools/README.mdis excluded by!**/*.md
📒 Files selected for processing (6)
orbit/pkg/table/ai_tools/internal/homes/homes.goorbit/pkg/table/ai_tools/internal/homes/homes_windows_test.goorbit/pkg/table/ai_tools/internal/homes/owner_other.goorbit/pkg/table/ai_tools/internal/homes/owner_unix.goorbit/pkg/table/ai_tools/internal/homes/owner_unix_test.goorbit/pkg/table/ai_tools/internal/homes/owner_windows.go
Resolves #51061
A profile directory's security-descriptor OWNER is an ACL field naming whoever administers the object, not the profile's user — on an administrator's profile it is commonly BUILTIN\Administrators. That put the group SID S-1-5-32-544 in uid and left username blank on every user-scoped row.
Enumerate HKLM...\ProfileList instead, which is where Windows records which account a profile belongs to, so a home arrives with its SID already attached. The key is admin-only-writable, preserving the anti-spoofing property the owner read was chosen for. The owner read stays as a fallback for homes the key does not record, now gated on the SID naming a user account so a group or well-known SID reports empty rather than a misleading value.
Checklist for submitter
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Summary by CodeRabbit