-
-
Notifications
You must be signed in to change notification settings - Fork 642
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
Remote Taskfiles: redact credentials of remote URLs in prompts and logs #2045
base: main
Are you sure you want to change the base?
Conversation
taskfile/node.go
Outdated
Location() string | ||
RedactedLocation() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a quick look on my phone, not a full review.
Is the raw (non-redacted) location actually used outside of the git node implementation? You could make the argument that the credentials should never be exposed via the interface and that Location
should just return the redacted version. This would save us having to add an interface method that only one of the implementations needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you @pd93 !
AFAIK, the Location
is used only to reference it in the graph
so, imho no objection to return the redacted
version.
Also, the http node implementation could / should have the same behavior, as we can use http://USER:PASS@URL
pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would make the whole change a lot simpler! I saw that the node.Location
is used to provide the cache key.
I think ignoring the username and password combination for the cache should be fine since different combinations shouldn't yield different Taskfile contents.
Adding the HTTP node redaction should be easy too.
@@ -22,7 +22,7 @@ type Node interface { | |||
Remote() bool | |||
ResolveEntrypoint(entrypoint string) (string, error) | |||
ResolveDir(dir string) (string, error) | |||
FilenameAndLastDir() (string, string) | |||
FilenameAndLastDir() (lastDir string, file string) // TODO the return order is implemented opposite to the naming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this caused some bugs? #1317 (comment)
I've turned this into a draft for now. |
@@ -122,5 +121,5 @@ func (node *GitNode) ResolveDir(dir string) (string, error) { | |||
} | |||
|
|||
func (node *GitNode) FilenameAndLastDir() (string, string) { | |||
return filepath.Base(node.path), filepath.Base(filepath.Dir(node.path)) | |||
return filepath.Base(filepath.Dir(node.filepath)), filepath.Base(node.filepath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taskfile/cache.go
uses it like this:
lastDir, filename := node.FilenameAndLastDir()
035469d
to
03a5551
Compare
03a5551
to
3fc6d75
Compare
Compiling it and running this as a development version actually breaks my own git-based Remote Taskfiles setup 😅 Back to draft, I guess. |
u.Path = basePath | ||
gitURL.RawQuery = "" | ||
gitURL.Path = urlPath | ||
baseURL := gitURL.Redacted() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually have to use the unredacted URL here.
This is to improve #1317.
I've implemented redaction support for the
taskfile.Node
interface, specifically for thetaskfile.GitNode
implementation which was logged with the clear-text user access tokens before.