Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend fails to render when invalid date in CTF #297

Open
daanbreur opened this issue Jul 17, 2024 · 1 comment
Open

Frontend fails to render when invalid date in CTF #297

daanbreur opened this issue Jul 17, 2024 · 1 comment

Comments

@daanbreur
Copy link
Contributor

Bug

If there is a CTF entry with a invalid date in the database the frontend bug out. You can keep using CTFNote by directly opening the ctf pages if you know their ID and name. The page for the bugged entry will not open using this trick however

image
image

In the pictures above you see what normally happens when using the website.

image
image
image

However if you "invalid date" you see that the graphql does send the data over but the site does not render properly. In the last image you see what happens when you directly go to the http://localhost:8088/#/ctf/2-ads/info page.

Proposal

This bug can be quite harmful because you will have to manually edit the database (or craft a GraphQL query) to get your instance working again. To fix this issue I have 2 proposed fixes.

  1. Make sure server side that invalid dates can never occur.
  2. Capture invalid dates client side and show an error.
  3. Make sure you cannot set these dates in the create CTF menu.
@daanbreur
Copy link
Contributor Author

From what I could find the bug probably lies in the function extractDate.
I am not exactly sure but it might even be a bug in date.extractDate from Quasar Date Utils. Or just wrong implementation of this function

function extractDate(d: string) {
const masks = [
'YYYY-MM-DDTHH:mm:ss.SSSZ',
'YYYY-MM-DDTHH:mm:ss.SSZ',
'YYYY-MM-DDTHH:mm:ss.SZ',
'YYYY-MM-DDTHH:mm:ssZ',
];
for (const mask of masks) {
const r = date.extractDate(d, mask);
if (r.valueOf() > 0) {
return r;
}
}
throw 'invalid date';
}

In some cases this function throws invalid date and there is no place in the UI that calls this function and catches the thrown error (as far as I can see by checking references)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant