From 5448a95ce799c7b5dbcf576b6d499a074eccbfc2 Mon Sep 17 00:00:00 2001 From: Martino Luca Date: Tue, 14 Mar 2017 09:54:27 -0700 Subject: [PATCH] [Infer][Localise] Group all issue types in one place, and provide their human-readable representation Reviewed By: jberdine Differential Revision: D4666961 fbshipit-source-id: 3ae487a --- infer/src/IR/Errlog.ml | 4 +- infer/src/IR/Exceptions.ml | 16 +- infer/src/IR/Localise.ml | 165 ++++++++++++------ infer/src/IR/Localise.mli | 54 ++++-- infer/src/backend/DifferentialFilters.ml | 2 +- infer/src/backend/InferPrint.re | 11 +- infer/src/backend/inferconfig.ml | 2 +- infer/src/backend/interproc.ml | 2 +- infer/src/backend/jsonbug.atd | 1 + infer/src/backend/printer.ml | 2 +- infer/src/backend/reporting.ml | 2 +- infer/src/backend/state.ml | 2 +- infer/src/backend/symExec.ml | 2 +- .../src/bufferoverrun/bufferOverrunChecker.ml | 3 +- infer/src/checkers/Siof.ml | 2 +- infer/src/checkers/ThreadSafety.ml | 2 +- infer/src/checkers/checkDeadCode.ml | 2 +- infer/src/checkers/checkTraceCallSequence.ml | 2 +- infer/src/checkers/checkers.ml | 25 +-- infer/src/checkers/checkers.mli | 2 +- infer/src/checkers/immutableChecker.ml | 2 +- infer/src/checkers/printfArgs.ml | 10 +- infer/src/checkers/repeatedCallsChecker.ml | 4 +- infer/src/eradicate/typeErr.ml | 46 ++--- infer/src/eradicate/typeErr.mli | 2 +- infer/src/quandary/TaintAnalysis.ml | 2 +- infer/src/unit/DifferentialFiltersTests.ml | 2 +- infer/src/unit/DifferentialTestsUtils.ml | 1 + .../codetoanalyze/java/quandary/issues.exp | 46 ++--- 29 files changed, 255 insertions(+), 163 deletions(-) diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index dceb34d33..91a91c3a5 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -218,7 +218,7 @@ let log_issue _ekind err_log loc node_id_key session ltr exn = let warn_str = let pp fmt = Format.fprintf fmt "%s %a" - (Localise.to_string err_name) + (Localise.to_issue_id err_name) Localise.pp_error_desc desc in F.asprintf "%t" pp in let d = match ekind with @@ -246,7 +246,7 @@ module Err_table = struct let pp_stats_footprint ekind fmt (err_table: err_log) = let err_name_map = ref String.Map.empty in (* map error name to count *) let count_err (err_name: Localise.t) n = - let err_string = Localise.to_string err_name in + let err_string = Localise.to_issue_id err_name in let count = try String.Map.find_exn !err_name_map err_string with Not_found -> 0 in err_name_map := String.Map.add ~key:err_string ~data:(count + n) !err_name_map in let count (ekind', in_footprint, err_name, _, _) eds = diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index 603a66773..7677fad6b 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -206,7 +206,8 @@ let recognize_exception exn = desc, None, Exn_developer, High, None, Nocat) | Invalid_argument s -> let desc = Localise.verbatim_desc s in - (Localise.from_string "Invalid_argument", desc, None, Exn_system, Low, None, Nocat) + (Localise.from_string "Invalid_argument", + desc, None, Exn_system, Low, None, Nocat) | Java_runtime_exception (exn_name, _, desc) -> let exn_str = Typename.name exn_name in (Localise.from_string exn_str, desc, None, Exn_user, High, None, Prover) @@ -230,7 +231,8 @@ let recognize_exception exn = Localise.no_desc, Some ml_loc, Exn_developer, High, None, Nocat) | Missing_fld (fld, ml_loc) -> let desc = Localise.verbatim_desc (Ident.fieldname_to_string fld) in - (Localise.from_string "Missing_fld", desc, Some ml_loc, Exn_developer, Medium, None, Nocat) + (Localise.from_string "Missing_fld" ~hum:"Missing Field", + desc, Some ml_loc, Exn_developer, Medium, None, Nocat) | Premature_nil_termination (desc, ml_loc) -> (Localise.premature_nil_termination, desc, Some ml_loc, Exn_user, High, None, Prover) @@ -273,11 +275,11 @@ let recognize_exception exn = (Localise.skip_pointer_dereference, desc, Some ml_loc, Exn_user, Medium, Some Kinfo, Nocat) (* always an info *) | Symexec_memory_error ml_loc -> - (Localise.from_string "Symexec_memory_error", + (Localise.from_string "Symexec_memory_error" ~hum:"Symbolic Execution Memory Error", Localise.no_desc, Some ml_loc, Exn_developer, Low, None, Nocat) | Sys_error s -> let desc = Localise.verbatim_desc s in - (Localise.from_string "Sys_error", + (Localise.from_string "Sys_error" ~hum:"System Error", desc, None, Exn_system, Low, None, Nocat) | Tainted_value_reaching_sensitive_function (desc, ml_loc) -> (Localise.tainted_value_reaching_sensitive_function, @@ -293,7 +295,7 @@ let recognize_exception exn = (Localise.unary_minus_applied_to_unsigned_expression, desc, Some ml_loc, Exn_user, Medium, None, Nocat) | Unknown_proc -> - (Localise.from_string "Unknown_proc", + (Localise.from_string "Unknown_proc" ~hum:"Unknown Procedure", Localise.no_desc, None, Exn_developer, Low, None, Nocat) | Unsafe_guarded_by_access (desc, ml_loc) -> (Localise.unsafe_guarded_by_access, @@ -302,7 +304,7 @@ let recognize_exception exn = (Localise.use_after_free, desc, Some ml_loc, Exn_user, High, None, Prover) | Wrong_argument_number ml_loc -> - (Localise.from_string "Wrong_argument_number", + (Localise.from_string "Wrong_argument_number" ~hum:"Wrong Argument Number", Localise.no_desc, Some ml_loc, Exn_developer, Low, None, Nocat) | Failure _ as f -> raise f @@ -319,7 +321,7 @@ let print_exception_html s exn = | None -> "" | Some ml_loc -> " " ^ L.ml_loc_to_string ml_loc in let desc_str = F.asprintf "%a" Localise.pp_error_desc desc in - (L.d_strln_color Red) (s ^ (Localise.to_string err_name) ^ " " ^ desc_str ^ ml_loc_string) + (L.d_strln_color Red) (s ^ (Localise.to_issue_id err_name) ^ " " ^ desc_str ^ ml_loc_string) (** string describing an error kind *) let err_kind_string = function diff --git a/infer/src/IR/Localise.ml b/infer/src/IR/Localise.ml index 9bfe7dd77..0e5fde400 100644 --- a/infer/src/IR/Localise.ml +++ b/infer/src/IR/Localise.ml @@ -14,64 +14,121 @@ open! IStd module F = Format -(** type of string used for localisation *) -type t = string [@@deriving compare] +type t = string * string [@@deriving compare] (* issue_id, human_readable *) let equal = [%compare.equal : t] +(** create from an ordinary string *) +let from_string ?hum s : t = + let prettify () = + String.lowercase s + |> String.split ~on:'_' + |> List.map ~f:String.capitalize + |> String.concat ~sep:" " + |> String.strip in + (s, match hum with Some str -> str | _ -> prettify ()) + +(** return the id of an issue *) +let to_issue_id (s, _) = s + +let to_human_readable_string (_, s) = s + (** pretty print a localised string *) -let pp fmt s = Format.fprintf fmt "%s" s - -(** create a localised string from an ordinary string *) -let from_string s = s - -(** convert a localised string to an ordinary string *) -let to_string s = s - -let analysis_stops = "ANALYSIS_STOPS" -let array_out_of_bounds_l1 = "ARRAY_OUT_OF_BOUNDS_L1" -let array_out_of_bounds_l2 = "ARRAY_OUT_OF_BOUNDS_L2" -let array_out_of_bounds_l3 = "ARRAY_OUT_OF_BOUNDS_L3" -let buffer_overrun = "BUFFER_OVERRUN" -let class_cast_exception = "CLASS_CAST_EXCEPTION" -let comparing_floats_for_equality = "COMPARING_FLOAT_FOR_EQUALITY" -let condition_is_assignment = "CONDITION_IS_ASSIGNMENT" -let condition_always_false = "CONDITION_ALWAYS_FALSE" -let condition_always_true = "CONDITION_ALWAYS_TRUE" -let context_leak = "CONTEXT_LEAK" -let dangling_pointer_dereference = "DANGLING_POINTER_DEREFERENCE" -let deallocate_stack_variable = "DEALLOCATE_STACK_VARIABLE" -let deallocate_static_memory = "DEALLOCATE_STATIC_MEMORY" -let deallocation_mismatch = "DEALLOCATION_MISMATCH" -let divide_by_zero = "DIVIDE_BY_ZERO" -let empty_vector_access = "EMPTY_VECTOR_ACCESS" -let field_not_null_checked = "IVAR_NOT_NULL_CHECKED" -let inherently_dangerous_function = "INHERENTLY_DANGEROUS_FUNCTION" -let memory_leak = "MEMORY_LEAK" -let null_dereference = "NULL_DEREFERENCE" -let parameter_not_null_checked = "PARAMETER_NOT_NULL_CHECKED" -let null_test_after_dereference = "NULL_TEST_AFTER_DEREFERENCE" -let pointer_size_mismatch = "POINTER_SIZE_MISMATCH" -let precondition_not_found = "PRECONDITION_NOT_FOUND" -let precondition_not_met = "PRECONDITION_NOT_MET" -let premature_nil_termination = "PREMATURE_NIL_TERMINATION_ARGUMENT" -let quandary_taint_error = "QUANDARY_TAINT_ERROR" -let registered_observer_being_deallocated = "REGISTERED_OBSERVER_BEING_DEALLOCATED" -let resource_leak = "RESOURCE_LEAK" -let retain_cycle = "RETAIN_CYCLE" -let return_value_ignored = "RETURN_VALUE_IGNORED" -let return_expression_required = "RETURN_EXPRESSION_REQUIRED" -let return_statement_missing = "RETURN_STATEMENT_MISSING" -let skip_function = "SKIP_FUNCTION" -let skip_pointer_dereference = "SKIP_POINTER_DEREFERENCE" -let stack_variable_address_escape = "STACK_VARIABLE_ADDRESS_ESCAPE" -let static_initialization_order_fiasco = "STATIC_INITIALIZATION_ORDER_FIASCO" -let tainted_value_reaching_sensitive_function = "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION" -let thread_safety_violation= "THREAD_SAFETY_VIOLATION" -let unary_minus_applied_to_unsigned_expression = "UNARY_MINUS_APPLIED_TO_UNSIGNED_EXPRESSION" -let unsafe_guarded_by_access = "UNSAFE_GUARDED_BY_ACCESS" -let uninitialized_value = "UNINITIALIZED_VALUE" -let use_after_free = "USE_AFTER_FREE" +let pp fmt t = Format.fprintf fmt "%s" (to_issue_id t) + +let analysis_stops = from_string "ANALYSIS_STOPS" +let array_out_of_bounds_l1 = from_string "ARRAY_OUT_OF_BOUNDS_L1" +let array_out_of_bounds_l2 = from_string "ARRAY_OUT_OF_BOUNDS_L2" +let array_out_of_bounds_l3 = from_string "ARRAY_OUT_OF_BOUNDS_L3" +let buffer_overrun = from_string "BUFFER_OVERRUN" +let checkers_access_global = from_string "CHECKERS_ACCESS_GLOBAL" +let checkers_dead_code = from_string "CHECKERS_DEAD_CODE" +let checkers_immutable_cast = from_string "CHECKERS_IMMUTABLE_CAST" +let checkers_print_c_call = from_string "CHECKERS_PRINT_C_CALL" +let checkers_print_objc_method_calls = from_string "CHECKERS_PRINT_OBJC_METHOD_CALLS" +let checkers_printf_args = from_string "CHECKERS_PRINTF_ARGS" +let checkers_repeated_calls = from_string "CHECKERS_REPEATED_CALLS" +let checkers_trace_calls_sequence = from_string "CHECKERS_TRACE_CALLS_SEQUENCE" +let class_cast_exception = from_string "CLASS_CAST_EXCEPTION" +let cluster_callback = from_string "CLUSTER_CALLBACK" +let comparing_floats_for_equality = from_string "COMPARING_FLOAT_FOR_EQUALITY" +let condition_always_false = from_string "CONDITION_ALWAYS_FALSE" +let condition_always_true = from_string "CONDITION_ALWAYS_TRUE" +let condition_is_assignment = from_string "CONDITION_IS_ASSIGNMENT" +let context_leak = from_string "CONTEXT_LEAK" +let dangling_pointer_dereference = from_string "DANGLING_POINTER_DEREFERENCE" +let deallocate_stack_variable = from_string "DEALLOCATE_STACK_VARIABLE" +let deallocate_static_memory = from_string "DEALLOCATE_STATIC_MEMORY" +let deallocation_mismatch = from_string "DEALLOCATION_MISMATCH" +let divide_by_zero = from_string "DIVIDE_BY_ZERO" +let empty_vector_access = from_string "EMPTY_VECTOR_ACCESS" +let eradicate_condition_redundant = + from_string "ERADICATE_CONDITION_REDUNDANT" ~hum:"Condition Redundant" +let eradicate_condition_redundant_nonnull = + from_string "ERADICATE_CONDITION_REDUNDANT_NONNULL" ~hum:"Condition Redundant Non-Null" +let eradicate_field_not_initialized = + from_string "ERADICATE_FIELD_NOT_INITIALIZED" ~hum:"Field Not Initialized" +let eradicate_field_not_mutable = + from_string "ERADICATE_FIELD_NOT_MUTABLE" ~hum:"Field Not Mutable" +let eradicate_field_not_nullable = + from_string "ERADICATE_FIELD_NOT_NULLABLE" ~hum:"Field Not Nullable" +let eradicate_field_over_annotated = + from_string "ERADICATE_FIELD_OVER_ANNOTATED" ~hum:"Field Over Annotated" +let eradicate_field_value_absent = + from_string "ERADICATE_FIELD_VALUE_ABSENT" ~hum:"Field Value Absent" +let eradicate_inconsistent_subclass_parameter_annotation = + from_string "ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION" + ~hum: "Inconsistent Subclass Parameter Annotation" +let eradicate_inconsistent_subclass_return_annotation = + from_string "ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION" + ~hum: "Inconsistent Subclass Return Annotation" +let eradicate_null_field_access = + from_string "ERADICATE_NULL_FIELD_ACCESS" ~hum:"Null Field Access" +let eradicate_null_method_call = + from_string "ERADICATE_NULL_METHOD_CALL" ~hum:"Null Method Call" +let eradicate_parameter_not_nullable = + from_string "ERADICATE_PARAMETER_NOT_NULLABLE" ~hum:"Parameter Not Nullable" +let eradicate_parameter_value_absent = + from_string "ERADICATE_PARAMETER_VALUE_ABSENT" ~hum:"Parameter Value Absent" +let eradicate_return_not_nullable = + from_string "ERADICATE_RETURN_NOT_NULLABLE" ~hum:"Return Not Nullable" +let eradicate_return_over_annotated = + from_string "ERADICATE_RETURN_OVER_ANNOTATED" ~hum:"Return Over Annotated" +let eradicate_return_value_not_present = + from_string "ERADICATE_RETURN_VALUE_NOT_PRESENT" ~hum:"Return Value Not Present" +let eradicate_value_not_present = + from_string "ERADICATE_VALUE_NOT_PRESENT" ~hum:"Value Not Present" +let field_not_null_checked = from_string "IVAR_NOT_NULL_CHECKED" +let inherently_dangerous_function = from_string "INHERENTLY_DANGEROUS_FUNCTION" +let memory_leak = from_string "MEMORY_LEAK" +let null_dereference = from_string "NULL_DEREFERENCE" +let null_test_after_dereference = from_string "NULL_TEST_AFTER_DEREFERENCE" +let parameter_not_null_checked = from_string "PARAMETER_NOT_NULL_CHECKED" +let pointer_size_mismatch = from_string "POINTER_SIZE_MISMATCH" +let precondition_not_found = from_string "PRECONDITION_NOT_FOUND" +let precondition_not_met = from_string "PRECONDITION_NOT_MET" +let premature_nil_termination = from_string "PREMATURE_NIL_TERMINATION_ARGUMENT" +let proc_callback = from_string "PROC_CALLBACK" ~hum:"Procedure Callback" +let quandary_taint_error = from_string "QUANDARY_TAINT_ERROR" +let registered_observer_being_deallocated = from_string "REGISTERED_OBSERVER_BEING_DEALLOCATED" +let resource_leak = from_string "RESOURCE_LEAK" +let retain_cycle = from_string "RETAIN_CYCLE" +let return_expression_required = from_string "RETURN_EXPRESSION_REQUIRED" +let return_statement_missing = from_string "RETURN_STATEMENT_MISSING" +let return_value_ignored = from_string "RETURN_VALUE_IGNORED" +let skip_function = from_string "SKIP_FUNCTION" +let skip_pointer_dereference = from_string "SKIP_POINTER_DEREFERENCE" +let stack_variable_address_escape = from_string "STACK_VARIABLE_ADDRESS_ESCAPE" +let static_initialization_order_fiasco = from_string "STATIC_INITIALIZATION_ORDER_FIASCO" +let tainted_value_reaching_sensitive_function = + from_string "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION" +let thread_safety_violation = from_string "THREAD_SAFETY_VIOLATION" +let unary_minus_applied_to_unsigned_expression = + from_string "UNARY_MINUS_APPLIED_TO_UNSIGNED_EXPRESSION" +let uninitialized_value = from_string "UNINITIALIZED_VALUE" +let unsafe_guarded_by_access = from_string "UNSAFE_GUARDED_BY_ACCESS" +let use_after_free = from_string "USE_AFTER_FREE" + type error_desc = { descriptions : string list; diff --git a/infer/src/IR/Localise.mli b/infer/src/IR/Localise.mli index 7b626f1bf..b933ddb13 100644 --- a/infer/src/IR/Localise.mli +++ b/infer/src/IR/Localise.mli @@ -20,22 +20,34 @@ val equal : t -> t -> bool (** pretty print a localised string *) val pp : Format.formatter -> t -> unit -(** create a localised string from an ordinary string *) -val from_string : string -> t +(** create from an ordinary string *) +val from_string : ?hum:string -> string -> t -(** convert a localised string to an ordinary string *) -val to_string : t -> string +(** return the id of an issue *) +val to_issue_id : t -> string + +(** return the human-readable name of an issue *) +val to_human_readable_string : t -> string val analysis_stops : t val array_out_of_bounds_l1 : t val array_out_of_bounds_l2 : t val array_out_of_bounds_l3 : t val buffer_overrun : t +val checkers_access_global : t +val checkers_dead_code : t +val checkers_immutable_cast : t +val checkers_print_c_call : t +val checkers_print_objc_method_calls : t +val checkers_printf_args : t +val checkers_repeated_calls : t +val checkers_trace_calls_sequence : t val class_cast_exception : t +val cluster_callback : t val comparing_floats_for_equality : t -val condition_is_assignment : t val condition_always_false : t val condition_always_true : t +val condition_is_assignment : t val context_leak : t val dangling_pointer_dereference : t val deallocate_stack_variable : t @@ -43,33 +55,51 @@ val deallocate_static_memory : t val deallocation_mismatch : t val divide_by_zero : t val empty_vector_access : t +val eradicate_condition_redundant : t +val eradicate_condition_redundant_nonnull : t +val eradicate_field_not_initialized : t +val eradicate_field_not_mutable : t +val eradicate_field_not_nullable : t +val eradicate_field_over_annotated : t +val eradicate_field_value_absent : t +val eradicate_inconsistent_subclass_parameter_annotation : t +val eradicate_inconsistent_subclass_return_annotation : t +val eradicate_null_field_access : t +val eradicate_null_method_call : t +val eradicate_parameter_not_nullable : t +val eradicate_parameter_value_absent : t +val eradicate_return_not_nullable : t +val eradicate_return_over_annotated : t +val eradicate_return_value_not_present : t +val eradicate_value_not_present : t val field_not_null_checked : t val inherently_dangerous_function : t val memory_leak : t val null_dereference : t -val parameter_not_null_checked : t val null_test_after_dereference : t +val parameter_not_null_checked : t val pointer_size_mismatch : t val precondition_not_found : t val precondition_not_met : t val premature_nil_termination : t +val proc_callback : t val quandary_taint_error : t val registered_observer_being_deallocated : t -val retain_cycle : t val resource_leak : t -val return_value_ignored : t +val retain_cycle : t val return_expression_required : t val return_statement_missing : t +val return_value_ignored : t +val skip_function : t +val skip_pointer_dereference : t val stack_variable_address_escape : t val static_initialization_order_fiasco : t +val tainted_value_reaching_sensitive_function : t +val thread_safety_violation : t val unary_minus_applied_to_unsigned_expression : t val uninitialized_value : t val unsafe_guarded_by_access : t val use_after_free : t -val skip_function : t -val skip_pointer_dereference : t -val tainted_value_reaching_sensitive_function : t -val thread_safety_violation : t (** description field of error messages *) type error_desc = { diff --git a/infer/src/backend/DifferentialFilters.ml b/infer/src/backend/DifferentialFilters.ml index dc793c369..6eb9da94c 100644 --- a/infer/src/backend/DifferentialFilters.ml +++ b/infer/src/backend/DifferentialFilters.ml @@ -183,7 +183,7 @@ let resolve_infer_eradicate_conflict let filters = filters_of_analyzer Config.Eradicate in filters.path_filter source_file in Config.equal_analyzer analyzer Config.Infer && - String.equal issue.bug_type (Localise.to_string Localise.null_dereference) && + String.equal issue.bug_type (Localise.to_issue_id Localise.null_dereference) && file_is_whitelisted () in let filter issues = List.filter ~f:(Fn.non should_discard_issue) issues in { diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index be96019be..26332022b 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -410,7 +410,7 @@ let module IssuesCsv = { Escape.escape_csv s }; let kind = Exceptions.err_kind_string ekind; - let type_str = Localise.to_string error_name; + let type_str = Localise.to_issue_id error_name; let procedure_id = Typ.Procname.to_filename procname; let filename = SourceFile.to_string source_file; let always_report = @@ -477,7 +477,7 @@ let module IssuesJson = { should_report ekind error_name error_desc eclass && report_filter source_file ) { let kind = Exceptions.err_kind_string ekind; - let bug_type = Localise.to_string error_name; + let bug_type = Localise.to_issue_id error_name; let procedure_id = Typ.Procname.to_filename procname; let file = SourceFile.to_string source_file; let json_ml_loc = @@ -505,7 +505,8 @@ let module IssuesJson = { qualifier_tags: error_desc_to_qualifier_tags_records error_desc, hash: get_bug_hash kind bug_type procedure_id file node_key error_desc, dotty: error_desc_to_dotty_string error_desc, - infer_source_loc: json_ml_loc + infer_source_loc: json_ml_loc, + bug_type_hum: Localise.to_human_readable_string error_name }; if (not !is_first_item) { pp "," @@ -656,7 +657,7 @@ let module IssuesXml = { let subtree label contents => Io_infer.Xml.create_tree label [] [Io_infer.Xml.String contents]; let kind = Exceptions.err_kind_string ekind; - let type_str = Localise.to_string error_name; + let type_str = Localise.to_issue_id error_name; let tree = { incr xml_issues_id; let attributes = [("id", string_of_int !xml_issues_id)]; @@ -787,7 +788,7 @@ let module Stats = { let process_err_log error_filter linereader err_log stats => { let found_errors = ref false; let process_row _ loc _ ekind in_footprint error_name error_desc _ ltr _ _ => { - let type_str = Localise.to_string error_name; + let type_str = Localise.to_issue_id error_name; if (in_footprint && error_filter error_desc error_name) { switch ekind { | Exceptions.Kerror => diff --git a/infer/src/backend/inferconfig.ml b/infer/src/backend/inferconfig.ml index 0429c916b..2d1b0682e 100644 --- a/infer/src/backend/inferconfig.ml +++ b/infer/src/backend/inferconfig.ml @@ -333,7 +333,7 @@ let filters_from_inferconfig inferconfig : filters = not (blacklist_files_containing_filter source_file) in let error_filter = function error_name -> - let error_str = Localise.to_string error_name in + let error_str = Localise.to_issue_id error_name in not (List.exists ~f:(String.equal error_str) inferconfig.suppress_errors) in { path_filter = path_filter; diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index 9c5e404cf..7f2fd5284 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -1370,7 +1370,7 @@ let perform_transition exe_env tenv proc_name source = Config.allow_leak := allow_leak; L.err "Error in collect_preconditions for %a@." Typ.Procname.pp proc_name; let err_name, _, ml_loc_opt, _, _, _, _ = Exceptions.recognize_exception exn in - let err_str = "exception raised " ^ (Localise.to_string err_name) in + let err_str = "exception raised " ^ (Localise.to_issue_id err_name) in L.err "Error: %s %a@." err_str L.pp_ml_loc_opt ml_loc_opt; [] in transition_footprint_re_exe tenv proc_name joined_pres in diff --git a/infer/src/backend/jsonbug.atd b/infer/src/backend/jsonbug.atd index 0af0f3075..d7de136c8 100644 --- a/infer/src/backend/jsonbug.atd +++ b/infer/src/backend/jsonbug.atd @@ -37,6 +37,7 @@ type jsonbug = { hash : int; ?dotty : string option; ?infer_source_loc: loc option; + bug_type_hum: string; } type report = jsonbug list diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index 5d438874c..5b95e0b9b 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -455,7 +455,7 @@ let create_table_err_per_line err_log = let err_per_line = Hashtbl.create 17 in let add_err _ loc _ _ _ err_name desc _ _ _ _ = let err_str = - Localise.to_string err_name ^ + Localise.to_issue_id err_name ^ " " ^ (F.asprintf "%a" Localise.pp_error_desc desc) in try diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 8a8a987c3..4be5772b4 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -39,7 +39,7 @@ let log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr exn = let err_name = match exn with | Exceptions.Frontend_warning (err_name, _, _) -> err_name | _ -> let err_name, _, _, _, _, _, _ = Exceptions.recognize_exception exn in - (Localise.to_string err_name) in + (Localise.to_issue_id err_name) in if (Inferconfig.is_checker_enabled err_name) then Errlog.log_issue err_kind err_log loc node_id session ltr exn diff --git a/infer/src/backend/state.ml b/infer/src/backend/state.ml index 5ee1965f1..29d731ce0 100644 --- a/infer/src/backend/state.ml +++ b/infer/src/backend/state.ml @@ -321,7 +321,7 @@ let process_execution_failures (log_issue : log_issue) pname = match fs.node_ok, fs.first_failure with | 0, Some (loc, key, _, loc_trace, exn) when not Config.debug_exceptions -> let ex_name, _, ml_loc_opt, _, _, _, _ = Exceptions.recognize_exception exn in - let desc' = Localise.verbatim_desc ("exception: " ^ Localise.to_string ex_name) in + let desc' = Localise.verbatim_desc ("exception: " ^ Localise.to_issue_id ex_name) in let exn' = Exceptions.Analysis_stops (desc', ml_loc_opt) in log_issue pname ~loc ~node_id:key ~ltr:loc_trace exn' | _ -> () in diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index 97a03bb4d..850a564fc 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -1271,7 +1271,7 @@ and instrs ?(mask_errors=false) tenv pdesc instrs ppl = | None -> "") in L.d_warning ("Generated Instruction Failed with: " ^ - (Localise.to_string err_name)^loc ); L.d_ln(); + (Localise.to_issue_id err_name)^loc ); L.d_ln(); [(p, path)] in let f plist instr = List.concat_map ~f:(exe_instr instr) plist in List.fold ~f ~init:ppl instrs diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index 2ee26e585..6f87422fa 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -405,7 +405,8 @@ struct | Some bucket when Typ.Procname.equal pname caller_pname -> let description = Dom.Condition.to_string cond in let error_desc = Localise.desc_buffer_overrun bucket description in - let exn = Exceptions.Checkers (Localise.to_string Localise.buffer_overrun, error_desc) in + let exn = + Exceptions.Checkers (Localise.to_issue_id Localise.buffer_overrun, error_desc) in let trace = [Errlog.make_trace_element 0 loc description []] in Reporting.log_error pname ~loc ~ltr:trace exn | _ -> () diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 25d15b5d6..3c63f5d35 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -209,7 +209,7 @@ let report_siof trace pdesc gname loc = description, (passthroughs, (final_sink', pt)::rest) in let ltr = SiofTrace.trace_of_error loc gname sink_path' in let caller_pname = Procdesc.get_proc_name pdesc in - let msg = Localise.to_string Localise.static_initialization_order_fiasco in + let msg = Localise.to_issue_id Localise.static_initialization_order_fiasco in let exn = Exceptions.Checkers (msg, Localise.verbatim_desc description) in Reporting.log_error caller_pname ~loc ~ltr exn in diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index b2d682142..fbac36fda 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -1003,7 +1003,7 @@ let report_thread_safety_violations ( _, tenv, pname, pdesc) make_description tr "call to %a" Typ.Procname.pp (CallSite.pname (PathDomain.Sink.call_site sink)) in let loc = CallSite.loc (PathDomain.Sink.call_site initial_sink) in let ltr = PathDomain.to_sink_loc_trace ~desc_of_sink path in - let msg = Localise.to_string Localise.thread_safety_violation in + let msg = Localise.to_issue_id Localise.thread_safety_violation in let description = make_description tenv pname final_sink_site initial_sink_site final_sink tab in let exn = Exceptions.Checkers (msg, Localise.verbatim_desc description) in diff --git a/infer/src/checkers/checkDeadCode.ml b/infer/src/checkers/checkDeadCode.ml index 61c59fd96..28b58befc 100644 --- a/infer/src/checkers/checkDeadCode.ml +++ b/infer/src/checkers/checkDeadCode.ml @@ -63,7 +63,7 @@ let do_node _ node (s : State.t) : (State.t list) * (State.t list) = (** Report an error. *) let report_error tenv description pn pd loc = if verbose then L.stderr "ERROR: %s@." description; - Checkers.ST.report_error tenv pn pd "CHECKERS_DEAD_CODE" loc description + Checkers.ST.report_error tenv pn pd Localise.checkers_dead_code loc description (** Check the final state at the end of the analysis. *) diff --git a/infer/src/checkers/checkTraceCallSequence.ml b/infer/src/checkers/checkTraceCallSequence.ml index 1af7161ac..e5d071a0b 100644 --- a/infer/src/checkers/checkTraceCallSequence.ml +++ b/infer/src/checkers/checkTraceCallSequence.ml @@ -39,7 +39,7 @@ let boolean_variables = (** Report a warning in the spec file of the procedure. *) let report_warning tenv description pn pd loc = if verbose then L.stderr "ERROR: %s@." description; - Checkers.ST.report_error tenv pn pd "CHECKERS_TRACE_CALLS_SEQUENCE" loc description + Checkers.ST.report_error tenv pn pd Localise.checkers_trace_calls_sequence loc description (** Tracing APIs. *) diff --git a/infer/src/checkers/checkers.ml b/infer/src/checkers/checkers.ml index 7aed81831..c3672d4ac 100644 --- a/infer/src/checkers/checkers.ml +++ b/infer/src/checkers/checkers.ml @@ -71,7 +71,7 @@ module ST = struct description (Option.value ~default:"" advice) [("always_report", string_of_bool always_report)] in - let exn = exception_kind kind localized_description in + let exn = exception_kind (Localise.to_issue_id kind) localized_description in let proc_attributes = Specs.pdesc_resolve_attributes proc_desc in (* Errors can be suppressed with annotations. An error of kind CHECKER_ERROR_NAME can be @@ -90,9 +90,11 @@ module ST = struct let is_parameter_suppressed = String.is_suffix a.class_name ~suffix:Annotations.suppress_lint && - List.mem ~equal:normalized_equal a.parameters kind in + List.mem ~equal:normalized_equal a.parameters (Localise.to_issue_id kind) in let is_annotation_suppressed = - String.is_suffix ~suffix:(normalize (drop_prefix kind)) (normalize a.class_name) in + String.is_suffix + ~suffix:(normalize (drop_prefix (Localise.to_issue_id kind))) + (normalize a.class_name) in is_parameter_suppressed || is_annotation_suppressed in @@ -134,7 +136,7 @@ module ST = struct if !verbose then begin L.stdout "%s: %a: %s@." - kind + (Localise.to_issue_id kind) SourceFile.pp loc.Location.file (Typ.Procname.to_string proc_name); L.stdout "%s@." description @@ -151,7 +153,7 @@ let report_calls_and_accesses tenv callback proc_desc instr = ST.report_error tenv proc_name proc_desc - (callback ^ "_CALLBACK") + callback (Procdesc.get_loc proc_desc) (Format.sprintf "field access %s.%s:%s in %s@." bt fn ft callee) | None -> @@ -160,7 +162,7 @@ let report_calls_and_accesses tenv callback proc_desc instr = ST.report_error tenv proc_name proc_desc - (callback ^ "_CALLBACK") + callback (Procdesc.get_loc proc_desc) (Format.sprintf "method call %s.%s(%s):%s in %s@." bt fn "..." rt callee) | None -> () @@ -168,7 +170,7 @@ let report_calls_and_accesses tenv callback proc_desc instr = (** Report all field accesses and method calls of a procedure. *) let callback_check_access { Callbacks.tenv; proc_desc } = Procdesc.iter_instrs - (fun _ instr -> report_calls_and_accesses tenv "PROC" proc_desc instr) + (fun _ instr -> report_calls_and_accesses tenv Localise.proc_callback proc_desc instr) proc_desc (** Report all field accesses and method calls of a class. *) @@ -178,7 +180,8 @@ let callback_check_cluster_access exe_env all_procs get_proc_desc _ = | Some proc_desc -> let tenv = Exe_env.get_tenv exe_env proc_name in Procdesc.iter_instrs - (fun _ instr -> report_calls_and_accesses tenv "CLUSTER" proc_desc instr) + (fun _ instr -> + report_calls_and_accesses tenv Localise.cluster_callback proc_desc instr) proc_desc | _ -> () @@ -553,7 +556,7 @@ let callback_print_c_method_calls { Callbacks.tenv; proc_desc; proc_name } = ST.report_error tenv proc_name proc_desc - "CHECKERS_PRINT_OBJC_METHOD_CALLS" + Localise.checkers_print_objc_method_calls loc description | Sil.Call (_, Exp.Const (Const.Cfun pn), _, loc, _) -> @@ -562,7 +565,7 @@ let callback_print_c_method_calls { Callbacks.tenv; proc_desc; proc_name } = ST.report_error tenv proc_name proc_desc - "CHECKERS_PRINT_C_CALL" + Localise.checkers_print_c_call loc description | _ -> () in @@ -578,7 +581,7 @@ let callback_print_access_to_globals { Callbacks.tenv; proc_desc; proc_name } = ST.report_error tenv proc_name proc_desc - "CHECKERS_ACCESS_GLOBAL" + Localise.checkers_access_global loc description in let rec get_global_var = function diff --git a/infer/src/checkers/checkers.mli b/infer/src/checkers/checkers.mli index e9fa6329f..eefaec0f5 100644 --- a/infer/src/checkers/checkers.mli +++ b/infer/src/checkers/checkers.mli @@ -25,7 +25,7 @@ module ST : sig Tenv.t -> Typ.Procname.t -> Procdesc.t -> - string -> + Localise.t -> Location.t -> ?advice: string option -> ?field_name: Ident.fieldname option -> diff --git a/infer/src/checkers/immutableChecker.ml b/infer/src/checkers/immutableChecker.ml index 85379328e..bfac711b6 100644 --- a/infer/src/checkers/immutableChecker.ml +++ b/infer/src/checkers/immutableChecker.ml @@ -43,7 +43,7 @@ let check_immutable_cast tenv curr_pname curr_pdesc typ_expected typ_found_opt l Checkers.ST.report_error tenv curr_pname curr_pdesc - "CHECKERS_IMMUTABLE_CAST" + Localise.checkers_immutable_cast loc description end diff --git a/infer/src/checkers/printfArgs.ml b/infer/src/checkers/printfArgs.ml index 435aef857..e35e5bfea 100644 --- a/infer/src/checkers/printfArgs.ml +++ b/infer/src/checkers/printfArgs.ml @@ -109,8 +109,6 @@ let rec format_string_type_names fmt_type:: format_string_type_names fmt_string (Str.match_end ()) with Not_found -> [] -let printf_args_name = "CHECKERS_PRINTF_ARGS" - let check_printf_args_ok tenv (node: Procdesc.Node.t) (instr: Sil.instr) @@ -134,7 +132,7 @@ let check_printf_args_ok tenv Checkers.ST.report_error tenv proc_name proc_desc - printf_args_name + Localise.checkers_printf_args instr_loc description else @@ -148,7 +146,7 @@ let check_printf_args_ok tenv Checkers.ST.report_error tenv proc_name proc_desc - printf_args_name + Localise.checkers_printf_args instr_loc description in @@ -196,13 +194,13 @@ let check_printf_args_ok tenv Checkers.ST.report_error tenv proc_name proc_desc - printf_args_name + Localise.checkers_printf_args cl "Format string must be string literal" with e -> L.stderr "%s Exception when analyzing %s: %s@." - printf_args_name + (Localise.to_issue_id Localise.checkers_printf_args) (Typ.Procname.to_string proc_name) (Exn.to_string e)) | None -> ()) diff --git a/infer/src/checkers/repeatedCallsChecker.ml b/infer/src/checkers/repeatedCallsChecker.ml index 16b02478a..9fc73af62 100644 --- a/infer/src/checkers/repeatedCallsChecker.ml +++ b/infer/src/checkers/repeatedCallsChecker.ml @@ -12,8 +12,6 @@ open! IStd module L = Logging module F = Format -let checkers_repeated_calls_name = "CHECKERS_REPEATED_CALLS" - (** Extension for the repeated calls check. *) module RepeatedCallsExtension : Eradicate.ExtensionT = @@ -138,7 +136,7 @@ struct SourceFile.pp alloc_loc.Location.file alloc_loc.Location.line in Checkers.ST.report_error tenv - curr_pname curr_pdesc checkers_repeated_calls_name loc description + curr_pname curr_pdesc Localise.checkers_repeated_calls loc description | None -> () end | _ -> () in diff --git a/infer/src/eradicate/typeErr.ml b/infer/src/eradicate/typeErr.ml index 3fc776f5f..1124957fe 100644 --- a/infer/src/eradicate/typeErr.ml +++ b/infer/src/eradicate/typeErr.ml @@ -227,7 +227,7 @@ end (* Strict *) type st_report_error = Typ.Procname.t -> Procdesc.t -> - string -> + Localise.t -> Location.t -> ?advice: string option -> ?field_name: Ident.fieldname option -> @@ -241,21 +241,21 @@ type st_report_error = let report_error_now tenv (st_report_error : st_report_error) err_instance loc pdesc : unit = let pname = Procdesc.get_proc_name pdesc in - let do_print ew_string kind_s s = + let do_print ew_string kind s = L.stdout "%a:%d " SourceFile.pp loc.Location.file loc.Location.line; let mname = match pname with | Typ.Procname.Java pname_java -> Typ.Procname.java_get_method pname_java | _ -> Typ.Procname.to_simplified_string pname in - L.stdout "%s %s in %s %s@." ew_string kind_s mname s in + L.stdout "%s %s in %s %s@." ew_string (Localise.to_issue_id kind) mname s in - let is_err, kind_s, description, advice, field_name, origin_loc = match err_instance with + let is_err, kind, description, advice, field_name, origin_loc = match err_instance with | Condition_redundant (b, s_opt, nonnull) -> let name = if nonnull - then "ERADICATE_CONDITION_REDUNDANT_NONNULL" - else "ERADICATE_CONDITION_REDUNDANT" in + then Localise.eradicate_condition_redundant_nonnull + else Localise.eradicate_condition_redundant in false, name, P.sprintf @@ -276,7 +276,7 @@ let report_error_now tenv | _ -> Typ.Procname.to_simplified_string pn in true, - "ERADICATE_FIELD_NOT_INITIALIZED", + Localise.eradicate_field_not_initialized, P.sprintf "Field `%s` is not initialized in %s and is not declared `@Nullable`" (Ident.fieldname_to_simplified_string fn) @@ -286,7 +286,7 @@ let report_error_now tenv None | Field_not_mutable (fn, (origin_description, origin_loc, _)) -> true, - "ERADICATE_FIELD_NOT_MUTABLE", + Localise.eradicate_field_not_mutable, P.sprintf "Field `%s` is modified but is not declared `@Mutable`. %s" (Ident.fieldname_to_simplified_string fn) @@ -297,13 +297,13 @@ let report_error_now tenv | Field_annotation_inconsistent (ann, fn, (origin_description, origin_loc, _)) -> let kind_s, description = match ann with | AnnotatedSignature.Nullable -> - "ERADICATE_FIELD_NOT_NULLABLE", + Localise.eradicate_field_not_nullable, P.sprintf "Field `%s` can be null but is not declared `@Nullable`. %s" (Ident.fieldname_to_simplified_string fn) origin_description | AnnotatedSignature.Present -> - "ERADICATE_FIELD_VALUE_ABSENT", + Localise.eradicate_field_value_absent, P.sprintf "Field `%s` is assigned a possibly absent value but is declared `@Present`. %s" (Ident.fieldname_to_simplified_string fn) @@ -325,7 +325,7 @@ let report_error_now tenv | _ -> Typ.Procname.to_simplified_string pn in true, - "ERADICATE_FIELD_OVER_ANNOTATED", + Localise.eradicate_field_over_annotated, P.sprintf "Field `%s` is always initialized in %s but is declared `@Nullable`" (Ident.fieldname_to_simplified_string fn) @@ -336,7 +336,7 @@ let report_error_now tenv | Null_field_access (s_opt, fn, (origin_description, origin_loc, _), indexed) -> let at_index = if indexed then "element at index" else "field" in true, - "ERADICATE_NULL_FIELD_ACCESS", + Localise.eradicate_null_field_access, P.sprintf "Object `%s` could be null when accessing %s `%s`. %s" (Option.value s_opt ~default:"") @@ -349,14 +349,14 @@ let report_error_now tenv | Call_receiver_annotation_inconsistent (ann, s_opt, pn, (origin_description, origin_loc, _)) -> let kind_s, description = match ann with | AnnotatedSignature.Nullable -> - "ERADICATE_NULL_METHOD_CALL", + Localise.eradicate_null_method_call, P.sprintf "The value of `%s` in the call to `%s` could be null. %s" (Option.value s_opt ~default:"") (Typ.Procname.to_simplified_string pn) origin_description | AnnotatedSignature.Present -> - "ERADICATE_VALUE_NOT_PRESENT", + Localise.eradicate_value_not_present, P.sprintf "The value of `%s` in the call to `%s` is not @Present. %s" (Option.value s_opt ~default:"") @@ -371,7 +371,7 @@ let report_error_now tenv | Parameter_annotation_inconsistent (ann, s, n, pn, _, (origin_desc, origin_loc, _)) -> let kind_s, description = match ann with | AnnotatedSignature.Nullable -> - "ERADICATE_PARAMETER_NOT_NULLABLE", + Localise.eradicate_parameter_not_nullable, P.sprintf "`%s` needs a non-null value in parameter %d but argument `%s` can be null. %s" (Typ.Procname.to_simplified_string pn) @@ -379,7 +379,7 @@ let report_error_now tenv s origin_desc | AnnotatedSignature.Present -> - "ERADICATE_PARAMETER_VALUE_ABSENT", + Localise.eradicate_parameter_value_absent, P.sprintf "`%s` needs a present value in parameter %d but argument `%s` can be absent. %s" (Typ.Procname.to_simplified_string pn) @@ -395,13 +395,13 @@ let report_error_now tenv | Return_annotation_inconsistent (ann, pn, (origin_description, origin_loc, _)) -> let kind_s, description = match ann with | AnnotatedSignature.Nullable -> - "ERADICATE_RETURN_NOT_NULLABLE", + Localise.eradicate_return_not_nullable, P.sprintf "Method `%s` may return null but it is not annotated with `@Nullable`. %s" (Typ.Procname.to_simplified_string pn) origin_description | AnnotatedSignature.Present -> - "ERADICATE_RETURN_VALUE_NOT_PRESENT", + Localise.eradicate_return_value_not_present, P.sprintf "Method `%s` may return an absent value but it is annotated with `@Present`. %s" (Typ.Procname.to_simplified_string pn) @@ -414,7 +414,7 @@ let report_error_now tenv origin_loc | Return_over_annotated pn -> false, - "ERADICATE_RETURN_OVER_ANNOTATED", + Localise.eradicate_return_over_annotated, P.sprintf "Method `%s` is annotated with `@Nullable` but never returns null." (Typ.Procname.to_simplified_string pn), @@ -423,7 +423,7 @@ let report_error_now tenv None | Inconsistent_subclass_return_annotation (pn, opn) -> false, - "ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION", + Localise.eradicate_inconsistent_subclass_return_annotation, P.sprintf "Method `%s` is annotated with `@Nullable` but overrides unannotated method `%s`." (Typ.Procname.to_simplified_string ~withclass: true pn) @@ -438,7 +438,7 @@ let report_error_now tenv | 3 -> "Third" | n -> (string_of_int n)^"th" in false, - "ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION", + Localise.eradicate_inconsistent_subclass_parameter_annotation, P.sprintf "%s parameter `%s` of method `%s` is not `@Nullable` but is declared `@Nullable`\ in the parent class method `%s`." @@ -449,12 +449,12 @@ let report_error_now tenv None, None in let ew_string = if is_err then "Error" else "Warning" in - do_print ew_string kind_s description; + do_print ew_string kind description; let always_report = Strict.err_instance_get_strict tenv err_instance <> None in st_report_error pname pdesc - kind_s + kind loc ~advice ~field_name diff --git a/infer/src/eradicate/typeErr.mli b/infer/src/eradicate/typeErr.mli index 8a8a5f5b5..e3befb1ac 100644 --- a/infer/src/eradicate/typeErr.mli +++ b/infer/src/eradicate/typeErr.mli @@ -69,7 +69,7 @@ val node_reset_forall : Procdesc.Node.t -> unit type st_report_error = Typ.Procname.t -> Procdesc.t -> - string -> + Localise.t -> Location.t -> ?advice: string option -> ?field_name: Ident.fieldname option -> diff --git a/infer/src/quandary/TaintAnalysis.ml b/infer/src/quandary/TaintAnalysis.ml index c0b516c2a..091f0ce31 100644 --- a/infer/src/quandary/TaintAnalysis.ml +++ b/infer/src/quandary/TaintAnalysis.ml @@ -178,7 +178,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct let report_error path = let caller_pname = Procdesc.get_proc_name proc_data.pdesc in - let msg = Localise.to_string Localise.quandary_taint_error in + let msg = Localise.to_issue_id Localise.quandary_taint_error in let trace_str = F.asprintf "%a" pp_path_short path in let ltr = TraceDomain.to_loc_trace path in let exn = Exceptions.Checkers (msg, Localise.verbatim_desc trace_str) in diff --git a/infer/src/unit/DifferentialFiltersTests.ml b/infer/src/unit/DifferentialFiltersTests.ml index 6263d8c2e..4056ec25d 100644 --- a/infer/src/unit/DifferentialFiltersTests.ml +++ b/infer/src/unit/DifferentialFiltersTests.ml @@ -475,7 +475,7 @@ let test_resolve_infer_eradicate_conflict = } | _ -> failwith "This mock only supports Eradicate" in let create_test analyzer (exp_introduced, exp_fixed, exp_preexisting) _ = - let null_dereference = Localise.to_string Localise.null_dereference in + let null_dereference = Localise.to_issue_id Localise.null_dereference in let current_report = [ create_fake_jsonbug ~bug_type:"bug_type_1" ~file:"file_1.java" ~hash:1 (); create_fake_jsonbug ~bug_type:null_dereference ~file:"file_2.java" ~hash:2 (); diff --git a/infer/src/unit/DifferentialTestsUtils.ml b/infer/src/unit/DifferentialTestsUtils.ml index e39e0b929..ff156eade 100644 --- a/infer/src/unit/DifferentialTestsUtils.ml +++ b/infer/src/unit/DifferentialTestsUtils.ml @@ -47,6 +47,7 @@ let create_fake_jsonbug hash; dotty; infer_source_loc; + bug_type_hum = kind; } let pp_diff_of_int_list group_name fmt (expected, actual) = diff --git a/infer/tests/codetoanalyze/java/quandary/issues.exp b/infer/tests/codetoanalyze/java/quandary/issues.exp index eea331679..3b3b952c9 100644 --- a/infer/tests/codetoanalyze/java/quandary/issues.exp +++ b/infer/tests/codetoanalyze/java/quandary/issues.exp @@ -33,8 +33,8 @@ codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.callSinkV codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.callSinkViaSubtypeBad(DynamicDispatch$Supertype), 2, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void DynamicDispatch$BadSubtype.callSink(Object),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.propagateViaInterfaceBad(DynamicDispatch$Interface), 3, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),flow through Object DynamicDispatch$BadInterfaceImpl1.propagate(Object),flow through Object DynamicDispatch$BadInterfaceImpl2.propagate(Object),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.propagateViaSubtypeBad(DynamicDispatch$Supertype), 3, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),flow through Object DynamicDispatch$BadSubtype.propagate(Object),call to void InferTaint.inferSensitiveSink(Object)] -codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.returnSourceViaInterfaceBad(DynamicDispatch$Interface), 2, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),return from Object DynamicDispatch$BadInterfaceImpl1.returnSource(),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.returnSourceViaInterfaceBad(DynamicDispatch$Interface), 2, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),return from Object DynamicDispatch$BadInterfaceImpl2.returnSource(),call to void InferTaint.inferSensitiveSink(Object)] +codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.returnSourceViaInterfaceBad(DynamicDispatch$Interface), 2, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),return from Object DynamicDispatch$BadInterfaceImpl1.returnSource(),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/DynamicDispatch.java, void DynamicDispatch.returnSourceViaSubtypeBad(DynamicDispatch$Supertype), 2, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),return from Object DynamicDispatch$BadSubtype.returnSource(),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/Exceptions.java, void Exceptions.callSinkThenThrowBad(), 1, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void Exceptions.callSinkThenThrow(Object),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/Exceptions.java, void Exceptions.sinkAfterCatchBad(), 7, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void InferTaint.inferSensitiveSink(Object)] @@ -114,45 +114,45 @@ codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.returnSou codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.setGlobalThenCallSinkBad(), 2, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),flow through void Interprocedural.setGlobal(Object),call to void Interprocedural.callSinkOnGlobal(),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/Interprocedural.java, void Interprocedural.singlePassthroughBad(), 3, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),flow through Object Interprocedural.id(Object),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getDeviceId(),call to int Log.e(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.e(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.e(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.e(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getVoiceMailNumber(),call to int Log.e(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.e(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.e(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from float Location.getBearing(),call to int Log.e(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSubscriberId(),call to int Log.e(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.e(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getLine1Number(),call to int Log.e(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.e(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.e(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 36, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.e(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getDeviceId(),call to int Log.println(int,String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.println(int,String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.println(int,String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.println(int,String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getVoiceMailNumber(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from float Location.getBearing(),call to int Log.println(int,String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.println(int,String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getLine1Number(),call to int Log.println(int,String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSubscriberId(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.println(int,String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from float Location.getBearing(),call to int Log.println(int,String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 37, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getDeviceId(),call to int Log.println(int,String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getLine1Number(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.w(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.w(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getDeviceId(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getVoiceMailNumber(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.w(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from float Location.getBearing(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.w(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getLine1Number(),call to int Log.w(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.w(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.w(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSubscriberId(),call to int Log.w(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSubscriberId(),call to int Log.wtf(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.wtf(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.wtf(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.w(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getVoiceMailNumber(),call to int Log.w(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 38, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.w(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getDeviceId(),call to int Log.wtf(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getLine1Number(),call to int Log.wtf(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from double Location.getAltitude(),call to int Log.wtf(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.wtf(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSubscriberId(),call to int Log.wtf(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getVoiceMailNumber(),call to int Log.wtf(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from double Location.getLatitude(),call to int Log.wtf(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getSimSerialNumber(),call to int Log.wtf(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from float Location.getBearing(),call to int Log.wtf(String,String)] -codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from String TelephonyManager.getLine1Number(),call to int Log.wtf(String,String)] codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from float Location.getSpeed(),call to int Log.wtf(String,String)] +codetoanalyze/java/quandary/LoggingPrivateData.java, void LoggingPrivateData.logAllSourcesBad(Location,TelephonyManager), 39, QUANDARY_TAINT_ERROR, [return from double Location.getLongitude(),call to int Log.wtf(String,String)] codetoanalyze/java/quandary/Recursion.java, void Recursion.callSinkThenDivergeBad(), 1, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void Recursion.callSinkThenDiverge(Object),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/Recursion.java, void Recursion.recursionBad(int,Object), 3, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void Recursion.recursionBad(int,Object),call to void InferTaint.inferSensitiveSink(Object)] codetoanalyze/java/quandary/Recursion.java, void Recursion.safeRecursionCallSinkBad(), 1, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void Recursion.safeRecursionCallSink(int,Object),call to void InferTaint.inferSensitiveSink(Object)]