Skip to content

Commit

Permalink
[chore] - use hex encode vs base64 (trufflesecurity#1256)
Browse files Browse the repository at this point in the history
* use hex encode vs base64.

* fix tests.
  • Loading branch information
ahrav committed Apr 14, 2023
1 parent 2fbf86a commit 461f1a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pkg/sources/gcs/gcs_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gcs

import (
aCtx "context"
"encoding/base64"
"encoding/hex"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -650,7 +650,7 @@ func (g *gcsManager) constructObject(ctx context.Context, obj *storage.ObjectHan
o.contentType = attrs.ContentType
o.owner = attrs.Owner
o.link = attrs.MediaLink
o.md5 = base64.StdEncoding.EncodeToString(attrs.MD5)
o.md5 = hex.EncodeToString(attrs.MD5)
o.createdAt = attrs.Created
o.updatedAt = attrs.Updated
o.acl = objectACLs(attrs.ACL)
Expand Down
32 changes: 16 additions & 16 deletions pkg/sources/gcs/gcs_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 150,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/aws1.txt?generation=1677870994890594&alt=media",
acl: []string{},
md5: "ek30X4Oc1ZSsI2sZUkzskg==",
md5: "7a4df45f839cd594ac236b19524cec92",
},
{
name: "moar2.txt",
Expand All @@ -489,7 +489,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 12,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/moar2.txt?generation=1677871000378542&alt=media",
acl: []string{},
md5: "5Z/5eUEET4XfUpfhwwLSYA==",
md5: "e59ff97941044f85df5297e1c302d260",
},
{
name: "aws3.txt",
Expand All @@ -498,7 +498,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 150,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th2/o/aws3.txt?generation=1677871022489611&alt=media",
acl: []string{},
md5: "JusDN4oMjpnuDOz5FVrOgQ==",
md5: "26eb03378a0c8e99ee0cecf9155ace81",
},
{
name: "moar.txt",
Expand All @@ -507,7 +507,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 6,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th3/o/moar.txt?generation=1677871042896804&alt=media",
acl: []string{},
md5: "CffgLxKQviEdpweiZvFTsw==",
md5: "09f7e02f1290be211da707a266f153b3",
},
{
name: "AMAZON_FASHION_5.json",
Expand All @@ -516,7 +516,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 1413469,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th4/o/AMAZON_FASHION_5.json?generation=1677871063457469&alt=media",
acl: []string{},
md5: "Wh2PSDqjRpUlY3kFDUKitw==",
md5: "5a1d8f483aa34695256379050d42a2b7",
},
},
wantNumBkt: 4,
Expand All @@ -534,7 +534,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 150,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/aws1.txt?generation=1677870994890594&alt=media",
acl: []string{},
md5: "ek30X4Oc1ZSsI2sZUkzskg==",
md5: "7a4df45f839cd594ac236b19524cec92",
},
{
name: "moar2.txt",
Expand All @@ -543,7 +543,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 12,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/moar2.txt?generation=1677871000378542&alt=media",
acl: []string{},
md5: "5Z/5eUEET4XfUpfhwwLSYA==",
md5: "e59ff97941044f85df5297e1c302d260",
},
},
wantNumBkt: 1,
Expand All @@ -561,7 +561,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 6,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th3/o/moar.txt?generation=1677871042896804&alt=media",
acl: []string{},
md5: "CffgLxKQviEdpweiZvFTsw==",
md5: "09f7e02f1290be211da707a266f153b3",
},
{
name: "AMAZON_FASHION_5.json",
Expand All @@ -570,7 +570,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 1413469,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th4/o/AMAZON_FASHION_5.json?generation=1677871063457469&alt=media",
acl: []string{},
md5: "Wh2PSDqjRpUlY3kFDUKitw==",
md5: "5a1d8f483aa34695256379050d42a2b7",
},
},
wantNumBkt: 2,
Expand All @@ -592,7 +592,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 150,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th2/o/aws3.txt?generation=1677871022489611&alt=media",
acl: []string{},
md5: "JusDN4oMjpnuDOz5FVrOgQ==",
md5: "26eb03378a0c8e99ee0cecf9155ace81",
},
{
name: "moar.txt",
Expand All @@ -601,7 +601,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 6,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th3/o/moar.txt?generation=1677871042896804&alt=media",
acl: []string{},
md5: "CffgLxKQviEdpweiZvFTsw==",
md5: "09f7e02f1290be211da707a266f153b3",
},
{
name: "AMAZON_FASHION_5.json",
Expand All @@ -610,7 +610,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 1413469,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th4/o/AMAZON_FASHION_5.json?generation=1677871063457469&alt=media",
acl: []string{},
md5: "Wh2PSDqjRpUlY3kFDUKitw==",
md5: "5a1d8f483aa34695256379050d42a2b7",
},
},
wantNumBkt: 4, // We still list objects in all buckets.
Expand All @@ -632,7 +632,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 150,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/aws1.txt?generation=1677870994890594&alt=media",
acl: []string{},
md5: "ek30X4Oc1ZSsI2sZUkzskg==",
md5: "7a4df45f839cd594ac236b19524cec92",
},
},
wantNumBkt: 1,
Expand All @@ -654,7 +654,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 150,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/aws1.txt?generation=1677870994890594&alt=media",
acl: []string{},
md5: "ek30X4Oc1ZSsI2sZUkzskg==",
md5: "7a4df45f839cd594ac236b19524cec92",
},
},
wantNumBkt: 4,
Expand All @@ -677,7 +677,7 @@ func TestGCSManagerListObjects(t *testing.T) {
size: 12,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/moar2.txt?generation=1677871000378542&alt=media",
acl: []string{},
md5: "5Z/5eUEET4XfUpfhwwLSYA==",
md5: "e59ff97941044f85df5297e1c302d260",
},
},
wantNumBkt: 1,
Expand Down Expand Up @@ -765,7 +765,7 @@ func TestGCSManagerListObjects_Resuming(t *testing.T) {
size: 12,
link: "https://storage.googleapis.com/download/storage/v1/b/test-bkt-th/o/moar2.txt?generation=1677871000378542&alt=media",
acl: []string{},
md5: "5Z/5eUEET4XfUpfhwwLSYA==",
md5: "e59ff97941044f85df5297e1c302d260",
},
},
wantNumBkt: 1,
Expand Down

0 comments on commit 461f1a6

Please sign in to comment.