turbot / steampipe-plugin-ldap

Use SQL to instantly query users, groups, OUs and more from LDAP. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/ldap
Apache License 2.0
9 stars 1 forks source link

function getOrganizationUnit crash if DN does not contains OU and no results will returned #9

Closed harlequin closed 2 years ago

harlequin commented 2 years ago

Describe the bug getOrganizationUnit crash if DN does not contains OU

func getOrganizationUnit(dn string) string {
    return dn[strings.Index(strings.ToUpper(dn), "OU"):]  // Here the function will crash in case OU not exists
}

Proposal is to change to logic like

func getOrganizationUnit(dn string) string {
    index := strings.Index(strings.ToUpper(dn), "OU")
    if index > -1 {
        return dn[index:]
    } else {
        return ""
    }
}
misraved commented 2 years ago

Thanks @harlequin for using Steampipe 👍

We will look into this issue and provide you with feedback shortly.

misraved commented 2 years ago

Thanks @harlequin for catching the issue 👍 .

The solution seems correct. Would you like to make the change by creating a pull request with the above-suggested logic?

Would really appreciate your contribution here 👍.

harlequin commented 2 years ago

PR is generated