<s> '''<STR_LIT>''' <EOL> from sqlalchemy import Column , ForeignKey , and_ <EOL> from sqlalchemy . orm import synonym , relationship , backref <EOL> from sqlalchemy . types import Unicode , Integer , Boolean , DateTime <EOL> from string import ascii_letters , digits <EOL> from models import dbsession , BaseObject <EOL> from models import common_association_table , lower_association_table , upper_association_table , numeric_association_table , mixed_association_table , lower_alpha_association_table , upper_alpha_association_table , mixed_alpha_association_table <EOL> class AnalysisReport ( BaseObject ) : <EOL> '''<STR_LIT>''' <EOL> job_id = Column ( Integer , ForeignKey ( '<STR_LIT>' ) , nullable = False ) <EOL> common_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = common_association_table , <EOL> ) <EOL> lower_case_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = lower_association_table , <EOL> ) <EOL> upper_case_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = upper_association_table , <EOL> ) <EOL> numeric_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = numeric_association_table , <EOL> ) <EOL> mixed_case_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = mixed_association_table , <EOL> ) <EOL> lower_alpha_numeric_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = lower_alpha_association_table , <EOL> ) <EOL> upper_alpha_numeric_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = upper_alpha_association_table , <EOL> ) <EOL> mixed_alpha_numeric_passwords = relationship ( "<STR_LIT>" , <EOL> secondary = mixed_alpha_association_table , <EOL> ) <EOL> __common__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:password>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ] <EOL> def analyze_all ( self , passwords ) : <EOL> '''<STR_LIT>''' <EOL> for index , password in enumerate ( passwords ) : <EOL> logging . debug ( "<STR_LIT>" % ( index , len ( passwords ) ) ) <EOL> self . test_lower_case_passwords ( password ) <EOL> self . test_upper_case_passwords ( password ) <EOL> self . test_numeric_passwords ( password ) <EOL> self . test_mixed_case_passwords ( password ) <EOL> self . test_lower_alpha_numeric ( password ) <EOL> self . test_upper_alpha_numeric ( password ) <EOL> self . test_mixed_alpha_numeric ( password ) <EOL> self . test_common_passwords ( password ) <EOL> dbsession . add ( self ) <EOL> dbsession . flush ( ) <EOL> def test_lower_case_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> if self . __regex__ ( "<STR_LIT>" , password . clear_text ) : <EOL> self . lower_case . append ( password ) <EOL> def test_upper_case_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> if self . __regex__ ( "<STR_LIT>" , password . clear_text ) : <EOL> self . upper_case . append ( password ) <EOL> def test_numeric_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> if self . __regex__ ( "<STR_LIT>" , password . clear_text ) : <EOL> self . numeric_passwords . append ( password ) <EOL> def test_mixed_case_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> contains_cases = self . __regex__ ( <EOL> "<STR_LIT>" , password . clear_text <EOL> ) <EOL> only_alpha = self . __regex__ ( "<STR_LIT>" , password . clear_text ) <EOL> if contains_cases and only_alpha : <EOL> self . mixed_case . append ( password ) <EOL> def test_lower_alpha_numeric_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> contains_alph_numeric = self . __regex__ ( <EOL> "<STR_LIT>" , password . clear_text <EOL> ) <EOL> only_alpha_numeric = self . __regex__ ( "<STR_LIT>" , password . clear_text ) <EOL> if contains_alph_numeric and only_alpha_numeric : <EOL> self . lower_alpha_numeric . append ( password ) <EOL> def test_upper_alpha_numeric_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> contains_alph_numeric = self . __regex__ ( <EOL> "<STR_LIT>" , password . clear_text <EOL> ) <EOL> only_alpha_numeric = self . __regex__ ( "<STR_LIT>" , password . clear_text ) <EOL> if contains_alph_numeric and only_alpha_numeric : <EOL> self . upper_case . append ( password ) <EOL> def test_mixed_alpha_numeric_passwords ( self , password ) : <EOL> '''<STR_LIT>''' <EOL> contains_mixed_alpha_numeric = self . __regex__ ( <EOL> "<STR_LIT>" , password . clear_text <EOL> ) <EOL> only_mixed_alpha_numeric = self . __regex__ ( <EOL> "<STR_LIT>" , password . clear_text <EOL> ) <EOL> if contains_mixed_alpha_numeric and only_mixed_alpha_numeric : <EOL> self . mixed_alpha_numeric . append ( password ) <EOL> def test_common_passwords ( self , password ) : <EOL> if password . clear_text . lower ( ) in self . __common__ : <EOL> self . common_passwords . append ( password ) <EOL> def __regex__ ( self , expression , string ) : <EOL> '''<STR_LIT>''' <EOL> regex = re . compile ( expression ) <EOL> return bool ( regex . match ( string ) ) </s>
