ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

Avoid too many return statements within this function.
Open

        return proposed
Severity: Major
Found in utils/compare_results.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return False
    Severity: Major
    Found in tests/ssg_test_suite/rule.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return self._final_scan_went_ok(runner, rule_id)
      Severity: Major
      Found in tests/ssg_test_suite/rule.py - About 30 mins to fix

        Function process_input_dict has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def process_input_dict(cls, input_contents, env_yaml, product_cpes=None):
                data = super(Group, cls).process_input_dict(input_contents, env_yaml, product_cpes)
                if data["rules"]:
                    rule_ids = data["rules"]
                    data["rules"] = {rid: None for rid in rule_ids}
        Severity: Minor
        Found in ssg/build_yaml.py - About 25 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 pretty has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def pretty(self, indent=0, debug=False):
                """
                Return a pretty formatted representation of self as an indented tree.
        
                If debug is True, also prints debug information for each expression arg.
        Severity: Minor
        Found in ssg/ext/boolean/boolean.py - About 25 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 main has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def main():
            args = parse_args()
        
            input_path, input_basename, path_base, output_dir = \
                ssg.build_guides.get_path_args(args)
        Severity: Minor
        Found in build-scripts/build_all_guides.py - About 25 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 added_variables has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def added_variables(self):
                variables = set()
                for task in self.tasks_data:
                    if "tags" not in task:
                        next
        Severity: Minor
        Found in utils/ansible_playbook_to_role.py - About 25 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 product_names_remediation has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def product_names_remediation(rule_obj, r_type):
            """
            For a rule_obj, check the scope of the platforms versus the product name
            of the remediations of type r_type.
            """
        Severity: Minor
        Found in ssg/rule_dir_stats.py - About 25 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_data_from_snippet has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def get_data_from_snippet(self, snippet_yaml, variables, refinements):
                """
                Extracts and resolves tasks and variables from Ansible snippet.
                """
                xccdf_var_pattern = re.compile(r"\(xccdf-var\s+(\S+)\)")
        Severity: Minor
        Found in ssg/playbook_builder.py - About 25 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 resolve has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def resolve(self, all_profiles, rules_by_id, controls_manager=None):
                if self.resolved:
                    return
        
                if controls_manager:
        Severity: Minor
        Found in ssg/entities/profile.py - About 25 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 main has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def main():
            args = parse_args()
            product_yaml = os.path.join(args.ssg_root, "products", args.product, "product.yml")
            if args.input_dir:
                input_dir = args.input_dir
        Severity: Minor
        Found in build-scripts/build_rule_playbooks.py - About 25 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 file has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def file(self, filepath):
                if filepath == 'tasks/main.yml':
                    return self.tasks_local_content
                elif filepath == 'vars/main.yml':
                    if len(self.vars_data) < 1:
        Severity: Minor
        Found in utils/ansible_playbook_to_role.py - About 25 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_ovalfiles has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def get_ovalfiles(checks):
            global exit_value
            # Iterate over all checks, grab the OVAL files referenced within
            ovalfiles = set()
            for check in checks:
        Severity: Minor
        Found in build-scripts/verify_references.py - About 25 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 reorder_according_to_ordering has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def reorder_according_to_ordering(unordered, ordering, regex=None):
            ordered = []
            if regex is None:
                regex = "|".join(["({0})".format(item) for item in ordering])
            regex = re.compile(regex)
        Severity: Minor
        Found in ssg/build_yaml.py - About 25 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 filter_rule_ids has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def filter_rule_ids(all_keys, queries):
            """
            From a set of queries (a comma separated list of queries, where a query is either a
            rule id or a substring thereof), return the set of matching keys from all_keys. When
            queries is the literal string "all", return all of the keys.
        Severity: Minor
        Found in ssg/rule_dir_stats.py - About 25 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 product_names_oval has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def product_names_oval(rule_obj):
            """
            For a rule_obj, check the scope of the platforms versus the product name
            of the OVAL objects.
            """
        Severity: Minor
        Found in ssg/rule_dir_stats.py - About 25 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 join_text_elements has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def join_text_elements(self):
                """
                This function collects the text of almost all subelements.
                Similar to what itertext() would do, except that this function skips some elements that
                are not relevant for comparison.
        Severity: Minor
        Found in ssg/xml.py - About 25 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 make_items_product_specific has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def make_items_product_specific(items_dict, product_suffix, allow_overwrites=False):
            """
            Function will normalize dictionary values for a specific product, by either
            removing product qualifier from the key (reference@product: value -> reference: value),
            or by dropping irrelevant entries (reference@other_product: value).
        Severity: Minor
        Found in ssg/entities/common.py - About 25 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 __init__ has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

            def __init__(self, rule, cis_ns):
                self.id = rule.get("id")
                self.oval = rule.find('./{%s}check[@system="%s"]' % (XCCDF12_NS, oval_ns))
                self.sce = rule.find('./{%s}check[@system="%s"]' % (XCCDF12_NS, sce_ns))
                self.bash_fix = rule.find('./{%s}fix[@system="%s"]' % (XCCDF12_NS, bash_rem_system))
        Severity: Minor
        Found in ssg/build_profile.py - About 25 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 set_variables_for_test_scenarios has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
        Open

        def set_variables_for_test_scenarios(data):
            if data["datatype"] == "int":
                if not data.get("value"):
                    # this implies XCCDF variable is used
                    data["wrong_value"] = 321
        Severity: Minor
        Found in shared/templates/sshd_lineinfile/template.py - About 25 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

        Severity
        Category
        Status
        Source
        Language