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

Validate SonarCloud webhook signature fail was caused by the JsonWriter build request payload #3361

Conversation

ahasgx
Copy link

@ahasgx ahasgx commented May 24, 2024

as a developer, i validate sonarcloud webhook signature fail was caused by the JsonWriter build request payload.

org.sonar.server.webhook.WebhookPayloadFactoryImpl#create build the WebhookPayload with the JsonWriter which in sonar-plugin-api.jar, JsonWriter based on Gson's JsonWriter and set the htmlSafe is true,
so it's escape some chars if the payload contains the chars which in the array HTML_SAFE_REPLACEMENT_CHARS, and signature the payload with the secret, then post the body by the callback url,

But the payload I received was un-escaped so that i validate SonarCloud webhook signature always fail, (the payload is changed).

for example: payload Object has a key-value is {"key": "key=val"}, by the JsonWriter to json, sonar server sign the payload is {"key": "key\u003dval"}, i received the payload is {"key": "key=val"}.

in the document https://docs.sonarsource.com/sonarcloud/advanced-setup/webhooks/#securing-your-webhooks,
i think at least the JsonWriter conver to json that escape some special chars maybe validate sonarcloud webhook signature fail need to describe clearly .

@ahasgx
Copy link
Author

ahasgx commented May 24, 2024

1716533948874

@lukasz-jarocki-sonarsource
Copy link
Member

Hi there,

Thanks for spotting the issue and this contribution! Before we proceed, could you clarify whether the issue you are having is with SonarCloud or SonarQube? Because you mention SonarCloud in your description but this pull request targets SonarQube product.

@ahasgx
Copy link
Author

ahasgx commented May 29, 2024

Hi there,

Thanks for spotting the issue and this contribution! Before we proceed, could you clarify whether the issue you are having is with SonarCloud or SonarQube? Because you mention SonarCloud in your description but this pull request targets SonarQube product.

Sorry, I thought it was the same organization.

@ahasgx ahasgx closed this May 29, 2024
@ahasgx
Copy link
Author

ahasgx commented May 29, 2024

ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants