def process_line()

in src/jndi_deobfuscate/jndi_deobfuscate.py [0:0]


def process_line(line: str, print_output: bool = True, print_debug: bool = True):
    """Given a single line, return any possible JNDI strings by running a number of deobfuscation methods."""
    if line:
        logger.debug(f"initial line is {line.strip()}")

    transform_method_names = [
        "_transform_url_decode",
        "_transform_replace_obfuscated_variable",
        "_transform_replace_upper_and_lower_methods",
        "_transform_replace_simple_lookups",
        "_transform_replace_default_values_from_unresolved_variables",
        "_transform_get_first_jndi_string",
        "_transform_return_string_that_passes_basic_jndi_validation",
    ]
    number_of_loops_ran = 0
    while number_of_loops_ran <= MAX_RECURSION_PER_STRING:
        number_of_loops_ran += 1

        if line is None:
            if print_debug:
                logger.debug(
                    f"Processing line is now empty; escaping this loop at count {number_of_loops_ran}"
                )
                break

        if print_debug:
            logger.debug(f"Processing line - loop number: {number_of_loops_ran}")
        line_at_beginning = line

        for transform in transform_method_names:
            has_changed, processed_data = _run_transform_return_output(
                method_name=transform,
                input_string=line,
                print_debug=print_debug,
            )
            if has_changed:
                line = processed_data["output_string"]
                logger.debug("Processing line - Line has changed; starting transforms over again")
                break
            if not processed_data["input_string"] or not processed_data["output_string"]:
                logger.debug(
                    "Processing line - at least one transform returned an empty set. returning None."
                )
                return None
        line_at_end = line
        if line_at_beginning == line_at_end:
            logger.debug(f"Processing line - recursion count for string is: {number_of_loops_ran}")
            if print_output:
                print(line)
            else:
                return line
            break

        if number_of_loops_ran == MAX_RECURSION_PER_STRING:
            logger.debug(f"Processing line - max recursion reached for string `{line}`")