1- from typing import Dict , List , Optional
1+ from typing import ClassVar , Dict , List , Optional
22
33from marshmallow import (
44 EXCLUDE ,
1414
1515
1616class Base :
17- SCHEMA = None
17+ SCHEMA : ClassVar [ Schema ]
1818
1919 def __init__ (self ):
2020 self .status_code = None
@@ -204,6 +204,10 @@ def __init__(self, break_type: str, policy: str, matches: List[Match], **kwargs)
204204 self .policy = policy
205205 self .matches = matches
206206
207+ @property
208+ def is_secret (self ) -> bool :
209+ return self .policy == "Secrets detection"
210+
207211 def __repr__ (self ):
208212 return (
209213 "break_type:{0}, "
@@ -255,19 +259,29 @@ def __init__(
255259 self .policy_breaks = policy_breaks
256260
257261 @property
258- def has_secrets (self ) -> bool :
262+ def has_policy_breaks (self ) -> bool :
259263 """has_secrets is an easy way to check if your provided document has policy breaks
260264
261265 >>> obj = ScanResult(2, [], [])
262- >>> obj.has_secrets
266+ >>> obj.has_policy_breaks
263267 True
264268
265- :return: true if there were policy breaks in the documents
269+ :return: true if there were policy breaks (including secrets) in the document
266270 :rtype: bool
267271 """
268272
269273 return self .policy_break_count > 0
270274
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+
271285 def __repr__ (self ):
272286 return (
273287 "policy_break_count:{0}, "
@@ -280,7 +294,7 @@ def __repr__(self):
280294 def __str__ (self ):
281295 return "{0} policy breaks from the evaluated policies: {1}" .format (
282296 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 ),
284298 )
285299
286300
@@ -316,20 +330,28 @@ def __init__(self, scan_results: List[ScanResult], **kwargs):
316330 self .scan_results = scan_results
317331
318332 @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
321335
322336 >>> obj = ScanResult(2, [], [])
323- >>> obj.has_secrets
337+ >>> obj.has_policy_breaks
324338 True
325339
326- :return: true if there were policy breaks in the documents
340+ :return: true if there were policy breaks (including secrets) in the documents
327341 :rtype: bool
328342 """
329343
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 )
333355
334356 def __repr__ (self ):
335357 return "scan_results:{0}" .format (self .scan_results )
0 commit comments