Skip to content

Conversation

@terrorbyte
Copy link
Collaborator

Adds a transform.ShuffleURLParameters function that takes a string value and converts it to a URL and takes the query parameters and changes their order. This is me shaking my fist angrily at terrible network signatures that care about parameter order.

As usual, oddly complex to deal with using crypto/rand as shuffle and some net/url.Values being a map[string][]string

@terrorbyte terrorbyte self-assigned this Dec 5, 2025
@terrorbyte terrorbyte added enhancement New feature or request go Pull requests that update go code labels Dec 5, 2025
@j-baines j-baines requested a review from Copilot December 5, 2025 20:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new function ShuffleURLParameters that randomizes the order of query parameters in URL strings to work around network signatures that are sensitive to parameter ordering.

  • Implements cryptographically secure shuffling using crypto/rand for seed generation
  • Handles URLs with or without schemes and multiple values for the same parameter key
  • Includes comprehensive test coverage for various URL formats and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
transform/transform.go Implements the ShuffleURLParameters function with URL parsing, parameter extraction, and cryptographically seeded shuffling
transform/transform_test.go Adds test cases covering relative URLs, full URLs with schemes, and invalid URL handling
Comments suppressed due to low confidence (1)

transform/transform.go:1

  • The testing package should not be imported in production code. Consider removing the testing.Testing() check and using a different approach for conditional logging, such as passing a logger interface or using build tags to separate test and production behavior.
package transform

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-baines j-baines self-requested a review December 5, 2025 20:45
@terrorbyte terrorbyte merged commit e37e979 into main Dec 6, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants