|
| 1 | +--- |
| 2 | +title: Announcing Hurl 6.1.0 |
| 3 | +layout: blog |
| 4 | +section: Blog |
| 5 | +permalink: /blog/:year/:month/:day/:title.html |
| 6 | +--- |
| 7 | + |
| 8 | +# {{ page.title }} |
| 9 | + |
| 10 | +<div class="blog-post-date">{{ page.date | date: "%b. %d, %Y" }}</div> |
| 11 | + |
| 12 | +The Hurl team is thrilled to announce [Hurl 6.1.0] <picture><source srcset="{{ '/assets/img/emoji-party-popper.avif' | prepend:site.baseurl }}" type="image/avif"><source srcset="{{ '/assets/img/emoji-party-popper.webp' | prepend:site.baseurl }}" type="image/webp"><source srcset="{{ '/assets/img/emoji-party-popper.png' | prepend:site.baseurl }}" type="image/png"><img class="emoji" src="{{ '/assets/img/emoji-party-popper.png' | prepend:site.baseurl }}" width="20" height="20" alt="Partying Face"></picture> ! |
| 13 | + |
| 14 | +[Hurl] is a command line tool powered by [curl], that runs HTTP requests defined in a simple plain text format: |
| 15 | + |
| 16 | +```hurl |
| 17 | +GET https://example.org/api/tests/4567 |
| 18 | +HTTP 200 |
| 19 | +[Asserts] |
| 20 | +header "x-foo" contains "bar" |
| 21 | +certificate "Expire-Date" daysAfterNow > 15 |
| 22 | +ip == "2001:0db8:85a3:0000:0000:8a2e:0370:733" |
| 23 | +jsonpath "$.status" == "RUNNING" # Check the status code |
| 24 | +jsonpath "$.tests" count == 25 # Check the number of items |
| 25 | +jsonpath "$.id" matches /\d{4}/ # Check the format of the id |
| 26 | +``` |
| 27 | + |
| 28 | +## What’s New in This Release |
| 29 | + |
| 30 | +- [Redacting Sensitive Values from Reports and Logs with Secrets](#redacting-sensitive-values-from-reports-and-logs-with-secrets) |
| 31 | +- [New Queries: IP Address, HTTP Version](#new-queries-ip-address-http-version) |
| 32 | +- [New Filters: base64Encode/Decode, toString](#new-filters-base64encodedecode-tostring) |
| 33 | +- [More curl Options](#more-curl-options) |
| 34 | + |
| 35 | +## Redacting Sensitive Values from Reports and Logs with Secrets |
| 36 | + |
| 37 | +In Hurl 6.1.0, we're introducing _secrets_, a simple way to redact sensitive datas from logs and reports. In HTTP workflows, |
| 38 | +it's highly probable that authentication tokens, API keys or other confidential values will be used in some parts of |
| 39 | +the network transfers. Sensitive data can transit in HTTP headers, URL or in HTTP request/response body and be accidentally |
| 40 | +leaked in the run. |
| 41 | + |
| 42 | +When a user enables logging for instance, Hurl outputs various part of the HTTP transactions on standard error. Let's say |
| 43 | +our Hurl file is using a secret header `x-password` with the value `sesame-ouvre-toi`: |
| 44 | + |
| 45 | +```hurl |
| 46 | +GET https://foo.com |
| 47 | +Content-Type: application/json |
| 48 | +x-password: sesame-ouvre-toi |
| 49 | +HTTP 200 |
| 50 | +``` |
| 51 | + |
| 52 | +A first step to not leak a secret is [to use a variable] so the Hurl file doesn't contain the secret value: |
| 53 | + |
| 54 | +{% raw %} |
| 55 | +```hurl |
| 56 | +GET https://foo.com |
| 57 | +Content-Type: application/json |
| 58 | +x-password: {{password}} |
| 59 | +HTTP 200 |
| 60 | +``` |
| 61 | +{% endraw %} |
| 62 | + |
| 63 | +To run this file, traditionally we set the variable value with an environment variable: |
| 64 | + |
| 65 | +```shell |
| 66 | +$ hurl --variable password=$PASSWORD foo.hurl |
| 67 | +``` |
| 68 | + |
| 69 | +But, if we run this file with [`--verbose`] option, we can accidentally leak the value of the secret header: |
| 70 | + |
| 71 | +```shell |
| 72 | +$ hurl --verbose foo.hurl |
| 73 | +* ------------------------------------------------------------------------------ |
| 74 | +* Executing entry 1 |
| 75 | +* |
| 76 | +* Cookie store: |
| 77 | +* |
| 78 | +* Request: |
| 79 | +* GET http://foo.com |
| 80 | +[1;31m* x-secret: sesame-ouvre-toi[0m |
| 81 | +* |
| 82 | +* Request can be run with the following curl command: |
| 83 | +* curl --request GET [1;31m--header 'x-secret: sesame-ouvre-toi'[0m --header 'Content-Type: application/json' 'http://foo.com' |
| 84 | +* |
| 85 | +> GET / HTTP/1.1 |
| 86 | +> Host: foo.com:80 |
| 87 | +> Accept: */* |
| 88 | +[1;31m> x-secret: sesame-ouvre-toi[0m |
| 89 | +> Content-Type: application/json |
| 90 | +> User-Agent: hurl/6.1.0 |
| 91 | +> Content-Length: 24 |
| 92 | +> |
| 93 | +* Request body: |
| 94 | +* |
| 95 | +< HTTP/1.1 200 OK |
| 96 | +< Server: Werkzeug |
| 97 | +... |
| 98 | +``` |
| 99 | +
|
| 100 | +Even without `--verbose` mode, assertion errors can leak secrets: |
| 101 | +
|
| 102 | +```shell |
| 103 | +$ hurl --error-format long foo.hurl |
| 104 | +HTTP/2 200 |
| 105 | +date: Fri, 14 Mar 2025 08:55:46 GMT |
| 106 | +content-type: text/html |
| 107 | +... |
| 108 | +[1;31mx-secret: TOP_SECRET_VALUE[0m |
| 109 | +x-content-type-options: nosniff |
| 110 | +accept-ranges: bytes |
| 111 | + |
| 112 | +<!DOCTYPE html> |
| 113 | +<html lang="en"> |
| 114 | +... |
| 115 | +</html> |
| 116 | + |
| 117 | +error: Assert status code |
| 118 | + --> /tmp/err.hurl:2:6 |
| 119 | + | |
| 120 | + | GET https://hurl.dev |
| 121 | + 2 | HTTP 400 |
| 122 | + | ^^^ actual value is <200> |
| 123 | + | |
| 124 | +``` |
| 125 | +
|
| 126 | +Started with Hurl 6.1.0, you can inject a variable whose value will be redacted from any logs using [`--secret` option]: |
| 127 | +
|
| 128 | +``` |
| 129 | +$ hurl --secret password=$PASSWORD foo.hurl |
| 130 | +``` |
| 131 | +
|
| 132 | +You can use `--secret` also to hide values even if these variables are not used in a Hurl file. This way, you can also protect |
| 133 | +your secrets when secret values are processed (turned on uppercase, encoded to base64 etc...), even if they're not actually |
| 134 | +used as Hurl variables: |
| 135 | +
|
| 136 | +``` |
| 137 | +$ PASSWORD_UPPER=$(printf "%s" "$PASSWORD" | tr '[:lower:]' '[:upper:]') |
| 138 | +$ PASSWORD_BASE_64=$(printf "%s" "$PASSWORD" | base64) |
| 139 | +$ hurl --secret password=$PASSWORD \ |
| 140 | + --secret password_1=$PASSWORD_UPPER \ |
| 141 | + --secret password_2=$PASSWORD_BASE_64 \ |
| 142 | + foo.hurl |
| 143 | +``` |
| 144 | +
|
| 145 | +Various CI/CD platforms like [GitHub Actions] or [GitLab CI/CD] can be configured to hide specific values from logs. |
| 146 | +But secrets in Hurl are also redacted from the reports ([HTML], [JSON], [JUnit] etc...) so you can safely store these reports |
| 147 | +as artifacts of your CI/CD pipelines. |
| 148 | +
|
| 149 | +Finally, sometimes you don't know a secret value beforehand, or the secret value is not static. In that case, the keyword |
| 150 | +[`redact` combined with captures] allows you to extract data from HTTP responses and redact it through the run: |
| 151 | +
|
| 152 | +```hurl |
| 153 | +GET http://bar.com/api/get-token |
| 154 | +HTTP 200 |
| 155 | +[Captures] |
| 156 | +token: header "X-Token" redact |
| 157 | +``` |
| 158 | +
|
| 159 | +## New Queries: IP Address, HTTP Version |
| 160 | +
|
| 161 | +Hurl allows you [to capture] and [assert data] from HTTP responses. Hurl is particular as it can extract "high level" data, |
| 162 | +like applying a JSONPath or a XPath expression to a response body, but Hurl can also work on a lower HTTP level: thanks |
| 163 | +to its [libcurl HTTP engine], you can extract SSL certificates attributes for instance: |
| 164 | +
|
| 165 | +```hurl |
| 166 | +GET https://example.org |
| 167 | +HTTP 200 |
| 168 | +[Captures] |
| 169 | +cert_subject: certificate "Subject" |
| 170 | +cert_issuer: certificate "Issuer" |
| 171 | +cert_expire_date: certificate "Expire-Date" |
| 172 | +cert_serial_number: certificate "Serial-Number" |
| 173 | +``` |
| 174 | +
|
| 175 | +With Hurl 6.1.0, we have added an [IP address query] that allows you to get the IP address from HTTP response: |
| 176 | +
|
| 177 | +```hurl |
| 178 | +GET https://example.org/hello |
| 179 | +HTTP 200 |
| 180 | +[Captures] |
| 181 | +server_ip: ip |
| 182 | +``` |
| 183 | +
|
| 184 | +IP address are strings and can be tested like any other values: |
| 185 | +
|
| 186 | +```hurl |
| 187 | +GET https://example.org/api/tests/4567 |
| 188 | +HTTP 200 |
| 189 | +[Asserts] |
| 190 | +ip == "2001:0db8:85a3:0000:0000:8a2e:0370:733" |
| 191 | +``` |
| 192 | +
|
| 193 | +As a convenience, we have also added two new predicates [`isIpv4` and `isIpv6`]({% link _docs/asserting-response.md%}#ip-address-assert) |
| 194 | +that perform format check on string values. For instance, you can set a request to [use IPv6 addresses]({% link _docs/manual.md %}#ipv6) |
| 195 | +and check that the response IP is well in the expected protocol: |
| 196 | +
|
| 197 | +```hurl |
| 198 | +GET https://example.org/foo |
| 199 | +[Options] |
| 200 | +ipv6: true |
| 201 | +HTTP 200 |
| 202 | +[Asserts] |
| 203 | +ip isIpv6 |
| 204 | +``` |
| 205 | +
|
| 206 | +With prior Hurl versions, user have been able to test response [HTTP version] with `HTTP/1.0`, `HTTP/1.1`, `HTTP/2`, `HTTP/3`: |
| 207 | +
|
| 208 | +```hurl |
| 209 | +GET https://example.org/http3 |
| 210 | +HTTP/3 200 |
| 211 | +
|
| 212 | +GET https://example.org/http2 |
| 213 | +HTTP/2 200 |
| 214 | +
|
| 215 | +# Or simply use HTTP to not test version! |
| 216 | +GET https://example.org/http2 |
| 217 | +HTTP 200 |
| 218 | +``` |
| 219 | +
|
| 220 | +With Hurl 6.1.0, we have added the query `version`, that allows to explicitly test HTTP versions, or even to capture its |
| 221 | +value: |
| 222 | +
|
| 223 | +```hurl |
| 224 | +# You can explicitly test HTTP version 1.0, 1.1, 2 or 3: |
| 225 | +GET https://example.org/http3 |
| 226 | +HTTP 200 |
| 227 | +[Asserts] |
| 228 | +version == "3" |
| 229 | +
|
| 230 | +GET https://example.org/http2 |
| 231 | +HTTP 200 |
| 232 | +[Asserts] |
| 233 | +version toFloat >= 2.0 |
| 234 | +
|
| 235 | +# You can even capture the HTTP version in a variable: |
| 236 | +GET https://example.org/http2 |
| 237 | +HTTP 200 |
| 238 | +[Captures] |
| 239 | +endpoint_version: version |
| 240 | +``` |
| 241 | +
|
| 242 | +## New Filters: base64Encode/Decode, toString |
| 243 | +
|
| 244 | +When extracting data from HTTP response, you can transform it with [filters]. With Hurl 6.1.0, we have added three |
| 245 | +new filters: |
| 246 | +
|
| 247 | +- `base64Encode/base64Decode`: as the name suggests, these filters allow to encode and decode data with [Base64 encoding] |
| 248 | + (standard variant with `=` padding and `+/` characters): |
| 249 | +
|
| 250 | +```hurl |
| 251 | +GET https://example.org/api |
| 252 | +HTTP 200 |
| 253 | +[Asserts] |
| 254 | +jsonpath "$.token" base64Decode == hex,e4bda0e5a5bde4b896e7958c; |
| 255 | +``` |
| 256 | +
|
| 257 | +- `toString`: allow to transforms value to a string |
| 258 | +
|
| 259 | +```hurl |
| 260 | +GET https://example.org/foo |
| 261 | +HTTP 200 |
| 262 | +[Asserts] |
| 263 | +status toString matches /(200|204)/ |
| 264 | +``` |
| 265 | +
|
| 266 | +## More curl Options |
| 267 | +
|
| 268 | +Finally, a last small evolution. Hurl adopts a lot of curl options, whether in command line: |
| 269 | +
|
| 270 | +```shell |
| 271 | +$ hurl --location bar.hurl |
| 272 | +``` |
| 273 | +
|
| 274 | +Or in [`[Options]` section]({% link _docs/request.md %}#options): |
| 275 | +
|
| 276 | +```hurl |
| 277 | +GET https://bar.com |
| 278 | +[Options] |
| 279 | +location: true |
| 280 | +HTTP 200 |
| 281 | +``` |
| 282 | +
|
| 283 | +With this new version, we have added [`--header`] option, that will add a specific HTTP header to all requests of a run: |
| 284 | +
|
| 285 | +```shell |
| 286 | +$ hurl --header 'x-header-b:baz' --header 'x-header-c:qux' foo.hurl |
| 287 | +``` |
| 288 | +
|
| 289 | +__That's all for today!__ |
| 290 | +
|
| 291 | +There are a lot of other improvements with Hurl 6.1.0 and also a lot of bug fixes, you can check the complete list of |
| 292 | +enhancements and bug fixes [in our release note]. |
| 293 | +
|
| 294 | +If you like Hurl, don't hesitate to [give us a star on GitHub] or share it on [𝕏 / Twitter] / [Bluesky]! |
| 295 | +
|
| 296 | +We'll be happy to hear from you, either for enhancement requests or for sharing your success story using Hurl! |
| 297 | +
|
| 298 | +
|
| 299 | +[Hurl 6.1.0]: https://github.com/Orange-OpenSource/hurl/releases/tag/6.1.0 |
| 300 | +[Hurl]: https://hurl.dev |
| 301 | +[curl]: https://curl.se |
| 302 | +[to use a variable]: {% link _docs/templates.md %}#injecting-variables |
| 303 | +[`--verbose`]: {% link _docs/manual.md %}#verbose |
| 304 | +[`--secret` option]: {% link _docs/templates.md %}#secrets |
| 305 | +[GitHub Actions]: https://github.com/features/actions |
| 306 | +[GitLab CI/CD]: https://docs.gitlab.com/ci/ |
| 307 | +[`redact` combined with captures]: {% link _docs/capturing-response.md %}#redacting-secrets |
| 308 | +[to capture]: {% link _docs/capturing-response.md %} |
| 309 | +[assert data]: {% link _docs/asserting-response.md %} |
| 310 | +[libcurl HTTP engine]: https://curl.se/libcurl/ |
| 311 | +[IP address query]: {% link _docs/asserting-response.md %}#ip-address-assert |
| 312 | +[use IPv6 addresses]: {% link _docs/manual.md %}#ipv6 |
| 313 | +[HTTP version]: {% link _docs/asserting-response.md %}#version-status |
| 314 | +[filters]: {% link _docs/filters.md %} |
| 315 | +[`--header`]: {% link _docs/manual.md %}#header |
| 316 | +[HTML]: {% link _docs/running-tests.md %}#html-report |
| 317 | +[JSON]: {% link _docs/running-tests.md %}#json-report |
| 318 | +[JUnit]: {% link _docs/running-tests.md %}#junit-report |
| 319 | +[Base64 encoding]: https://en.wikipedia.org/wiki/Base64 |
| 320 | +[in our release note]: https://github.com/Orange-OpenSource/hurl/releases/tag/6.1.0 |
| 321 | +[𝕏 / Twitter]: https://x.com/HurlDev |
| 322 | +[Bluesky]: https://bsky.app/profile/hurldev.bsky.social |
| 323 | +[give us a star on GitHub]: https://github.com/Orange-OpenSource/hurl/stargazers |
0 commit comments