<s> import ast <EOL> import fnmatch <EOL> from bandit . core import issue <EOL> def report_issue ( check , name ) : <EOL> return issue . Issue ( <EOL> severity = check . get ( '<STR_LIT>' , '<STR_LIT>' ) , confidence = '<STR_LIT>' , <EOL> text = check [ '<STR_LIT:message>' ] . replace ( '<STR_LIT>' , name ) , <EOL> ident = name , test_id = check . get ( "<STR_LIT:id>" , '<STR_LIT>' ) ) <EOL> def blacklist ( context , config ) : <EOL> """<STR_LIT>""" <EOL> blacklists = config <EOL> node_type = context . node . __class__ . __name__ <EOL> if node_type == '<STR_LIT>' : <EOL> func = context . node . func <EOL> if isinstance ( func , ast . Name ) and func . id == '<STR_LIT>' : <EOL> if len ( context . node . args ) : <EOL> if isinstance ( context . node . args [ <NUM_LIT:0> ] , ast . Str ) : <EOL> name = context . node . args [ <NUM_LIT:0> ] . s <EOL> else : <EOL> name = "<STR_LIT>" <EOL> else : <EOL> name = "<STR_LIT>" <EOL> else : <EOL> name = context . call_function_name_qual <EOL> for check in blacklists [ node_type ] : <EOL> for qn in check [ '<STR_LIT>' ] : <EOL> if fnmatch . fnmatch ( name , qn ) : <EOL> return report_issue ( check , name ) <EOL> if node_type . startswith ( '<STR_LIT>' ) : <EOL> prefix = "<STR_LIT>" <EOL> if node_type == "<STR_LIT>" : <EOL> if context . node . module is not None : <EOL> prefix = context . node . module + "<STR_LIT:.>" <EOL> for check in blacklists [ node_type ] : <EOL> for name in context . node . names : <EOL> for qn in check [ '<STR_LIT>' ] : <EOL> if ( prefix + name . name ) . startswith ( qn ) : <EOL> return report_issue ( check , name . name ) </s>
