Skip to content

Commit

Permalink
Sanitize user input before logging it. (#892)
Browse files Browse the repository at this point in the history
* Sanitize user input before logging it.

* Sanitize user input before logging it.
  • Loading branch information
claudiamurialdo authored Oct 31, 2023
1 parent 3fe6742 commit e31cc8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Run(string myQueueItem, FunctionContext context)
string functionName = context.FunctionDefinition.Name;

QueueMessage queueMessage = SetupMessage(context, myQueueItem);
log.LogInformation($"GeneXus Queue trigger handler. Function processed: {functionName} Invocation Id: {context.InvocationId}. Queue item : {queueMessage.Id}");
log.LogInformation($"GeneXus Queue trigger handler. Function processed: {functionName} Invocation Id: {context.InvocationId}. Queue item : {StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList)}");

try
{
Expand Down Expand Up @@ -197,20 +197,20 @@ private void ProcessMessage(FunctionContext context, ILogger log, QueueMessage q
}
catch (Exception)
{
log.LogError("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, queueMessage.Id);
log.LogError("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList));
throw; //Throw the exception so the runtime can Retry the operation.
}
}
}
else
{
exMessage = string.Format("{0} GeneXus procedure could not be executed for Message Id {1}.", FunctionExceptionType.SysRuntimeError, queueMessage.Id);
exMessage = string.Format("{0} GeneXus procedure could not be executed for Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList));
throw new Exception(exMessage);
}
}
catch (Exception)
{
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, queueMessage.Id);
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList));
throw; //Throw the exception so the runtime can Retry the operation.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Run(string myQueueItem, FunctionContext context)
string functionName = context.FunctionDefinition.Name;

Message message = SetupMessage(context, myQueueItem);
log.LogInformation($"GeneXus Service Bus trigger handler. Function processed: {functionName}. Queue item Id: {message.MessageId}");
log.LogInformation($"GeneXus Service Bus trigger handler. Function processed: {functionName}. Queue item Id: {StringUtil.Sanitize(message.MessageId, StringUtil.LogUserEntryWhiteList)}");

try
{
Expand Down Expand Up @@ -236,7 +236,7 @@ private void ProcessMessage(FunctionContext context, ILogger log, Message messag
}
catch (Exception)
{
exMessage = string.Format("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, message.MessageId);
exMessage = string.Format("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(message.MessageId, StringUtil.LogUserEntryWhiteList));
log.LogError(exMessage);
throw; //Throw the exception so the runtime can Retry the operation.
}
Expand All @@ -250,7 +250,7 @@ private void ProcessMessage(FunctionContext context, ILogger log, Message messag
}
catch (Exception)
{
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, message.MessageId);
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(message.MessageId, StringUtil.LogUserEntryWhiteList));
throw; //Throw the exception so the runtime can Retry the operation.
}
}
Expand Down

0 comments on commit e31cc8a

Please sign in to comment.