From 4cc29729f98afe2f4271b2ee1c0ff34c1c1e8f60 Mon Sep 17 00:00:00 2001 From: Damien Garros Date: Fri, 11 Oct 2019 13:45:37 -0400 Subject: [PATCH 1/6] Update pillow version to 6.2.0 A new CVE just got reporter regarding Pillow http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-16865 it's affecting all version prior to 6.2.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3ad165a4b..b467651cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ graphviz==0.10.1 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 From c7d9bf839ee6cf977525bc3378b21b0544431773 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 13 Oct 2019 03:09:58 -0400 Subject: [PATCH 2/6] implemented #3445 - Add support for additional user defined headers to be added to webhook requests --- docs/release-notes/version-2.6.md | 3 +-- .../0027_webhook_additional_headers.py | 19 +++++++++++++++++++ netbox/extras/models.py | 12 ++++++++++++ netbox/extras/webhooks_worker.py | 3 +++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 netbox/extras/migrations/0027_webhook_additional_headers.py 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 4e8a56b34..ea71cf95e 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -70,6 +70,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, @@ -115,6 +121,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, From b8feba107065585f11d0da2adcb8911e541fec03 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 13 Oct 2019 04:12:58 -0400 Subject: [PATCH 3/6] implemented #3606 - added stale bot config --- .github/stale.yaml | 22 ++++++++++++++++++++++ CONTRIBUTING.md | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/stale.yaml diff --git a/.github/stale.yaml b/.github/stale.yaml new file mode 100644 index 000000000..3f309b0ca --- /dev/null +++ b/.github/stale.yaml @@ -0,0 +1,22 @@ +# 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" +# 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 From a7380ba353bd6587713e113e21044b109bfb1db0 Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Mon, 14 Oct 2019 09:29:04 +0200 Subject: [PATCH 4/6] Add SCRIPTS_ROOT to configuration.example.py Fixes #3608 by adding the new variable to the example configuration. --- netbox/netbox/configuration.example.py | 4 ++++ 1 file changed, 4 insertions(+) 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. From 91f045a2e47a818fa7ec95ef77523d65ed0c6a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markku=20Leini=C3=B6?= Date: Tue, 15 Oct 2019 20:51:57 +0300 Subject: [PATCH 5/6] Update examples in webhooks.md --- docs/additional-features/webhooks.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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": "", From f08968da494ff4bbe341075622c26df3e9c113c4 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 17 Oct 2019 14:28:27 -0400 Subject: [PATCH 6/6] Exempt issues tagged with "status: blocked" --- .github/stale.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/stale.yaml b/.github/stale.yaml index 3f309b0ca..7c8d03f12 100644 --- a/.github/stale.yaml +++ b/.github/stale.yaml @@ -6,6 +6,7 @@ daysUntilClose: 7 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