|
15 | 15 | from requests import request, Response, HTTPError |
16 | 16 | from sklearn.metrics.pairwise import cosine_similarity |
17 | 17 |
|
18 | | -__version__ = "1.2.1" |
| 18 | +__version__ = "1.2.2" |
19 | 19 |
|
20 | 20 | re_conf = { |
21 | 21 | "apikey": environ.get("REAI_API_KEY", ""), |
@@ -335,43 +335,25 @@ def RE_upload(fpath: str) -> Response: |
335 | 335 | :param fpath: File path for binary to analyse |
336 | 336 | """ |
337 | 337 | bin_id = re_binary_id(fpath) |
338 | | - result = re_hash_check(bin_id) |
339 | 338 |
|
340 | | - if result: |
| 339 | + with open(fpath, "rb") as fd: |
| 340 | + res: Response = reveng_req( |
| 341 | + requests.post, "v1/upload", files={"file": fd}) |
| 342 | + |
| 343 | + if res.ok: |
341 | 344 | logger.info( |
342 | | - "File %s - %s already uploaded. Skipping upload...", fpath, bin_id) |
343 | | - |
344 | | - res = Response() |
345 | | - res.status_code = 200 |
346 | | - res.url = f"{re_conf['host']}/v1/upload" |
347 | | - res._content = ( |
348 | | - ( |
349 | | - '{0}"success": true,' |
350 | | - '"message": "File already uploaded!",' |
351 | | - '"sha_256_hash": "{1}"{2}' |
352 | | - ) |
353 | | - .format("{", bin_id, "}") |
354 | | - .encode() |
| 345 | + "Successfully uploaded binary to your account. %s - %s", fpath, bin_id |
| 346 | + ) |
| 347 | + elif res.status_code == 400: |
| 348 | + if "error" in res.json().keys(): |
| 349 | + logger.warning("Error uploading %s - %s", |
| 350 | + fpath, res.json()["error"]) |
| 351 | + elif res.status_code == 413: |
| 352 | + logger.warning("File too large. Please upload files under 10MB.") |
| 353 | + elif res.status_code == 500: |
| 354 | + logger.error( |
| 355 | + "Internal Server Error. Please contact support. Skipping upload..." |
355 | 356 | ) |
356 | | - else: |
357 | | - with open(fpath, "rb") as fd: |
358 | | - res: Response = reveng_req( |
359 | | - requests.post, "v1/upload", files={"file": fd}) |
360 | | - |
361 | | - if res.ok: |
362 | | - logger.info( |
363 | | - "Successfully uploaded binary to your account. %s - %s", fpath, bin_id |
364 | | - ) |
365 | | - elif res.status_code == 400: |
366 | | - if "error" in res.json().keys(): |
367 | | - logger.warning("Error uploading %s - %s", |
368 | | - fpath, res.json()["error"]) |
369 | | - elif res.status_code == 413: |
370 | | - logger.warning("File too large. Please upload files under 10MB.") |
371 | | - elif res.status_code == 500: |
372 | | - logger.error( |
373 | | - "Internal Server Error. Please contact support. Skipping upload..." |
374 | | - ) |
375 | 357 |
|
376 | 358 | res.raise_for_status() |
377 | 359 | return res |
@@ -1302,6 +1284,7 @@ def RE_similar_functions( |
1302 | 1284 | res.raise_for_status() |
1303 | 1285 | return res |
1304 | 1286 |
|
| 1287 | + |
1305 | 1288 | def RE_binary_ann( |
1306 | 1289 | analysis_id: int, |
1307 | 1290 | confidence: float = 0.0, |
|
0 commit comments