Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ <h4 style="margin-top: 0px;">Add Parameters:</h4>
<tbody ng-repeat="paramjen in scriptparams">
<tr ng-repeat="params in paramjen.scriptParameters" ng-init="number = countInit()">
<td class="booleanParam">
<label class="control-label" for="choiceName">Parameter {{number+1}}:<span class="red">*</span></label>
<label class="control-label" for="choiceName">Parameter{{number+1}}:<span class="red">*</span></label>
</td>
<td>
<input id="description" type="text" class="form-control" name="description" ng-model="params.paramDesc" disabled="disabled">
</td>
<td>
<input type="text" class="form-control" name="value" ng-if="params.paramType === 'Default'" ng-model="params.paramVal" required>
<input type="password" class="form-control" name="value" ng-if="params.paramType === 'Password'" ng-model="params.paramVal" required>
<input type="text" class="form-control" name="value" ng-if="params.paramType === 'Restricted'" ng-model="params.paramVal" required>
<input type="text" class="form-control" name="value" ng-if="params.paramType === '' || params.paramType === 'Default'" ng-model="params.paramVal">
<input type="password" class="form-control" name="value" ng-if="params.paramType === 'Password'" ng-model="params.paramVal">
<input type="text" class="form-control" name="value" ng-if="params.paramType === 'Restricted'" ng-model="params.paramVal">
</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h4 class="modal-title"><i class="fa fa-th-list"></i> Add Script Params</h4>
<table id="booleanTable" class="table table-striped table-bordered table-hover dataTable no-footer" cellpadding="5px" width="100%">
<thead>
<tr>
<th class="headParamTable">Key</th>
<th class="headParamTable">Parameter</th>
<th class="headParamTable">Value</th>
<th class="headParamTable">Description</th>
<th class="headParamTable">Type</th>
Expand All @@ -20,12 +20,11 @@ <h4 class="modal-title"><i class="fa fa-th-list"></i> Add Script Params</h4>
</thead>
<tbody>
<tr ng-repeat="param in params track by $index">
<td class="booleanParam"><label class="control-label" for="choiceName">Parameter {{$index+1}}:<span class="red">*</span></label></td>
<td class="booleanParam"><label class="control-label" for="choiceName">Parameter{{$index+1}}:<span class="red">*</span></label></td>
<td><input id="paramVal" type="text" class="form-control" name="paramVal" ng-model="param.paramVal"></td>
<td><input id="paramDesc" type="text" class="form-control" name="paramDesc" ng-model="param.paramDesc"></td>
<td><select id="paramType" name="paramType" class="form-control" ng-model="param.paramType">
<option value="">Choose</option>
<option value="Default">Default</option>
<td><select id="paramType" name="paramType" ng-init="param.paramType = ''" class="form-control" ng-model="param.paramType">
<option value="">Default</option>
<option value="Password">Password</option>
<option value="Restricted">Restricted</option>
</select></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,11 @@ <h5>Script Details</h5>
</thead>
<tbody>
<tr ng-repeat="param in scriptParamsObj[selectedScript._id] track by $index">
<td ng-if="param.paramType === 'Default'">{{param.paramVal}}</td>
<td ng-if="param.paramType === 'Default' || param.paramType === ''">{{param.paramVal}}</td>
<td ng-if="param.paramType === 'Restricted' || param.paramType === 'Password'">.....</td>
<td>{{param.paramDesc}}</td>
<td>{{param.paramType}}</td>
<td ng-if="param.paramType === 'Default' || param.paramType === ''">Default</td>
<td ng-if="param.paramType === 'Restricted' || param.paramType === 'Password'">{{param.paramType}}</td>
<td>
<button title="Delete" type="button" ng-click="removeScriptParams(selectedScript._id,param);"><i class=" fa fa-trash-o"></i></button>
</td>
Expand Down
6 changes: 5 additions & 1 deletion server/app/model/classes/tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
38 changes: 29 additions & 9 deletions server/app/routes/v1.0/routes_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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 = [];
Expand Down
4 changes: 2 additions & 2 deletions server/app/services/botsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down