|
38 | 38 | "zoho", |
39 | 39 | } |
40 | 40 |
|
41 | | -BANNED_SFTP_OPTIONS: Final[set[str]] = { |
42 | | - "key_file", # path to a local file |
43 | | - "pubkey_file", # path to a local file |
44 | | - "known_hosts_file", # path to a local file |
45 | | - "ssh", # arbitrary command to be executed |
| 41 | +BANNED_OPTIONS: Final[dict[str, set[str]]] = { |
| 42 | + "sftp": { |
| 43 | + "key_file", # path to a local file |
| 44 | + "pubkey_file", # path to a local file |
| 45 | + "known_hosts_file", # path to a local file |
| 46 | + "ssh", # arbitrary command to be executed |
| 47 | + }, |
| 48 | + "webdav": { |
| 49 | + "bearer_token_command", # arbitrary command to be executed |
| 50 | + }, |
46 | 51 | } |
47 | 52 |
|
48 | 53 |
|
@@ -252,14 +257,15 @@ def __patch_switchdrive_storage(spec: list[dict[str, Any]]) -> None: |
252 | 257 | ) |
253 | 258 |
|
254 | 259 |
|
255 | | -def __patch_schema_remove_banned_sftp_options(spec: list[dict[str, Any]]) -> None: |
256 | | - """Remove unsafe SFTP options.""" |
257 | | - sftp = find_storage(spec, "sftp") |
258 | | - options = [] |
259 | | - for option in sftp["Options"]: |
260 | | - if option["Name"] not in BANNED_SFTP_OPTIONS: |
261 | | - options.append(option) |
262 | | - sftp["Options"] = options |
| 260 | +def __patch_schema_remove_banned_options(spec: list[dict[str, Any]]) -> None: |
| 261 | + """Remove unsafe options.""" |
| 262 | + for storage_type, banned in BANNED_OPTIONS.items(): |
| 263 | + storage = find_storage(spec, storage_type) |
| 264 | + options = [] |
| 265 | + for option in storage["Options"]: |
| 266 | + if option["Name"] not in banned: |
| 267 | + options.append(option) |
| 268 | + storage["Options"] = options |
263 | 269 |
|
264 | 270 |
|
265 | 271 | def __patch_schema_add_openbis_type(spec: list[dict[str, Any]]) -> None: |
@@ -354,7 +360,7 @@ def apply_patches(spec: list[dict[str, Any]]) -> None: |
354 | 360 | __patch_schema_remove_oauth_propeties, |
355 | 361 | __patch_polybox_storage, |
356 | 362 | __patch_switchdrive_storage, |
357 | | - __patch_schema_remove_banned_sftp_options, |
| 363 | + __patch_schema_remove_banned_options, |
358 | 364 | __patch_schema_add_openbis_type, |
359 | 365 | ] |
360 | 366 |
|
|
0 commit comments