Skip to content

Commit fb3d1ef

Browse files
kkthxbye-codejeremystretch
authored andcommitted
Check for the extras.run_script permission when running scripts via. the API
1 parent d7c37d9 commit fb3d1ef

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

netbox/extras/api/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ def post(self, request, pk):
318318
"""
319319
Run a Script identified as "<module>.<script>" and return the pending JobResult as the result
320320
"""
321+
322+
if not request.user.has_perm('extras.run_script'):
323+
raise PermissionDenied("This user does not have permission to run scripts.")
324+
321325
script = self._get_script(pk)()
322326
input_serializer = serializers.ScriptInputSerializer(data=request.data)
323327

netbox/extras/tests/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ def test_get_script(self):
590590

591591
@skipIf(not rq_worker_running, "RQ worker not running")
592592
def test_run_script(self):
593+
self.add_permissions('extras.run_script')
593594

594595
script_data = {
595596
'var1': 'FooBar',

0 commit comments

Comments
 (0)