Skip to content

feat: redact credentials in remote urls - #2220

Merged
pd93 merged 5 commits into
mainfrom
2100-redacted-url-credentials
May 24, 2025
Merged

feat: redact credentials in remote urls#2220
pd93 merged 5 commits into
mainfrom
2100-redacted-url-credentials

Conversation

@pd93

@pd93 pd93 commented Apr 28, 2025

Copy link
Copy Markdown
Member

Fixes #2100 and replaces #2045

Ensures that any credentials embedded in the URL are redacted by using the built in url.Redacted() function. The cache keys have also been altered slightly, so users may have to redownload some files that they already have cached.

@pd93

pd93 commented Apr 28, 2025

Copy link
Copy Markdown
Member Author

@iwittkau, very open to comments as you were the author of the last PR.

@pd93
pd93 force-pushed the 2100-redacted-url-credentials branch from 94ff7fa to 474eec1 Compare April 28, 2025 16:16
@iwittkau

iwittkau commented Apr 29, 2025

Copy link
Copy Markdown
Contributor

I think this test should be added an pass:

func TestGitNode_redaction(t *testing.T) {
	t.Parallel()

	node, err := NewGitNode("https://git:token@github.com/foo/bar.git//directory/Taskfile.yml?ref=main", "", false)
	assert.NoError(t, err)
	assert.Equal(t, "main", node.ref)
	assert.Equal(t, "directory/Taskfile.yml", node.path)
	assert.Equal(t, "https://git:xxxxx@github.com/foo/bar.git//directory/Taskfile.yml?ref=main", node.Location())
	// assert.Equal(t, "https://git:xxxxx@github.com/foo/bar.git", node.URL.String())
	entrypoint, err := node.ResolveEntrypoint("common.yml")
	assert.NoError(t, err)
	assert.Equal(t, "https://git:xxxxx@github.com/foo/bar.git//directory/common.yml?ref=main", entrypoint)
}

@iwittkau iwittkau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🎉

I'll give it a try with my work setup tomorrow.

Comment thread taskfile/node_git.go
Comment thread taskfile/node_git.go Outdated
@iwittkau

Copy link
Copy Markdown
Contributor

I think you could keep GitNode.URL unexported to make sure its String and Redacted funcs are called correctly.

@pd93

pd93 commented May 1, 2025

Copy link
Copy Markdown
Member Author

I think you could keep GitNode.URL unexported to make sure its String and Redacted funcs are called correctly.

Yeah, we don't really need any of the properties on Node implementations to be exported. They have constructors and they're quite bespoke. Package API users can just roll their own Nodes if they need custom behavior. I have unexported all Node fields.

@pd93
pd93 requested review from andreynering and vmaerten May 1, 2025 18:16
@iwittkau

iwittkau commented May 5, 2025

Copy link
Copy Markdown
Contributor

@pd93 I just noticed that this branch needs a go mod tidy.

@vmaerten vmaerten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is cache naming is way better like this!

Comment thread taskfile/node_http.go
@pd93
pd93 requested a review from vmaerten May 20, 2025 20:37

@vmaerten vmaerten left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ! gj :)

@iwittkau

Copy link
Copy Markdown
Contributor

I've been using this for a while now and it works nicely 👍🏻

@pd93
pd93 merged commit 5323990 into main May 24, 2025
@pd93
pd93 deleted the 2100-redacted-url-credentials branch May 24, 2025 12:38
pd93 added a commit that referenced this pull request May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote taskfile could potentially expose secrets

3 participants