Skip to content
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

Fix: Interpolate variables into MultiHTTP request bodies #713

Merged
merged 3 commits into from
May 30, 2024

Conversation

The-9880
Copy link
Contributor

@The-9880 The-9880 commented May 29, 2024

Addresses #637.
Writing encoding.b64decode(<BODY>) into the template doesn't let us catch where the user is referencing variables.

We should either:

  1. Write the whole string expression ("literal " +vars['var1']+ " more text " +vars['var2']) directly into the template, or
  2. Add a functional block in the template to take the b64-decoded $body and replace any interpolated variables in the template code itself.

For option 1, buildBody could likely just return the result of performVariableExpansion on the body payload.

Option 2 is probably better practice as the user input won't escape the string; however users who are trying to execute arbitrary code could just leverage scripted checks.

@The-9880 The-9880 requested a review from a team as a code owner May 29, 2024 19:51
…expression that interpolates referenced variables.
@The-9880 The-9880 force-pushed the multihttp-body-vars branch from 7e9deff to f8daec4 Compare May 29, 2024 19:53
nadiamoe
nadiamoe previously approved these changes May 30, 2024
Copy link
Member

@nadiamoe nadiamoe left a comment

Choose a reason for hiding this comment

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

LGTM! Just a small nit about t parallelism

internal/prober/multihttp/script_test.go Show resolved Hide resolved
internal/prober/multihttp/script_test.go Show resolved Hide resolved
@The-9880 The-9880 merged commit bac84cb into main May 30, 2024
4 checks passed
@The-9880 The-9880 deleted the multihttp-body-vars branch May 30, 2024 15:37
The-9880 added a commit that referenced this pull request Jun 10, 2024
* Chore(deps): Bump golang.org/x/net from 0.24.0 to 0.25.0
* Chore(deps): Bump the prometheus-go group across 1 directory with 2 updates
* Chore(deps): Bump github.com/mccutchen/go-httpbin/v2
* Update to grafana-build-tools v0.11.0 (#705)
* Remove adhoc and traceroute feature flags. (#707)
* Chore(deps): Bump github.com/KimMachineGun/automemlimit
* checks/test: make timer big enough for context cancel to be picked up
* Fix: Interpolate variables into MultiHTTP request bodies (#713)
* Chore(deps): Bump github.com/prometheus/prometheus (#716)
* Chore(deps): Bump github.com/rs/zerolog from 1.32.0 to 1.33.0
* --- updated-dependencies: - dependency-name: kernel.org/pub/linux/libs/security/libcap/cap   dependency-type: direct:production   update-type: version-update:semver-patch ...
* MultiHttp script should decode the payload as a string and replace the variable placeholders with the values. The result should be assigned to the request body. (#717)
* Build(deps): Bump golang.org/x/net from 0.25.0 to 0.26.0
* Enable K6 by default in agent deployments (#722)

Signed-off-by: Anant Sharma <[email protected]>
@The-9880 The-9880 mentioned this pull request Jun 10, 2024
The-9880 added a commit that referenced this pull request Jun 11, 2024
* Chore(deps): Bump golang.org/x/net from 0.24.0 to 0.25.0
* Chore(deps): Bump the prometheus-go group across 1 directory with 2 updates
* Chore(deps): Bump github.com/mccutchen/go-httpbin/v2
* Update to grafana-build-tools v0.11.0 (#705)
* Remove adhoc and traceroute feature flags. (#707)
* Chore(deps): Bump github.com/KimMachineGun/automemlimit
* checks/test: make timer big enough for context cancel to be picked up
* Fix: Interpolate variables into MultiHTTP request bodies (#713)
* Chore(deps): Bump github.com/prometheus/prometheus (#716)
* Chore(deps): Bump github.com/rs/zerolog from 1.32.0 to 1.33.0
* --- updated-dependencies: - dependency-name: kernel.org/pub/linux/libs/security/libcap/cap   dependency-type: direct:production   update-type: version-update:semver-patch ...
* MultiHttp script should decode the payload as a string and replace the variable placeholders with the values. The result should be assigned to the request body. (#717)
* Build(deps): Bump golang.org/x/net from 0.25.0 to 0.26.0
* Enable K6 by default in agent deployments (#722)
* Fix: deprecate --features and warn user (#726)
* k6runner: use check context for http request (#715)

Signed-off-by: Anant Sharma <[email protected]>
@The-9880 The-9880 mentioned this pull request Jun 11, 2024
The-9880 added a commit that referenced this pull request Jun 13, 2024
* Chore(deps): Bump golang.org/x/net from 0.24.0 to 0.25.0
* Chore(deps): Bump the prometheus-go group across 1 directory with 2 updates
* Chore(deps): Bump github.com/mccutchen/go-httpbin/v2
* Update to grafana-build-tools v0.11.0 (#705)
* Remove adhoc and traceroute feature flags. (#707)
* Chore(deps): Bump github.com/KimMachineGun/automemlimit
* checks/test: make timer big enough for context cancel to be picked up
* Fix: Interpolate variables into MultiHTTP request bodies (#713)
* Chore(deps): Bump github.com/prometheus/prometheus (#716)
* Chore(deps): Bump github.com/rs/zerolog from 1.32.0 to 1.33.0
* --- updated-dependencies: - dependency-name: kernel.org/pub/linux/libs/security/libcap/cap   dependency-type: direct:production   update-type: version-update:semver-patch ...
* MultiHttp script should decode the payload as a string and replace the variable placeholders with the values. The result should be assigned to the request body. (#717)
* Build(deps): Bump golang.org/x/net from 0.25.0 to 0.26.0
* Enable K6 by default in agent deployments (#722)
* Fix: deprecate --features and warn user (#726)
* k6runner: use check context for http request (#715)

Signed-off-by: Anant Sharma <[email protected]>
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.

2 participants