From c96d03cc4b3ae3f3a8b702e66ccc1932110b049a Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 21 Jul 2016 12:22:03 -0400 Subject: [PATCH 01/22] Post-release version bump --- netbox/netbox/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 7c916ed8498..0bae707bc09 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -12,7 +12,7 @@ "the documentation.") -VERSION = '1.3.1' +VERSION = '1.3.2-dev' # Import local configuration for setting in ['ALLOWED_HOSTS', 'DATABASE', 'SECRET_KEY']: From f44b20bbda9b8aa1ce803de1d363f2211a117a71 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 21 Jul 2016 12:27:20 -0400 Subject: [PATCH 02/22] Fixed old links in the documentation --- README.md | 2 +- docs/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 419f27b02bc..2cf8f0193d4 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,6 @@ Questions? Comments? Please join us on IRC in **#netbox** on **irc.freenode.net* # Installation -Please see docs/getting-started.md for instructions on installing NetBox. +Please see [the documentation](http://netbox.readthedocs.io/en/latest/) for instructions on installing NetBox. To upgrade NetBox, please download the [latest release](https://github.com/digitalocean/netbox/releases) and run `upgrade.sh`. diff --git a/docs/index.md b/docs/index.md index e9f57253df3..a661b5e0eb9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -50,4 +50,4 @@ NetBox is built on the [Django](https://djangoproject.com/) Python framework and # Getting Started -See the [getting started](getting-started.md) guide for help with getting NetBox up and running quickly. +See the [installation guide](installation/postgresql.md) for help getting NetBox up and running quickly. From 275223ec53ef61ec5ef19d0662ce37ec4da0e423 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 21 Jul 2016 14:48:02 -0400 Subject: [PATCH 03/22] Fixes #359: Use standard serializers for related objects --- netbox/dcim/api/views.py | 61 +++++++++++++++------------------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/netbox/dcim/api/views.py b/netbox/dcim/api/views.py index 27b908d56c6..8eac377f2d5 100644 --- a/netbox/dcim/api/views.py +++ b/netbox/dcim/api/views.py @@ -419,53 +419,36 @@ def get(self, request): return Response() else: - raise MissingFilterException(detail='Must specify search parameters (peer-device and peer-interface).') + raise MissingFilterException(detail='Must specify search parameters "peer-device" and "peer-interface".') # Initialize response skeleton - response = dict() - response['device'] = serializers.DeviceSerializer(device).data - response['console-ports'] = [] - response['power-ports'] = [] - response['interfaces'] = [] - - # Build console connections + response = { + 'device': serializers.DeviceSerializer(device).data, + 'console-ports': [], + 'power-ports': [], + 'interfaces': [], + } + + # Console connections console_ports = ConsolePort.objects.filter(device=device).select_related('cs_port__device') for cp in console_ports: - cp_info = dict() - cp_info['name'] = cp.name - if cp.cs_port: - cp_info['console-server'] = cp.cs_port.device.name - cp_info['port'] = cp.cs_port.name - else: - cp_info['console-server'] = None - cp_info['port'] = None - response['console-ports'].append(cp_info) + data = serializers.ConsolePortSerializer(instance=cp).data + del(data['device']) + response['console-ports'].append(data) - # Build power connections + # Power connections power_ports = PowerPort.objects.filter(device=device).select_related('power_outlet__device') for pp in power_ports: - pp_info = dict() - pp_info['name'] = pp.name - if pp.power_outlet: - pp_info['pdu'] = pp.power_outlet.device.name - pp_info['outlet'] = pp.power_outlet.name - else: - pp_info['pdu'] = None - pp_info['outlet'] = None - response['power-ports'].append(pp_info) + data = serializers.PowerPortSerializer(instance=pp).data + del(data['device']) + response['power-ports'].append(data) - # Built interface connections - interfaces = Interface.objects.filter(device=device) + # Interface connections + interfaces = Interface.objects.filter(device=device).select_related('connected_as_a', 'connected_as_b', + 'circuit') for iface in interfaces: - iface_info = dict() - iface_info['name'] = iface.name - peer_interface = iface.get_connected_interface() - if peer_interface: - iface_info['device'] = peer_interface.device.name - iface_info['interface'] = peer_interface.name - else: - iface_info['device'] = None - iface_info['interface'] = None - response['interfaces'].append(iface_info) + data = serializers.InterfaceDetailSerializer(instance=iface).data + del(data['device']) + response['interfaces'].append(data) return Response(response) From 55ab7206952d5a4b3c34cb6aa07fdf270896e519 Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Thu, 21 Jul 2016 21:05:24 +0200 Subject: [PATCH 04/22] Be more specific in the documentation regarding ALLOWED_HOSTS. --- docs/configuration/mandatory-settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration/mandatory-settings.md b/docs/configuration/mandatory-settings.md index 07a6d8ede48..86deddc780e 100644 --- a/docs/configuration/mandatory-settings.md +++ b/docs/configuration/mandatory-settings.md @@ -2,7 +2,7 @@ NetBox's local configuration is held in `netbox/netbox/configuration.py`. An exa ## ALLOWED_HOSTS -This is a list of valid fully-qualified domain names (FQDNs) for the NetBox server. NetBox will not permit write access to the server via any other hostnames. The first FQDN in the list will be treated as the preferred name. +This is a list of valid fully-qualified domain names (FQDNs) that is used to reach the NetBox service. Usually this is the same as the hostname for the NetBox server, but can also be different (e.g. when using a reverse proxy serving the NetBox website under a different FQDN than the hostname of the NetBox server). NetBox will not permit access to the server via any other hostnames (or IP's). The value of this option is also used to set ```CSRF_TRUSTED_ORIGINS```, which restricts ```HTTP POST``` to the same set of hosts (more about this [here](https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-CSRF_TRUSTED_ORIGINS)). Keep in mind that NetBox, by default, has ```USE_X_FORWARDED_HOST = True``` (in ```netbox/netbox/settings.py```) which means that if you're using a reverse proxy, it's the FQDN used to reach that reverse proxy which needs to be in this list (more about this [here](https://docs.djangoproject.com/en/1.9/ref/settings/#allowed-hosts)). Example: From deda796e422da1ff7566b5363462113d9684e73e Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Fri, 22 Jul 2016 17:41:00 +0200 Subject: [PATCH 05/22] Triple -> single ticks + grammar. --- docs/configuration/mandatory-settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration/mandatory-settings.md b/docs/configuration/mandatory-settings.md index 86deddc780e..8d96cf3a78b 100644 --- a/docs/configuration/mandatory-settings.md +++ b/docs/configuration/mandatory-settings.md @@ -2,7 +2,7 @@ NetBox's local configuration is held in `netbox/netbox/configuration.py`. An exa ## ALLOWED_HOSTS -This is a list of valid fully-qualified domain names (FQDNs) that is used to reach the NetBox service. Usually this is the same as the hostname for the NetBox server, but can also be different (e.g. when using a reverse proxy serving the NetBox website under a different FQDN than the hostname of the NetBox server). NetBox will not permit access to the server via any other hostnames (or IP's). The value of this option is also used to set ```CSRF_TRUSTED_ORIGINS```, which restricts ```HTTP POST``` to the same set of hosts (more about this [here](https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-CSRF_TRUSTED_ORIGINS)). Keep in mind that NetBox, by default, has ```USE_X_FORWARDED_HOST = True``` (in ```netbox/netbox/settings.py```) which means that if you're using a reverse proxy, it's the FQDN used to reach that reverse proxy which needs to be in this list (more about this [here](https://docs.djangoproject.com/en/1.9/ref/settings/#allowed-hosts)). +This is a list of valid fully-qualified domain names (FQDNs) that is used to reach the NetBox service. Usually this is the same as the hostname for the NetBox server, but can also be different (e.g. when using a reverse proxy serving the NetBox website under a different FQDN than the hostname of the NetBox server). NetBox will not permit access to the server via any other hostnames (or IPs). The value of this option is also used to set `CSRF_TRUSTED_ORIGINS`, which restricts `HTTP POST` to the same set of hosts (more about this [here](https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-CSRF_TRUSTED_ORIGINS)). Keep in mind that NetBox, by default, has `USE_X_FORWARDED_HOST = True` (in `netbox/netbox/settings.py`) which means that if you're using a reverse proxy, it's the FQDN used to reach that reverse proxy which needs to be in this list (more about this [here](https://docs.djangoproject.com/en/1.9/ref/settings/#allowed-hosts)). Example: From b9223dda1af3126c25e69f8a83c0a771fce912f9 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Jul 2016 12:16:03 -0400 Subject: [PATCH 06/22] Updated CONTRIBUTING to discourage the use of issues for questions/discussion --- CONTRIBUTING.md | 73 +++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f9434e32c20..046f6cd7909 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,39 +1,52 @@ -# Contributing to NetBox +## Getting Help -Thank you for your interest in contributing to NetBox! This document contains some quick pointers on reporting bugs and -requesting new features. +If you encounter any issues installing or using NetBox, try one of the following resources to get assistance. Please +**do not** open an issue on GitHub except to report bugs or request features. -## Reporting Issues +### Freenode IRC -* First, ensure that you've installed the latest stable version of NetBox. If you're running an older version, it's -possible that the bug has already been fixed. +Join the #netbox channel on [Freenode IRC](https://freenode.net/). You can connect to Freenode at irc.freenode.net using +an IRC client, or you can use their [webchat client](https://webchat.freenode.net/). -* Check the [issues list](https://github.com/digitalocean/netbox/issues) to see if the bug you've found has already been -reported. If you think you may be experiencing a reported issue, please add a quick comment to it with a "+1" and a -quick description of how it's affecting your installation. +### Reddit -* If you're having trouble installing NetBox, please join #netbox on irc.freenode.net and ask for help before creating -an issue on GitHub. Many installation problems are simple fixes. The issues list should be reserved for bug reports and -feature requests. +We have established [/r/netbox](https://www.reddit.com/r/netbox) on Reddit for NetBox issues and general discussion. +Reddit registration is free and does not require providing an email address (although it is encouraged). -* When submitting an issue, please be as descriptive as possible. Be sure to describe: +## Reporting Bugs + +* First, ensure that you've installed the [latest stable version](https://github.com/digitalocean/netbox/releases) of +NetBox. If you're running an older version, it's possible that the bug has already been fixed. + +* Next, check the GitHub [issues list](https://github.com/digitalocean/netbox/issues) to see if the bug you've found has +already been reported. If you think you may be experiencing a reported issue that hasn't already been resolved, please +click "add a reaction" in the top right corner of the issue and add a thumbs up (+1). You might also want to add a +comment describing how it's affecting your installation. This will allow us to prioritize bugs based on how many users +are affected. + +* If you haven't found an existing issue that describes your suspected bug, please inquire about it on IRC or Reddit. +**Do not** file an issue until you have received confirmation that it is in fact a bug. Invalid issues are very +distracting and slow the pace at which NetBox is developed. + +* When submitting an issue, please be as descriptive as possible. Be sure to include: * The environment in which NetBox is running * The exact steps that can be taken to reproduce the issue (if applicable) * Any error messages returned + * Screenshots (if applicable) * Keep in mind that we prioritize bugs based on their severity and how much work is required to resolve them. It may -take some time for someone to address your issue. If it's been longer than a week with no updates, please ping us on -IRC. +take some time for someone to address your issue. ## Feature Requests -* First, check the [issues list](https://github.com/digitalocean/netbox/issues) to see if the feature you're requesting -has already been requested (and possibly rejected). If it has, click "add a reaction" in the top right corner of the -issue and add a thumbs up (+1). This ensures that the issue has a better chance of making it onto the roadmap. Also feel -free to add a comment with any additional justification for the feature. +* First, check the GitHub [issues list](https://github.com/digitalocean/netbox/issues) to see if the feature you're +requesting is already listed. (Be sure to search closed issues as well, since some feature requests are rejected.) If +the feature you'd like to see has already been requested, click "add a reaction" in the top right corner of the issue +and add a thumbs up (+1). This ensures that the issue has a better chance of making it onto the roadmap. Also feel free +to add a comment with any additional justification for the feature. -* While discussion of new features is welcome, it's important to limit the scope of NetBox's feature set to avoid +* While suggestions for new features are welcome, it's important to limit the scope of NetBox's feature set to avoid feature creep. For example, the following features would be firmly out of scope for NetBox: * Ticket management @@ -41,17 +54,18 @@ feature creep. For example, the following features would be firmly out of scope * Acting as a DNS server * Acting as an authentication server -* Feature requests must be very narrowly defined. The more effort you put into writing a feature request, the better its -chances are of being implemented. Overly broad feature requests will be closed. +* Before filing a new feature request, propose it on IRC or Reddit first. Feedback you receive there will help validate +and shape the proposed feature before filing a formal issue. -* If you're not sure whether the feature you want is a good fit for NetBox, please ask in #netbox on irc.freenode.net. -Even if it's not quite right for NetBox, we may be able to point you to a tool better suited for the job. +* Good feature requests are very narrowly defined. Be sure to enumerate specific functionality and data schema. The more +effort you put into writing a feature request, the better its chances are of being implemented. Overly broad feature +requests will be closed. -* When submitting a feature request, be sure to include the following: +* When submitting a feature request on GitHub, be sure to include the following: - * A detailed description of the functionality + * A detailed description of the proposed functionality * A use case for the feature; who would use it and what value it would add to NetBox - * A rough description of any changes necessary to the database schema (if applicable) + * A rough description of any changes necessary to the database schema * Any third-party libraries or other resources which would be involved ## Submitting Pull Requests @@ -60,9 +74,8 @@ Even if it's not quite right for NetBox, we may be able to point you to a tool b before beginning work​. This will help prevent wasting time on something that might we might not be able to implement. When suggesting a new feature, also make sure it won't conflict with any work that's already in progress. -* When submitting a pull request, please be sure to work off of branch `develop`, rather than branch `master`. -In NetBox, the `develop` branch is used for ongoing development, while `master` is used for tagging new -stable releases. +* When submitting a pull request, please be sure to work off of the `develop` branch, rather than `master`. In NetBox, +the `develop` branch is used for ongoing development, while `master` is used for tagging new stable releases. * All code submissions should meet the following criteria (CI will enforce these checks): From b62cd32428ffa0c125d6f81e243cc9331196c2ad Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Jul 2016 14:43:14 -0400 Subject: [PATCH 07/22] Fixes #370: Notify user when secret decryption fails --- netbox/project-static/js/secrets.js | 18 +++++++++++------- .../secrets/inc/private_key_modal.html | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/netbox/project-static/js/secrets.js b/netbox/project-static/js/secrets.js index 21d8656e6ae..181984b7182 100644 --- a/netbox/project-static/js/secrets.js +++ b/netbox/project-static/js/secrets.js @@ -10,15 +10,16 @@ $(document).ready(function() { $('#privkey_modal').modal('show'); } else { unlock_secret(secret_id, private_key); - $(this).hide(); - $(this).siblings('button.lock-secret').show(); } }); // Locking a secret $('button.lock-secret').click(function (event) { var secret_id = $(this).attr('secret-id'); - $('#secret_' + secret_id).html('********'); + var secret_div = $('#secret_' + secret_id); + + // Delete the plaintext + secret_div.html('********'); $(this).hide(); $(this).siblings('button.unlock-secret').show(); }); @@ -81,13 +82,16 @@ $(document).ready(function() { xhr.setRequestHeader("X-CSRFToken", csrf_token); }, success: function (response, status) { - var secret_plaintext = response.plaintext; - $('#secret_' + secret_id).html(secret_plaintext); - return true; + $('#secret_' + secret_id).html(response.plaintext); + $('button.unlock-secret').hide(); + $('button.lock-secret').show(); }, error: function (xhr, ajaxOptions, thrownError) { if (xhr.status == 403) { - alert("Decryption failed: " + xhr.statusText); + alert("Permission denied"); + } else { + var json = jQuery.parseJSON(xhr.responseText); + alert("Decryption failed: " + json['error']); } } }); diff --git a/netbox/templates/secrets/inc/private_key_modal.html b/netbox/templates/secrets/inc/private_key_modal.html index 5ab5400c3b5..0e1e6219af1 100644 --- a/netbox/templates/secrets/inc/private_key_modal.html +++ b/netbox/templates/secrets/inc/private_key_modal.html @@ -17,7 +17,10 @@