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

[BUG] ipdevinfo ip search crashes on invalid IP address input #2589

Closed
lunkwill42 opened this issue Mar 13, 2023 · 1 comment · Fixed by #2590
Closed

[BUG] ipdevinfo ip search crashes on invalid IP address input #2589

lunkwill42 opened this issue Mar 13, 2023 · 1 comment · Fixed by #2590
Assignees
Labels

Comments

@lunkwill42
Copy link
Member

Describe the bug

If the view portadmin-ip is visited using an invalid IP address as input, the page crashes with a TypeError, rather than handle the error gracefully. This also results in an e-mail being sent unnecessarily to the site admins.

It's not clear how this URL is reachable from within NAV. It may be that someone edited a URL by hand and made a typo, provoking this silly error.

To Reproduce

  1. Go to /ipdevinfo/ip=127.0.0.256/ on your NAV installation.
  2. See error

Expected behavior

If the IP input is invalid, the page should render normally, but display a helpful error message to that effect.

Tracebacks

Traceback (most recent call last):
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/venvs/nav/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/ipdevinfo/views.py", line 271, in ipdev_details
    netbox = get_netbox(name=name, addr=addr)
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/ipdevinfo/views.py", line 177, in get_netbox
    host_information = get_host_info(name or addr)
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/web/ipdevinfo/host_information.py", line 51, in _get_host_info
    if is_valid_ip(host, strict=True):
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/util.py", line 80, in is_valid_ip
    return _is_valid_ip_socket(ip)
  File "/opt/venvs/nav/lib/python3.7/site-packages/nav/util.py", line 88, in _is_valid_ip_socket
    socket.inet_pton(socket.AF_INET, ip)  # IPv4

Environment (please complete the following information):

  • NAV version installed: 5.6.0
@lunkwill42
Copy link
Member Author

Fixed by #2590

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

Successfully merging a pull request may close this issue.

2 participants