Skip to content

refactor(test): build LDAP fixtures via ldap.NewObject instead of unsafe - #255

Merged
CybotTM merged 1 commit into
mainfrom
fix/drop-unsafe-fixtures
Jul 29, 2026
Merged

refactor(test): build LDAP fixtures via ldap.NewObject instead of unsafe#255
CybotTM merged 1 commit into
mainfrom
fix/drop-unsafe-fixtures

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 29, 2026

Copy link
Copy Markdown
Member

simple-ldap-go v1.14.0 adds func NewObject(cn, dn string) Object (netresearch/simple-ldap-go#191). Until then Object.cn/Object.dn were written only by the package-internal objectFromEntry, so a consumer could not construct a fixture with a DN through the public API — the test helper reached for reflect plus unsafe.Pointer(dnField.UnsafeAddr()), which gosec reports as G103.

Removed: setObjectDN() and the reflect/unsafe imports in internal/server/test_helpers_test.go. The three mock users (admin, user1, user2) now get their Object from ldap.NewObject(cn, dn) in the struct literal.

setObjectDN only wrote dn and left cn empty; NewObject takes both. Each fixture uses the leading RDN of its own DN as the cn — CN=admin,OU=Users,DC=example,DC=com gives "admin" — which is what the directory would return for these entries. Nothing in raybeam reads CN() today, so this only makes the fixtures less lopsided.

go mod tidy also dropped stale duplicate entries in go.sum (older go-ldap, gofiber, asn1-ber versions that no longer resolve).

simple-ldap-go v1.14.0 adds NewObject(cn, dn), so the mock LDAP fixtures
no longer need reflect + unsafe.Pointer to write the unexported Object.dn
field. setObjectDN is gone; the DN now comes from the struct literal.

The constructor also sets cn, which setObjectDN left empty. Each fixture
gets the cn from the leading RDN of its own DN (CN=admin -> "admin").

Refs: netresearch/simple-ldap-go#191
Signed-off-by: Sebastian Mendel <[email protected]>
Copilot AI review requested due to automatic review settings July 29, 2026 00:17
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
gomod/github.com/netresearch/simple-ldap-go 1.14.0 🟢 7.5
Details
CheckScoreReason
Packaging⚠️ -1packaging workflow not detected
Dependency-Update-Tool🟢 10update tool detected
Code-Review🟢 10all changesets reviewed
Security-Policy🟢 4security policy file detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Binary-Artifacts🟢 10no binaries found in the repo
Maintained🟢 1030 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Vulnerabilities🟢 73 existing vulnerabilities detected
SAST🟢 10SAST tool is run on all commits
Signed-Releases⚠️ 0Project has not signed or included provenance with any releases.
License🟢 10license file detected
Fuzzing🟢 10project is fuzzed
Branch-Protection🟢 3branch protection is not maximal on development and all release branches
Contributors🟢 10project has 9 contributing companies or organizations
CI-Tests🟢 1014 out of 14 merged PRs checked by a CI test -- score normalized to 10

Scanned Files

  • go.mod

@sonarqubecloud

Copy link
Copy Markdown

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file tests labels Jul 29, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.70%. Comparing base (f963d3c) to head (44d5307).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #255   +/-   ##
=======================================
  Coverage   74.70%   74.70%           
=======================================
  Files          10       10           
  Lines         427      427           
=======================================
  Hits          319      319           
  Misses         88       88           
  Partials       20       20           
Flag Coverage Δ
e2e 74.70% <ø> (ø)
integration 74.70% <ø> (ø)
unittests 74.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CybotTM
CybotTM added this pull request to the merge queue Jul 29, 2026
Merged via the queue into main with commit c78730a Jul 29, 2026
27 of 28 checks passed
@CybotTM
CybotTM deleted the fix/drop-unsafe-fixtures branch July 29, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants