dnstats/dnstatsio

View on GitHub
dnstats/charts/__init__.py

Summary

Maintainability
A
1 hr
Test Coverage

Possible SQL injection vector through string-based query construction.
Open

    dmarc_sub_policy_adoption = 'select count(*) from site_runs sr ' \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    caa_reporting = "select count(*) from site_runs " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    dmarc_subpolicy_query = "select count(*), dp.display_name, dp.color from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    spf_grade_distribution = "select spf_grade, count(*) from site_runs where run_id={} group by spf_grade order by spf_grade".format(
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

By default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities.
Open

    env = Environment(loader=file_loader)
Severity: Major
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    mx_query = 'select count(*) from site_runs ' \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    email_providers = "select count(*), display_name from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    dns_providers = "select count(*), display_name from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    caa_grade_distribution = "select caa_grade, count(*) from site_runs where run_id={} group by caa_grade order by caa_grade".format(
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    securitytxt_adoption_query = "select count(*) from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

                """.format(run_id)
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    dmarc_policy_query = "select count(*), dp.display_name, dp.color from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    dmarc_grade_distribution = "select dmarc_grade, count(*) from site_runs where run_id={}  group by dmarc_grade order by dmarc_grade".format(
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    caa_adoption_query = 'select count(*) from site_runs ' \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    dnssec_adoption = "select count(*) from site_runs " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

By default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities.
Open

    env = Environment(loader=file_loader)
Severity: Major
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    spf_adoption_query = "select count(*) from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

                """.format(run_id)
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

     """.format(run_id)
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    caa_has_wilcard = "select count(*) from site_runs where run_id = {} and caa_wildcard_count > 0".format(run_id)
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    dmarc_adoption_query = "select count(*) from site_runs where run_id = {} and has_dmarc is true".format(run_id)
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Possible SQL injection vector through string-based query construction.
Open

    spf_reports_query = "select count(*), sp.display_name, sp.color from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py by bandit

Function create_reports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def create_reports(run_id: int):
    spf_adoption_query = "select count(*) from site_runs sr " \
                         "where sr.run_id = {} and sr.has_spf is true".format(run_id)

    securitytxt_adoption_query = "select count(*) from site_runs sr " \
Severity: Minor
Found in dnstats/charts/__init__.py - About 1 hr to fix

    Function _run_report has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _run_report(query: str, report: str, adoption: bool, run_id: int, random_colors=False):
    Severity: Minor
    Found in dnstats/charts/__init__.py - About 35 mins to fix

      Continuation line over-indented for visual indent
      Open

                               "where sr.run_id = {} and sr.has_securitytxt is true".format(run_id)
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Continuation lines indentation.

      Continuation lines should align wrapped elements either vertically
      using Python's implicit line joining inside parentheses, brackets
      and braces, or using a hanging indent.
      
      When using a hanging indent these considerations should be applied:
      - there should be no arguments on the first line, and
      - further indentation should be used to clearly distinguish itself
        as a continuation line.
      
      Okay: a = (\n)
      E123: a = (\n    )
      
      Okay: a = (\n    42)
      E121: a = (\n   42)
      E122: a = (\n42)
      E123: a = (\n    42\n    )
      E124: a = (24,\n     42\n)
      E125: if (\n    b):\n    pass
      E126: a = (\n        42)
      E127: a = (24,\n      42)
      E128: a = (24,\n    42)
      E129: if (a or\n    b):\n    pass
      E131: a = (\n    42\n 24)

      Indentation is not a multiple of 4
      Open

         else:
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Line too long (134 > 120 characters)
      Open

          spf_grade_distribution = "select spf_grade, count(*) from site_runs where run_id={} group by spf_grade order by spf_grade".format(
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Indentation is not a multiple of 4
      Open

            return int(str(num)[0:1])
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Indentation is not a multiple of 4
      Open

         if not num or num < 10:
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Indentation is not a multiple of 4
      Open

             return 0
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Indentation is not a multiple of 4
      Open

            return 0
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Too many blank lines (2)
      Open

          spf_reports_query = "select count(*), sp.display_name, sp.color from site_runs sr " \
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Separate top-level function and class definitions with two blank lines.

      Method definitions inside a class are separated by a single blank
      line.
      
      Extra blank lines may be used (sparingly) to separate groups of
      related functions.  Blank lines may be omitted between a bunch of
      related one-liners (e.g. a set of dummy implementations).
      
      Use blank lines in functions, sparingly, to indicate logical
      sections.
      
      Okay: def a():\n    pass\n\n\ndef b():\n    pass
      Okay: def a():\n    pass\n\n\nasync def b():\n    pass
      Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
      Okay: default = 1\nfoo = 1
      Okay: classify = 1\nfoo = 1
      
      E301: class Foo:\n    b = 0\n    def bar():\n        pass
      E302: def a():\n    pass\n\ndef b(n):\n    pass
      E302: def a():\n    pass\n\nasync def b(n):\n    pass
      E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
      E303: def a():\n\n\n\n    pass
      E304: @decorator\n\ndef a():\n    pass
      E305: def a():\n    pass\na()
      E306: def a():\n    def b():\n        pass\n    def c():\n        pass

      Indentation is not a multiple of 4
      Open

         if num == 100:
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Expected 2 blank lines, found 1
      Open

      def _create_html(category_data: [()], histograms: [()], run_id: int, js_filename: str):
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Separate top-level function and class definitions with two blank lines.

      Method definitions inside a class are separated by a single blank
      line.
      
      Extra blank lines may be used (sparingly) to separate groups of
      related functions.  Blank lines may be omitted between a bunch of
      related one-liners (e.g. a set of dummy implementations).
      
      Use blank lines in functions, sparingly, to indicate logical
      sections.
      
      Okay: def a():\n    pass\n\n\ndef b():\n    pass
      Okay: def a():\n    pass\n\n\nasync def b():\n    pass
      Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
      Okay: default = 1\nfoo = 1
      Okay: classify = 1\nfoo = 1
      
      E301: class Foo:\n    b = 0\n    def bar():\n        pass
      E302: def a():\n    pass\n\ndef b(n):\n    pass
      E302: def a():\n    pass\n\nasync def b(n):\n    pass
      E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
      E303: def a():\n\n\n\n    pass
      E304: @decorator\n\ndef a():\n    pass
      E305: def a():\n    pass\na()
      E306: def a():\n    def b():\n        pass\n    def c():\n        pass

      Line too long (134 > 120 characters)
      Open

          caa_grade_distribution = "select caa_grade, count(*) from site_runs where run_id={} group by caa_grade order by caa_grade".format(
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (143 > 120 characters)
      Open

          dmarc_grade_distribution = "select dmarc_grade, count(*) from site_runs where run_id={}  group by dmarc_grade order by dmarc_grade".format(
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Too many blank lines (2)
      Open

          category_data = [_run_report(spf_adoption_query, 'SPF Adoption', True, run_id),
      Severity: Minor
      Found in dnstats/charts/__init__.py by pep8

      Separate top-level function and class definitions with two blank lines.

      Method definitions inside a class are separated by a single blank
      line.
      
      Extra blank lines may be used (sparingly) to separate groups of
      related functions.  Blank lines may be omitted between a bunch of
      related one-liners (e.g. a set of dummy implementations).
      
      Use blank lines in functions, sparingly, to indicate logical
      sections.
      
      Okay: def a():\n    pass\n\n\ndef b():\n    pass
      Okay: def a():\n    pass\n\n\nasync def b():\n    pass
      Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
      Okay: default = 1\nfoo = 1
      Okay: classify = 1\nfoo = 1
      
      E301: class Foo:\n    b = 0\n    def bar():\n        pass
      E302: def a():\n    pass\n\ndef b(n):\n    pass
      E302: def a():\n    pass\n\nasync def b(n):\n    pass
      E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
      E303: def a():\n\n\n\n    pass
      E304: @decorator\n\ndef a():\n    pass
      E305: def a():\n    pass\na()
      E306: def a():\n    def b():\n        pass\n    def c():\n        pass

      There are no issues that match your filters.

      Category
      Status