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

Escape double quotes when migrating portal settings. #1814

Conversation

aaronweeden
Copy link
Contributor

@aaronweeden aaronweeden commented Jan 25, 2024

Description

This PR fixes a bug in which double quotes are not properly escaped when migrating portal settings.

Motivation and Context

This was noticed when testing the upgrade path for the ondemand module.

In xdmod-ondemand, in configuration/portal_settings.d/ondemand.ini, the value for webserver_format_str has backslash-escaped double quotes.

When running the test steps below (which are based on the CircleCI upgrade path for xdmod-ondemand) (and instead cloning https://github.com/ubccr/xdmod into /xdmod), after running the first set of commands, the file /etc/xdmod/portal_settings.d/ondemand.ini had unescaped quotes.

This is because when the file is parsed in classes/OpenXdmod/Migration/ConfigFilesMigration.php in the function writeModulePortalSettingsFile when it calls parse_ini_file, the backslashes are not preserved in the data, so they are not written back into the file.

Then, after running the second set of commands below, the web server log parser prints Skip for each of the lines in the example log file, so no data are loaded into the modw_ondemand database, because the double quotes in the format string are not being properly escaped in the regex used to parse the file.

Tests performed

In a Docker container running tools-ext-01.ccr.xdmod.org/xdmod-10.5.0-x86_64:rockylinux8.5-0.3:

  1. Run the commands below:
    export COMPOSER_ALLOW_SUPERUSER=1
    export XDMOD_REALMS='jobs,storage,cloud'
    export XDMOD_IS_CORE=yes
    export XDMOD_INSTALL_DIR=/xdmod
    export XDMOD_TEST_MODE=upgrade
    export XDMOD_SRC_DIR=/xdmod
    git clone https://github.com/aaronweeden/xdmod -b portal-settings-migration-escape-quotes /xdmod
    git clone https://github.com/aaronweeden/xdmod-ondemand -b update-11.0 /xdmod-ondemand
    dnf module -y reset nodejs
    dnf module -y install nodejs:16
    cd /xdmod-ondemand
    ln -s `pwd` $XDMOD_SRC_DIR/open_xdmod/modules/ondemand
    composer install -d $XDMOD_SRC_DIR --no-progress
    export XDMOD_SOURCE_DIR=/xdmod
    pushd $XDMOD_SRC_DIR
    ~/bin/buildrpm xdmod ondemand
    popd
    $XDMOD_SRC_DIR/tests/ci/bootstrap.sh
    
  2. Confirm the value webserver_format_str is the same for /etc/xdmod/portal_settings.d/ondemand.ini and /xdmod/open_xdmod/modules/ondemand/configuration/portal_settings.d/ondemand.ini.
  3. Run the commands below (these come from xdmod-ondemand in tests/scripts/bootstrap.sh):
    expect ./tests/scripts/setup.tcl | col -b
    sudo -u xdmod xdmod-ingestor
    LOGPATH=/tmp/ondemand
    mkdir $LOGPATH
    cp ./tests/artifacts/*.log $LOGPATH
    sudo -u xdmod xdmod-ondemand-ingestor -d $LOGPATH -u https://localhost:3443 -r styx --debug
    
  4. Confirm the parser did not print Skip for the lines in the example log file, and the modw_ondemand database has the expected data.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@aaronweeden aaronweeden added the bug Bugfixes label Jan 25, 2024
@aaronweeden aaronweeden added this to the 11.0.0 milestone Jan 25, 2024
@aaronweeden aaronweeden force-pushed the portal-settings-migration-escape-quotes branch from 6dea2df to 1b84a76 Compare February 20, 2024 16:48
@aaronweeden aaronweeden merged commit 4961fb8 into ubccr:xdmod11.0 Feb 20, 2024
4 checks passed
@aaronweeden aaronweeden deleted the portal-settings-migration-escape-quotes branch February 20, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugfixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants