csirtgadgets/verbose-robot

View on GitHub

Showing 56 of 172 total issues

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

Function send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def send(self, data):
        if len(self.hooks) == 0:
            logger.info('no webhooks to send to... '
                        'is your webhooks.yml missing?')
            return
Severity: Minor
Found in cif/webhooks.py - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('q')
        args = parser.parse_args()

Severity: Minor
Found in cif/httpd/predict.py - About 55 mins 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 _check_create_queue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _check_create_queue(self, last_flushed):
        if len(self.create_queue) == 0:
            return time.time()

        if ((time.time() - last_flushed) <= CREATE_QUEUE_FLUSH) \
Severity: Minor
Found in cif/store/__init__.py - About 55 mins 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 search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def search(self, data):
        s = self.handle().query(Token)

        for k in ['token', 'username', 'admin', 'write', 'read']:
            if data.get(k):
Severity: Minor
Found in cif/store/sqlite/token.py - About 55 mins 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

Avoid deeply nested control flow statements.
Open

                    with open(args.config_path, 'w') as f:
                        f.write(yaml.dump(data, default_flow_style=False))

Severity: Major
Found in cif/store/__init__.py - About 45 mins to fix

    Function _pull has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _pull(self, filters):
            try:
                with Client(ROUTER_ADDR, session['token']) as client:
                    r = client.indicators_search(filters)
    
    
    Severity: Minor
    Found in cif/httpd/indicators.py - About 45 mins 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 has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _upsert(self, s, n, d, token, cached_added, batch):
    Severity: Minor
    Found in cif/store/sqlite/indicator.py - About 45 mins to fix

      Function _check_indicator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _check_indicator(i, t):
          if not i.get('group'):
              i['group'] = t['groups'][0]
      
          if not i.get('provider'):
      Severity: Minor
      Found in cif/store/helpers.py - About 45 mins 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_indicators_create has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def handle_indicators_create(self, token, data, id=None, client_id=None,
      Severity: Minor
      Found in cif/store/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            with open(args.config_path, 'w') as f:
                                f.write(yaml.dump(data, default_flow_style=False))
        
        
        Severity: Major
        Found in cif/store/__init__.py - About 45 mins to fix

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

          def main():
              from gevent import pywsgi, pool
              from geventwebsocket.handler import WebSocketHandler
          
              p = get_argument_parser()
          Severity: Minor
          Found in cif/httpd/app.py - About 45 mins 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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def upsert(self, token, data, **kwargs):
                  if isinstance(data, dict):
                      data = [data]
          
                  s = self.handle()
          Severity: Minor
          Found in cif/store/sqlite/indicator.py - About 45 mins 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 _search_bulk has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def _search_bulk(filters):
              try:
                  with Client(ROUTER_ADDR, session['token']) as client:
                      r = client.indicators_search(filters)
          
          
          Severity: Minor
          Found in cif/httpd/app.py - About 45 mins 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 before_request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def before_request():
              """
              Grab the API token from headers
          
              :return: 401 if no token is present
          Severity: Minor
          Found in cif/httpd/app.py - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def process(i, max=MAX_QUERY_RESULTS):
              if not _enabled(i):
                  return
          
              try:
          Severity: Minor
          Found in cif/hunter/farsight.py - About 35 mins 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

          Avoid too many return statements within this function.
          Open

                  return myfeed, 200
          Severity: Major
          Found in cif/httpd/indicators.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return {'data': r, 'message': 'success'}, 201
            Severity: Major
            Found in cif/httpd/indicators.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return s
              Severity: Major
              Found in cif/store/sqlite/indicator.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return s
                Severity: Major
                Found in cif/store/sqlite/indicator.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language