Script object variables display and accept objects the user cannot view

Đang mở
#82 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python

Hướng nghiên cứu

Start by tracing the UI and REST run paths that render and validate Script forms, then inspect how ObjectVar and MultiObjectVar resolve submitted IDs. Check where NetBox's restrict_form_fields() helper is applied and how object-level view permissions affect its queryset. Done means inaccessible objects are neither shown as selected values nor accepted on submission, including REST requests.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

app: scripts severity: low status: backlog type: bug
Plugin Version

v0.0.1

NetBox Version

v4.7.4

Python Version

3.12

Steps to Reproduce
  1. As an administrator, upload and activate this Script:
    from ipam.models import Prefix
    from netbox_scripts import ObjectVar, Script
    
    
    class InspectPrefix(Script):
        prefix = ObjectVar(model=Prefix)
    
        def run(self, data, commit):
            self.log_info(str(data['prefix']), obj=data['prefix'])
    
  2. Create a prefix, such as 10.0.0.0/24, and note its ID.
  3. Sign in as a non-superuser with run permission on the Script and no view permission for prefixes, either directly or through a group.
  4. Open /plugins/netbox-scripts/scripts/<script-id>/run/?prefix=<prefix-id>.
  5. Submit the form.
Expected Behavior

ObjectVar and MultiObjectVar display and accept only objects the requesting user can view, including any object-level permission constraints.

The prefix is not displayed as a selected value. Submitting its ID through the UI or REST API returns an invalid-choice error without creating a Job.

Observed Behavior

The Run page displays 10.0.0.0/24 as the selected prefix. Submitting the form creates a Job with that Prefix object in data, despite the user's lack of view permission.

Dropdown searches and the advanced selector respect view permissions, but prefilled and submitted IDs are resolved against an unrestricted queryset. MultiObjectVar and REST submissions are affected too.

The UI and REST run paths do not apply NetBox's restrict_form_fields() helper before rendering or validating the form. The label is exposed before the Script runs, so permission checks inside run() cannot prevent it.

Ngôn ngữ chính
Python
Star
8
Fork
0
Merge trung bình
9 giờ 34 phút
Pull request đã merge (30 ngày)
32

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của netbox-community/netbox-scripts

Tất cả issue của netbox-community/netbox-scripts

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.