Explorar o código

check object-level permission constraints (#20830)

Elliott Balsley hai 2 meses
pai
achega
c6248f1142
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      netbox/extras/api/views.py

+ 4 - 2
netbox/extras/api/views.py

@@ -290,10 +290,12 @@ class ScriptViewSet(ModelViewSet):
         """
         """
         Run a Script identified by its numeric PK or module & name and return the pending Job as the result
         Run a Script identified by its numeric PK or module & name and return the pending Job 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)
+
+        if not request.user.has_perm('extras.run_script', obj=script):
+            raise PermissionDenied("This user does not have permission to run this script.")
+
         input_serializer = serializers.ScriptInputSerializer(
         input_serializer = serializers.ScriptInputSerializer(
             data=request.data,
             data=request.data,
             context={'script': script}
             context={'script': script}