helpers.py 文件源码

python
阅读 63 收藏 0 点赞 0 评论 0

项目:united-states-of-browsers 作者: kchawla-pi 项目源码 文件源码
def safetychecks_deprecated(record: Union[Dict[Text, Dict], Iterable[Text]]) -> True:
    """ Checks the names being inserted using string formatting for suspicious characters.
    Prevents SQL injection attacks.
    Returns True or Exits the program.
    """
    safe_chars = set(string.ascii_lowercase)
    safe_chars.update(['_'])
    try:
        fields_chars = set(''.join([field for field in record.keys()]))
    except AttributeError:
        fields_chars = set(list(record))
    if fields_chars.issubset(safe_chars):
        return True
    else:
        print(fields_chars, record, '\n',
            'Browser Database tables have suspicious characters in field names. Please examine them.',
            'As a precaution against an SQL injection attack, only lowercase letters and underscore '
            'charaters are permitted in field names.',
            'Program halted.', sep='\n')
        sys.exit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号