Skip to content

Remove dead-code validation block for unbound distinguishedName variable (#5)#6

Merged
p0dalirius merged 1 commit into
mainfrom
bugfix-dead-distinguishedname-check
May 21, 2026
Merged

Remove dead-code validation block for unbound distinguishedName variable (#5)#6
p0dalirius merged 1 commit into
mainfrom
bugfix-dead-distinguishedname-check

Conversation

@p0dalirius

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #5

Root Cause

A package-level variable distinguishedName string was declared at main.go:33 and validated at L69–L72 inside parseArgs(), but no corresponding flag was ever registered with the argument parser. As a result, len(distinguishedName) was always 0 in parseArgs(), the validation branch never ran, and its warning text referenced a --distinguished-name option that does not exist. The same name happens to be used as a local variable inside parse.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.go referenced the variable. The local distinguishedName in parse.go (assigned from entry.GetAttributeValue("distinguishedName")) is unaffected.

How Verified

Static: grep -n "distinguishedName" main.go parse.go after the change confirms the only remaining references in main.go are the literal LDAP attribute name in the attributes slice and that parse.go continues to use its own local variable of the same name. Code compiles cleanly with go build.
Runtime: ./KeyCredentialHound -h shows 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

  • Files changed: main.go
  • Submodule pointer updated: no
  • Behavioral changes outside the bug fix: none

Risk and Rollout

Trivial: no observable behavior change. The removed validation never ran in any past invocation.

…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.
@p0dalirius p0dalirius self-assigned this May 21, 2026
@p0dalirius p0dalirius merged commit 962b855 into main May 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead-code validation block for unbound distinguishedName variable

1 participant