Skip to content

Conversation

@akshaymankar
Copy link
Member

@akshaymankar akshaymankar commented May 22, 2025

https://wearezeta.atlassian.net/browse/WPB-17733

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@akshaymankar akshaymankar requested a review from a team as a code owner May 22, 2025 15:27
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label May 22, 2025
@akshaymankar akshaymankar force-pushed the aws-auth-with-zauth branch from 9e1733b to 9fdc180 Compare May 28, 2025 09:35
@akshaymankar akshaymankar force-pushed the aws-auth-with-zauth branch from a3f66d3 to ba517b3 Compare May 28, 2025 09:48
@akshaymankar akshaymankar requested review from a team as code owners May 28, 2025 10:00
@akshaymankar akshaymankar requested a review from supersven May 28, 2025 10:19
Copy link
Contributor

@fisx fisx left a comment

Choose a reason for hiding this comment

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

L(almost)GTM. i've only found one (trivial) bug, approving on condition of that getting fixed.

char const * bearer = "Bearer ";
size_t bearer_len = 7; // strlen(bearer) is not safe, says sonar cloud
char const * aws4_hmac_sha256 = "AWS4-HMAC-SHA256 ";
size_t aws4_hmac_sha256_len = 17;
Copy link
Contributor

Choose a reason for hiding this comment

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

i think i've solved the mystery of why the test does not fail when i say aws4_hmac_sha256_len = 7: token_from_aws_hmac_header skips all tokens up to Credentials=. auth_header_len there is calculated here given the shorter aws4_hmac_sha256_len, so still reaches to the actual end of the buffer.

so the bug that we had here was actually never able to materialize in behavior due to defensive programming.

static ZauthResult token_from_header (ngx_str_t const * hdr, ZauthToken ** t) {
if (strncmp((char const *) hdr->data, "Bearer ", 7) == 0) {
return zauth_token_parse(&hdr->data[7], hdr->len - 7, t);
char const * bearer = "Bearer ";
Copy link
Contributor

Choose a reason for hiding this comment

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

If you define your strings as char[], then you can use sizeof instead of hardcoding the length.

Copy link
Contributor

Choose a reason for hiding this comment

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

i tried, also the -1 trick, but somehow got it wrong, and the code didn't really seem easier to read or much safer to me. also, this is how it's done in this code base.

@fisx fisx force-pushed the aws-auth-with-zauth branch from 2772cb3 to e897c0e Compare June 4, 2025 11:52
@fisx fisx merged commit 2004a2d into develop Jun 5, 2025
8 checks passed
@fisx fisx deleted the aws-auth-with-zauth branch June 5, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants