Content-Length: 259389 | pFad | https://github.com/googleapis/google-cloud-go/issues/10684

A5 datastore: Key.String() includes namespace · Issue #10684 · googleapis/google-cloud-go · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datastore: Key.String() includes namespace #10684

Closed
sgp opened this issue Aug 14, 2024 · 0 comments
Closed

datastore: Key.String() includes namespace #10684

sgp opened this issue Aug 14, 2024 · 0 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. triage me I really want to be triaged.

Comments

@sgp
Copy link
Contributor

sgp commented Aug 14, 2024

Client

Datastore >= v1.14.0

Environment

Any

Go Environment

Any (but tested on go version go1.21.11 darwin/arm64)

Code

package main

import (
	"cloud.google.com/go/datastore"
	"fmt"
)

func main() {
	k := datastore.NameKey("Foo", "Bar", nil)
	fmt.Printf("Key (no namespace)\t%s\n", k)

	k.Namespace = "Sensitive"
	fmt.Printf("Key (namespaced)\t%s\n", k)
}

Expected behavior

Calling String() on a *datastore.Key functions the way it always did, keeping namespace opaque.

Key (no namespace)      /Foo,Bar
Key (namespaced)        /Foo,Bar

Actual behavior

Namespace is leaked when calling String().

Key (no namespace)      /Foo,Bar
Key (namespaced)        /Foo,Bar,Sensitive

Additional context

I understand that the change was made in #8363 to fix a real bug. However, the fix changed a stable API to achieve its goals, making it difficult to consume the latest library if there are tests that check for logs or other things containing the string value of a key. Furthermore, as we use namespaces for multi-tenancy, it's important that we don't accidentally leak namespace values outside of logs (via API or some other means). While it's possible to audit our code to never use a String() representation of the key, or to ever present keys at all, it feels like the best course of action is to not include the namespace in the string representation at all.

@sgp sgp added the triage me I really want to be triaged. label Aug 14, 2024
sgp added a commit to pendo-io/google-cloud-go that referenced this issue Aug 14, 2024
Datastore namespaces may be sensitive, and it's best not to emit
them.

Provide a `datastore.Key.StringWithNamespace()` as an alternative,
and use this version internally, which preserves the fix from
googleapis#7829.
@product-auto-label product-auto-label bot added the api: datastore Issues related to the Datastore API. label Aug 15, 2024
sgp added a commit to pendo-io/google-cloud-go that referenced this issue Aug 27, 2024
sgp added a commit to pendo-io/google-cloud-go that referenced this issue Aug 29, 2024
Datastore namespaces may be sensitive, and it's best not to emit
them.

Provide a `datastore.Key.StringWithNamespace()` as an alternative,
and use this version internally, which preserves the fix from
googleapis#7829.
sgp added a commit to pendo-io/google-cloud-go that referenced this issue Aug 29, 2024
sgp added a commit to sgp/google-cloud-go that referenced this issue Sep 5, 2024
Datastore namespaces may be sensitive, and it's best not to emit
them.

Provide a `datastore.Key.StringWithNamespace()` as an alternative,
and use this version internally, which preserves the fix from
googleapis#7829.
sgp added a commit to sgp/google-cloud-go that referenced this issue Sep 5, 2024
…#10684)

fix(datastore): remove namespace from Key.String()

Fixes googleapis#10684.

Datastore namespaces may be sensitive, and it's best not to emit them.

Restores the behavior of `Key.String` prior to googleapis#8363, but maintains the
fix for googleapis#7829 by providing an internal implementation that does provide
the namespace.
@bhshkh bhshkh closed this as completed in 40229e6 Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/google-cloud-go/issues/10684

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy