Skip to content

Commit 031e5bf

Browse files
authored
Merge pull request #5924 from stellar/main
Merge master into protocol-next branch
2 parents e4d2cd5 + cbd4462 commit 031e5bf

5 files changed

Lines changed: 74 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ This monorepo contains a number of sdk's:
1212
Official project releases may be found here: https://github.com/stellar/go-stellar-sdk/releases
1313
## Pending
1414

15+
## [0.3.0]
16+
17+
### Security Fixes
18+
* historyarchive: Added size bound to `GetPathHAS` to prevent resource exhaustion ([#5918](https://github.com/stellar/go-stellar-sdk/pull/5918))
19+
20+
### New Features
21+
* xdr: Added `SafeUnmarshalBase64WithOptions` and regenerated with output size tracking ([#5916](https://github.com/stellar/go-stellar-sdk/pull/5916))
22+
1523
## [0.2.0]
1624

1725
### Breaking Changes

support/datastore/gcs.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,11 @@ func (b GCSDataStore) putFile(ctx context.Context, filePath string, in io.Writer
209209
func (b GCSDataStore) ListFilePaths(ctx context.Context, options ListFileOptions) ([]string, error) {
210210
var fullPrefix string
211211

212-
// When 'prefix' is empty, ensure the base prefix ends with a slash (e.g., "a/b/")
213-
// so the query returns only objects within that directory, not similarly named paths like "a/b-1".
214-
if options.Prefix == "" {
215-
fullPrefix = b.prefix
216-
if !strings.HasSuffix(fullPrefix, "/") {
217-
fullPrefix += "/"
218-
}
219-
} else {
220-
// Join the caller-provided prefix with the datastore prefix
221-
fullPrefix = path.Join(b.prefix, options.Prefix)
212+
// Ensure the prefix ends with a slash so the query returns only objects
213+
// within that directory, not similarly named paths like "a/b-1".
214+
fullPrefix = path.Join(b.prefix, options.Prefix)
215+
if fullPrefix != "" {
216+
fullPrefix += "/"
222217
}
223218

224219
var StartAfter string

support/datastore/gcs_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,40 @@ func TestGCSListFilePaths(t *testing.T) {
437437
require.Equal(t, []string{"a", "b"}, paths)
438438
}
439439

440+
func TestGCSListFilePaths_NoPrefix(t *testing.T) {
441+
server := fakestorage.NewServer([]fakestorage.Object{
442+
{
443+
ObjectAttrs: fakestorage.ObjectAttrs{BucketName: "test-bucket", Name: "a"},
444+
Content: []byte("1"),
445+
},
446+
{
447+
ObjectAttrs: fakestorage.ObjectAttrs{BucketName: "test-bucket", Name: "b"},
448+
Content: []byte("1"),
449+
},
450+
{
451+
ObjectAttrs: fakestorage.ObjectAttrs{BucketName: "test-bucket", Name: "c"},
452+
Content: []byte("1"),
453+
},
454+
})
455+
defer server.Stop()
456+
457+
store, err := FromGCSClient(context.Background(), server.Client(), "test-bucket")
458+
require.NoError(t, err)
459+
t.Cleanup(func() { _ = store.Close() })
460+
461+
paths, err := store.ListFilePaths(context.Background(), ListFileOptions{})
462+
require.NoError(t, err)
463+
require.Equal(t, []string{"a", "b", "c"}, paths)
464+
465+
paths, err = store.ListFilePaths(context.Background(), ListFileOptions{Limit: 2})
466+
require.NoError(t, err)
467+
require.Equal(t, []string{"a", "b"}, paths)
468+
469+
paths, err = store.ListFilePaths(context.Background(), ListFileOptions{StartAfter: "a"})
470+
require.NoError(t, err)
471+
require.Equal(t, []string{"b", "c"}, paths)
472+
}
473+
440474
func TestGCSListFilePaths_WithPrefix(t *testing.T) {
441475
server := fakestorage.NewServer([]fakestorage.Object{
442476
{

support/datastore/s3.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,11 @@ func (b S3DataStore) putFile(ctx context.Context, filePath string, in io.WriterT
288288
func (b S3DataStore) ListFilePaths(ctx context.Context, options ListFileOptions) ([]string, error) {
289289
var fullPrefix string
290290

291-
// When 'prefix' is empty, ensure the base prefix ends with a slash (e.g., "a/b/")
292-
// so the query returns only objects within that directory, not similarly named paths like "a/b-1".
293-
if options.Prefix == "" {
294-
fullPrefix = b.prefix
295-
if !strings.HasSuffix(fullPrefix, "/") {
296-
fullPrefix += "/"
297-
}
298-
} else {
299-
// Join the caller-provided prefix with the datastore prefix
300-
fullPrefix = path.Join(b.prefix, options.Prefix)
291+
// Ensure the prefix ends with a slash so the query returns only objects
292+
// within that directory, not similarly named paths like "a/b-1".
293+
fullPrefix = path.Join(b.prefix, options.Prefix)
294+
if fullPrefix != "" {
295+
fullPrefix += "/"
301296
}
302297

303298
var StartAfter string

support/datastore/s3_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,28 @@ func TestS3ListFilePaths(t *testing.T) {
256256
require.Equal(t, []string{"a", "b"}, paths)
257257
}
258258

259+
func TestS3ListFilePaths_NoPrefix(t *testing.T) {
260+
ctx := context.Background()
261+
store, teardown := setupTestS3DataStore(t, ctx, "test-bucket", map[string]mockS3Object{
262+
"a": {body: []byte("1")},
263+
"b": {body: []byte("1")},
264+
"c": {body: []byte("1")},
265+
})
266+
defer teardown()
267+
268+
paths, err := store.ListFilePaths(context.Background(), ListFileOptions{})
269+
require.NoError(t, err)
270+
require.Equal(t, []string{"a", "b", "c"}, paths)
271+
272+
paths, err = store.ListFilePaths(context.Background(), ListFileOptions{Limit: 2})
273+
require.NoError(t, err)
274+
require.Equal(t, []string{"a", "b"}, paths)
275+
276+
paths, err = store.ListFilePaths(context.Background(), ListFileOptions{StartAfter: "a"})
277+
require.NoError(t, err)
278+
require.Equal(t, []string{"b", "c"}, paths)
279+
}
280+
259281
func TestS3ListFilePaths_WithPrefix(t *testing.T) {
260282
ctx := context.Background()
261283
store, teardown := setupTestS3DataStore(t, ctx, "test-bucket/objects/testnet", map[string]mockS3Object{

0 commit comments

Comments
 (0)