GranularFireplace commited on
Commit
62f0c6e
·
verified ·
1 Parent(s): f956e55

edit yara response

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -372,17 +372,18 @@ async def analyse_yara(file_name: str):
372
  app.state.yara_rules.match,
373
  file_path
374
  )
375
- return [{
376
- "rule": match.rule,
377
- "namespace": match.namespace,
378
- "tags": match.tags,
379
- "meta": match.meta,
380
- "strings": [{
381
- "offset": s[0],
382
- "identifier": s[1],
383
- "data": s[2].decode('utf-8', errors='replace')
384
- } for s in match.strings]
385
- } for match in matches]
 
386
  except Exception as e:
387
  logger.error(f"YARA analysis failed: {str(e)}")
388
  raise HTTPException(
 
372
  app.state.yara_rules.match,
373
  file_path
374
  )
375
+ if matches:
376
+ return {"result": "Found",
377
+ "matches": [{
378
+ "rule": match.rule,
379
+ "namespace": match.namespace,
380
+ "tags": match.tags,
381
+ "meta": match.meta,
382
+ "strings": [s for s in match.strings]
383
+ } for match in matches]
384
+ }
385
+ else:
386
+ return {"result": "Does not match"}
387
  except Exception as e:
388
  logger.error(f"YARA analysis failed: {str(e)}")
389
  raise HTTPException(