From 6548cf1bb3756f952312c713958057dec55d8b72 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Wed, 4 Jan 2017 12:40:23 +0530 Subject: [PATCH 1/3] BOTs Implementation --- server/app/model/classes/tasks/tasks.js | 6 +++- server/app/routes/v1.0/routes_tasks.js | 38 +++++++++++++++++++------ server/app/services/botsService.js | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/server/app/model/classes/tasks/tasks.js b/server/app/model/classes/tasks/tasks.js index 1f24c7d8a..9b87b7a7f 100755 --- a/server/app/model/classes/tasks/tasks.js +++ b/server/app/model/classes/tasks/tasks.js @@ -1089,8 +1089,12 @@ function filterScriptTaskData(data,callback){ if (scriptTask.scriptParameters.length > 0) { scriptCount++; for (var k = 0; k < scriptTask.scriptParameters.length; k++) { - scriptTask.scriptParameters[k].paramVal = cryptography.decryptText(scriptTask.scriptParameters[k].paramVal, cryptoConfig.decryptionEncoding, + if(scriptTask.scriptParameters[k].paramType === '' || scriptTask.scriptParameters[k].paramType === 'Default' || scriptTask.scriptParameters[k].paramType === 'Password'){ + scriptTask.scriptParameters[k].paramVal = cryptography.decryptText(scriptTask.scriptParameters[k].paramVal, cryptoConfig.decryptionEncoding, cryptoConfig.encryptionEncoding); + }else { + scriptTask.scriptParameters[k].paramVal = ''; + } } } else { scriptCount++; diff --git a/server/app/routes/v1.0/routes_tasks.js b/server/app/routes/v1.0/routes_tasks.js index b92e70f64..9d6928efa 100755 --- a/server/app/routes/v1.0/routes_tasks.js +++ b/server/app/routes/v1.0/routes_tasks.js @@ -545,7 +545,7 @@ module.exports.setRoutes = function(app, sessionVerification) { res.status(500).send(errorResponses.db.error); return; } - encryptedParam(taskData.scriptDetails,function(err, encryptedParam) { + encryptedParam(taskData.scriptDetails,scriptTask.taskConfig.scriptDetails,function(err, encryptedParam) { if (err) { logger.error(err); res.status(500).send("Failed to encrypted script parameters: ", err); @@ -684,7 +684,7 @@ module.exports.setRoutes = function(app, sessionVerification) { }; -function encryptedParam(paramDetails, callback) { +function encryptedParam(paramDetails,existingParams, callback) { var cryptoConfig = appConfig.cryptoSettings; var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password); var count = 0; @@ -695,13 +695,33 @@ function encryptedParam(paramDetails, callback) { count++; for (var j = 0; j < paramDetail.scriptParameters.length; j++) { (function (scriptParameter) { - var encryptedText = cryptography.encryptText(scriptParameter.paramVal, cryptoConfig.encryptionEncoding, - cryptoConfig.decryptionEncoding); - encryptedList.push({ - paramVal: encryptedText, - paramDesc: scriptParameter.paramDesc, - paramType: scriptParameter.paramType - }); + if(scriptParameter.paramType ==='Restricted' && scriptParameter.paramVal ===''){ + if(paramDetails.length === existingParams.length && paramDetail.scriptId ===existingParams[i].scriptId) { + encryptedList.push({ + paramVal: existingParams[i].scriptParameters[j].paramVal, + paramDesc: scriptParameter.paramDesc, + paramType: scriptParameter.paramType + }); + }else{ + for(var k = 0; k < existingParams.length; k++){ + if(paramDetail.scriptId === existingParams[k].scriptId){ + encryptedList.push({ + paramVal: existingParams[k].scriptParameters[j].paramVal, + paramDesc: scriptParameter.paramDesc, + paramType: scriptParameter.paramType + }); + } + } + } + }else { + var encryptedText = cryptography.encryptText(scriptParameter.paramVal, cryptoConfig.encryptionEncoding, + cryptoConfig.decryptionEncoding); + encryptedList.push({ + paramVal: encryptedText, + paramDesc: scriptParameter.paramDesc, + paramType: scriptParameter.paramType + }); + } if (encryptedList.length === paramDetail.scriptParameters.length) { paramDetail.scriptParameters = encryptedList; encryptedList = []; diff --git a/server/app/services/botsService.js b/server/app/services/botsService.js index 902571d19..5e784d442 100644 --- a/server/app/services/botsService.js +++ b/server/app/services/botsService.js @@ -399,7 +399,7 @@ function filterScriptBotsData(data,callback){ if (scriptBot.scriptParameters.length > 0) { scriptCount++; for (var k = 0; k < scriptBot.scriptParameters.length; k++) { - if(scriptBot.scriptParameters[k].paramType === 'Default' || scriptBot.scriptParameters[k].paramType === 'Password'){ + if(scriptBot.scriptParameters[k].paramType === '' || scriptBot.scriptParameters[k].paramType === 'Default' || scriptBot.scriptParameters[k].paramType === 'Password'){ scriptBot.scriptParameters[k].paramVal = cryptography.decryptText(scriptBot.scriptParameters[k].paramVal, cryptoConfig.decryptionEncoding, cryptoConfig.encryptionEncoding); }else { From 1cce31d79b3ddd231a1cd6fe34d95c751edc3fe8 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Wed, 4 Jan 2017 13:11:06 +0530 Subject: [PATCH 2/3] BOTs Implementation --- .../sections/dashboard/bots/view/editParams.html | 4 ++-- .../workzone/orchestration/popups/addScriptParams.html | 9 ++++----- .../dashboard/workzone/orchestration/popups/newTask.html | 5 +++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/cat3/src/partials/sections/dashboard/bots/view/editParams.html b/client/cat3/src/partials/sections/dashboard/bots/view/editParams.html index 4c81a396a..4f6c2e5f2 100644 --- a/client/cat3/src/partials/sections/dashboard/bots/view/editParams.html +++ b/client/cat3/src/partials/sections/dashboard/bots/view/editParams.html @@ -89,13 +89,13 @@

Add Parameters:

- + - + diff --git a/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/addScriptParams.html b/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/addScriptParams.html index 052d788a5..9595ac27b 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/addScriptParams.html +++ b/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/addScriptParams.html @@ -11,7 +11,7 @@ - + @@ -20,12 +20,11 @@ - + - diff --git a/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/newTask.html b/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/newTask.html index c28c6c900..98a6df5bf 100644 --- a/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/newTask.html +++ b/client/cat3/src/partials/sections/dashboard/workzone/orchestration/popups/newTask.html @@ -579,10 +579,11 @@
Script Details
- + - + + From a29eec147b57a1e0f47dae78ff021e37004dbc93 Mon Sep 17 00:00:00 2001 From: Durgesh1988 Date: Wed, 4 Jan 2017 13:23:48 +0530 Subject: [PATCH 3/3] CAT-2613 Unable to Execute Chef task & Jenkins JOB from BOTS --- server/app/services/botsService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app/services/botsService.js b/server/app/services/botsService.js index 5e784d442..134f3008a 100644 --- a/server/app/services/botsService.js +++ b/server/app/services/botsService.js @@ -330,7 +330,7 @@ botsService.executeBots = function executeBots(botId,reqBody,callback){ if(reqBody.paramOptions.scriptParams){ encryptedParam(reqBody.paramOptions.scriptParams,next); }else{ - next([],next); + next(null,[]); } }, function(encryptedParamList,next) {