Restore url.PathEscape on user-supplied path segments in url.JoinPath calls

url.JoinPath does not percent-encode slashes or reserved characters in
its arguments, so user-supplied values (group IDs, slugs, team IDs) must
be wrapped with url.PathEscape to prevent path traversal. Update cursor
rule and contrib guide to codify this as a mandatory practice.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-20 12:57:26 +04:00
parent 16876de0ae
commit f0fe70fe1c
9 changed files with 26 additions and 18 deletions

View File

@@ -67,7 +67,7 @@ type gitlabMember struct {
func (d *GitLabDriver) ListAccounts(ctx context.Context) ([]AccountRecord, error) {
var records []AccountRecord
u, err := url.JoinPath("https://gitlab.com", "api", "v4", "groups", d.groupID, "members", "all")
u, err := url.JoinPath("https://gitlab.com", "api", "v4", "groups", url.PathEscape(d.groupID), "members", "all")
if err != nil {
return nil, fmt.Errorf("cannot build gitlab members URL: %w", err)
}