Skip to content

Conversation

@pd93
Copy link
Member

@pd93 pd93 commented Apr 28, 2025

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
Copy link
Member Author

pd93 commented Apr 28, 2025

@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
Copy link
Contributor

iwittkau commented Apr 29, 2025

I think this test should be added an pass:

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

	node, err := NewGitNode("https://git:[email protected]/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:[email protected]/foo/bar.git//directory/Taskfile.yml?ref=main", node.Location())
	// assert.Equal(t, "https://git:[email protected]/foo/bar.git", node.URL.String())
	entrypoint, err := node.ResolveEntrypoint("common.yml")
	assert.NoError(t, err)
	assert.Equal(t, "https://git:[email protected]/foo/bar.git//directory/common.yml?ref=main", entrypoint)
}

Copy link
Contributor

@iwittkau iwittkau left a comment

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.

@iwittkau
Copy link
Contributor

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

@pd93
Copy link
Member Author

pd93 commented May 1, 2025

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
Copy link
Contributor

iwittkau commented May 5, 2025

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

Copy link
Member

@vmaerten vmaerten left a comment

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!

@pd93 pd93 requested a review from vmaerten May 20, 2025 20:37
Copy link
Member

@vmaerten vmaerten left a comment

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
Contributor

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

@pd93 pd93 merged commit 5323990 into main May 24, 2025
15 checks passed
@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

4 participants