@@ -52,7 +52,7 @@ def __init__(self, key: Optional[str] = None, signing_secret: Optional[str] = No
5252 self .logger = logging .getLogger (__name__ )
5353
5454 def scan_text (self , texts : List [str ], detection_rules : Optional [List [DetectionRule ]] = None ,
55- detection_rule_uuids : Optional [List [str ]] = None ) -> Tuple [List [List [Finding ]], List [str ]]:
55+ detection_rule_uuids : Optional [List [str ]] = None , context_bytes = None ) -> Tuple [List [List [Finding ]], List [str ]]:
5656 """Scan text with Nightfall.
5757
5858 This method takes the specified config and then makes
@@ -67,6 +67,8 @@ def scan_text(self, texts: List[str], detection_rules: Optional[List[DetectionRu
6767 :param detection_rule_uuids: List of detection rule UUIDs to scan each text with.
6868 These can be created in the Nightfall UI.
6969 :type detection_rule_uuids: List[str] or None
70+ :param context_bytes: The number of bytes of context (leading and trailing) to return with any matched findings.
71+ :type context_bytes: int or None
7072 :returns: list of findings, list of redacted input texts
7173 """
7274
@@ -78,6 +80,8 @@ def scan_text(self, texts: List[str], detection_rules: Optional[List[DetectionRu
7880 config ["detectionRuleUUIDs" ] = detection_rule_uuids
7981 if detection_rules :
8082 config ["detectionRules" ] = [d .as_dict () for d in detection_rules ]
83+ if context_bytes :
84+ config ["contextBytes" ] = context_bytes
8185 request_body = {
8286 "payload" : texts ,
8387 "config" : config
0 commit comments