Skip to content

fix(webhook-github-app): Allow new lines in base64 key for module webhook-github-app #3714

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

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

imphil
Copy link
Contributor

@imphil imphil commented Jan 10, 2024

We store the github_app.key_base64 configuration settings with
newlines (nothing unusual, actually). This breaks the
webhook-github-api module, which then reports the following when
running terraform apply:

module.webhook-github-app.null_resource.update_app (local-exec): Executing: ["bash" "-c" ".terraform/modules/webhook-github-app/modules/webhook-github-app/bin/update-app.sh -e https://REDACTED/webhook -s REDACTED -a REDACTED -k FIRSTLINE\nSECONDLINE\nAND_SO_ON==\n"]
module.webhook-github-app.null_resource.update_app (local-exec): Could not read private key from /dev/fd/63
module.webhook-github-app.null_resource.update_app (local-exec): 40975344027F0000:error:1608010C:STORE routines:ossl_store_handle_load_result:unsupported:crypto/store/store_result.c:151:
module.webhook-github-app.null_resource.update_app (local-exec): {"message":"A JSON web token could not be decoded","documentation_url":"https://docs.github.com/rest"}gh: A JSON web token could not be decoded (HTTP 401)

The root cause is that base64 -d cannot decode the argument passed
through -k. Fix that by telling echo to leave the newlines in place,
so that base64 -d can deal with them. Adding tr -d is not necessary
in this case.

imphil and others added 2 commits January 10, 2024 21:39
We store the `github_app.key_base64` configuration settings with
newlines (nothing unusual, actually). This breaks the
`webhook-github-api` module, which then reports the following when
running `terraform apply`:

```
module.webhook-github-app.null_resource.update_app (local-exec): Executing: ["bash" "-c" ".terraform/modules/webhook-github-app/modules/webhook-github-app/bin/update-app.sh -e https://REDACTED/webhook -s REDACTED -a REDACTED -k FIRSTLINE\nSECONDLINE\nAND_SO_ON==\n"]
module.webhook-github-app.null_resource.update_app (local-exec): Could not read private key from /dev/fd/63
module.webhook-github-app.null_resource.update_app (local-exec): 40975344027F0000:error:1608010C:STORE routines:ossl_store_handle_load_result:unsupported:crypto/store/store_result.c:151:
module.webhook-github-app.null_resource.update_app (local-exec): {"message":"A JSON web token could not be decoded","documentation_url":"https://docs.github.com/rest"}gh: A JSON web token could not be decoded (HTTP 401)
```

The root cause is that `base64 -d` cannot decode the argument passed
through `-k`. Fix that by telling `echo` to leave the newlines in place,
so that `base64 -d` can deal with them. Adding `tr -d` is not necessary
in this case.
@npalm npalm self-requested a review January 12, 2024 08:39
@npalm npalm changed the title fix: Make webhook-github-app work with key_base64 with newlines fix(webhook-github-app): Allow new lines in base64 key for module webhook-github-app Jan 12, 2024
Copy link
Member

@npalm npalm left a comment

Choose a reason for hiding this comment

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

@imphil thanks, LGTM

@npalm npalm merged commit 57f056d into github-aws-runners:main Jan 12, 2024
@imphil imphil deleted the webhook-github-app-newlines branch January 12, 2024 11:02
npalm pushed a commit that referenced this pull request Jan 12, 2024
🤖 I have created a release *beep* *boop*
---


##
[5.6.2](philips-labs/terraform-aws-github-runner@v5.6.1...v5.6.2)
(2024-01-12)


### Bug Fixes

* **multi-runner:** remove renundant default labels
([#3715](https://github.com/philips-labs/terraform-aws-github-runner/issues/3715))
([9353734](philips-labs/terraform-aws-github-runner@9353734))
* **webhook-github-app:** Allow new lines in base64 key for module
webhook-github-app
([#3714](https://github.com/philips-labs/terraform-aws-github-runner/issues/3714))
([57f056d](philips-labs/terraform-aws-github-runner@57f056d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: forest-releaser[bot] <80285352+forest-releaser[bot]@users.noreply.github.com>
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