From 6e6e8fa2d92e030cd85737add1579c369a9b0cdf Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 30 Mar 2023 12:44:36 -0400 Subject: [PATCH] Set user agent for RSS feed requests --- netbox/extras/dashboard/widgets.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/netbox/extras/dashboard/widgets.py b/netbox/extras/dashboard/widgets.py index c745f1dff..78c1a49d0 100644 --- a/netbox/extras/dashboard/widgets.py +++ b/netbox/extras/dashboard/widgets.py @@ -4,6 +4,7 @@ from hashlib import sha256 import feedparser from django import forms +from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.core.cache import cache from django.template.loader import render_to_string @@ -208,7 +209,10 @@ class RSSFeedWidget(DashboardWidget): if feed_content := cache.get(self.cache_key): feed = feedparser.FeedParserDict(feed_content) else: - feed = feedparser.parse(self.config['feed_url']) + feed = feedparser.parse( + self.config['feed_url'], + request_headers={'User-Agent': f'NetBox/{settings.VERSION}'} + ) if not feed.bozo: # Cap number of entries max_entries = self.config.get('max_entries')