From 56e5759aadc48129a33935b9de05b17151c1172e Mon Sep 17 00:00:00 2001 From: gustavoluvizotto Date: Fri, 3 May 2024 18:15:32 +0200 Subject: [PATCH 1/4] Fix LDAP GetError and LDAP search (#509) * When trying to parse ldap error, value can be nil --- error.go | 2 +- search.go | 6 +++++- v3/error.go | 2 +- v3/search.go | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/error.go b/error.go index 53c6d62..0014ffe 100644 --- a/error.go +++ b/error.go @@ -220,7 +220,7 @@ func GetLDAPError(packet *ber.Packet) error { return &Error{ ResultCode: resultCode, MatchedDN: response.Children[1].Value.(string), - Err: fmt.Errorf("%s", response.Children[2].Value.(string)), + Err: fmt.Errorf("%v", response.Children[2].Value), Packet: packet, } } diff --git a/search.go b/search.go index b5550ba..62be105 100644 --- a/search.go +++ b/search.go @@ -579,9 +579,13 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { return result, ErrSizeLimitExceeded } + attr := make([]*ber.Packet, 0) + if len(packet.Children[1].Children) > 1 { + attr = packet.Children[1].Children[1].Children + } entry := &Entry{ DN: packet.Children[1].Children[0].Value.(string), - Attributes: unpackAttributes(packet.Children[1].Children[1].Children), + Attributes: unpackAttributes(attr), } result.Entries = append(result.Entries, entry) case 5: diff --git a/v3/error.go b/v3/error.go index 53c6d62..0014ffe 100644 --- a/v3/error.go +++ b/v3/error.go @@ -220,7 +220,7 @@ func GetLDAPError(packet *ber.Packet) error { return &Error{ ResultCode: resultCode, MatchedDN: response.Children[1].Value.(string), - Err: fmt.Errorf("%s", response.Children[2].Value.(string)), + Err: fmt.Errorf("%v", response.Children[2].Value), Packet: packet, } } diff --git a/v3/search.go b/v3/search.go index b5550ba..62be105 100644 --- a/v3/search.go +++ b/v3/search.go @@ -579,9 +579,13 @@ func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error) { return result, ErrSizeLimitExceeded } + attr := make([]*ber.Packet, 0) + if len(packet.Children[1].Children) > 1 { + attr = packet.Children[1].Children[1].Children + } entry := &Entry{ DN: packet.Children[1].Children[0].Value.(string), - Attributes: unpackAttributes(packet.Children[1].Children[1].Children), + Attributes: unpackAttributes(attr), } result.Entries = append(result.Entries, entry) case 5: From dbdc485259442f987d83e604cd4f5859cfc1be58 Mon Sep 17 00:00:00 2001 From: Christopher Puschmann Date: Tue, 28 May 2024 19:36:51 +0200 Subject: [PATCH 2/4] chore: Fix desynced root and v3 directory (#521) As pointed out in https://github.com/go-ldap/ldap/issues/520#issue-2319762177, the subdirectory v3 has been out of sync. This PR copies all missing changes to the root directory. --- conn.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conn.go b/conn.go index bf5b07a..05febbc 100644 --- a/conn.go +++ b/conn.go @@ -535,9 +535,10 @@ func (l *Conn) processMessages() { l.messageContexts[message.MessageID] = message.Context // Add timeout if defined - if l.getTimeout() > 0 { + requestTimeout := l.getTimeout() + if requestTimeout > 0 { go func() { - timer := time.NewTimer(time.Duration(l.getTimeout())) + timer := time.NewTimer(time.Duration(requestTimeout)) defer func() { if err := recover(); err != nil { l.err = fmt.Errorf("ldap: recovered panic in RequestTimeout: %v", err) From bc6bdd8fdaf43f1be891821039121282eb8dd43a Mon Sep 17 00:00:00 2001 From: Tetsuya Morimoto Date: Tue, 20 Aug 2024 18:30:27 +0900 Subject: [PATCH 3/4] ci: Add go 1.23 build/testing to github workflow (#526) --- .github/workflows/lint.yml | 2 +- .github/workflows/pr.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f57089b..8fb17e1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.22' + go-version: '1.23' cache: false - uses: actions/checkout@v3 - name: golangci-lint diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 14d1089..2ed8bc7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,6 +10,7 @@ jobs: strategy: matrix: go: [ + '1.23', '1.22', '1.21', '1.20', From 25c2d4887969f129839932c7af45a3a2e68fe97e Mon Sep 17 00:00:00 2001 From: Tetsuya Morimoto Date: Wed, 21 Aug 2024 04:06:46 +0900 Subject: [PATCH 4/4] ci: bump action versions in github actions (#527) --- .github/workflows/lint.yml | 6 +++--- .github/workflows/pr.yml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8fb17e1..4f47342 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,13 +11,13 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version: '1.23' cache: false - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: version: latest only-new-issues: true diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2ed8bc7..1dc683c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,10 +25,10 @@ jobs: name: Go ${{ matrix.go }}.x PR Validate ${{ matrix.branch }} (Modules) steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} @@ -47,9 +47,9 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v6 with: - version: v1.50.0 + version: latest only-new-issues: true