ComplianceAsCode/content

View on GitHub

Showing 229 of 962 total issues

Function get_rule_dir_ovals has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

def get_rule_dir_ovals(dir_path, product=None):
    """
    Gets a list of OVALs contained in a rule directory. If product is
    None, returns all OVALs. If product is not None, returns applicable
    OVALs in order of priority:
Severity: Minor
Found in ssg/rules.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 parse_from_file_with_jinja has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

    def parse_from_file_with_jinja(self, env_yaml, cpe_platforms):
        self.local_env_yaml.update(env_yaml)
        result = super(BashRemediation, self).parse_from_file_with_jinja(
            self.local_env_yaml, cpe_platforms)

Severity: Minor
Found in ssg/build_remediations.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 add_profiles_from_dir has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

    def add_profiles_from_dir(self, dir_, env_yaml, product_cpes):
        for dir_item in sorted(os.listdir(dir_)):
            dir_item_path = os.path.join(dir_, dir_item)
            if not os.path.isfile(dir_item_path):
                continue
Severity: Minor
Found in ssg/build_yaml.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_implemented_stigs has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

def get_implemented_stigs(product, root_path, build_config_yaml_path,
                          reference_str, json_path, resolved_rules_dir,
                          build_root):
    platform_rules = get_platform_rules(product, json_path, resolved_rules_dir, build_root)

Severity: Minor
Found in utils/create_scap_delta_tailoring.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 _ensure_by_xccdf_referenced_oval_def_is_defined_in_oval_file has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

    def _ensure_by_xccdf_referenced_oval_def_is_defined_in_oval_file(self):
        # Ensure all OVAL checks referenced by XCCDF are implemented in OVAL file
        # Drop the reference from XCCDF to OVAL definition if:
        # * Particular OVAL definition isn't present in OVAL file,
        # * That OVAL definition doesn't constitute a remote OVAL
Severity: Minor
Found in ssg/build_renumber.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 _rule_matches_rule_spec has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

    def _rule_matches_rule_spec(self, rule_short_id):
        rule_id = OSCAP_RULE + rule_short_id
        if 'ALL' in self.rule_spec:
            return True
        else:
Severity: Minor
Found in tests/ssg_test_suite/rule.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_build_dir has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

def check_build_dir(build_dir):
    profiles_per_benchmark = defaultdict(list)
    for path in glob.glob(os.path.join(build_dir, "ssg-*-ds.xml")):
        gather_profiles_from_datastream(path, build_dir, profiles_per_benchmark)

Severity: Minor
Found in tests/stable_profile_ids.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 _add_cce has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

def _add_cce(directory, cce_pool, rules, product_yaml, args):
    product = product_yaml["product"]

    def is_relevant_rule(rule_path, rule, rule_lines):
        for r in rules:
Severity: Minor
Found in utils/fix_rules.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 main has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

def main():
    args = parse_args()

    json_file = open(args.json, 'r')
    known_rules = json.load(json_file)
Severity: Minor
Found in utils/mod_checks.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 main has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
Open

def main():
    args = parse_args()

    json_file = open(args.json, 'r')
    known_rules = json.load(json_file)
Severity: Minor
Found in utils/mod_fixes.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 process_remediation has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def process_remediation(
Severity: Major
Found in build-scripts/collect_remediations.py - About 50 mins to fix

    Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, env_yaml, resolved_rules_dir, templates_dir,
    Severity: Major
    Found in ssg/templates.py - About 50 mins to fix

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, old_content, new_content, rule_id, show_diffs, rule_diffs,
      Severity: Major
      Found in ssg/content_diff.py - About 50 mins to fix

        Function collect_remediations has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def collect_remediations(
        Severity: Major
        Found in build-scripts/collect_remediations.py - About 50 mins to fix

          Function get_implemented_stigs has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def get_implemented_stigs(product, root_path, build_config_yaml_path,
          Severity: Major
          Found in utils/create_scap_delta_tailoring.py - About 50 mins to fix

            Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, old_content, new_content, rule_id, show_diffs, rule_diffs,
            Severity: Major
            Found in ssg/content_diff.py - About 50 mins to fix

              Function main has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
              Open

              def main():
                  options, args = parse_args()
              
                  if options.centos:
                      mapping = ssg.constants.RHEL_CENTOS_CPE_MAPPING
              Severity: Minor
              Found in build-scripts/enable_derivatives.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 j < i:
                                          i -= 1
                                      continue
              Severity: Major
              Found in ssg/ext/boolean/boolean.py - About 45 mins to fix

                Function remove_cce_reference has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                Open

                def remove_cce_reference(tree_root, namespace):
                    """
                    Remove CCE identifiers from OVAL checks in XML tree
                    """
                    for definition in tree_root.findall(".//{%s}definition" % (namespace)):
                Severity: Minor
                Found in ssg/build_derivatives.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 is_applicable_for_product has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
                Open

                def is_applicable_for_product(platform, product):
                    """Based on the platform dict specifier of the remediation script to
                    determine if this remediation script is applicable for this product.
                    Return 'True' if so, 'False' otherwise"""
                
                
                Severity: Minor
                Found in ssg/utils.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

                Severity
                Category
                Status
                Source
                Language