-
Notifications
You must be signed in to change notification settings - Fork 53
Bed 6619 collection of objectguid #253
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
Bed 6619 collection of objectguid #253
Conversation
WalkthroughAdds ObjectGUID handling for computer objects: includes Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant Processor as LdapPropertyProcessor
participant LDAP as LDAP Entry
Caller->>Processor: ReadComputerProperties(entry)
Processor->>LDAP: Read standard computer properties
Processor->>LDAP: Read `objectguid` bytes (optional)
alt objectguid present && bytes length == 16
Note right of Processor #DDEEFF: try/catch GUID construction
Processor->>Processor: Byte[] -> Guid -> ToString().ToUpperInvariant()
Processor->>Processor: props["ObjectGUID"] = guidString
else missing or invalid
Note right of Processor #F6F6F6: Skip ObjectGUID population
end
Processor-->>Caller: props dictionary
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)test/unit/LdapPropertyTests.cs (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
test/unit/LdapPropertyTests.cs (1)
439-603: Add test cases for ObjectGUID edge cases.Consider adding dedicated test cases to cover:
- Computer with null objectguid (graceful skip)
- Computer with empty byte array for objectguid
- Computer with malformed objectguid bytes (not 16 bytes)
These tests would verify the defensive handling suggested in the processor review and ensure devices without valid ObjectGUIDs "fail gracefully" as mentioned in the PR description.
Do you want me to generate example test cases for these scenarios?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/CommonLib/LdapQueries/CommonProperties.cs(1 hunks)src/CommonLib/Processors/LdapPropertyProcessor.cs(1 hunks)test/unit/LdapPropertyTests.cs(6 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
test/unit/LdapPropertyTests.cs (1)
test/unit/Utils.cs (2)
Utils(11-23)B64ToBytes(13-16)
src/CommonLib/LdapQueries/CommonProperties.cs (1)
src/CommonLib/Enums/LDAPProperties.cs (1)
LDAPProperties(3-99)
src/CommonLib/Processors/LdapPropertyProcessor.cs (4)
src/CommonLib/DirectoryObjects/DirectoryEntryWrapper.cs (1)
GetByteProperty(177-181)src/CommonLib/DirectoryObjects/IDirectoryObject.cs (1)
GetByteProperty(17-17)src/CommonLib/DirectoryObjects/SearchResultEntryWrapper.cs (1)
GetByteProperty(177-191)src/CommonLib/Enums/LDAPProperties.cs (1)
LDAPProperties(3-99)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (2)
test/unit/LdapPropertyTests.cs (1)
395-395: ObjectGUID is not processed for user objects.The objectguid test data added here won't be processed because
ReadUserPropertiesin LdapPropertyProcessor.cs does not extract the ObjectGUID. OnlyReadComputerPropertiesincludes ObjectGUID extraction logic (lines 439-444).Consider removing this test data or clarifying why it's included if it's for future use.
src/CommonLib/LdapQueries/CommonProperties.cs (1)
34-34: LGTM! Correctly adds ObjectGUID to computer method properties.This change is necessary to ensure ObjectGUID is fetched during computer object queries, enabling the extraction logic in
ReadComputerProperties. The placement is appropriate and consistent with existing property declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/CommonLib/Processors/LdapPropertyProcessor.cs (1)
447-450: Consider catching ArgumentException specifically.The general catch block works but could mask unexpected exceptions. Since
new Guid(byte[])throwsArgumentExceptionfor invalid input, catching it specifically improves clarity and error handling.Apply this diff:
- catch + catch (ArgumentException) { // Skip malformed GUID bytes }test/unit/LdapPropertyTests.cs (2)
395-395: Remove unused objectguid test data.This test is for
ReadUserProperties, which doesn't process ObjectGUID (onlyReadComputerPropertiesdoes, per the PR scope). The objectguid entry is unused and could be removed for clarity.
1459-1459: Add assertions to verify ObjectGUID extraction.The test includes objectguid in the test data but doesn't assert it's correctly processed. Add assertions after line 1490 to verify extraction, similar to other computer property tests.
Add these assertions:
Assert.Contains("objectguid", keys); Assert.Equal("A6F75BA4-F1AE-4B47-A606-E3A0A69AEC83", props["objectguid"]);Note: You'll need to extract
propsandkeysfrom the test result, similar to how it's done in other tests around lines 1422-1423.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/CommonLib/Processors/LdapPropertyProcessor.cs(1 hunks)test/unit/LdapPropertyTests.cs(8 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
test/unit/LdapPropertyTests.cs (1)
test/unit/Utils.cs (2)
Utils(11-23)B64ToBytes(13-16)
src/CommonLib/Processors/LdapPropertyProcessor.cs (5)
src/CommonLib/DirectoryObjects/DirectoryEntryWrapper.cs (1)
GetByteProperty(177-181)src/CommonLib/DirectoryObjects/IDirectoryObject.cs (1)
GetByteProperty(17-17)src/CommonLib/DirectoryObjects/SearchResultEntryWrapper.cs (1)
GetByteProperty(177-191)test/unit/Facades/MockDirectoryObject.cs (1)
GetByteProperty(151-153)src/CommonLib/Enums/LDAPProperties.cs (1)
LDAPProperties(3-99)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
test/unit/LdapPropertyTests.cs (1)
547-548: LGTM!The assertions correctly verify ObjectGUID extraction with proper uppercase formatting matching the implementation.
Description
Motivation and Context
How Has This Been Tested?
Locally in a hybrid lab with both Entra and AD devices. I ran SharpHound
in an AD environment and observed the ObjectGuid being populated in the
collect and eventually in the BH info panel. If a device does not have an ObjectGUID,
it will simply ignore and fail gracefully.
Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Tests