Skip to content

Commit 5ce2759

Browse files
authored
Merge pull request #4384 from Ginger-Automation/CodeQL-ALert-Fix---Uncontrolled-command-line
Do not assign the Expression to mValueCalculated if it was failed to …
2 parents 5fac81d + db227a4 commit 5ce2759

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

Ginger/GingerCoreNET/ValueExpressionLib/ValueExpression.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ private void EvaluateFlowDetails()
292292
}
293293
catch (Exception ex)
294294
{
295-
mValueCalculated = mValueCalculated.Replace(match.Value, string.Format("['{0}' Expression is not valid, Error:'{1}']", match.Value, ex.Message));
296-
Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to evaluate flow details expression '{0}'", match.Value), ex);
295+
mValueCalculated = mValueCalculated.Replace(match.Value, $"Expression is not valid, Error:'{ex.Message}'");
296+
Reporter.ToLog(eLogLevel.ERROR, $"Failed to evaluate flow details expression, Error: '{match.Value}'", ex);
297297
}
298298
}
299299

@@ -305,8 +305,8 @@ private void EvaluateFlowDetails()
305305
}
306306
catch (Exception ex)
307307
{
308-
mValueCalculated = mValueCalculated.Replace(match.Value, string.Format("['{0}' Expression is not valid, Error:'{1}']", match.Value, ex.Message));
309-
Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to evaluate flow details expression '{0}'", match.Value), ex);
308+
mValueCalculated = mValueCalculated.Replace(match.Value, $"Failed to evaluate ExecutionJsonData expression, Error:'{ex.Message}'");
309+
Reporter.ToLog(eLogLevel.ERROR, $"Failed to evaluate ExecutionJsonData expression, Error:'{match.Value}'", ex);
310310
}
311311
}
312312
}
@@ -340,7 +340,7 @@ private void ReplaceExecutionJsonDataDetails(string josnExpression)
340340
}
341341
else
342342
{
343-
mValueCalculated = mValueCalculated.Replace(josnExpression, string.Format("['{0}' Expression Supported only in case the selected Execution Logger type is DB.]", josnExpression));
343+
mValueCalculated = mValueCalculated.Replace(josnExpression, $"[Expression Supported only in case the selected Execution Logger type is DB.]");
344344
return;
345345
}
346346

@@ -558,8 +558,8 @@ private void ReplaceFlowDetails(string flowDetailsExpression)
558558
}
559559
else
560560
{
561-
mValueCalculated = mValueCalculated.Replace(flowDetailsExpression, string.Format("['{0}' Expression is not valid]", flowDetailsExpression));
562-
Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to evaluate flow details expression '{0}' due to invalid 'Field'", flowDetailsExpression));
561+
mValueCalculated = mValueCalculated.Replace(flowDetailsExpression, "[Expression is not valid]");
562+
Reporter.ToLog(eLogLevel.ERROR, $"Failed to evaluate flow details expression '{flowDetailsExpression}' due to invalid 'Field'");
563563
return;
564564
}
565565
}
@@ -671,7 +671,7 @@ private void ReplaceGlobalParameter(string p)
671671
}
672672
else
673673
{
674-
mValueCalculated = mValueCalculated.Replace(p, string.Format("ERROR: The Global Model Parameter '{0}' was not found", VarName));
674+
mValueCalculated = mValueCalculated.Replace(p, $"ERROR: The Global Model Parameter was not found");
675675
}
676676
}
677677

@@ -795,7 +795,7 @@ public void ReplaceDataSource(string p)
795795
// use only the error string otherwise the output might look anamalous
796796
// eg: //*[text()="{Error: The Data Source Variable was not found }"]
797797

798-
mValueCalculated = string.Format("ERROR: The Data Source Variable '{0}' was not found", DSName);
798+
mValueCalculated = $"ERROR: The Data Source Variable was not found";
799799
return;
800800
}
801801

@@ -1071,7 +1071,7 @@ public void ReplaceDataSource(string p)
10711071
}
10721072
else
10731073
{
1074-
mValueCalculated = "ERROR: Not Valid RowNum:" + rowNum;
1074+
mValueCalculated = $"ERROR: Not Valid RowNum:";
10751075
}
10761076
}
10771077

@@ -1284,9 +1284,8 @@ public void ReplaceDataSource(string p)
12841284
}
12851285
catch (Exception e)
12861286
{
1287-
mValueCalculated = e.Message.Contains("There is no row at") ? "No Row Found" : pOrg;
1288-
// Is there a reason to print an error in the console?
1289-
Console.WriteLine(e.StackTrace);
1287+
mValueCalculated = "ERROR: Failed to query data source";
1288+
Reporter.ToLog(eLogLevel.ERROR, "LiteDB data source query failed", e);
12901289
}
12911290
}
12921291
}

0 commit comments

Comments
 (0)