Skip to content

Commit e31cc8a

Browse files
Sanitize user input before logging it. (#892)
* Sanitize user input before logging it. * Sanitize user input before logging it.
1 parent 3fe6742 commit e31cc8a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

dotnet/src/extensions/Azure/Handlers/QueueHandler/QueueTriggerHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void Run(string myQueueItem, FunctionContext context)
3030
string functionName = context.FunctionDefinition.Name;
3131

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

3535
try
3636
{
@@ -197,20 +197,20 @@ private void ProcessMessage(FunctionContext context, ILogger log, QueueMessage q
197197
}
198198
catch (Exception)
199199
{
200-
log.LogError("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, queueMessage.Id);
200+
log.LogError("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList));
201201
throw; //Throw the exception so the runtime can Retry the operation.
202202
}
203203
}
204204
}
205205
else
206206
{
207-
exMessage = string.Format("{0} GeneXus procedure could not be executed for Message Id {1}.", FunctionExceptionType.SysRuntimeError, queueMessage.Id);
207+
exMessage = string.Format("{0} GeneXus procedure could not be executed for Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList));
208208
throw new Exception(exMessage);
209209
}
210210
}
211211
catch (Exception)
212212
{
213-
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, queueMessage.Id);
213+
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(queueMessage.Id, StringUtil.LogUserEntryWhiteList));
214214
throw; //Throw the exception so the runtime can Retry the operation.
215215
}
216216
}

dotnet/src/extensions/Azure/Handlers/ServiceBusHandler/ServiceBusTriggerHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Run(string myQueueItem, FunctionContext context)
3131
string functionName = context.FunctionDefinition.Name;
3232

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

3636
try
3737
{
@@ -236,7 +236,7 @@ private void ProcessMessage(FunctionContext context, ILogger log, Message messag
236236
}
237237
catch (Exception)
238238
{
239-
exMessage = string.Format("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, message.MessageId);
239+
exMessage = string.Format("{0} Error invoking the GX procedure for Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(message.MessageId, StringUtil.LogUserEntryWhiteList));
240240
log.LogError(exMessage);
241241
throw; //Throw the exception so the runtime can Retry the operation.
242242
}
@@ -250,7 +250,7 @@ private void ProcessMessage(FunctionContext context, ILogger log, Message messag
250250
}
251251
catch (Exception)
252252
{
253-
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, message.MessageId);
253+
log.LogError("{0} Error processing Message Id {1}.", FunctionExceptionType.SysRuntimeError, StringUtil.Sanitize(message.MessageId, StringUtil.LogUserEntryWhiteList));
254254
throw; //Throw the exception so the runtime can Retry the operation.
255255
}
256256
}

0 commit comments

Comments
 (0)