<s> '''<STR_LIT>''' <EOL> import os <EOL> import sys <EOL> import argparse <EOL> import logging <EOL> import processor <EOL> from cloghandler import ConcurrentRotatingFileHandler <EOL> from conf import config <EOL> from datetime import datetime as dt <EOL> class Scanner : <EOL> def __init__ ( self ) : <EOL> self . filename = "<STR_LIT>" <EOL> self . source = "<STR_LIT>" <EOL> self . archive = "<STR_LIT>" <EOL> self . suppress_report = "<STR_LIT>" <EOL> self . file = "<STR_LIT>" <EOL> self . yara_rule_path = config . SCANNER_CONFIG [ '<STR_LIT>' ] <EOL> self . export_path = config . SCANNER_CONFIG [ '<STR_LIT>' ] <EOL> self . log_path = config . SCANNER_CONFIG [ '<STR_LIT>' ] <EOL> self . max_depth = config . SCANNER_CONFIG [ '<STR_LIT>' ] <EOL> self . dbg_h = "<STR_LIT>" <EOL> self . scan_h = "<STR_LIT>" <EOL> self . timeout = config . SCANNER_CONFIG [ '<STR_LIT>' ] <EOL> self . alert = False <EOL> self . full = "<STR_LIT>" <EOL> self . sub_objects = [ ] <EOL> def check_directories ( self ) : <EOL> if not os . path . isdir ( self . log_path ) : <EOL> try : <EOL> os . makedirs ( self . log_path ) <EOL> except : <EOL> print '<STR_LIT>' % self . log_path <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if not os . path . isdir ( self . export_path ) : <EOL> try : <EOL> os . makedirs ( self . export_path ) <EOL> except : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:0> ] <EOL> print '<STR_LIT>' % self . export_path <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> def initialize_logger ( self ) : <EOL> self . dbg_h = logging . getLogger ( '<STR_LIT>' ) <EOL> dbglog = '<STR_LIT>' % ( self . log_path , '<STR_LIT>' ) <EOL> dbg_rotateHandler = ConcurrentRotatingFileHandler ( dbglog , "<STR_LIT:a>" ) <EOL> self . dbg_h . addHandler ( dbg_rotateHandler ) <EOL> self . dbg_h . setLevel ( logging . ERROR ) <EOL> self . scan_h = logging . getLogger ( '<STR_LIT>' ) <EOL> scanlog = '<STR_LIT>' % ( self . log_path , '<STR_LIT>' ) <EOL> scan_rotateHandler = ConcurrentRotatingFileHandler ( scanlog , "<STR_LIT:a>" ) <EOL> self . scan_h . addHandler ( scan_rotateHandler ) <EOL> self . scan_h . setLevel ( logging . INFO ) <EOL> def check_yara_file ( self ) : <EOL> if not os . path . isfile ( self . yara_rule_path ) : <EOL> self . dbg_h . error ( '<STR_LIT>' % ( dt . now ( ) , self . yara_rule_path ) ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> def scan_file ( self ) : <EOL> return processor . scan_file ( self ) </s>
