@@ -88,7 +88,6 @@ def scan_text(self, texts: list[str], detection_rule_uuids: list[str] = None,
8888 findings = [[Finding .from_dict (f ) for f in item_findings ] for item_findings in parsed_response ["findings" ]]
8989 return findings , parsed_response .get ("redactedPayload" )
9090
91-
9291 def _scan_text_v3 (self , data ):
9392 response = requests .post (
9493 url = self .TEXT_SCAN_ENDPOINT_V3 ,
@@ -110,14 +109,10 @@ def _scan_text_v3(self, data):
110109 # File Scan
111110
112111 def scan_file (self , location : str , webhook_url : str , policy_uuid : str = None ,
113- detection_rule_uuids : list [str ] = None , detection_rules : list [DetectionRule ] = None ):
112+ detection_rule_uuids : list [str ] = None , detection_rules : list [DetectionRule ] = None ,
113+ ) -> [str , str ]:
114114 """Scan file with Nightfall.
115-
116- Either policy_uuid or detection_rule_uuids or detection_rules is required.
117- ::
118- policy_uuid: "uuid"
119- detection_rule_uuids: ["uuid",]
120- detection_rules: [{detection_rule},]
115+ At least one of policy_uuid, detection_rule_uuids or detection_rules is required.
121116
122117 :param location: location of file to scan.
123118 :param webhook_url: webhook endpoint which will receive the results of the scan.
@@ -127,6 +122,7 @@ def scan_file(self, location: str, webhook_url: str, policy_uuid: str = None,
127122 :type detection_rule_uuids: list[str] or None
128123 :param detection_rules: list of detection rules.
129124 :type detection_rules: list[DetectionRule] or None
125+ :returns: (scan_id, message)
130126 """
131127
132128 if not policy_uuid and not detection_rule_uuids and not detection_rules :
@@ -150,8 +146,9 @@ def scan_file(self, location: str, webhook_url: str, policy_uuid: str = None,
150146 detection_rule_uuids = detection_rule_uuids ,
151147 detection_rules = detection_rules )
152148 _validate_response (response , 200 )
149+ parsed_response = response .json ()
153150
154- return response . json ()
151+ return parsed_response [ "id" ], parsed_response [ "message" ]
155152
156153 def _file_scan_initialize (self , location : str ):
157154 data = {
@@ -218,7 +215,7 @@ def _file_scan_scan(self, session_id: str, webhook_url: str, policy_uuid: str,
218215 )
219216 return response
220217
221- def validate_webhook (self , request_signature : str , request_timestamp : str , request_data : str ):
218+ def validate_webhook (self , request_signature : str , request_timestamp : str , request_data : str ) -> bool :
222219 """
223220 Validate the integrity of webhook requests coming from Nightfall.
224221
0 commit comments