Skip to content

Find, verify, and analyze leaked credentials

Use correct date format for Date posted. (#1211)

ahrav03a534d59f2d
diff --git a/pkg/sources/gcs/gcs.go b/pkg/sources/gcs/gcs.go
index 1bd141ec9..9735479c3 100644
--- a/pkg/sources/gcs/gcs.go
+++ b/pkg/sources/gcs/gcs.go
@@ -6,6 +6,7 @@ import (
"io"
"os"
"sort"
+ "strconv"
"sync"
diskbufferreader "github.com/bill-rich/disk-buffer-reader"
@@ -395,7 +396,7 @@ func (s *Source) processObject(ctx context.Context, o object) error {
Email: o.owner,
ContentType: o.contentType,
Acls: o.acl,
- CreatedAt: o.createdAt.String(),
+ CreatedAt: strconv.FormatInt(o.createdAt.Unix(), 10), // Unix time as string
UpdatedAt: o.updatedAt.String(),
},
},
diff --git a/pkg/sources/gcs/gcs_test.go b/pkg/sources/gcs/gcs_test.go
index 973a5d9c6..7a893ee1b 100644
--- a/pkg/sources/gcs/gcs_test.go
+++ b/pkg/sources/gcs/gcs_test.go
@@ -6,6 +6,7 @@ import (
"io"
"sort"
"testing"
+ "time"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
@@ -265,6 +266,7 @@ func createTestObject(id int) object {
acl: []string{"authenticatedUsers"},
size: 42,
Reader: &mockReader{data: []byte(fmt.Sprintf("hello world %d", id))},
+ createdAt: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
}
}
@@ -284,6 +286,7 @@ func createTestSourceChunk(id int) *sources.Chunk {
Link: fmt.Sprintf("https://storage.googleapis.com/%s/%s", testBucket, fmt.Sprintf("object%d", id)),
Acls: []string{"authenticatedUsers"},
+ CreatedAt: "1577836800",
},
},
},
@@ -331,9 +334,10 @@ func TestSourceChunks_ListObjects(t *testing.T) {
return got[i].SourceMetadata.GetGcs().Filename < got[j].SourceMetadata.GetGcs().Filename
})
- for _, c := range got {
- assert.Equal(t, c.SourceMetadata.GetGcs().Filename, c.SourceMetadata.GetGcs().Filename)
- assert.Equal(t, c.Data, c.Data)
+ for i, c := range got {
+ assert.Equal(t, want[i].SourceMetadata.GetGcs().Filename, c.SourceMetadata.GetGcs().Filename)
+ assert.Equal(t, want[i].Data, c.Data)
+ assert.Equal(t, want[i].SourceMetadata.GetGcs().CreatedAt, c.SourceMetadata.GetGcs().CreatedAt)
}
}