csirtgadgets/csirtg-indicator-py

View on GitHub

Showing 54 of 54 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                ts = '{}-{}-{}T{}:{}:{}Z'.format(match.group(1), match.group(2), match.group(3), match.group(4),
                                                 match.group(5), match.group(6))
Severity: Major
Found in csirtg_indicator/utils/ztime.py and 1 other location - About 2 hrs to fix
csirtg_indicator/utils/ztime.py on lines 58..59

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 52.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                ts = '{}-{}-{}T{}:{}:{}Z'.format(match.group(1), match.group(2), match.group(3), match.group(4),
                                                 match.group(5), match.group(6))
Severity: Major
Found in csirtg_indicator/utils/ztime.py and 1 other location - About 2 hrs to fix
csirtg_indicator/utils/ztime.py on lines 69..70

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 52.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def format_keys(self):
        d = self.__dict__()
        for k in d:
            if PYVERSION == 2:
                if not isinstance(d[k], unicode):
Severity: Minor
Found in csirtg_indicator/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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    for t in text:
        output.write(t)
        yield str(output.getvalue())

        if isinstance(output, StringIO):
Severity: Major
Found in csirtg_indicator/format/zbindrpzip.py and 1 other location - About 1 hr to fix
csirtg_indicator/format/zbindrpz.py on lines 31..36

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    for t in text:
        output.write(t)
        yield str(output.getvalue())

        if isinstance(output, StringIO):
Severity: Major
Found in csirtg_indicator/format/zbindrpz.py and 1 other location - About 1 hr to fix
csirtg_indicator/format/zbindrpzip.py on lines 61..66

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

        text = [
            ';;; generated by: {} at {}'.format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
            '; RPZ DATA!',
            '$TTL    1',
            '@       IN      SOA     localhost. root.localhost. (',
Severity: Major
Found in csirtg_indicator/format/zbindrpz.py and 3 other locations - About 1 hr to fix
csirtg_indicator/format/zbindrpz.py on lines 17..28
csirtg_indicator/format/zbindrpzip.py on lines 47..58
csirtg_indicator/format/zbindrpzip.py on lines 90..101

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

        text = [
            ';;; generated by: {} at {}'.format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
            '; RPZ-IP DATA!',
            '$TTL    1',
            '@       IN      SOA     localhost. root.localhost. (',
Severity: Major
Found in csirtg_indicator/format/zbindrpzip.py and 3 other locations - About 1 hr to fix
csirtg_indicator/format/zbindrpz.py on lines 17..28
csirtg_indicator/format/zbindrpz.py on lines 61..72
csirtg_indicator/format/zbindrpzip.py on lines 47..58

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    text = [
        ";;; generated by: {} at {}".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
        ';RPZ-IP DATA!',
        '$TTL    1',
        '@       IN      SOA     localhost. root.localhost. (',
Severity: Major
Found in csirtg_indicator/format/zbindrpzip.py and 3 other locations - About 1 hr to fix
csirtg_indicator/format/zbindrpz.py on lines 17..28
csirtg_indicator/format/zbindrpz.py on lines 61..72
csirtg_indicator/format/zbindrpzip.py on lines 90..101

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

    text = [
        ";;; generated by: {} at {}".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
        ';RPZ DATA!',
        '$TTL    1',
        '@       IN      SOA     localhost. root.localhost. (',
Severity: Major
Found in csirtg_indicator/format/zbindrpz.py and 3 other locations - About 1 hr to fix
csirtg_indicator/format/zbindrpz.py on lines 61..72
csirtg_indicator/format/zbindrpzip.py on lines 47..58
csirtg_indicator/format/zbindrpzip.py on lines 90..101

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

def get_lines(data, filename=OUTPUT_PATH):
    output = StringIO()
    text = [
        ";;; generated by: {} at {}".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
        ';RPZ DATA!',
Severity: Minor
Found in csirtg_indicator/format/zbindrpz.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 get_lines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_lines(data, filename=OUTPUT_PATH):
    output = StringIO()
    text = [
        ";;; generated by: {} at {}".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
        ';RPZ-IP DATA!',
Severity: Minor
Found in csirtg_indicator/format/zbindrpzip.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 normalize_indicator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def normalize_indicator(i, itype=None, lowercase=False, lowercase_explicit=False):
    if itype == 'fqdn':
        i = i.rstrip('.')
        # only don't lowercase if lowercase=False and lowercase_explicit=True (set by user)
        if lowercase or not lowercase_explicit:
Severity: Minor
Found in csirtg_indicator/utils/__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 _indicator_row has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _indicator_row(i, cols):
    if isinstance(i, Indicator):
        i = i.__dict__()

    r = dict()
Severity: Minor
Found in csirtg_indicator/format/zjson.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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def __init__(self, *args, **kwargs):
        super(BindRPZIP, self).__init__(*args, **kwargs)

        self.output = kwargs.get('output', OUTPUT_PATH)
Severity: Major
Found in csirtg_indicator/format/zbindrpzip.py and 2 other locations - About 50 mins to fix
csirtg_indicator/format/zbind.py on lines 34..37
csirtg_indicator/format/zbindrpz.py on lines 55..58

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 36.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def __init__(self, *args, **kwargs):
        super(Bind, self).__init__(*args, **kwargs)

        self.output = kwargs.get('output', OUTPUT_PATH)
Severity: Major
Found in csirtg_indicator/format/zbind.py and 2 other locations - About 50 mins to fix
csirtg_indicator/format/zbindrpz.py on lines 55..58
csirtg_indicator/format/zbindrpzip.py on lines 84..87

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 36.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    def __init__(self, *args, **kwargs):
        super(BindRPZ, self).__init__(*args, **kwargs)

        self.output = kwargs.get('output', OUTPUT_PATH)
Severity: Major
Found in csirtg_indicator/format/zbindrpz.py and 2 other locations - About 50 mins to fix
csirtg_indicator/format/zbind.py on lines 34..37
csirtg_indicator/format/zbindrpzip.py on lines 84..87

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 36.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def indicator(self, i):
        if not i:
            self._indicator = None
            return

Severity: Minor
Found in csirtg_indicator/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

Avoid deeply nested control flow statements.
Open

                        if ',' in x:
                            tmp_list.extend([y.strip() for y in x.split(',') if y])
                        else:
                            tmp_list.append(x.strip())
                    kwargs[k] = tmp_list
Severity: Major
Found in csirtg_indicator/indicator.py - About 45 mins to fix

    Function get_lines has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_lines(data, filename=OUTPUT_PATH):
        output = StringIO()
        output.write("// generated by: {} at {}\n".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')))
    
        for i in data:
    Severity: Minor
    Found in csirtg_indicator/format/zbind.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 t
    Severity: Major
    Found in csirtg_indicator/utils/ztime.py - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language