View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
17126 | Bug reports | Encryption | public | 2021-02-24 13:43 | 2021-04-08 19:55 |
Reporter | annighoefer | Assigned To | p_teichmann | ||
Priority | high | Severity | partial_block | ||
Status | assigned | Resolution | fixed | ||
Product Version | 4.4.7 | ||||
Summary | 17126: encrypted questions do not work when multiple groups are used | ||||
Description | Encrypted data of encrypted question in database are encrypted again, if participant switch between groups with "previous" and "next" button or submit the survey. After that, data can't be decrypted and isn't readable in the backend under Responses (Screenshot). | ||||
Steps To Reproduce | 1. add multiple groups and questions into groups (at least 2 groups) 2. add encrypted Question in first group 3. set Format to "Question by Question" or "Group by Group" under General Settings 4. activate survey 5. go to the survey 6. fill out the questions 7. submit the survey 8. go to "Responses" in the backend 9. the encrypted questions show encrypted value, the field can no longer be decrypted | ||||
Additional Information | Every time there is a change between the groups, the function encryptSave () is called with the current response object. But the response object contains encrypted attributes and with encryptSave these are encrypted again. My quick & dirty solution is before the encryptSave function is called, the encrypted attributes are decrypted. (see patch) | ||||
Tags | encryption | ||||
Complete LimeSurvey version number (& build) | Release 4.4.9+210219 da4b348 | ||||
I will donate to the project if issue is resolved | No | ||||
Browser | |||||
Database & DB-Version | mysql Ver 8.0.23 | ||||
Server OS (if known) | |||||
Webserver software & version (if known) | |||||
PHP Version | PHP 7.4.15 | ||||
em_manager_helper.patch (1,903 bytes)
diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index 25391f7d10..938a904b9b 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -5171,7 +5171,28 @@ class LimeExpressionManager return; } if ($oResponse->submitdate == null || Survey::model()->findByPk($this->sid)->alloweditaftercompletion == 'Y') { + + // -------------- BUG CODE IMPLEMENTATION DECRYPT FIRST ENCRYPTED FIELDS ------- + + // get all encrypted attributes of current survey + $encryptedAttributes = Response::getEncryptedAttributes($this->sid); + + if (count($encryptedAttributes) > 0) { + $decryptedAttributes = array(); + + foreach ($encryptedAttributes as $key => $value) { + if (isset($oResponse->$value) && $oResponse->$value) { + // decrypt all encrypted values of current survey + $decryptedAttributes[$value] = $oResponse->decrypt($oResponse->$value); + } + } + + // set decypted values to response object + $oResponse->setAttributes($decryptedAttributes, false); + } + $oResponse->setAttributes($aResponseAttributes, false); + if (!$oResponse->encryptSave()) { $message = submitfailed('', print_r($oResponse->getErrors(), true)); // $response->getErrors() is array[string[]], then can not join if (($this->debugLevel & LEM_DEBUG_VALIDATION_SUMMARY) == LEM_DEBUG_VALIDATION_SUMMARY) { |
|
Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=31559 | |
LimeSurvey: master 052188f1 2021-04-08 09:46:14 Details Diff |
Fixed issue 17126: encrypted question causes error when multiple groups are used or question by question mode is activated |
Affected Issues 17126 |
|
mod - application/helpers/expressions/em_manager_helper.php | Diff File | ||
mod - application/models/LSActiveRecord.php | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2021-02-24 13:43 | annighoefer | New Issue | |
2021-02-24 13:43 | annighoefer | File Added: em_manager_helper.patch | |
2021-02-24 13:43 | annighoefer | File Added: screenshot-1.png | |
2021-02-24 14:49 | ollehar | Tag Attached: encryption | |
2021-02-24 14:49 | ollehar | Assigned To | => p_teichmann |
2021-02-24 14:49 | ollehar | Status | new => assigned |
2021-02-24 14:49 | ollehar | Priority | none => normal |
2021-02-24 14:49 | ollehar | Severity | minor => partial_block |
2021-02-24 14:49 | ollehar | Steps to Reproduce Updated | View Revisions |
2021-03-29 14:14 | c_schmitz | Priority | normal => high |
2021-04-08 12:13 | p_teichmann | Changeset attached | => LimeSurvey master 052188f1 |
2021-04-08 12:13 | p_teichmann | Note Added: 63866 | |
2021-04-08 12:13 | p_teichmann | Resolution | open => fixed |