Skip to content

Commit 63e5bd7

Browse files
committed
fixes
1 parent b8a18fb commit 63e5bd7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

netbox/extras/api/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,14 @@ def post(self, request, pk):
333333
Run a Script identified by its numeric PK or module & name and return the pending Job as the result
334334
"""
335335

336-
script = self._get_script(pk)
337-
338336
# Running a script is a state-changing operation. If token authentication is in use, enforce the token's
339-
# write ability. Session-authenticated requests are unaffected (request.auth is not a Token).
337+
# write ability before performing any object lookup. Session-authenticated requests are unaffected
338+
# (request.auth is not a Token).
340339
if isinstance(request.auth, Token) and not request.auth.write_enabled:
341340
raise PermissionDenied("This token does not permit write operations.")
342341

342+
script = self._get_script(pk)
343+
343344
if not request.user.has_perm('extras.run_script', obj=script):
344345
raise PermissionDenied("This user does not have permission to run this script.")
345346

0 commit comments

Comments
 (0)