pengdaqian commited on
Commit
de7de27
1 Parent(s): 3528c05
Files changed (1) hide show
  1. scan.py +3 -2
scan.py CHANGED
@@ -2,6 +2,7 @@ import pyclamd
2
 
3
  from picklescan.scanner import (
4
  scan_url,
 
5
  ScanResult, SafetyLevel
6
  )
7
 
@@ -15,7 +16,7 @@ def scan_file(file_path: str):
15
  if file_path.startswith("http"):
16
  scan_result: ScanResult = scan_url(file_path)
17
  else:
18
- return None
19
 
20
  globalImports = list(map(lambda x: fmt_import(x.module, x.name), scan_result.globals))
21
  dangerousImports = list(map(lambda x: fmt_import(x.module, x.name),
@@ -45,7 +46,7 @@ def init_clamd():
45
  def clamd_file(file_path: str, clamd):
46
  if file_path.startswith("http"):
47
  import urllib.request
48
- tmp_path = f'/tmp/clamd_{file_path.split("/")[-1]}'
49
  urllib.request.urlretrieve(file_path, tmp_path)
50
  ret = clamd.scan_file(tmp_path)
51
  if ret is None:
 
2
 
3
  from picklescan.scanner import (
4
  scan_url,
5
+ scan_file_path,
6
  ScanResult, SafetyLevel
7
  )
8
 
 
16
  if file_path.startswith("http"):
17
  scan_result: ScanResult = scan_url(file_path)
18
  else:
19
+ scan_result: ScanResult = scan_file_path(file_path)
20
 
21
  globalImports = list(map(lambda x: fmt_import(x.module, x.name), scan_result.globals))
22
  dangerousImports = list(map(lambda x: fmt_import(x.module, x.name),
 
46
  def clamd_file(file_path: str, clamd):
47
  if file_path.startswith("http"):
48
  import urllib.request
49
+ tmp_path = f'/tmp/clamd_{file_path.split("/")[-1].split("?")[0]}'
50
  urllib.request.urlretrieve(file_path, tmp_path)
51
  ret = clamd.scan_file(tmp_path)
52
  if ret is None: