ComplianceAsCode/content

View on GitHub

Showing 238 of 1,093 total issues

Function compare_checks has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
Open

def compare_checks(self, old_rule, new_rule, system, identifier):
check_system_uri = self.check_system_map[system]["uri"]
old_check = old_rule.get_check_element(check_system_uri)
new_check = new_rule.get_check_element(check_system_uri)
if (old_check is None and new_check is not None):
Severity: Minor
Found in ssg/content_diff.py - About 1 hr to fix

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

def process_input_dict(cls, input_contents, env_yaml, product_cpes=None):
"""
Take the contents of the definition as a dictionary, and
add defaults or raise errors if a required member is not present.
 
 
Severity: Minor
Found in ssg/entities/common.py - About 1 hr to fix

Function process_results has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
Open

def process_results(result_path):
ret_val = True
tree = ET.parse(result_path)
root = tree.getroot()
results = root.find("./{%s}results" % scapval_results_ns)
Severity: Minor
Found in tests/run_scapval.py - About 1 hr to fix

Function print_result_differences has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
Open

def print_result_differences(json_results):
results = [json.load(open(fname, "r")) for fname in json_results]
rules = [common.RuleResult(r) for r in sum(results, [])]
aggregated_results = aggregate_results_by_scenarios(rules)
 
 
Severity: Minor
Found in tests/analyze_results.py - About 1 hr to fix

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

def main():
overall_result = True
args = parse_args()
if args.datastream is not None:
build_dir = os.path.dirname(args.datastream)
Severity: Minor
Found in tests/run_scapval.py - About 1 hr to fix

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

def __init__(
Severity: Major
Found in tests/ssg_test_suite/oscap.py - About 1 hr to fix

    Function parse_stats_subcommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def parse_stats_subcommand(subparsers):
    parser_stats = subparsers.add_parser(
    "stats",
    description=(
    "Obtains and displays XCCDF profile statistics. Namely number of rules in the profile,"
    Severity: Minor
    Found in build-scripts/profile_tool.py - About 1 hr to fix

      Function from_control_dict has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def from_control_dict(cls, control_dict, env_yaml=None, default_level=["default"]):
      """
      Create a control instance from a dictionary of control attributes.
       
      Args:
      Severity: Minor
      Found in ssg/controls.py - About 1 hr to fix

        Function main has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def main():
        args = _parse_args()
        base_path = args.base
        target_path = args.target
        target_sheet = get_worksheet(base_path)
        Severity: Minor
        Found in utils/srg_diff.py - About 1 hr to fix

          Function _walk_rule has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def _walk_rule(args, rule_obj, oval_func, remediation_func, verbose_output):
          """
          Walks a single rule and updates verbose_output if visited.
           
          Internal function for walk_rules and walk_rules_parallel.
          Severity: Minor
          Found in ssg/rule_dir_stats.py - About 1 hr to fix

          Function build has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def build(self, profile_id=None, rule_id=None):
          """
          Creates Playbooks for a specified profile.
          If profile is not given, creates playbooks for all profiles
          in the product.
          Severity: Minor
          Found in ssg/playbook_builder.py - About 1 hr to fix

          Function __lt__ has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def __lt__(self, other):
          comparator = Expression.__lt__(self, other)
          if comparator is not NotImplemented:
          return comparator
           
           
          Severity: Minor
          Found in ssg/ext/boolean/boolean.py - About 1 hr to fix

          Function validate_references has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def validate_references(self, yaml_file):
          """
          Validates the references section of a YAML file.
           
          Args:
          Severity: Minor
          Found in ssg/build_yaml.py - About 1 hr to fix

          Function load_entities has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def load_entities(self, rules_by_id, values_by_id, groups_by_id):
          """
          Load entities into the current object's rules, values, and groups attributes.
           
          This method updates the current object's `rules`, `values`, and `groups` attributes with
          Severity: Minor
          Found in ssg/build_yaml.py - About 1 hr to fix

          Function validate_playbook has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def validate_playbook(playbook, args):
          assert "name" in playbook, "playbook doesn't have a name"
          assert "hosts" in playbook, "playbook doesn't have the hosts entry"
          assert playbook["hosts"] == "@@HOSTS@@", "playbook's hosts is not set to @@HOSTS@@"
          assert "become" in playbook, "playbook doesn't have a become key"
          Severity: Minor
          Found in tests/assert_ansible_schema.py - About 1 hr to fix

          Function set_variables_for_test_scenarios has a Cognitive Complexity of 12 (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 1 hr to fix

          Function get_viable_profiles has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def get_viable_profiles(selected_profiles, datastream, benchmark, script=None):
          """Read data stream, and return set intersection of profiles of given
          benchmark and those provided in `selected_profiles` parameter.
          """
           
           
          Severity: Minor
          Found in tests/ssg_test_suite/rule.py - About 1 hr to fix

          Function machine_platform_missing_in_rules has a Cognitive Complexity of 12 (exceeds 7 allowed). Consider refactoring.
          Open

          def machine_platform_missing_in_rules(ds_path, short_ids_to_check):
          machine_platform_missing = False
          tree = ET.parse(ds_path)
          root = tree.getroot()
          only_rules_query = ".//{%s}Rule" % ssg.constants.XCCDF12_NS
          Severity: Minor
          Found in tests/test_machine_only_rules.py - About 1 hr to fix

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

          def move_patches_up_to_date_to_source_data_stream_component(datastreamtree):
          ds_checklists = datastreamtree.find(
          ".//{%s}checklists" % datastream_namespace)
          checklists_component_ref = ds_checklists.find(
          "{%s}component-ref" % datastream_namespace)
          Severity: Minor
          Found in build-scripts/compose_ds.py - About 1 hr to fix

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

            def __init__(self, TRUE_class=None, FALSE_class=None, Symbol_class=None, Function_class=None,
            Severity: Major
            Found in ssg/ext/boolean/boolean.py - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language