Bug Description
When the SCCM module is executed with the following option:
-o REC_RESOLVE=TRUE
the module crashes during recursive object resolution.
Root Cause
The resolve_recursive() method builds an LDAP filter using a Distinguished Name (DN) without escaping LDAP special characters. If the DN contains characters that require escaping, the resulting LDAP filter is malformed, causing the LDAP query to fail and the module to terminate unexpectedly.
Steps to Reproduce:
- Run the SCCM module with recursive resolution enabled:
o REC_RESOLVE=TRUE
- Execute the module against an environment containing objects whose Distinguished Names include characters requiring LDAP filter escaping.
- Observe that the module crashes during recursive resolution.
Expected Behavior
The DN should be properly escaped before being incorporated into the LDAP filter, allowing recursive resolution to complete successfully without errors.
Actual Behavior
The module constructs an invalid LDAP filter, causing the LDAP query to fail and the SCCM module to crash.
Proposed Fix
Escape the Distinguished Name before it is inserted into the LDAP filter within the resolve_recursive() method. This ensures that LDAP filters remain valid regardless of the DN contents and prevents crashes when recursive resolution is enabled.
Note: I have also submitted a pull request with this fix in sccm.py. The changes resolve the issue in my environment, and recursive resolution now works correctly with REC_RESOLVE=TRUE. Please review the implementation and let me know if any modifications are required.
Bug Description
When the SCCM module is executed with the following option:
-o REC_RESOLVE=TRUEthe module crashes during recursive object resolution.
Root Cause
The resolve_recursive() method builds an LDAP filter using a Distinguished Name (DN) without escaping LDAP special characters. If the DN contains characters that require escaping, the resulting LDAP filter is malformed, causing the LDAP query to fail and the module to terminate unexpectedly.
Steps to Reproduce:
o REC_RESOLVE=TRUEExpected Behavior
The DN should be properly escaped before being incorporated into the LDAP filter, allowing recursive resolution to complete successfully without errors.
Actual Behavior
The module constructs an invalid LDAP filter, causing the LDAP query to fail and the SCCM module to crash.
Proposed Fix
Escape the Distinguished Name before it is inserted into the LDAP filter within the resolve_recursive() method. This ensures that LDAP filters remain valid regardless of the DN contents and prevents crashes when recursive resolution is enabled.
Note: I have also submitted a pull request with this fix in sccm.py. The changes resolve the issue in my environment, and recursive resolution now works correctly with REC_RESOLVE=TRUE. Please review the implementation and let me know if any modifications are required.