How to use the cobra.log.logger.critical function in cobra

To help you get started, we’ve selected a few cobra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WhaleShark-Team / cobra / cobra / __init__.py View on Github external
if args.report:
            logger.info('[REPORT] Start report')
            res = Report().run()
            if res is False:
                logger.critical('[REPORT] Cobra Report failed')
            else:
                logger.info('[REPORT] Cobra Report Success ')
            exit()

        if args.host is None and args.port is None and args.target is '' and args.output is '':
            parser.print_help()
            exit()

        if 'windows' in platform.platform().lower():
            logger.critical('Nonsupport Windows!!!')

        if args.host is not None and args.port is not None:
            try:
                if not int(args.port) <= 65535:
                    logger.critical('port must be 0-65535.')
                    exit()
            except ValueError as e:
                logger.critical('port must be 0-65535')
                exit()
            logger.debug('[INIT] start RESTful Server...')
            api.start(args.host, args.port, args.debug)
        else:
            logger.debug('[INIT] start scanning...')

            # Native CLI mode
            if args.sid is None:
github WhaleShark-Team / cobra / cobra / cast.py View on Github external
"""
        grep = Tool().grep
        if self.language not in self.regex:
            logger.info("[AST] Undefined language's functions regex {0}".format(self.language))
            return False
        regex_functions = self.regex[self.language]['functions']
        param = [grep, "-s", "-n", "-r", "-P"] + [regex_functions, self.file_path]
        p = subprocess.Popen(param, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        result, error = p.communicate()
        try:
            result = result.decode('utf-8')
            error = error.decode('utf-8')
        except AttributeError as e:
            pass
        if len(error) is not 0:
            logger.critical('[AST] {err}'.format(err=error.strip()))
        if len(result):
            functions = {}
            lines = result.strip().split("\n")
            prev_function_name = ''
            for index, line in enumerate(lines):
                line = line.strip()
                if line == '':
                    logger.info('[AST] Empty')
                    continue
                line_arr = line.split(':')
                if len(line_arr) < 2:
                    logger.info("[AST] Not found(:)")

                regex_annotation = self.regex[self.language]['annotation']
                string = re.findall(regex_annotation, line_arr[1].strip())
                if len(string) >= 1 and string[0] != '':
github WhaleShark-Team / cobra / cobra / utils.py View on Github external
target_git_cases = ['http://', 'https://', 'ssh://']
        for tgc in target_git_cases:
            if self.target[0:len(tgc)] == tgc:
                target_mode = TARGET_MODE_GIT

        if os.path.isfile(self.target):
            target_mode = TARGET_MODE_FILE
            try:
                if self.target.split('.')[-1] in Config('upload', 'extensions').value.split('|'):
                    target_mode = TARGET_MODE_COMPRESS
            except AttributeError as e:
                logger.critical('Please config the config file copy from the config.template file')
        if os.path.isdir(self.target):
            target_mode = TARGET_MODE_FOLDER
        if target_mode is None:
            logger.critical('[PARSE-ARGS] [-t ] can\'t empty!')
            exit()
        logger.debug('[PARSE-ARGS] Target Mode: {mode}'.format(mode=target_mode))
        return target_mode
github WhaleShark-Team / cobra / cobra / send_mail.py View on Github external
server.login(user=username, password=password)
        server.sendmail(from_addr=username, to_addrs=receiver, msg=msg.as_string())
        server.quit()
        logger.info('[EMAIL] Email delivered successfully.')
        return True
    except smtplib.SMTPRecipientsRefused:
        logger.critical('[EMAIL] Email delivery rejected.')
        return False
    except smtplib.SMTPAuthenticationError:
        logger.critical('[EMAIL] SMTP authentication error.')
        return False
    except smtplib.SMTPSenderRefused:
        logger.critical('[EMAIL] SMTP sender refused.')
        return False
    except smtplib.SMTPException as error:
        logger.critical(error)
        logger.critical('[EMAIL] Please config SMTP Server, port, username, password and sender in config file')
        return False
github WhaleShark-Team / cobra / cobra / utils.py View on Github external
target_git_cases = ['http://', 'https://', 'ssh://']
        for tgc in target_git_cases:
            if self.target[0:len(tgc)] == tgc:
                target_mode = TARGET_MODE_GIT

        if os.path.isfile(self.target):
            target_mode = TARGET_MODE_FILE
            try:
                if self.target.split('.')[-1] in Config('upload', 'extensions').value.split('|'):
                    target_mode = TARGET_MODE_COMPRESS
            except AttributeError as e:
                logger.critical('Please config the config file copy from the config.template file')
        if os.path.isdir(self.target):
            target_mode = TARGET_MODE_FOLDER
        if target_mode is None:
            logger.critical('[PARSE-ARGS] [-t ] can\'t empty!')
            exit()
        logger.debug('[PARSE-ARGS] Target Mode: {mode}'.format(mode=target_mode))
        return target_mode
github WhaleShark-Team / cobra / git_projects.py View on Github external
exit()

    if ',' in args.target:
        targets = args.target.split(',')
    else:
        targets = args.target

    try:
        if ',' in args.rules:
            rules = args.rules.split(',')
            for rule in rules:
                if _check_rule_name(rule) is False:
                    logger.critical('[GIT-PRO] Exception special rule name(e.g: CVI-110001): {sr}'.format(sr=rule))
        else:
            if _check_rule_name(args.rules) is False:
                logger.critical('[GIT-PRO] Exception special rule name(e.g: CVI-110001): {sr}'.format(sr=args.rules))

    except TypeError:
        logger.info('[GIT-PRO] The rules is None, Cobra will use all rules to scan')

    start(targets, args.format, args.output, args.rules, args.dels, args.all)
github WhaleShark-Team / cobra / cobra / report.py View on Github external
smtp = smtplib.SMTP_SSL(host=self.host, port=self.port)
            smtp.login(self.user, self.password)
            smtp.sendmail(self.user, self.to, message.as_string())
            logger.info('[EMAIL] Email delivered successfully.')
            return True
        except smtplib.SMTPRecipientsRefused:
            logger.critical('[EMAIL] Email delivery rejected.')
            return False
        except smtplib.SMTPAuthenticationError:
            logger.critical('[EMAIL] SMTP authentication error.')
            return False
        except smtplib.SMTPSenderRefused:
            logger.critical('[EMAIL] SMTP sender refused.')
            return False
        except smtplib.SMTPException as error:
            logger.critical(error)
            logger.critical('[EMAIL] Please config SMTP Server, port, username, password and sender in config file')
            return False
github WhaleShark-Team / cobra / cobra / rule.py View on Github external
{
            'php':{
                'chiefly': 'true',
                'extensions':[
                    '.php',
                    '.php3',
                    '.php4',
                    '.php5'
                ]
            }
        }
        """
        language_extensions = {}
        xml_languages = self._read_xml('languages.xml')
        if xml_languages is None:
            logger.critical('languages read failed!!!')
            return None
        for language in xml_languages:
            l_name = language.get('name').lower()
            l_chiefly = 'false'
            if language.get('chiefly') is not None:
                l_chiefly = language.get('chiefly')
            language_extensions[l_name] = {
                'chiefly': l_chiefly,
                'extensions': []
            }
            for lang in language:
                l_ext = lang.get('value').lower()
                language_extensions[l_name]['extensions'].append(l_ext)
        return language_extensions