Skip to content

Commit

Permalink
fix(sanitize): assert number for timestamp (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler authored Dec 17, 2024
2 parents 84afa76 + 5fe672c commit 76d7064
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ end
-- Sanitize inputs before every interaction
local function assertAndSanitizeInputs(msg)
assert(
msg.Timestamp and msg.Timestamp >= LastKnownMessageTimestamp,
msg.Timestamp and tonumber(msg.Timestamp) >= LastKnownMessageTimestamp,
"Timestamp must be greater than or equal to the last known message timestamp of "
.. LastKnownMessageTimestamp
.. " but was "
Expand Down
7 changes: 5 additions & 2 deletions tests/monitor/monitor.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ describe('setup', () => {
);
const evalIndex = handlersList.indexOf('_eval');
const defaultIndex = handlersList.indexOf('_default');
const sanitizeIndex = handlersList.indexOf('sanitize');
const pruneIndex = handlersList.indexOf('prune');
assert(
pruneIndex > evalIndex && pruneIndex === defaultIndex + 1,
`Prune index (${pruneIndex}) is not the first handler after _default (${defaultIndex + 1})`,
pruneIndex > sanitizeIndex &&
sanitizeIndex > evalIndex &&
pruneIndex === defaultIndex + 1,
`Prune index (${pruneIndex}) and sanitize index (${sanitizeIndex}) are not the first and second handlers after _default (${defaultIndex + 1})`,
);
});
});
Expand Down

0 comments on commit 76d7064

Please sign in to comment.