reait 1.2.1__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
reait/api.py CHANGED
@@ -15,7 +15,7 @@ from pandas import DataFrame
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
@@ -1301,3 +1283,31 @@ def RE_similar_functions(
1301
1283
 
1302
1284
  res.raise_for_status()
1303
1285
  return res
1286
+
1287
+
1288
+ def RE_binary_ann(
1289
+ analysis_id: int,
1290
+ confidence: float = 0.0,
1291
+ nns: int = 1,
1292
+ collection_ids: list[int] = None,
1293
+ binary_ids: list[int] = None,
1294
+ ) -> Response:
1295
+ """
1296
+ Perform binary ANN (Approximate Nearest Neighbor) search.
1297
+ :param analysis_id: Analysis ID
1298
+ :param confidence: Confidence threshold for the search
1299
+ :param nns: Number of nearest neighbors to retrieve
1300
+ :param collection_ids: List of collection IDs to search within
1301
+ :param binary_ids: List of binary IDs to search within
1302
+ """
1303
+ end_point = f"v2/binary_ann/{analysis_id}"
1304
+ json_data = {
1305
+ "confidence": confidence,
1306
+ "nns": nns,
1307
+ "collection_ids": collection_ids or [],
1308
+ "binary_ids": binary_ids or [],
1309
+ }
1310
+
1311
+ res: Response = reveng_req(requests.post, end_point, json_data=json_data)
1312
+ res.raise_for_status()
1313
+ return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reait
3
- Version: 1.2.1
3
+ Version: 1.2.2
4
4
  Summary: RevEng.AI Toolkit and Python API
5
5
  Home-page: https://github.com/RevEng-AI/reait
6
6
  Author: James Patrick-Evans
@@ -0,0 +1,9 @@
1
+ reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
2
+ reait/api.py,sha256=10D3tITkhQN1mb04hHpgJgq26cii9gpzD2B3jcSxFQ0,36915
3
+ reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
4
+ reait-1.2.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
+ reait-1.2.2.dist-info/METADATA,sha256=WOJrwIHV2HD6zY_g5AyL1i7JJ2knoOM42MNJ6TXAIww,47663
6
+ reait-1.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ reait-1.2.2.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
8
+ reait-1.2.2.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
9
+ reait-1.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- reait/__init__.py,sha256=EoVCKwQwWxEBfwe-iEE5rFKvhi1gPEA8NPhnzXJTb2Y,42
2
- reait/api.py,sha256=ztgJEvd76L_ddN7vLxtCtLY4n3pxddMvu4VP7YA2a1w,36642
3
- reait/main.py,sha256=rSzEowDrK2KFmmLdbRNVsfVpvMLZNXA3fQOrBw03T4Y,20396
4
- reait-1.2.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
- reait-1.2.1.dist-info/METADATA,sha256=Twgqyouwxy3lRCDP1YDAlct5_ltT2sPio0eHg5rX0eA,47663
6
- reait-1.2.1.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
7
- reait-1.2.1.dist-info/entry_points.txt,sha256=8Ek11o7a6O8hjBFw6-1vmkBfbv_45O2vOKj5CDUB1e4,42
8
- reait-1.2.1.dist-info/top_level.txt,sha256=EnJssmctKe3Ugjcmu66L9_Q4elLdAwaXK6M8E6E8f_M,6
9
- reait-1.2.1.dist-info/RECORD,,