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

Fix issue with SONARQUBE_EXTRA_PROPERTIES containing equals #69251

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

akhamar
Copy link
Contributor

@akhamar akhamar commented Jul 15, 2024

Description of the change

Fix an issue with sonarqube script that do not extract extra env var (SONARQUBE_EXTRA_PROPERTIES)

Benefits

Fix an issue

Possible drawbacks

None ?

Applicable issues

N/A

Additional information

Invalid replacement of extra vars (SONARQUBE_EXTRA_PROPERTIES)

Script

#!/bin/bash

SONARQUBE_EXTRA_PROPERTIES=sonar.core.serverBaseURL=https://example.com,sonar.auth.saml.enabled=true,sonar.auth.saml.applicationId=Example,sonar.auth.saml.providerName=SAML,sonar.auth.saml.providerId=https://example.com/saml2?idpid=IDEXAMPLE,sonar.auth.saml.loginUrl=https://example.com/saml2/idp?idpid=IDEXAMPLE,sonar.auth.saml.user.login=login,sonar.auth.saml.user.name=username,sonar.auth.saml.user.email=email
echo "SONARQUBE_EXTRA_PROPERTIES: $SONARQUBE_EXTRA_PROPERTIES"

IFS=',' read -r -a additional_properties <<< "$SONARQUBE_EXTRA_PROPERTIES"
if [[ "${#additional_properties[@]}" -gt 0 ]]; then
    info "Adding properties provided via SONARQUBE_EXTRA_PROPERTIES to sonar.properties"
    for property in "${additional_properties[@]}"; do
        echo "${property%=*}=${property#*=}"
    done
fi

Invalid result

SONARQUBE_EXTRA_PROPERTIES: sonar.core.serverBaseURL=https://example.com,sonar.auth.saml.enabled=true,sonar.auth.saml.applicationId=Example,sonar.auth.saml.providerName=SAML,sonar.auth.saml.providerId=https://example.com/saml2?idpid=IDEXAMPLE,sonar.auth.saml.loginUrl=https://example.com/saml2/idp?idpid=IDEXAMPLE,sonar.auth.saml.user.login=login,sonar.auth.saml.user.name=username,sonar.auth.saml.user.email=email
info: No menu item 'Adding properties provided via SONARQUBE_EXTRA_PROPERTIES to sonar.properties' in node '(dir)Top'
sonar.core.serverBaseURL=https://example.com
sonar.auth.saml.enabled=true
sonar.auth.saml.applicationId=Example
sonar.auth.saml.providerName=SAML
sonar.auth.saml.providerId=https://example.com/saml2?idpid=https://example.com/saml2?idpid=IDEXAMPLE
sonar.auth.saml.loginUrl=https://example.com/saml2/idp?idpid=https://example.com/saml2/idp?idpid=IDEXAMPLE
sonar.auth.saml.user.login=login
sonar.auth.saml.user.name=username
sonar.auth.saml.user.email=email

sonar.auth.saml.providerId=https://example.com/saml2?idpid=https://example.com/saml2?idpid=IDEXAMPLE

Invalid double replacement

Correct replacement of extra vars (SONARQUBE_EXTRA_PROPERTIES)

Script

#!/bin/bash

SONARQUBE_EXTRA_PROPERTIES=sonar.core.serverBaseURL=https://example.com,sonar.auth.saml.enabled=true,sonar.auth.saml.applicationId=Example,sonar.auth.saml.providerName=SAML,sonar.auth.saml.providerId=https://example.com/saml2?idpid=IDEXAMPLE,sonar.auth.saml.loginUrl=https://example.com/saml2/idp?idpid=IDEXAMPLE,sonar.auth.saml.user.login=login,sonar.auth.saml.user.name=username,sonar.auth.saml.user.email=email
echo "SONARQUBE_EXTRA_PROPERTIES: $SONARQUBE_EXTRA_PROPERTIES"

IFS=',' read -r -a additional_properties <<< "$SONARQUBE_EXTRA_PROPERTIES"
if [[ "${#additional_properties[@]}" -gt 0 ]]; then
    info "Adding properties provided via SONARQUBE_EXTRA_PROPERTIES to sonar.properties"
    for property in "${additional_properties[@]}"; do
        echo "${property%%=*}=${property#*=}"
    done
fi

Correct result

SONARQUBE_EXTRA_PROPERTIES: sonar.core.serverBaseURL=https://example.com,sonar.auth.saml.enabled=true,sonar.auth.saml.applicationId=Example,sonar.auth.saml.providerName=SAML,sonar.auth.saml.providerId=https://example.com/saml2?idpid=IDEXAMPLE,sonar.auth.saml.loginUrl=https://example.com/saml2/idp?idpid=IDEXAMPLE,sonar.auth.saml.user.login=login,sonar.auth.saml.user.name=username,sonar.auth.saml.user.email=email
info: No menu item 'Adding properties provided via SONARQUBE_EXTRA_PROPERTIES to sonar.properties' in node '(dir)Top'
sonar.core.serverBaseURL=https://example.com
sonar.auth.saml.enabled=true
sonar.auth.saml.applicationId=Example
sonar.auth.saml.providerName=SAML
sonar.auth.saml.providerId=https://example.com/saml2?idpid=IDEXAMPLE
sonar.auth.saml.loginUrl=https://example.com/saml2/idp?idpid=IDEXAMPLE
sonar.auth.saml.user.login=login
sonar.auth.saml.user.name=username
sonar.auth.saml.user.email=email

sonar.auth.saml.providerId=https://example.com/saml2?idpid=IDEXAMPLE

Correct replacement

Fix issue with extra env var with equals in them

Signed-off-by: Mastah <32886437+akhamar@users.noreply.github.com>
Fix issue with extra env var with equals in them

Signed-off-by: Mastah <32886437+akhamar@users.noreply.github.com>
@github-actions github-actions bot added sonarqube triage Triage is needed labels Jul 15, 2024
@github-actions github-actions bot requested a review from javsalgar July 15, 2024 09:18
@carrodher carrodher added verify Execute verification workflow for these changes in-progress labels Jul 15, 2024
@github-actions github-actions bot removed the triage Triage is needed label Jul 15, 2024
@github-actions github-actions bot removed the request for review from javsalgar July 15, 2024 09:30
@github-actions github-actions bot requested a review from alemorcuq July 15, 2024 09:30
Copy link

This Pull Request has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thank you for your contribution.

@github-actions github-actions bot added the stale 15 days without activity label Jul 31, 2024
@carrodher carrodher requested review from andresbono and removed request for alemorcuq July 31, 2024 16:25
@carrodher carrodher assigned andresbono and unassigned alemorcuq Jul 31, 2024
@github-actions github-actions bot removed the stale 15 days without activity label Aug 1, 2024
Copy link
Contributor

@andresbono andresbono left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@andresbono andresbono merged commit 71db2a0 into bitnami:main Aug 9, 2024
27 checks passed
@andresbono
Copy link
Contributor

The next release of the container images will include your fix. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved sonarqube verify Execute verification workflow for these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants