簡體   English   中英

有沒有辦法限制sklearn下載數據集?

[英]Is there a way to restrict sklearn from downloading datasets?

參考與 tar 文件相關的最新安全問題 - https://www.theregister.com/2022/09/22/python_vulnerability_tarfile/

我們正在使用Creosote工具 - https://github.com/advanced-threat-research/Creosote

檢查python虛擬環境安裝的代碼和包是否存在漏洞。

以下是 Creosote 工具生成的報告:

 ::::::::  :::::::::  :::::::::: ::::::::   ::::::::   :::::::: ::::::::::: :::::::::: 
:+:    :+: :+:    :+: :+:       :+:    :+: :+:    :+: :+:    :+:    :+:     :+:        
+:+        +:+    +:+ +:+       +:+    +:+ +:+        +:+    +:+    +:+     +:+        
+#+        +#++:++#:  +#++:++#  +#+    +:+ +#++:++#++ +#+    +:+    +#+     +#++:++#   
+#+        +#+    +#+ +#+       +#+    +#+        +#+ +#+    +#+    +#+     +#+        
#+#    #+# #+#    #+# #+#       #+#    #+# #+#    #+# #+#    #+#    #+#     #+#        
 ########  ###    ### ########## ########   ########   ########     ###     ########## 
 
Starting scan of:venv/
        Scanning for Vulnerabilities:
                Error reading file:venv/lib/python3.10/site-packages/joblib/test/test_func_inspect_special_encoding.py
                        'utf-8' codec can't decode byte 0xa4 in position 64: invalid start byte
                Scan Completed

4 files with vulns:     0 vulns, 0 probable vulns, and 4 potential vulns found
        venv/lib/python3.10/site-packages/pip/_vendor/distlib/util.py
                Found potential vulns on lines: 1252
        venv/lib/python3.10/site-packages/sklearn/datasets/_lfw.py
                Found potential vulns on lines: 111
        venv/lib/python3.10/site-packages/sklearn/datasets/_twenty_newsgroups.py
                Found potential vulns on lines: 77
        venv/lib/python3.10/site-packages/dateutil/zoneinfo/rebuild.py
                Found potential vulns on lines: 24

如您所見,該報告標記了 sklearn/datasets 子包中的潛在漏洞。 有沒有辦法限制sklearn下載它?

或者一般來說,如何修復此漏洞以避免任何生產問題?

scikit-learn 默認不下載數據集。 所以有幾個選擇。

選項 0 :該漏洞看起來需要管理員權限。 避免: sudo python something.py

選項 1 :不要運行此代碼:

from sklearn.datasets import fetch_lfw_people, fetch_20newsgroups
lfw = fetch_lfw_people()
news = fetch_20newsgroups()

選項 2 :我不熟悉 Creosote,但在 scikit-learn 中使用tarfile似乎沒有被標記。 例如: fetch_california_housing 如果某些fetch_方法存在潛在漏洞,則應在上游進行調試和修補。

選項 3 :如果包中存在此代碼被認為對您的組織有危險:修改和構建符合您組織安全策略的輪子。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM