ipython / ipython/traitlets

Application.load_config_file loads all files with same basename as given file

Đang mở
#850 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
653
Fork
217
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
2

Mô tả

Even if `load_config_file` is given an absolute path to a config file, it will load all files that have the same basename that are in that directory.

This is highly surprising and potentially a security issue.

Example:

```python
from pathlib import Path
from traitlets import Integer
from traitlets.config import Application
from tempfile import TemporaryDirectory

class Foo(Application):
bar = Integer(0).tag(config=True)

def start(self):
print(self.bar)

if __name__ == "__main__":
with TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
json_path = tmpdir / "foo.json"
py_path = tmpdir / "foo.py"

# valid python, invalid
py_path.write_text("c.Foo.bar = 10")
json_path.write_text("Invalid json")

app = Foo()
app.load_config_file(py_path)
app.start()

# other way around
py_path.write_text("raise Exception('You loaded the python file!')")
json_path.write_text('{"Foo": {"bar": 11}}')

app = Foo()
app.load_config_file(json_path)
app.start()
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

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.