Пример #1
0
        override this method to handle things appropriately.
        '''

        for l in f:
            l = l.strip()
            if not l: continue

            # Pylint marks the start of a module with a line like **** <module>
            if l.startswith('*****'): continue

            m = self._report_re.match(l)
            if m:
                f = m.groupdict()
                msg = self.create_issue(checker = 'PyLint.'+f['tag'],
                            tag = f['tag'],
                            description = f['description'],
                            function = f['function'],
                            subcategory = f['subcategory']
                           )
                msg.add_location(f['line'], f['file'], f['description'])
                self.add_issue(msg)
            else:
                # Pylint inserts code snippets for some issues; skip those lines
                pass
                #print 'Unrecognized input format:', l
                #sys.exit(-1)

if __name__ == '__main__':
    opts = get_opts('pylint_import.py', sys.argv)
    print PyLintCollector(**opts).run(sys.argv[-1])
Пример #2
0
import xml.etree.ElementTree as ET

class CppCheckCollector(CoverityIssueCollector):
    '''
    A simple collector for cppcheck reports.  The cppcheck analysis should use
    the --xml-version=2 option, and we recommend the following additional
    options: --enable=all --suppress=missingIncludeSystem
    '''

    _checker_prefix = 'cppcheck'

    def process(self, f):
        tree = ET.parse(f)
        root = tree.getroot()
        for e in root.findall('./errors/error'):
            a = e.attrib
            msg = self.create_issue(
                       checker = a['id'],
                       subcategory = a['severity'],
                       tag = a['msg'],
                       description = a['verbose']
                       )
            for loc in e.findall('location'):
                msg.add_location(loc.attrib['line'], loc.attrib['file'], loc.attrib.get('description'))
            self.add_issue(msg)

if __name__ == '__main__':
    import sys
    opts = get_opts('cppcheck_import.py', sys.argv)
    print CppCheckCollector(**opts).run(sys.argv[-1])
Пример #3
0
                'checker': issue['warning_type'],
                'tag': 'Warning',
                'subcategory': issue['confidence'],
                'description': ''.join(description)
            }
            if issue['fingerprint']:
                attrs['extra'] = issue['fingerprint']
            if issue['location'] and issue['location'].get('method',None):
                attrs['function'] = issue['location']['class']+'.'+issue['location']['method']
            if issue['line'] is None:
                issue['line'] = self.find_line(issue)

            msg = self.create_issue(**attrs)

            # Do we need to walk over issue['render_path'] to create
            # dataflow events?
        
            # Also takes description, method, tag
            msg.add_location(
                issue['line'],
                issue['file'],
                link = issue.get('link', None),
                linktext = issue.get('link') and '[Brakeman description]' or None
            )
            self.add_issue(msg)

if __name__ == '__main__':
    import sys
    opts = get_opts('brakeman_import.py', sys.argv)
    print BrakemanCollector(**opts).run(sys.argv[-1])
Пример #4
0
                        var_in = ' from %s (aka %s)' % (var_ain, var_in)
                    elif var_in:
                        var_in = ' from '+var_in
                    else:
                        var_in = ''

                    description = '%s%s to %s' % (tag, var_in, var_out)

                    try:
                        msg.add_location(line, filename, description, method=method, tag=tag)
                    except AttributeError:
                        for n in ('line','filename','description','method','tag'):
                            print n.upper(), locals()[n]
                        raise

                if confidence_level != 'Low' and not suppressed:
                    # The first loc is going to be treated as the main event,
                    # so let's set that event's description to None so that
                    # it will get the long description associated with the
                    # ProblemDescription field.
                    msg.main_event = -1 
                    msg._locs[msg.main_event].description = None
                    msg.function = msg._locs[msg.main_event].method

                    self.add_issue(msg) 

if __name__ == '__main__':
    import sys
    opts = get_opts('catnet_import.py', sys.argv)
    print CatNETCollector(**opts).run(sys.argv[-1])
Пример #5
0
import xml.etree.ElementTree as ET

class CheckstyleCollector(CoverityIssueCollector):
    _checker_prefix='checkstyle'

    '''
    A simple collector for Checkstyle reports.
    '''
    def process(self, f):
        tree = ET.parse(f)
        root = tree.getroot()
        for f in root.findall('file'):
            # <file name=""> ... </file>
            for e in f.findall('error'):
                # <error line="" severity="" message="" source=""/>
                a = e.attrib
                cls = a['source'].split('.')
                msg = self.create_issue(checker = '.'.join(cls[-2:]),
                            subcategory = a['severity'],
                            tag = cls[-1],
                            description = a['message']
                           )
                msg.add_location(e.attrib['line'], f.attrib['name'])
                self.add_issue(msg)

if __name__ == '__main__':
    import sys
    opts = get_opts('checkstyle_import.py', sys.argv)
    print CheckstyleCollector(**opts).run(sys.argv[-1])
    def process(self, f):
        '''
        This method assumes that reports are isolated to a single line.
        If your tool reports issues on multiple lines, or for some other
        reason the report lines may not be reordered, you'll need to override
        this method to handle things appropriately.
        '''
        for l in f:
            if not l.strip(): continue
            m = self._report_re.match(l)
            if m:
                f = m.groupdict()
                msg = self.create_issue(
                    checker='AdaControl',
                    tag=f['description'],
                    description=f['description'],
                    subcategory=f['subcategory'],
                )
                msg.add_location(f['line'], f['file'])
                self.add_issue(msg)
            elif l.strip() == 'Counts summary:':
                break
            else:
                print 'Unrecognized input format:', l
                sys.exit(-1)


if __name__ == '__main__':
    opts = get_opts('adacontrol_import.py', sys.argv)
    print AdaControlCollector(**opts).run(sys.argv[-1])
import xml.etree.ElementTree as ET


class CheckstyleCollector(CoverityIssueCollector):
    _checker_prefix = 'checkstyle'
    '''
    A simple collector for Checkstyle reports.
    '''
    def process(self, f):
        tree = ET.parse(f)
        root = tree.getroot()
        for f in root.findall('file'):
            # <file name=""> ... </file>
            for e in f.findall('error'):
                # <error line="" severity="" message="" source=""/>
                a = e.attrib
                cls = a['source'].split('.')
                msg = self.create_issue(checker='.'.join(cls[-2:]),
                                        subcategory=a['severity'],
                                        tag=cls[-1],
                                        description=a['message'])
                msg.add_location(e.attrib['line'], f.attrib['name'])
                self.add_issue(msg)


if __name__ == '__main__':
    import sys
    opts = get_opts('checkstyle_import.py', sys.argv)
    print CheckstyleCollector(**opts).run(sys.argv[-1])
Пример #8
0
                    description = '%s%s to %s' % (tag, var_in, var_out)

                    try:
                        msg.add_location(line,
                                         filename,
                                         description,
                                         method=method,
                                         tag=tag)
                    except AttributeError:
                        for n in ('line', 'filename', 'description', 'method',
                                  'tag'):
                            print n.upper(), locals()[n]
                        raise

                if confidence_level != 'Low' and not suppressed:
                    # The first loc is going to be treated as the main event,
                    # so let's set that event's description to None so that
                    # it will get the long description associated with the
                    # ProblemDescription field.
                    msg.main_event = -1
                    msg._locs[msg.main_event].description = None
                    msg.function = msg._locs[msg.main_event].method

                    self.add_issue(msg)


if __name__ == '__main__':
    import sys
    opts = get_opts('catnet_import.py', sys.argv)
    print CatNETCollector(**opts).run(sys.argv[-1])
Пример #9
0
    def process(self, f):
        '''
        This method assumes that reports are isolated to a single line.
        If your tool reports issues on multiple lines, or for some other
        reason the report lines may not be reordered, you'll need to override
        this method to handle things appropriately.
        '''
        for l in f:
            if not l.strip(): continue
            m = self._report_re.match(l)
            if m:
                f = m.groupdict()
                msg = self.create_issue(
                    checker='JSHint',
                    tag=f['description'],
                    description=f['description'],
                    subcategory='Error',
                )
                msg.add_location(f['line'], f['file'])
                self.add_issue(msg)
            elif self._summary_re.match(l):
                pass
            else:
                print 'Unrecognized input format:', l
                sys.exit(-1)


if __name__ == '__main__':
    opts = get_opts('jshint_import.py', sys.argv)
    print JSHintCollector(**opts).run(sys.argv[-1])
Пример #10
0
                'subcategory': issue['confidence'],
                'description': ''.join(description)
            }
            if issue['fingerprint']:
                attrs['extra'] = issue['fingerprint']
            if issue['location'] and issue['location'].get('method', None):
                attrs['function'] = issue['location']['class'] + '.' + issue[
                    'location']['method']
            if issue['line'] is None:
                issue['line'] = self.find_line(issue)

            msg = self.create_issue(**attrs)

            # Do we need to walk over issue['render_path'] to create
            # dataflow events?

            # Also takes description, method, tag
            msg.add_location(
                issue['line'],
                issue['file'],
                link=issue.get('link', None),
                linktext=issue.get('link') and '[Brakeman description]'
                or None)
            self.add_issue(msg)


if __name__ == '__main__':
    import sys
    opts = get_opts('brakeman_import.py', sys.argv)
    print BrakemanCollector(**opts).run(sys.argv[-1])
Пример #11
0
    -R L003 -R L004 -R L005 -R L006 -R T008 -R T011 -R T012 -R T019
    '''
    _report_re = re.compile(r'^(?P<file>.+):(?P<line>\d+):\s*\((?P<subcategory>.+)\) (?P<description>.*)$', re.M)

    def process(self, f):
        '''
        This method assumes that reports are isolated to a single line.
        If your tool reports issues on multiple lines, or for some other
        reason the report lines may not be reordered, you'll need to override
        this method to handle things appropriately.
        '''
        for l in f:
            if not l.strip(): continue
            m = self._report_re.match(l)
            if m:
                f = m.groupdict()
                msg = self.create_issue(checker='Vera++',
                            tag = f['subcategory'],
                            description = f['description'],
                            subcategory = f['subcategory']
                           )
                msg.add_location(f['line'], f['file'], f['description'])
                self.add_issue(msg)
            else:
                print 'Unrecognized input format:', l
                sys.exit(-1)

if __name__ == '__main__':
    opts = get_opts('vera++_import.py', sys.argv)
    print VeraCollector(**opts).run(sys.argv[-1])
Пример #12
0
    _summary_re = re.compile(r'^\s*\d+\s+errors.*$', re.M | re.I)

    def process(self, f):
        '''
        This method assumes that reports are isolated to a single line.
        If your tool reports issues on multiple lines, or for some other
        reason the report lines may not be reordered, you'll need to override
        this method to handle things appropriately.
        '''
        for l in f:
            if not l.strip(): continue
            m = self._report_re.match(l)
            if m:
                f = m.groupdict()
                msg = self.create_issue(checker='JSHint',
                            tag = f['description'],
                            description = f['description'],
                            subcategory = 'Error',
                           )
                msg.add_location(f['line'], f['file'])
                self.add_issue(msg)
            elif self._summary_re.match(l):
                pass
            else:
                print 'Unrecognized input format:', l
                sys.exit(-1)

if __name__ == '__main__':
    opts = get_opts('jshint_import.py', sys.argv)
    print JSHintCollector(**opts).run(sys.argv[-1])
Пример #13
0
    _report_re = re.compile(r'^(?P<file>.+):(?P<line>\d+):\d+:\s*.+:\s*(?P<subcategory>.+): (?P<description>.*)$', re.M)

    def process(self, f):
        '''
        This method assumes that reports are isolated to a single line.
        If your tool reports issues on multiple lines, or for some other
        reason the report lines may not be reordered, you'll need to override
        this method to handle things appropriately.
        '''
        for l in f:
            if not l.strip(): continue
            m = self._report_re.match(l)
            if m:
                f = m.groupdict()
                msg = self.create_issue(checker='AdaControl',
                            tag = f['description'],
                            description = f['description'],
                            subcategory = f['subcategory'],
                           )
                msg.add_location(f['line'], f['file'])
                self.add_issue(msg)
            elif l.strip() == 'Counts summary:':
                break
            else:
                print 'Unrecognized input format:', l
                sys.exit(-1)

if __name__ == '__main__':
    opts = get_opts('adacontrol_import.py', sys.argv)
    print AdaControlCollector(**opts).run(sys.argv[-1])