@@ -52,7 +52,8 @@ 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 : Optional [int ] = None ) -> \
56+ Tuple [List [List [Finding ]], List [str ]]:
5657 """Scan text with Nightfall.
5758
5859 This method takes the specified config and then makes
@@ -67,6 +68,8 @@ def scan_text(self, texts: List[str], detection_rules: Optional[List[DetectionRu
6768 :param detection_rule_uuids: List of detection rule UUIDs to scan each text with.
6869 These can be created in the Nightfall UI.
6970 :type detection_rule_uuids: List[str] or None
71+ :param context_bytes: The number of bytes of context (leading and trailing) to return with any matched findings.
72+ :type context_bytes: int or None
7073 :returns: list of findings, list of redacted input texts
7174 """
7275
@@ -78,6 +81,8 @@ def scan_text(self, texts: List[str], detection_rules: Optional[List[DetectionRu
7881 config ["detectionRuleUUIDs" ] = detection_rule_uuids
7982 if detection_rules :
8083 config ["detectionRules" ] = [d .as_dict () for d in detection_rules ]
84+ if context_bytes :
85+ config ["contextBytes" ] = context_bytes
8186 request_body = {
8287 "payload" : texts ,
8388 "config" : config
0 commit comments