File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 35
35
JWTService ,
36
36
MultiScanResult ,
37
37
QuotaResponse ,
38
+ RemediationMessages ,
38
39
ScanResult ,
39
40
SecretScanPreferences ,
40
41
ServerMetadata ,
@@ -151,6 +152,7 @@ class GGClient:
151
152
user_agent : str
152
153
extra_headers : Dict
153
154
secret_scan_preferences : SecretScanPreferences
155
+ remediation_messages : RemediationMessages
154
156
callbacks : Optional [GGClientCallbacks ]
155
157
156
158
def __init__ (
@@ -214,6 +216,7 @@ def __init__(
214
216
)
215
217
self .maximum_payload_size = MAXIMUM_PAYLOAD_SIZE
216
218
self .secret_scan_preferences = SecretScanPreferences ()
219
+ self .remediation_messages = RemediationMessages ()
217
220
218
221
def request (
219
222
self ,
@@ -676,6 +679,7 @@ def read_metadata(self) -> Optional[Detail]:
676
679
"general__maximum_payload_size" , MAXIMUM_PAYLOAD_SIZE
677
680
)
678
681
self .secret_scan_preferences = metadata .secret_scan_preferences
682
+ self .remediation_messages = metadata .remediation_messages
679
683
return None
680
684
681
685
def create_jwt (
Original file line number Diff line number Diff line change 5
5
MULTI_DOCUMENT_LIMIT = 20
6
6
DOCUMENT_SIZE_THRESHOLD_BYTES = 1048576 # 1MB
7
7
MAXIMUM_PAYLOAD_SIZE = 2621440 # 25MB
8
+
9
+ DEFAULT_PRE_COMMIT_MESSAGE = """Since the secret was detected before the commit was made:
10
+ 1. replace the secret with its reference (e.g. environment variable).
11
+ 2. commit again."""
12
+
13
+ DEFAULT_PRE_PUSH_MESSAGE = """Since the secret was detected before the push BUT after the commit, you need to:
14
+ 1. rewrite the git history making sure to replace the secret with its reference (e.g. environment variable).
15
+ 2. push again."""
16
+
17
+ DEFAULT_PRE_RECEIVE_MESSAGE = """A pre-receive hook set server side prevented you from pushing secrets.
18
+ Since the secret was detected during the push BUT after the commit, you need to:
19
+ 1. rewrite the git history making sure to replace the secret with its reference (e.g. environment variable).
20
+ 2. push again."""
Original file line number Diff line number Diff line change 19
19
)
20
20
from typing_extensions import Self
21
21
22
- from .config import DOCUMENT_SIZE_THRESHOLD_BYTES , MULTI_DOCUMENT_LIMIT
22
+ from .config import (
23
+ DEFAULT_PRE_COMMIT_MESSAGE ,
24
+ DEFAULT_PRE_PUSH_MESSAGE ,
25
+ DEFAULT_PRE_RECEIVE_MESSAGE ,
26
+ DOCUMENT_SIZE_THRESHOLD_BYTES ,
27
+ MULTI_DOCUMENT_LIMIT ,
28
+ )
23
29
24
30
25
31
class ToDictMixin :
@@ -734,13 +740,23 @@ class SecretScanPreferences:
734
740
maximum_documents_per_scan : int = MULTI_DOCUMENT_LIMIT
735
741
736
742
743
+ @dataclass
744
+ class RemediationMessages :
745
+ pre_commit : str = DEFAULT_PRE_COMMIT_MESSAGE
746
+ pre_push : str = DEFAULT_PRE_PUSH_MESSAGE
747
+ pre_receive : str = DEFAULT_PRE_RECEIVE_MESSAGE
748
+
749
+
737
750
@dataclass
738
751
class ServerMetadata (Base , FromDictMixin ):
739
752
version : str
740
753
preferences : Dict [str , Any ]
741
754
secret_scan_preferences : SecretScanPreferences = field (
742
755
default_factory = SecretScanPreferences
743
756
)
757
+ remediation_messages : RemediationMessages = field (
758
+ default_factory = RemediationMessages
759
+ )
744
760
745
761
746
762
ServerMetadata .SCHEMA = cast (
You can’t perform that action at this time.
0 commit comments