How to use the ffpuppet.helpers.SanitizerConfig function in ffpuppet

To help you get started, we’ve selected a few ffpuppet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MozillaSecurity / ffpuppet / ffpuppet / test_helpers.py View on Github external
def parse(opt_str):
        opts = dict()
        for entry in SanitizerConfig.re_delim.split(opt_str):
            key, value = entry.split("=")
            opts[key] = value
        return opts
    is_windows = sys.platform.startswith("win")
github MozillaSecurity / ffpuppet / ffpuppet / helpers.py View on Github external
def configure_sanitizers(env, target_dir, log_path):
    # https://github.com/google/sanitizers/wiki/SanitizerCommonFlags
    common_flags = (
        ("abort_on_error", "false"),
        ("allocator_may_return_null", "true"),
        ("disable_coredump", "true"),
        ("handle_abort", "true"),  # if true, abort_on_error=false to prevent hangs
        ("handle_sigbus", "true"),  # set to be safe
        ("handle_sigfpe", "true"),  # set to be safe
        ("handle_sigill", "true"),  # set to be safe
        ("symbolize", "true"))

    # setup Address Sanitizer options if not set manually
    # https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
    asan_config = SanitizerConfig()
    asan_config.load_options(env, "ASAN_OPTIONS")
    for flag in common_flags:
        asan_config.add(*flag)
    #asan_config.add("alloc_dealloc_mismatch", "false")  # different defaults per OS
    asan_config.add("check_initialization_order", "true")
    #asan_config.add("detect_stack_use_after_return", "true")  # https://bugzil.la/1057551
    #asan_config.add("detect_stack_use_after_scope", "true")
    asan_config.add("detect_invalid_pointer_pairs", "1")
    asan_config.add("detect_leaks", "false")
    # log_path is required for FFPuppet logging to function properly
    if "log_path" in asan_config:
        log.warning("ASAN_OPTIONS=log_path is used internally and cannot be set externally")
    asan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    # attempt to save some memory during deep stack allocations
    asan_config.add("malloc_context_size", "20")
    asan_config.add("sleep_before_dying", "0")
github MozillaSecurity / ffpuppet / ffpuppet / helpers.py View on Github external
lsan_config.load_options(env, "LSAN_OPTIONS")
    lsan_config.add("max_leaks", "1")
    lsan_config.add("print_suppressions", "false")
    env["LSAN_OPTIONS"] = lsan_config.options

    # setup Thread Sanitizer options if not set manually
    tsan_config = SanitizerConfig()
    tsan_config.load_options(env, "TSAN_OPTIONS")
    tsan_config.add("halt_on_error", "1")
    if "log_path" in tsan_config:
        log.warning("TSAN_OPTIONS=log_path is used internally and cannot be set externally")
    tsan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    env["TSAN_OPTIONS"] = tsan_config.options

    # setup Undefined Behavior Sanitizer options if not set manually
    ubsan_config = SanitizerConfig()
    ubsan_config.load_options(env, "UBSAN_OPTIONS")
    for flag in common_flags:
        ubsan_config.add(*flag)
    if "log_path" in ubsan_config:
        log.warning("UBSAN_OPTIONS=log_path is used internally and cannot be set externally")
    ubsan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    ubsan_config.add("print_stacktrace", "1")
    env["UBSAN_OPTIONS"] = ubsan_config.options

    if "ASAN_SYMBOLIZER_PATH" not in env:
        # ASAN_SYMBOLIZER_PATH only needs to be set on platforms other than Windows
        if not platform.system().lower().startswith("windows"):
            symbolizer_bin = os.path.join(target_dir, "llvm-symbolizer")
            if os.path.isfile(symbolizer_bin):
                env["ASAN_SYMBOLIZER_PATH"] = symbolizer_bin
        elif not os.path.join(target_dir, "llvm-symbolizer.exe"):
github MozillaSecurity / ffpuppet / ffpuppet / helpers.py View on Github external
asan_config.add("malloc_context_size", "20")
    asan_config.add("sleep_before_dying", "0")
    asan_config.add("strict_init_order", "true")
    asan_config.add("strict_string_checks", "true")  # breaks old builds (esr52)
    env["ASAN_OPTIONS"] = asan_config.options

    # setup Leak Sanitizer options if not set manually
    # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
    lsan_config = SanitizerConfig()
    lsan_config.load_options(env, "LSAN_OPTIONS")
    lsan_config.add("max_leaks", "1")
    lsan_config.add("print_suppressions", "false")
    env["LSAN_OPTIONS"] = lsan_config.options

    # setup Thread Sanitizer options if not set manually
    tsan_config = SanitizerConfig()
    tsan_config.load_options(env, "TSAN_OPTIONS")
    tsan_config.add("halt_on_error", "1")
    if "log_path" in tsan_config:
        log.warning("TSAN_OPTIONS=log_path is used internally and cannot be set externally")
    tsan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    env["TSAN_OPTIONS"] = tsan_config.options

    # setup Undefined Behavior Sanitizer options if not set manually
    ubsan_config = SanitizerConfig()
    ubsan_config.load_options(env, "UBSAN_OPTIONS")
    for flag in common_flags:
        ubsan_config.add(*flag)
    if "log_path" in ubsan_config:
        log.warning("UBSAN_OPTIONS=log_path is used internally and cannot be set externally")
    ubsan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    ubsan_config.add("print_stacktrace", "1")
github MozillaSecurity / ffpuppet / ffpuppet / helpers.py View on Github external
asan_config.add("detect_invalid_pointer_pairs", "1")
    asan_config.add("detect_leaks", "false")
    # log_path is required for FFPuppet logging to function properly
    if "log_path" in asan_config:
        log.warning("ASAN_OPTIONS=log_path is used internally and cannot be set externally")
    asan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    # attempt to save some memory during deep stack allocations
    asan_config.add("malloc_context_size", "20")
    asan_config.add("sleep_before_dying", "0")
    asan_config.add("strict_init_order", "true")
    asan_config.add("strict_string_checks", "true")  # breaks old builds (esr52)
    env["ASAN_OPTIONS"] = asan_config.options

    # setup Leak Sanitizer options if not set manually
    # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer
    lsan_config = SanitizerConfig()
    lsan_config.load_options(env, "LSAN_OPTIONS")
    lsan_config.add("max_leaks", "1")
    lsan_config.add("print_suppressions", "false")
    env["LSAN_OPTIONS"] = lsan_config.options

    # setup Thread Sanitizer options if not set manually
    tsan_config = SanitizerConfig()
    tsan_config.load_options(env, "TSAN_OPTIONS")
    tsan_config.add("halt_on_error", "1")
    if "log_path" in tsan_config:
        log.warning("TSAN_OPTIONS=log_path is used internally and cannot be set externally")
    tsan_config.add("log_path", "'%s'" % log_path, overwrite=True)
    env["TSAN_OPTIONS"] = tsan_config.options

    # setup Undefined Behavior Sanitizer options if not set manually
    ubsan_config = SanitizerConfig()