Dependency Graph

Dependency Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
17126Bug reportsEncryptionpublic2021-07-14 13:16
Reporterannighoefer Assigned Top_teichmann  
PriorityhighSeveritypartial_block 
Status closedResolutionfixed 
Product Version4.4.7 
Fixed in Version4.5.x 
Summary17126: 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)

Tagsencryption
Attached Files
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) {
em_manager_helper.patch (1,903 bytes)   
screenshot-1.png (89,485 bytes)   
screenshot-1.png (89,485 bytes)   
Bug heat6
Complete LimeSurvey version number (& build) Release 4.4.9+210219 da4b348
I will donate to the project if issue is resolvedNo
Browser
Database type & versionmysql Ver 8.0.23
Server OS (if known)
Webserver software & version (if known)
PHP VersionPHP 7.4.15

Relationships

related to 17409 closedp_teichmann Exporting 3000 encrypted results (200 questions) to Excel requires too many ressources, export fails 

Activities

p_teichmann

p_teichmann

2021-04-08 12:13

administrator   ~63866

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=31559

c_schmitz

c_schmitz

2021-07-12 11:53

administrator   ~65335

Release done.

Related Changesets

LimeSurvey: master 052188f1

2021-04-08 09:46:14

p_teichmann

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

Issue History

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
2021-03-29 14:14 c_schmitz Priority normal => high
2021-03-29 14:14 c_schmitz Sync to Zoho Project => |Yes|
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
2021-04-08 19:55 kjnerhus Issue Monitored: kjnerhus
2021-07-06 09:35 p_teichmann Status assigned => resolved
2021-07-06 09:35 p_teichmann Fixed in Version => 4.5.x
2021-07-12 11:53 c_schmitz Note Added: 65335
2021-07-12 11:53 c_schmitz Status resolved => closed
2021-07-14 13:16 Mazi Relationship added related to 17409