|
18 | 18 | 1. Pin to specific revisions/commits when downloading models, files or datasets |
19 | 19 |
|
20 | 20 | Common unsafe patterns: |
21 | | -- ``AutoModel.from_pretrained("model-name")`` without revision |
22 | | -- ``load_dataset("dataset-name")`` without revision |
23 | | -- ``hf_hub_download()`` without revision parameter |
24 | | -- ``snapshot_download()`` without revision parameter |
| 21 | +- ``AutoModel.from_pretrained("org/model-name")`` |
| 22 | +- ``AutoModel.from_pretrained("org/model-name", revision="main")`` |
| 23 | +- ``AutoModel.from_pretrained("org/model-name", revision="v1.0.0")`` |
| 24 | +- ``load_dataset("org/dataset-name")`` without revision |
| 25 | +- ``load_dataset("org/dataset-name", revision="main")`` |
| 26 | +- ``load_dataset("org/dataset-name", revision="v1.0")`` |
| 27 | +- ``AutoTokenizer.from_pretrained("org/model-name")`` |
| 28 | +- ``AutoTokenizer.from_pretrained("org/model-name", revision="main")`` |
| 29 | +- ``AutoTokenizer.from_pretrained("org/model-name", revision="v3.3.0")`` |
| 30 | +- ``hf_hub_download(repo_id="org/model_name", filename="file_name")`` |
| 31 | +- ``hf_hub_download(repo_id="org/model_name", filename="file_name", revision="main")`` |
| 32 | +- ``hf_hub_download(repo_id="org/model_name", filename="file_name", revision="v2.0.0")`` |
| 33 | +- ``snapshot_download(repo_id="org/model_name")`` |
| 34 | +- ``snapshot_download(repo_id="org/model_name", revision="main")`` |
| 35 | +- ``snapshot_download(repo_id="org/model_name", revision="refs/pr/1")`` |
| 36 | +
|
25 | 37 |
|
26 | 38 | :Example: |
27 | 39 |
|
|
39 | 51 |
|
40 | 52 | - https://cwe.mitre.org/data/definitions/494.html |
41 | 53 | - https://huggingface.co/docs/huggingface_hub/en/guides/download#from-specific-version |
42 | | - - https://huggingface.co/docs/huggingface_hub/guides/download |
43 | 54 |
|
44 | 55 | .. versionadded:: 1.9.0 |
45 | 56 |
|
@@ -99,7 +110,7 @@ def huggingface_unsafe_download(context): |
99 | 110 | # Check for revision parameter (the key security control) |
100 | 111 | revision_value = context.get_call_arg_value("revision") |
101 | 112 | commit_id_value = context.get_call_arg_value("commit_id") |
102 | | - |
| 113 | + |
103 | 114 | # Check if a revision or commit_id is specified |
104 | 115 | revision_to_check = revision_value or commit_id_value |
105 | 116 |
|
|
0 commit comments