瀏覽代碼

chore(api): enhance ruff rules to disallow dangerous functions and modules (#16461)

tags/1.1.2
QuantumGhost 7 月之前
父節點
當前提交
383af7bf76
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 7 行新增1 行删除
  1. 6
    0
      api/.ruff.toml
  2. 1
    1
      api/models/dataset.py

+ 6
- 0
api/.ruff.toml 查看文件

"UP", # pyupgrade rules "UP", # pyupgrade rules
"W191", # tab-indentation "W191", # tab-indentation
"W605", # invalid-escape-sequence "W605", # invalid-escape-sequence
# security related linting rules
# RCE proctection (sort of)
"S102", # exec-builtin, disallow use of `exec`
"S307", # suspicious-eval-usage, disallow use of `eval` and `ast.literal_eval`
"S301", # suspicious-pickle-usage, disallow use of `pickle` and its wrappers.
"S302", # suspicious-marshal-usage, disallow use of `marshal` module
] ]


ignore = [ ignore = [

+ 1
- 1
api/models/dataset.py 查看文件

self.embedding = pickle.dumps(embedding_data, protocol=pickle.HIGHEST_PROTOCOL) self.embedding = pickle.dumps(embedding_data, protocol=pickle.HIGHEST_PROTOCOL)


def get_embedding(self) -> list[float]: def get_embedding(self) -> list[float]:
return cast(list[float], pickle.loads(self.embedding))
return cast(list[float], pickle.loads(self.embedding)) # noqa: S301




class DatasetCollectionBinding(db.Model): # type: ignore[name-defined] class DatasetCollectionBinding(db.Model): # type: ignore[name-defined]

Loading…
取消
儲存