mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Check for the extras.run_script permission when running scripts via. the API
This commit is contained in:
committed by
Jeremy Stretch
parent
d7c37d9dd6
commit
fb3d1ef399
@ -318,6 +318,10 @@ class ScriptViewSet(ViewSet):
|
|||||||
"""
|
"""
|
||||||
Run a Script identified as "<module>.<script>" and return the pending JobResult as the result
|
Run a Script identified as "<module>.<script>" and return the pending JobResult as the result
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not request.user.has_perm('extras.run_script'):
|
||||||
|
raise PermissionDenied("This user does not have permission to run scripts.")
|
||||||
|
|
||||||
script = self._get_script(pk)()
|
script = self._get_script(pk)()
|
||||||
input_serializer = serializers.ScriptInputSerializer(data=request.data)
|
input_serializer = serializers.ScriptInputSerializer(data=request.data)
|
||||||
|
|
||||||
|
@ -590,6 +590,7 @@ class ScriptTest(APITestCase):
|
|||||||
|
|
||||||
@skipIf(not rq_worker_running, "RQ worker not running")
|
@skipIf(not rq_worker_running, "RQ worker not running")
|
||||||
def test_run_script(self):
|
def test_run_script(self):
|
||||||
|
self.add_permissions('extras.run_script')
|
||||||
|
|
||||||
script_data = {
|
script_data = {
|
||||||
'var1': 'FooBar',
|
'var1': 'FooBar',
|
||||||
|
Reference in New Issue
Block a user