Skip to content

Commit

Permalink
feat(metadata): add general server payload maximum to secret scan pre…
Browse files Browse the repository at this point in the history
…ferences
  • Loading branch information
fnareoh committed Jan 2, 2024
1 parent 7cf0356 commit c82b140
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pygitguardian/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ def read_metadata(self) -> Optional[Detail]:
result.status_code = resp.status_code
return result
metadata = ServerMetadata.from_dict(resp.json())

metadata.secret_scan_preferences.general__maximum_payload_size = (
metadata.preferences["general__maximum_payload_size"]
)
self.secret_scan_preferences = metadata.secret_scan_preferences
return None

Expand Down
1 change: 1 addition & 0 deletions pygitguardian/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

MULTI_DOCUMENT_LIMIT = 20
DOCUMENT_SIZE_THRESHOLD_BYTES = 1048576 # 1MB
GENERAL_MAXIMUM_PAYLOAD = 2621440 # 2.5MB
7 changes: 6 additions & 1 deletion pygitguardian/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
)
from typing_extensions import Self

from .config import DOCUMENT_SIZE_THRESHOLD_BYTES, MULTI_DOCUMENT_LIMIT
from .config import (
DOCUMENT_SIZE_THRESHOLD_BYTES,
GENERAL_MAXIMUM_PAYLOAD,
MULTI_DOCUMENT_LIMIT,
)


class ToDictMixin:
Expand Down Expand Up @@ -658,6 +662,7 @@ def __repr__(self) -> str:
class SecretScanPreferences:
maximum_document_size: int = DOCUMENT_SIZE_THRESHOLD_BYTES
maximum_documents_per_scan: int = MULTI_DOCUMENT_LIMIT
general__maximum_payload_size: int = GENERAL_MAXIMUM_PAYLOAD


@dataclass
Expand Down

0 comments on commit c82b140

Please sign in to comment.