|
6 | 6 | from pathlib import Path
|
7 | 7 | from typing import Any, Dict, List, Optional, Union, cast
|
8 | 8 |
|
9 |
| -import click |
10 | 9 | import requests
|
11 | 10 | from requests import Response, Session, codes
|
12 | 11 |
|
|
36 | 35 | MAX_TAR_CONTENT_SIZE = 30 * 1024 * 1024
|
37 | 36 |
|
38 | 37 |
|
| 38 | +class ContentTooLarge(Exception): |
| 39 | + """ |
| 40 | + Raised if the total size of files sent by the client exceeds MAX_TAR_CONTENT_SIZE |
| 41 | + """ |
| 42 | + |
| 43 | + pass |
| 44 | + |
| 45 | + |
39 | 46 | class Versions:
|
40 | 47 | app_version: Optional[str] = None
|
41 | 48 | secrets_engine_version: Optional[str] = None
|
@@ -86,7 +93,7 @@ def _create_tar(root_path: Path, filenames: List[str]) -> bytes:
|
86 | 93 | full_path = root_path / filename
|
87 | 94 | current_dir_size += os.path.getsize(full_path)
|
88 | 95 | if current_dir_size > MAX_TAR_CONTENT_SIZE:
|
89 |
| - raise click.ClickException( |
| 96 | + raise ContentTooLarge( |
90 | 97 | f"The total size of the files processed exceeds {MAX_TAR_CONTENT_SIZE / (1024 * 1024):.0f}MB, "
|
91 | 98 | f"please try again with less files"
|
92 | 99 | )
|
@@ -393,7 +400,6 @@ def iac_directory_scan(
|
393 | 400 | scan_parameters: IaCScanParameters,
|
394 | 401 | extra_headers: Optional[Dict[str, str]] = None,
|
395 | 402 | ) -> Union[Detail, IaCScanResult]:
|
396 |
| - |
397 | 403 | tar = _create_tar(directory, filenames)
|
398 | 404 | result: Union[Detail, IaCScanResult]
|
399 | 405 | try:
|
|
0 commit comments