Private key input for GCP streaming form
Problem Statement
Currently in GCP config streaming form when a user enters a private key input its substitutes \n
with \\n
which makes the private key wrong.
This problem does not occur when using GraphQL API https://docs.gitlab.com/ee/administration/audit_event_streaming/graphql_api.html#google-cloud-logging-streaming, we need to handle this in frontend and make sure in input we are only sending \n
with a single \
character.
This bug was found in verification of #409424 (closed). for more info check: #409424 (comment 1461420428)
Verification steps
- go to issue-reproduce audit events streams
- Create Google Cloud Logging destination -> Select Add streaming destination > Google Cloud Logging
- enter some data for Project ID, Client Email, and Log ID
- Copy the fake private key below and paste in the Private Key input. all
\n
should be converted to new lines. - Open the network tab in chrome devtools
- When clicking "Add", inspect the API call and check that the private key input in the graphql payload does not contain escaped newlines like
\\n
.
Fake private key
-----BEGIN PRIVATE KEY-----\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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nxxxxxxxxxxxxxxxxxxxxx=\n-----END PRIVATE KEY-----\nYou could also check with a GCP account and real private key and verify that the logs are coming through. This was tested by @harsimarsandhu
on the MR: !125746 (comment 1463426369)
Edited by Lorenz van Herwaarden