Using values of enumeration to obtain nice and short human readable representations.
This commit is contained in:
parent
fb13925be9
commit
ae3bbd7339
|
@ -28,18 +28,21 @@ from ExtensionCrawler.js_mincer import mince_js
|
|||
|
||||
class DetectionType(Enum):
|
||||
"""Enumeration for detection types."""
|
||||
FILENAME = 1
|
||||
FILECONTENT = 2
|
||||
FILENAME_FILECONTENT = 3
|
||||
URL = 4
|
||||
HASH = 5
|
||||
FILENAME = "filename"
|
||||
COMMENTBLOCK = "comment_block"
|
||||
CODEBLOCK = "code_block"
|
||||
FILENAME_COMMENT = "filename_and_comment_block"
|
||||
FILENAME_CODE = "filename_and_code_block"
|
||||
URL = "known_url"
|
||||
MD5 = "md5"
|
||||
SHA1 = "sha1"
|
||||
|
||||
class FileClassification(Enum):
|
||||
""" Enumeration for file classification"""
|
||||
LIBRARY = 1
|
||||
LIKELY_LIBRARY = 2
|
||||
APPLICATION = 3
|
||||
EMPTY_FILE = 4
|
||||
LIBRARY = "known_library"
|
||||
LIKELY_LIBRARY = "likely_library"
|
||||
APPLICATION = "likely_application"
|
||||
EMPTY_FILE = "empty_file"
|
||||
|
||||
def load_lib_identifiers():
|
||||
"""Initialize identifiers for known libraries from JSON file."""
|
||||
|
@ -116,7 +119,7 @@ def analyse_md5_checksum(zipfile, js_file, js_info):
|
|||
js_info['lib'] = lib
|
||||
js_info['ver'] = md5['version']
|
||||
js_info['type'] = FileClassification.LIBRARY
|
||||
js_info['detectMethod'] = DetectionType.HASH
|
||||
js_info['detectMethod'] = DetectionType.MD5
|
||||
return [js_info]
|
||||
return None
|
||||
|
||||
|
|
|
@ -251,9 +251,9 @@ def parse_and_insert_crx(ext_id, date, datepath, con):
|
|||
con.insert(
|
||||
"jsfile",
|
||||
crx_etag=etag,
|
||||
detect_method=str(js_file_info['detectMethod']),
|
||||
detect_method=(js_file_info['detectMethod']).value,
|
||||
filename=js_file_info['jsFilename'],
|
||||
type=(js_file_info['type']).name,
|
||||
type=(js_file_info['type']).value,
|
||||
lib=js_file_info['lib'],
|
||||
path=js_file_info['path'],
|
||||
md5=js_file_info['md5'],
|
||||
|
|
Loading…
Reference in New Issue