Describe the bug
If you set Time options to hours and set a large number as input (e.g. 123123123123) then you will get a 500 error.
You will get different errors based on how big the number is. 123123123123 gives a InvalidTimeZoneDisplacementValue with the message
time zone displacement out of range: "-14043795-09-03 12:45"
LINE 4: ...username) LIKE 'username' AND (time >= timestamp '-14043795...
while 123123123123123 gives an OSError with the message [Errno 75] Value too large for defined data type
To Reproduce
Steps to reproduce the behavior
- Go to
/radius/logsearch
- Enter a username (doesnt have to be real) in the box beneath where it says
Username
- Change
Time options to Hour(s)
- Put
123123123123 in the box beneath where it says Hour(s)
- Click
Search
- See error
Expected behavior
If there is a logical limit to how big the number should be, then either the form shouldnt allow you to
click Search until you enter a valid number, or an error should be shown saying something along the lines of Hours must be between X and Y after you click the button.
If there shouldnt be a limit on how big the number can be, then it should work the same as it does with a smaller number.
Tracebacks
Traceback (most recent call last):
File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/source/python/nav/web/radius/views.py", line 93, in log_search
query.execute()
File "/source/python/nav/web/radius/db.py", line 56, in execute
cursor.execute(self.query, self.parameters)
Exception Type: InvalidTimeZoneDisplacementValue at /radius/logsearch
Exception Value: time zone displacement out of range: "-14043795-09-03 12:49"
LINE 4: ... LOWER(username) LIKE '1' AND (time >= timestamp '-14043795...
^
Traceback (most recent call last):
File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/source/python/nav/web/radius/views.py", line 82, in log_search
query = LogSearchQuery(
File "/source/python/nav/web/radius/db.py", line 180, in __init__
DATEFORMAT_SEARCH, time.localtime(time.time() - searchtime)
Exception Type: OSError at /radius/logsearch
Exception Value: [Errno 75] Value too large for defined data type
Describe the bug
If you set
Time optionsto hours and set a large number as input (e.g.123123123123) then you will get a500error.You will get different errors based on how big the number is.
123123123123gives aInvalidTimeZoneDisplacementValuewith the messagewhile
123123123123123gives anOSErrorwith the message[Errno 75] Value too large for defined data typeTo Reproduce
Steps to reproduce the behavior
/radius/logsearchUsernameTime optionstoHour(s)123123123123in the box beneath where it saysHour(s)SearchExpected behavior
If there is a logical limit to how big the number should be, then either the form shouldnt allow you to
click
Searchuntil you enter a valid number, or an error should be shown saying something along the lines ofHours must be between X and Yafter you click the button.If there shouldnt be a limit on how big the number can be, then it should work the same as it does with a smaller number.
Tracebacks