Skip to content

Commit

Permalink
fix(sense-events): Better handling of unknown UDP messages
Browse files Browse the repository at this point in the history
Fixes #880
  • Loading branch information
Göran Sander committed Aug 28, 2024
1 parent adffeda commit d122863
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib/udp_handlers_log_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ export function udpInitLogEventServer() {
`LOG EVENT: ${msg[0]}:${msg[5]}:${msg[4]}, ${msg[6]}: ${msg[8]}`
);

// Check if the message is a log event message we recognise
// If not, log a warning and return
// Take into account that msg[0] may be undefined, so check for that first
if (
msg[0] === undefined ||
(msg[0].toLowerCase() !== '/qseow-engine/' &&
msg[0].toLowerCase() !== '/qseow-proxy/' &&
msg[0].toLowerCase() !== '/qseow-repository/' &&
msg[0].toLowerCase() !== '/qseow-scheduler/')
) {
// Show warning, include first 512 characters of the message
const msgShort = message.toString().substring(0, 512);
globals.logger.warn(
`LOG EVENT: Received message that is not a recognised log event: ${msgShort}`
);
return;
}

// Check if any of the log event sources are enabled in the configuration
if (
(globals.config.get('Butler-SOS.logEvents.source.engine.enable') === true &&
Expand Down
16 changes: 16 additions & 0 deletions src/lib/udp_handlers_user_activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ export function udpInitUserActivityServer() {
msg[0] = msg[0].toLowerCase().replace('/', '');
msg[0] = msg[0].replace('/', '');

// Check if the message is a user event message we recognise
// If not, log a warning and return
// Take into account that msg[0] may be undefined, so check for that first
if (
msg[0] === undefined ||
(msg[0].toLowerCase() !== 'qseow-proxy-connection' &&
msg[0].toLowerCase() !== 'qseow-proxy-session')
) {
// Show warning, include first 512 characters of the message
const msgShort = message.toString().substring(0, 512);
globals.logger.warn(
`USER EVENT: Received message that is not a recognised user event: ${msgShort}`
);
return;
}

// Build object and convert to JSON
let msgObj;
if (msg[0] === 'qseow-proxy-connection' || msg[0] === 'qseow-proxy-session') {
Expand Down

0 comments on commit d122863

Please sign in to comment.