Script run responses include storage backend error text

オープン
#88 コメント 2 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
security

調査の方向性

Start by reading validation.py around build_error_sanitizer and storage/store.py around _stream_verified, then trace how script_class_context passes load errors to the REST and UI views. Check how the sanitizer handles backend-specific error details while preserving useful administrator logging. Done when script run responses omit storage backend details and the full error remains available in server logs; consider the upload path covered by #77.

索引モデルが issue の本文から書いたものです。

説明

app: scripts Bucket: KTLO severity: low status: accepted type: bug
Plugin Version

v0.0.1 (also present on main)

NetBox Version

v4.7.4

Python Version

3.12

Steps to Reproduce
  1. Use the default filesystem storage backend for script source.
  2. Activate a revision for an upload project so it has a runnable Script.
  3. Make that revision's stored files unreadable by the NetBox process, and clear the local runtime cache so the run has to read from storage.
  4. Run the Script through the REST API (POST /api/plugins/scripts/scripts/<id>/run/), or from its run view in the UI.
Expected Behavior

The response says the Script could not be loaded, without storage backend details. The full error goes to the server log for the administrator.

Observed Behavior

Found by reading the code on main, not by running these steps. The example message below shows the shape the code produces, not captured output.

The load failure is shown to the user by api/views.py:351-358 (REST) and views/scripts.py:198 (UI). It comes from script_class_context, which passes the error through build_error_sanitizer (validation.py:239-261). The sanitizer replaces the storage key, digest, local cache directory and runtime root, but not the storage backend's own root path or other backend text. Reading a stored file wraps the backend exception text (storage/store.py, _stream_verified), so a filesystem read failure still shows something like Permission denied: '/opt/netbox/netbox/media/<scripts root>/<storage>/<digest>/script.py'. Other backends would include their own error text, such as an S3 endpoint URL.

The upload path has the same root cause and is covered by #77. CodeQL reports this one as py/stack-trace-exposure (alert 3).

主要言語
Python
スター
8
フォーク
0
平均マージ
11時間 22分
マージ済み PR(30日)
40

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

netbox-community/netbox-scripts のほかの issue

netbox-community/netbox-scripts の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。