diff --git a/.github/stale.yaml b/.github/stale.yaml new file mode 100644 index 000000000..7c8d03f12 --- /dev/null +++ b/.github/stale.yaml @@ -0,0 +1,23 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 14 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - "status: accepted" + - "status: gathering feedback" + - "status: blocked" +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. NetBox + is governed by a small group of core maintainers which means not all opened + issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md). +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: > + This issue has been automatically closed due to lack of activity. In an + effort to reduce noise, please do not comment any further. Note that the + core maintainers may elect to reopen this issue at a later date if deemed + necessary. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a688be9b3..1ecdbf1ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -118,6 +118,29 @@ feedback. **Do not** comment on an issue just to show your support (give the top post a :+1: instead) or ask for an ETA. These comments will be deleted to reduce noise in the discussion. +## Issue Lifecycle + +When a correctly formatted issue is submitted it is evaluated by a moderator +who may elect to immediately label the issue as accepted in addition to another +issue type label. In other cases, the issue may be labeled as "status: gathering feedback" +which will often be accompanied by a comment from a moderator asking for further dialog from the community. +If an issue is labeled as "status: revisions needed" a moderator has identified a problem with +the issue itself and is asking for the submitter himself to update the original post with +the requested information. If the original post is not updated in a reasonable amount of time, +the issue will be closed as invalid. + +The core maintainers group has chosen to make use of the GitHub Stale bot to aid in issue management. + +* Issues will be marked as stale after 14 days of no activity. + +* Then after 7 more days of inactivity, the issue will be closed. + +* Any issue with either the "status: accepted" or "status: gathering feedback" labels applied will be exempt from all Stale bot actions. + +It is natural that some new issues get more attention than others. Often this is a metric of an issues's +overall usefulness to the project. In other cases in which issues merely get lost in the shuffle, +notifications from Stale bot can bring renewed attention to potentially meaningful issues. + ## Maintainer Guidance * Maintainers are expected to contribute at least four hours per week to the diff --git a/docs/additional-features/webhooks.md b/docs/additional-features/webhooks.md index 0e74640fa..9a02449f8 100644 --- a/docs/additional-features/webhooks.md +++ b/docs/additional-features/webhooks.md @@ -11,8 +11,10 @@ The webhook POST request is structured as so (assuming `application/json` as the ```no-highlight { "event": "created", - "signal_received_timestamp": 1508769597, - "model": "Site" + "timestamp": "2019-10-12 12:51:29.746944", + "username": "admin", + "model": "site", + "request_id": "43d8e212-94c7-4f67-b544-0dcde4fc0f43", "data": { ... } @@ -24,8 +26,10 @@ The webhook POST request is structured as so (assuming `application/json` as the ```no-highlight { "event": "deleted", - "signal_received_timestamp": 1508781858.544069, - "model": "Site", + "timestamp": "2019-10-12 12:55:44.030750", + "username": "johnsmith", + "model": "site", + "request_id": "e9bb83b2-ebe4-4346-b13f-07144b1a00b4", "data": { "asn": None, "comments": "", diff --git a/docs/release-notes/version-2.6.md b/docs/release-notes/version-2.6.md index 4badcfedf..fe72331a7 100644 --- a/docs/release-notes/version-2.6.md +++ b/docs/release-notes/version-2.6.md @@ -2,12 +2,11 @@ ## Enhancements +* [#3445](https://github.com/netbox-community/netbox/issues/3445) - Add support for additional user defined headers to be added to webhook requests * [#3499](https://github.com/netbox-community/netbox/issues/3499) - Add `ca_file_path` to Webhook model to support user supplied CA certificate verification of webhook requests ## Bug Fixes - - --- # v2.6.6 (2019-10-10) diff --git a/netbox/extras/migrations/0027_webhook_additional_headers.py b/netbox/extras/migrations/0027_webhook_additional_headers.py new file mode 100644 index 000000000..8b1f04f19 --- /dev/null +++ b/netbox/extras/migrations/0027_webhook_additional_headers.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2 on 2019-10-13 07:06 + +import django.contrib.postgres.fields.jsonb +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('extras', '0026_webhook_ca_file_path'), + ] + + operations = [ + migrations.AddField( + model_name='webhook', + name='additional_headers', + field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), + ), + ] diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 5a7cf04d0..5e9c64f2b 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -67,6 +67,12 @@ class Webhook(models.Model): default=WEBHOOK_CT_JSON, verbose_name='HTTP content type' ) + additional_headers = JSONField( + null=True, + blank=True, + help_text="User supplied headers which should be added to the request in addition to the HTTP content type. " + "Headers are supplied as key/value pairs in a JSON object." + ) secret = models.CharField( max_length=255, blank=True, @@ -112,6 +118,12 @@ class Webhook(models.Model): 'ca_file_path': 'Do not specify a CA certificate file if SSL verification is dissabled.' }) + # Verify that JSON data is provided as an object + if self.additional_headers and type(self.additional_headers) is not dict: + raise ValidationError({ + 'additional_headers': 'Header JSON data must be in object form. Example: {"X-API-KEY": "abc123"}' + }) + # # Custom fields diff --git a/netbox/extras/webhooks_worker.py b/netbox/extras/webhooks_worker.py index c50a0a368..9a637e852 100644 --- a/netbox/extras/webhooks_worker.py +++ b/netbox/extras/webhooks_worker.py @@ -25,6 +25,9 @@ def process_webhook(webhook, data, model_name, event, timestamp, username, reque headers = { 'Content-Type': webhook.get_http_content_type_display(), } + if webhook.additional_headers: + headers.update(webhook.additional_headers) + params = { 'method': 'POST', 'url': webhook.payload_url, diff --git a/netbox/netbox/configuration.example.py b/netbox/netbox/configuration.example.py index ebc3d4540..16316bb66 100644 --- a/netbox/netbox/configuration.example.py +++ b/netbox/netbox/configuration.example.py @@ -154,6 +154,10 @@ PREFER_IPV4 = False # this setting is derived from the installed location. # REPORTS_ROOT = '/opt/netbox/netbox/reports' +# The file path where custom scripts will be stored. A trailing slash is not needed. Note that the default value of +# this setting is derived from the installed location. +# SCRIPTS_ROOT = '/opt/netbox/netbox/scripts' + # By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use # local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only # database access.) Note that the user as which NetBox runs must have read and write permissions to this path. diff --git a/requirements.txt b/requirements.txt index f2a5c84ba..7b923f40f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ drf-yasg[validation]==1.16.0 Jinja2==2.10.1 Markdown==2.6.11 netaddr==0.7.19 -Pillow==6.0.0 +Pillow==6.2.0 psycopg2-binary==2.8.3 py-gfm==0.1.4 pycryptodome==3.8.2