csirtgadgets/verbose-robot

View on GitHub

Showing 56 of 172 total issues

File indicator.py has 558 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import arrow
import json
from base64 import b64encode
import ipaddress
Severity: Major
Found in cif/store/sqlite/indicator.py - About 1 day to fix

    Function _filter_terms has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def _filter_terms(self, filters, s):
    
            idx = ['reported_at', 'itype', 'confidence', 'probability', 'provider', 'asn', 'cc', 'asn_desc',
                   'rdata', 'region', 'uuid', 'tags']
    
    
    Severity: Minor
    Found in cif/store/sqlite/indicator.py - About 6 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File __init__.py has 404 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
    
    import logging
    import textwrap
    import ujson as json
    Severity: Minor
    Found in cif/store/__init__.py - About 5 hrs to fix

      Function _upsert has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def _upsert(self, s, n, d, token, cached_added, batch):
              try:
                  # check to see if it's been added in the cache
                  if cached_added.get(d['indicator']):
                      if d.get('last_at') in cached_added[d['indicator']]:
      Severity: Minor
      Found in cif/store/sqlite/indicator.py - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function start has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def start(self):
              self.context = zmq.Context()
              self.router = self.context.socket(zmq.ROUTER)
              self.router_write = self.context.socket(zmq.ROUTER)
              self.router_write_h = self.context.socket(zmq.ROUTER)
      Severity: Minor
      Found in cif/store/__init__.py - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function process has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

      def process(i):
          if not ENABLED:
              return
      
          if not i.is_fqdn():
      Severity: Minor
      Found in cif/hunter/fqdn.py - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      File router.py has 307 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python3
      
      import ujson as json
      import logging
      import textwrap
      Severity: Minor
      Found in cif/router.py - About 3 hrs to fix

        Function _pull_feed has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            def _pull_feed(self, filters, agg=True):
                if agg and not filters.get('reported_at') and not filters.get('days') \
                        and not filters.get('hours'):
                    if not filters.get('itype'):
                        filters['days'] = str(DAYS_SHORT)
        Severity: Minor
        Found in cif/httpd/indicators.py - About 3 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function firehose has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def firehose(ws):
            """Firehose"""
        
            t = pull_token()
        
        
        Severity: Minor
        Found in cif/httpd/app.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function handle_message has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_message(self, m):
                err = None
                id, client_id, token, mtype, data = m
        
                try:
        Severity: Minor
        Found in cif/store/__init__.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function main has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def main():
            p = get_argument_parser()
            p = ArgumentParser(
                description=textwrap.dedent('''\
                 Env Variables:
        Severity: Minor
        Found in cif/store/__init__.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function post has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def post(self):
                """Create an Indicator"""
                if len(request.data) == 0:
                    return 'missing indicator', 422
        
        
        Severity: Minor
        Found in cif/httpd/indicators.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function get has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self):
                """List all indicators"""
                filters = self._filters_cleanup()
        
                logger.debug(filters)
        Severity: Minor
        Found in cif/httpd/indicators.py - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _filter_indicator has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def _filter_indicator(self, filters, s):
        
                for k, v in list(filters.items()):
                    if k not in VALID_FILTERS:
                        del filters[k]
        Severity: Minor
        Found in cif/store/sqlite/indicator.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _flush_create_queue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _flush_create_queue(self):
                for t in self.create_queue:
                    if len(self.create_queue[t]['messages']) == 0:
                        continue
        
        
        Severity: Minor
        Found in cif/store/__init__.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function _upsert_filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def _upsert_filter(self, s, d, tags):
                # setup query
                i = s.query(Indicator).options(lazyload('*')).filter_by(
                    provider=d['provider'],
                    itype=d['itype'],
        Severity: Minor
        Found in cif/store/sqlite/indicator.py - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function __init__ has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(self, **kwargs):
        
                self.uuid = kwargs.get('uuid')
                self.indicator = kwargs.get('indicator')
                self.group = kwargs.get('group', 'everyone')
        Severity: Minor
        Found in cif/store/sqlite/indicator.py - About 1 hr to fix

          Function handle_message_gatherer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_message_gatherer(self, s):
                  id, token, mtype, data = Msg().recv(s)
          
                  sock = self.store.s_write
                  if token == self.hunter_token:
          Severity: Minor
          Found in cif/router.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function _upsert_itype has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def _upsert_itype(self, s, i):
                  if i.itype == 'ipv4':
                      match = re.search('^(\S+)\/(\d+)$', i.indicator)  # TODO -- use ipaddress
                      if match:
                          ipv4 = Ipv4(ipv4=match.group(1), mask=match.group(2), indicator=i)
          Severity: Minor
          Found in cif/store/sqlite/indicator.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def process(self, data):
                  if isinstance(data, dict):
                      data = [data]
          
                  s = time()
          Severity: Minor
          Found in cif/gatherer/__init__.py - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Severity
          Category
          Status
          Source
          Language