def _normalize(self, entry): """ Normalize the entry using the query and the method that made it """ message = entry.get('@message') context = entry.get('@context', dict()) return '{}-{}-no-limit'.format(generalize_sql(message), context.get('method'))
def _normalize(self, entry): """ Normalize given SQL error using normalized query and error code """ context = self._get_context_from_entry(entry) if context is not None: query = context.get('query') if query is not None: # merge context coming from DB error reporting with # the one extracted from exception message (using self._get_context_from_entry) merged_context = entry.get('@context', {}) merged_context.update(context) err_no = merged_context.get('errno') return '{}-{}'.format( # PLATFORM-1512: normalize SQL parse errors (possibly SQL injection tries) # using function name instead of a normalized query merged_context.get('function') if err_no == self.ER_PARSE_ERROR else generalize_sql(query), err_no) return None
def _normalize(self, entry): """ Normalize given entry """ return 'Backend-{}-{}-{}'.format( entry.get('@message').encode('utf8'), entry.get('@fields', {}).get('script_name', 'n/a'), generalize_sql(entry.get('@context', {}).get('error', 'n/a')))
def _get_report(self, entry): """ Format the report to be sent to JIRA """ context = entry.get('@context') query = context.get('query') normalized = generalize_sql(query) # remove server IP from error message error_no_ip = context.get('error').\ replace('({})'.format(context.get('server')), '').\ strip() # format the report full_message = self.FULL_MESSAGE_TEMPLATE.format( message=entry.get('@message', '').strip(), query=query, error=error_no_ip, function=context.get('function'), server=context.get('server'), backtrace=self._get_backtrace_from_exception( entry.get('@exception'))).strip() description = self.REPORT_TEMPLATE.format( env=self._get_env_from_entry(entry), source_host=entry.get('@source_host', 'n/a'), context_formatted=json.dumps(entry.get('@context', {}), indent=True), fields_formatted=json.dumps(entry.get('@fields', {}), indent=True), full_message=full_message, url=self._get_url_from_entry(entry) or 'n/a').strip() return Report(summary='[DB error {err}] {function} - {query}'.format( err=error_no_ip, function=context.get('function'), query=normalized), description=description, label=self.REPORT_LABEL)
def _get_report(self, entry): """ Format the report to be sent to JIRA """ context = entry.get('@context') query = context.get('query') normalized = generalize_sql(query) # remove server IP from error message error_no_ip = context.get('error').\ replace('({})'.format(context.get('server')), '').\ strip() # format the report full_message = self.FULL_MESSAGE_TEMPLATE.format( message=entry.get('@message', '').strip(), query=query, error=error_no_ip, function=context.get('function'), server=context.get('server'), backtrace=self._get_backtrace_from_exception(entry.get('@exception')) ).strip() description = self.REPORT_TEMPLATE.format( env=self._get_env_from_entry(entry), source_host=entry.get('@source_host', 'n/a'), context_formatted=json.dumps(entry.get('@context', {}), indent=True), fields_formatted=json.dumps(entry.get('@fields', {}), indent=True), full_message=full_message, url=self._get_url_from_entry(entry) or 'n/a' ).strip() return Report( summary='[DB error {err}] {function} - {query}'.format( err=error_no_ip, function=context.get('function'), query=normalized), description=description, label=self.REPORT_LABEL )
def _normalize(self, entry): """ Normalize the entry using the controller and method names """ sql = generalize_sql(entry.get('query')) return '{}-{}'.format(self.REPORT_LABEL, sql)
def _normalize(self, entry): """ Normalize given SQL error using normalized query and error code """ context = self._get_context_from_entry(entry) if context is not None: query = context.get('query') if query is not None: # merge context coming from DB error reporting with # the one extracted from exception message (using self._get_context_from_entry) merged_context = entry.get('@context', {}) merged_context.update(context) err_no = merged_context.get('errno') return '{}-{}'.format( # PLATFORM-1512: normalize SQL parse errors (possibly SQL injection tries) # using function name instead of a normalized query merged_context.get('function') if err_no == self.ER_PARSE_ERROR else generalize_sql(query), err_no ) return None