1
- from typing import Dict , List , Optional
1
+ from typing import ClassVar , Dict , List , Optional
2
2
3
3
from marshmallow import (
4
4
EXCLUDE ,
14
14
15
15
16
16
class Base :
17
- SCHEMA = None
17
+ SCHEMA : ClassVar [ Schema ]
18
18
19
19
def __init__ (self ):
20
20
self .status_code = None
@@ -204,6 +204,10 @@ def __init__(self, break_type: str, policy: str, matches: List[Match], **kwargs)
204
204
self .policy = policy
205
205
self .matches = matches
206
206
207
+ @property
208
+ def is_secret (self ) -> bool :
209
+ return self .policy == "Secrets detection"
210
+
207
211
def __repr__ (self ):
208
212
return (
209
213
"break_type:{0}, "
@@ -255,19 +259,29 @@ def __init__(
255
259
self .policy_breaks = policy_breaks
256
260
257
261
@property
258
- def has_secrets (self ) -> bool :
262
+ def has_policy_breaks (self ) -> bool :
259
263
"""has_secrets is an easy way to check if your provided document has policy breaks
260
264
261
265
>>> obj = ScanResult(2, [], [])
262
- >>> obj.has_secrets
266
+ >>> obj.has_policy_breaks
263
267
True
264
268
265
- :return: true if there were policy breaks in the documents
269
+ :return: true if there were policy breaks (including secrets) in the document
266
270
:rtype: bool
267
271
"""
268
272
269
273
return self .policy_break_count > 0
270
274
275
+ @property
276
+ def has_secrets (self ) -> bool :
277
+ """has_secrets is an easy way to check if your provided document has secrets
278
+
279
+ :return: true if there were secrets in the document
280
+ :rtype: bool
281
+ """
282
+
283
+ return any (policy_break .is_secret for policy_break in self .policy_breaks )
284
+
271
285
def __repr__ (self ):
272
286
return (
273
287
"policy_break_count:{0}, "
@@ -280,7 +294,7 @@ def __repr__(self):
280
294
def __str__ (self ):
281
295
return "{0} policy breaks from the evaluated policies: {1}" .format (
282
296
self .policy_break_count ,
283
- ", " .join ([ policy_break .policy for policy_break in self .policy_breaks ] ),
297
+ ", " .join (policy_break .policy for policy_break in self .policy_breaks ),
284
298
)
285
299
286
300
@@ -316,20 +330,28 @@ def __init__(self, scan_results: List[ScanResult], **kwargs):
316
330
self .scan_results = scan_results
317
331
318
332
@property
319
- def has_secrets (self ) -> bool :
320
- """has_secrets is an easy way to check if your provided document has policy breaks
333
+ def has_policy_breaks (self ) -> bool :
334
+ """has_policy_breaks is an easy way to check if your provided document has policy breaks
321
335
322
336
>>> obj = ScanResult(2, [], [])
323
- >>> obj.has_secrets
337
+ >>> obj.has_policy_breaks
324
338
True
325
339
326
- :return: true if there were policy breaks in the documents
340
+ :return: true if there were policy breaks (including secrets) in the documents
327
341
:rtype: bool
328
342
"""
329
343
330
- return any (
331
- (len (scan_result .policy_breaks ) > 0 for scan_result in self .scan_results )
332
- )
344
+ return any (scan_result .has_policy_breaks for scan_result in self .scan_results )
345
+
346
+ @property
347
+ def has_secrets (self ) -> bool :
348
+ """has_secrets is an easy way to check if your provided document has secrets
349
+
350
+ :return: true if there were secrets in the documents
351
+ :rtype: bool
352
+ """
353
+
354
+ return any (scan_result .has_secrets for scan_result in self .scan_results )
333
355
334
356
def __repr__ (self ):
335
357
return "scan_results:{0}" .format (self .scan_results )
0 commit comments