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

Search for circuit ID with / generates error #1243

Closed
awfki opened this issue Jun 1, 2017 · 1 comment
Closed

Search for circuit ID with / generates error #1243

awfki opened this issue Jun 1, 2017 · 1 comment
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@awfki
Copy link

awfki commented Jun 1, 2017

Issue type:

Bug Report

Python version: 2.7.5
NetBox version: v2.0.4

Entered "39/KFFN/111376/TWCS" (no quotes) in the search field and received the error message below.

It seems that it interpreted a number and slash as an IP/prefix and it doesn't allow that. I'd think the simplest solution would be to check for alpha characters and if present assume it's not an IP.

Internal Server Error: /search/

ValueError at /search/
IPAddress() does not support netmasks or subnet prefixes! See documentation for details.

Request Method: GET
Request URL: https://netbox.rsglab.lan/search/?q=39%2FKFFN%2F111376%2FTWCS
Django Version: 1.11.1
Python Executable: /usr/bin/python
Python Version: 2.7.5
Python Path: ['/opt/netbox/netbox', '/opt/netbox/netbox', '/usr/bin', '/usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages']
Server time: Thu, 1 Jun 2017 19:30:09 +0000
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'corsheaders',
'debug_toolbar',
'django_filters',
'django_tables2',
'mptt',
'rest_framework',
'rest_framework_swagger',
'circuits',
'dcim',
'ipam',
'extras',
'secrets',
'tenancy',
'users',
'utilities')
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'utilities.middleware.LoginRequiredMiddleware',
'utilities.middleware.APIVersionMiddleware')

Traceback:

File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)

File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)

File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python2.7/site-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)

File "/usr/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
88. return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/netbox/views.py" in get
191. filtered_queryset = filter_cls({'q': form.cleaned_data['q']}, queryset=queryset).qs

File "/usr/lib/python2.7/site-packages/django_filters/filterset.py" in qs
214. qs = filter_.filter(qs, value)

File "/usr/lib/python2.7/site-packages/django_filters/filters.py" in call
687. return self.method(qs, self.f.name, value)

File "/opt/netbox/netbox/ipam/filters.py" in search
86. prefix = str(IPNetwork(value.strip()).cidr)

File "/usr/lib/python2.7/site-packages/netaddr/ip/init.py" in init
923. implicit_prefix, flags)

File "/usr/lib/python2.7/site-packages/netaddr/ip/init.py" in parse_ip_network
805. mask = IPAddress(val2, module.version, flags=INET_PTON)

File "/usr/lib/python2.7/site-packages/netaddr/ip/init.py" in init
280. % self.class.name)

Exception Type: ValueError at /search/
Exception Value: IPAddress() does not support netmasks or subnet prefixes! See documentation for details.
Request information:
USER: gozer

GET:
q = u'39/KFFN/111376/TWCS'

POST: No POST data

FILES: No FILES data

COOKIES:
csrftoken = 'SpDaLUVy2C5hDyUrYf89WFTVwqyNv4qknu3eFMTk6OMJsRmTE6RKsz7tqlN1uFyJ'
sessionid = '1ihdi18e07ks2ognmgkqy7w7qu99v9rf'

META:
CSRF_COOKIE = 'SpDaLUVy2C5hDyUrYf89WFTVwqyNv4qknu3eFMTk6OMJsRmTE6RKsz7tqlN1uFyJ'
HTTP_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8'
HTTP_ACCEPT_ENCODING = 'gzip, deflate, sdch, br'
HTTP_ACCEPT_LANGUAGE = 'en-US,en;q=0.8'
HTTP_CONNECTION = 'close'
HTTP_COOKIE = 'sessionid=1ihdi18e07ks2ognmgkqy7w7qu99v9rf; csrftoken=SpDaLUVy2C5hDyUrYf89WFTVwqyNv4qknu3eFMTk6OMJsRmTE6RKsz7tqlN1uFyJ'
HTTP_HOST = '127.0.0.1:8001'
HTTP_REFERER = 'https://netbox.rsglab.lan/dcim/devices/?q=ms&mac_address='
HTTP_UPGRADE_INSECURE_REQUESTS = '1'
HTTP_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
HTTP_X_FORWARDED_HOST = 'netbox.rsglab.lan'
HTTP_X_FORWARDED_PROTO = 'https'
HTTP_X_REAL_IP = '172.22.5.4'
PATH_INFO = u'/search/'
QUERY_STRING = 'q=39%2FKFFN%2F111376%2FTWCS'
RAW_URI = '/search/?q=39%2FKFFN%2F111376%2FTWCS'
REMOTE_ADDR = '127.0.0.1'
REMOTE_PORT = '50522'
REQUEST_METHOD = 'GET'
SCRIPT_NAME = u''
SERVER_NAME = '127.0.0.1'
SERVER_PORT = '8001'
SERVER_PROTOCOL = 'HTTP/1.0'
SERVER_SOFTWARE = 'gunicorn/18.0'
gunicorn.socket = <socket._socketobject object at 0x699e600>
wsgi.errors = <open file '', mode 'w' at 0x7f966dfb01e0>
wsgi.file_wrapper = ''
wsgi.input = <gunicorn.http.body.Body object at 0x6b9a750>
wsgi.multiprocess = True
wsgi.multithread = False
wsgi.run_once = False
wsgi.url_scheme = 'https'
wsgi.version =

Settings:
Using settings module netbox.settings
ABSOLUTE_URL_OVERRIDES = {}
ADMINS = [['Dave Noonan', 'dnoonan@rsglab.com'], ['Bobby Roberts', 'broberts@rsglab.com']]
ALLOWED_HOSTS = ['netbox', 'netbox.rsglab.lan', '10.132.226.220']
APPEND_SLASH = True
AUTHENTICATION_BACKENDS = [u'django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS = u''
AUTH_USER_MODEL = u'auth.User'
BANNER_BOTTOM = ''
BANNER_TOP = ''
BASE_DIR = '/opt/netbox/netbox'
BASE_PATH = ''
CACHES = {u'default': {u'BACKEND': u'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS = u'default'
CACHE_MIDDLEWARE_KEY_PREFIX = u'
'
CACHE_MIDDLEWARE_SECONDS = 600
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_REGEX_WHITELIST = []
CORS_ORIGIN_WHITELIST = []
CSRF_COOKIE_AGE = 31449600
CSRF_COOKIE_DOMAIN = None
CSRF_COOKIE_HTTPONLY = False
CSRF_COOKIE_NAME = u'csrftoken'
CSRF_COOKIE_PATH = u'/'
CSRF_COOKIE_SECURE = False
CSRF_FAILURE_VIEW = u'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME = u'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS = ['netbox', 'netbox.rsglab.lan', '10.132.226.220']
CSRF_USE_SESSIONS = False
DATABASE = {'ENGINE': 'django.db.backends.postgresql', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'netbox', 'CONN_MAX_AGE': 0, 'TIME_ZONE': None, 'PORT': '', 'HOST': 'localhost', 'USER': 'netbox', 'TEST': {'COLLATION': None, 'CHARSET': None, 'NAME': None, 'MIRROR': None}, 'PASSWORD': u'', 'OPTIONS': {}}
DATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': 'netbox', 'CONN_MAX_AGE': 0, 'TIME_ZONE': None, 'PORT': '', 'HOST': 'localhost', 'USER': 'netbox', 'TEST': {'COLLATION': None, 'CHARSET': None, 'NAME': None, 'MIRROR': None}, 'PASSWORD': u'
', 'OPTIONS': {}}}
DATABASE_ROUTERS = []
DATA_UPLOAD_MAX_MEMORY_SIZE = 2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
DATETIME_FORMAT = 'N j, Y g:i a'
DATETIME_INPUT_FORMATS = [u'%Y-%m-%d %H:%M:%S', u'%Y-%m-%d %H:%M:%S.%f', u'%Y-%m-%d %H:%M', u'%Y-%m-%d', u'%m/%d/%Y %H:%M:%S', u'%m/%d/%Y %H:%M:%S.%f', u'%m/%d/%Y %H:%M', u'%m/%d/%Y', u'%m/%d/%y %H:%M:%S', u'%m/%d/%y %H:%M:%S.%f', u'%m/%d/%y %H:%M', u'%m/%d/%y']
DATE_FORMAT = 'N j, Y'
DATE_INPUT_FORMATS = [u'%Y-%m-%d', u'%m/%d/%Y', u'%m/%d/%y', u'%b %d %Y', u'%b %d, %Y', u'%d %b %Y', u'%d %b, %Y', u'%B %d %Y', u'%B %d, %Y', u'%d %B %Y', u'%d %B, %Y']
DEBUG = False
DEBUG_PROPAGATE_EXCEPTIONS = False
DEBUG_TOOLBAR_CONFIG = {'DISABLE_PANELS': ['debug_toolbar.panels.redirects.RedirectsPanel', 'debug_toolbar.panels.templates.TemplatesPanel']}
DECIMAL_SEPARATOR = u'.'
DEFAULT_CHARSET = u'utf-8'
DEFAULT_CONTENT_TYPE = u'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER = u'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE = u'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL = u'webmaster@localhost'
DEFAULT_INDEX_TABLESPACE = u''
DEFAULT_TABLESPACE = u''
DISALLOWED_USER_AGENTS = []
EMAIL = {'USERNAME': '', 'SERVER': 'localhost', 'FROM_EMAIL': '', 'TIMEOUT': 10, 'PASSWORD': u'', 'PORT': 25}
EMAIL_BACKEND = u'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_HOST_PASSWORD = u'
'
EMAIL_HOST_USER = ''
EMAIL_PORT = 25
EMAIL_SSL_CERTFILE = None
EMAIL_SSL_KEYFILE = u''
EMAIL_SUBJECT_PREFIX = '[NetBox] '
EMAIL_TIMEOUT = 10
EMAIL_USE_LOCALTIME = False
EMAIL_USE_SSL = False
EMAIL_USE_TLS = False
ENFORCE_GLOBAL_UNIQUE = True
FILE_CHARSET = u'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS = None
FILE_UPLOAD_HANDLERS = [u'django.core.files.uploadhandler.MemoryFileUploadHandler', u'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE = 2621440
FILE_UPLOAD_PERMISSIONS = None
FILE_UPLOAD_TEMP_DIR = None
FIRST_DAY_OF_WEEK = 0
FIXTURE_DIRS = []
FORCE_SCRIPT_NAME = None
FORMAT_MODULE_PATH = None
FORM_RENDERER = u'django.forms.renderers.DjangoTemplates'
HOSTNAME = 'netbox.rsglab.lan'
IGNORABLE_404_URLS = []
INSTALLED_APPS =
INTERNAL_IPS =
LANGUAGES = [(u'af', u'Afrikaans'), (u'ar', u'Arabic'), (u'ast', u'Asturian'), (u'az', u'Azerbaijani'), (u'bg', u'Bulgarian'), (u'be', u'Belarusian'), (u'bn', u'Bengali'), (u'br', u'Breton'), (u'bs', u'Bosnian'), (u'ca', u'Catalan'), (u'cs', u'Czech'), (u'cy', u'Welsh'), (u'da', u'Danish'), (u'de', u'German'), (u'dsb', u'Lower Sorbian'), (u'el', u'Greek'), (u'en', u'English'), (u'en-au', u'Australian English'), (u'en-gb', u'British English'), (u'eo', u'Esperanto'), (u'es', u'Spanish'), (u'es-ar', u'Argentinian Spanish'), (u'es-co', u'Colombian Spanish'), (u'es-mx', u'Mexican Spanish'), (u'es-ni', u'Nicaraguan Spanish'), (u'es-ve', u'Venezuelan Spanish'), (u'et', u'Estonian'), (u'eu', u'Basque'), (u'fa', u'Persian'), (u'fi', u'Finnish'), (u'fr', u'French'), (u'fy', u'Frisian'), (u'ga', u'Irish'), (u'gd', u'Scottish Gaelic'), (u'gl', u'Galician'), (u'he', u'Hebrew'), (u'hi', u'Hindi'), (u'hr', u'Croatian'), (u'hsb', u'Upper Sorbian'), (u'hu', u'Hungarian'), (u'ia', u'Interlingua'), (u'id', u'Indonesian'), (u'io', u'Ido'), (u'is', u'Icelandic'), (u'it', u'Italian'), (u'ja', u'Japanese'), (u'ka', u'Georgian'), (u'kk', u'Kazakh'), (u'km', u'Khmer'), (u'kn', u'Kannada'), (u'ko', u'Korean'), (u'lb', u'Luxembourgish'), (u'lt', u'Lithuanian'), (u'lv', u'Latvian'), (u'mk', u'Macedonian'), (u'ml', u'Malayalam'), (u'mn', u'Mongolian'), (u'mr', u'Marathi'), (u'my', u'Burmese'), (u'nb', u'Norwegian Bokm\xe5l'), (u'ne', u'Nepali'), (u'nl', u'Dutch'), (u'nn', u'Norwegian Nynorsk'), (u'os', u'Ossetic'), (u'pa', u'Punjabi'), (u'pl', u'Polish'), (u'pt', u'Portuguese'), (u'pt-br', u'Brazilian Portuguese'), (u'ro', u'Romanian'), (u'ru', u'Russian'), (u'sk', u'Slovak'), (u'sl', u'Slovenian'), (u'sq', u'Albanian'), (u'sr', u'Serbian'), (u'sr-latn', u'Serbian Latin'), (u'sv', u'Swedish'), (u'sw', u'Swahili'), (u'ta', u'Tamil'), (u'te', u'Telugu'), (u'th', u'Thai'), (u'tr', u'Turkish'), (u'tt', u'Tatar'), (u'udm', u'Udmurt'), (u'uk', u'Ukrainian'), (u'ur', u'Urdu'), (u'vi', u'Vietnamese'), (u'zh-hans', u'Simplified Chinese'), (u'zh-hant', u'Traditional Chinese')]
LANGUAGES_BIDI = [u'he', u'ar', u'fa', u'ur']
LANGUAGE_CODE = 'en-us'
LANGUAGE_COOKIE_AGE = None
LANGUAGE_COOKIE_DOMAIN = None
LANGUAGE_COOKIE_NAME = u'django_language'
LANGUAGE_COOKIE_PATH = u'/'
LDAP_CONFIGURED = False
LDAP_IGNORE_CERT_ERRORS = False
LOCALE_PATHS = []
LOGGING = {}
LOGGING_CONFIG = u'logging.config.dictConfig'
LOGIN_REDIRECT_URL = u'/accounts/profile/'
LOGIN_REQUIRED = False
LOGIN_URL = '/login/'
LOGOUT_REDIRECT_URL = None
MAINTENANCE_MODE = False
MANAGERS = []
MEDIA_ROOT = '/opt/netbox/netbox/media'
MEDIA_URL = '/media/'
MESSAGE_STORAGE = u'django.contrib.messages.storage.fallback.FallbackStorage'
MESSAGE_TAGS = {40: 'danger'}
MIDDLEWARE =
MIDDLEWARE_CLASSES = [u'django.middleware.common.CommonMiddleware', u'django.middleware.csrf.CsrfViewMiddleware']
MIGRATION_MODULES = {}
MONTH_DAY_FORMAT = u'F j'
NETBOX_PASSWORD = u'
'
NETBOX_USERNAME = ''
NUMBER_GROUPING = 0
PAGINATE_COUNT = 100
PASSWORD_HASHERS = u''
PASSWORD_RESET_TIMEOUT_DAYS = u'
'
PREFER_IPV4 = False
PREPEND_WWW = False
REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.SessionAuthentication', 'utilities.api.TokenAuthentication'), 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',), 'DEFAULT_VERSION': '2.0', 'DEFAULT_PERMISSION_CLASSES': ('utilities.api.TokenPermissions',), 'PAGE_SIZE': 100, 'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning', 'ALLOWED_VERSIONS': ['2.0'], 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination'}
REST_FRAMEWORK_VERSION = '2.0'
ROOT_URLCONF = 'netbox.urls'
SECRETS_MIN_PUBKEY_SIZE = u''
SECRET_KEY = u'
'
SECURE_BROWSER_XSS_FILTER = False
SECURE_CONTENT_TYPE_NOSNIFF = False
SECURE_HSTS_INCLUDE_SUBDOMAINS = False
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_PROXY_SSL_HEADER =
SECURE_REDIRECT_EXEMPT = []
SECURE_SSL_HOST = None
SECURE_SSL_REDIRECT = False
SERVER_EMAIL = ''
SESSION_CACHE_ALIAS = u'default'
SESSION_COOKIE_AGE = 1209600
SESSION_COOKIE_DOMAIN = None
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_NAME = u'sessionid'
SESSION_COOKIE_PATH = u'/'
SESSION_COOKIE_SECURE = False
SESSION_ENGINE = u'django.contrib.sessions.backends.db'
SESSION_EXPIRE_AT_BROWSER_CLOSE = False
SESSION_FILE_PATH = None
SESSION_SAVE_EVERY_REQUEST = False
SESSION_SERIALIZER = u'django.contrib.sessions.serializers.JSONSerializer'
SETTINGS_MODULE = 'netbox.settings'
SHORT_DATETIME_FORMAT = 'Y-m-d H:i'
SHORT_DATE_FORMAT = 'Y-m-d'
SHORT_TIME_FORMAT = 'H:i:s'
SIGNING_BACKEND = u'django.core.signing.TimestampSigner'
SILENCED_SYSTEM_CHECKS = []
STATICFILES_DIRS = '/opt/netbox/netbox/project-static'
STATICFILES_FINDERS = [u'django.contrib.staticfiles.finders.FileSystemFinder', u'django.contrib.staticfiles.finders.AppDirectoriesFinder']
STATICFILES_STORAGE = u'django.contrib.staticfiles.storage.StaticFilesStorage'
STATIC_ROOT = '/opt/netbox/netbox/static/'
STATIC_URL = '/static/'
TEMPLATES = [{'DIRS': ['/opt/netbox/netbox/templates/'], 'APP_DIRS': True, 'OPTIONS': {'context_processors': ['django.template.context_processors.debug', 'django.template.context_processors.request', 'django.template.context_processors.media', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'utilities.context_processors.settings']}, 'BACKEND': 'django.template.backends.django.DjangoTemplates'}]
TEST_NON_SERIALIZED_APPS = []
TEST_RUNNER = u'django.test.runner.DiscoverRunner'
THOUSAND_SEPARATOR = u','
TIME_FORMAT = 'g:i a'
TIME_INPUT_FORMATS = [u'%H:%M:%S', u'%H:%M:%S.%f', u'%H:%M']
TIME_ZONE = 'UTC'
USE_ETAGS = False
USE_I18N = True
USE_L10N = False
USE_THOUSAND_SEPARATOR = False
USE_TZ = True
USE_X_FORWARDED_HOST = True
USE_X_FORWARDED_PORT = False
VERSION = '2.0.4'
WSGI_APPLICATION = 'netbox.wsgi.application'
X_FRAME_OPTIONS = u'SAMEORIGIN'
YEAR_MONTH_FORMAT = u'F Y'

@jeremystretch jeremystretch added the type: bug A confirmed report of unexpected behavior in the application label Jun 1, 2017
@jeremystretch
Copy link
Member

Odd. I'm not too sure what's happening inside netaddr but it's raising a ValueError instead of AddrFormatError. Oh well, easy enough to fix.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants