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

V-93037 Add edge case for single OU #83

Closed
karikarshivani opened this issue Sep 9, 2022 · 0 comments · Fixed by #87
Closed

V-93037 Add edge case for single OU #83

karikarshivani opened this issue Sep 9, 2022 · 0 comments · Fixed by #87
Assignees
Labels
bug Something isn't working

Comments

@karikarshivani
Copy link
Contributor

karikarshivani commented Sep 9, 2022

This code block might be leading to the following error when running the profile against a Domain Controller:

ou_list = json(command: "Get-ADOrganizationalUnit -filter * -SearchBase '#{distinguishedName}' | Select-Object -ExpandProperty distinguishedname | ConvertTo-Json").params

ou_list.each do |ou|
         acl_rules = json(command: "(Get-ACL -Audit -Path AD:'#{ou}').Access | ConvertTo-CSV | ConvertFrom-CSV | ConvertTo-JSON").params

Error:

undefined method `each' for "OU=Domain Controllers,DC=saf,DC=cms":String

Recommendation:
Since the tests are 100 lines long, the easiest way to address this would be to set the variable as an array early on so single values don't affect the for loop.

ou_list = []
ou_list << json(command: <cmd>).params
if ou_list.empty?
  <skip>
else
  <for loop with tests>
@karikarshivani karikarshivani self-assigned this Sep 9, 2022
@karikarshivani karikarshivani added the bug Something isn't working label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant