Remove dead-code validation block for unbound distinguishedName variable (#5)#6
Merged
Merged
Conversation
…ble (#5) The `distinguishedName` package variable was declared but never registered with the argument parser, so the validation branch checking it was unreachable and the warning message referenced a non-existent `--distinguished-name` flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes #5
Root Cause
A package-level variable
distinguishedName stringwas declared atmain.go:33and validated at L69–L72 insideparseArgs(), but no corresponding flag was ever registered with the argument parser. As a result,len(distinguishedName)was always0inparseArgs(), the validation branch never ran, and its warning text referenced a--distinguished-nameoption that does not exist. The same name happens to be used as a local variable insideparse.go's loop (where it stores the LDAP attribute of each entry), but those are unrelated scopes.Fix Description
Delete the unused package-level variable and the unreachable validation block. No other code in
main.goreferenced the variable. The localdistinguishedNameinparse.go(assigned fromentry.GetAttributeValue("distinguishedName")) is unaffected.How Verified
Static:
grep -n "distinguishedName" main.go parse.goafter the change confirms the only remaining references inmain.goare the literal LDAP attribute name in theattributesslice and thatparse.gocontinues to use its own local variable of the same name. Code compiles cleanly withgo build.Runtime:
./KeyCredentialHound -hshows the same help output as before;./KeyCredentialHound -dc 1.2.3.4 ...proceeds to the LDAP connection step exactly as it did previously (the removed block was unreachable).Test Coverage
None: the deleted code was unreachable; there is no behavior to cover with a test, and the repository has no Go test suite.
Scope of Change
main.goRisk and Rollout
Trivial: no observable behavior change. The removed validation never ran in any past invocation.