diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index 5509cda5e..5b25474cc 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -511,7 +511,14 @@ and angelic_execution = "Angelic execution, where the analysis ignores errors caused by unknown procedure calls" and annotation_reachability = - CLOpt.mk_json ~long:"annotation-reachability" + CLOpt.mk_bool ~long:"annotation-reachability" ~in_help:CLOpt.[Analyze, manual_generic] + "the annotation reachability checker. Given a pair of source and sink annotation, e.g. \ + @PerformanceCritical and @Expensive, this checker will warn whenever some method annotated \ + with @PerformanceCritical calls, directly or indirectly, another method annotated with \ + @Expensive" + +and annotation_reachability_custom_pairs = + CLOpt.mk_json ~long:"annotation-reachability-custom-pairs" ~in_help:CLOpt.[Analyze, manual_java] "Specify custom sources/sink for the annotation reachability checker\n\ Example format: for custom annotations com.my.annotation.{Source1,Source2,Sink1}\n\ @@ -844,7 +851,7 @@ and enable_checks = and eradicate = CLOpt.mk_bool ~long:"eradicate" ~in_help:CLOpt.[Analyze, manual_generic] - "the eradicate checker for Java annotations" + "the eradicate @Nullable checker for Java annotations" and eradicate_condition_redundant = CLOpt.mk_bool ~long:"eradicate-condition-redundant" @@ -972,6 +979,12 @@ and icfg_dotty_outfile = "If set, specifies path where .dot file should be written, it overrides the path for all \ other options that would generate icfg file otherwise" +and immutable_cast = + CLOpt.mk_bool ~long:"immutable-cast" ~in_help:CLOpt.[Analyze, manual_generic] + "the detection of object cast from immutable type to mutable type. \ + For instance, it will detect cast from ImmutableList to List, ImmutableMap to Map, \ + and ImmutableSet to Set." + and infer_cache = CLOpt.mk_path_opt ~deprecated:["infer_cache"; "-infer_cache"] ~long:"infer-cache" ~meta:"dir" "Select a directory to contain the infer cache (Buck and Java only)" @@ -1139,6 +1152,12 @@ and print_builtins = CLOpt.mk_bool ~deprecated:["print_builtins"] ~long:"print-builtins" "Print the builtin functions and exit" +and printf_args = + CLOpt.mk_bool ~long:"printf-args" ~in_help:CLOpt.[Analyze, manual_generic] + "the detection of mismatch between the Java printf format strings and the argument types \ + For, example, this checker will warn about the type error in \ + `printf(\"Hello %d\", \"world\")`" + and print_using_diff = CLOpt.mk_bool ~deprecated_no:["noprintdiff"] ~long:"print-using-diff" ~default:true "Highlight the difference w.r.t. the previous prop when printing symbolic execution debug info" @@ -1656,6 +1675,7 @@ and analysis_suppress_errors_options = and analysis_stops = !analysis_stops and angelic_execution = !angelic_execution and annotation_reachability = !annotation_reachability +and annotation_reachability_custom_pairs = !annotation_reachability_custom_pairs and array_level = !array_level and ast_file = !ast_file and biabduction = !biabduction @@ -1724,6 +1744,7 @@ and frontend_debug = !frontend_debug and frontend_stats = !frontend_stats and headers = !headers and icfg_dotty_outfile = !icfg_dotty_outfile +and immutable_cast = !immutable_cast and infer_cache = !infer_cache and iphoneos_target_sdk_version = !iphoneos_target_sdk_version and issues_fields = !issues_fields @@ -1759,6 +1780,7 @@ and patterns_modeled_expensive = match patterns_modeled_expensive with (k,r) -> and per_procedure_parallelism = !per_procedure_parallelism and pmd_xml = !pmd_xml and precondition_stats = !precondition_stats +and printf_args = !printf_args and print_logs = !print_logs and print_builtins = !print_builtins and print_types = !print_types diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index a9ca83179..48342e183 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -166,7 +166,8 @@ val analysis_stops : bool val analysis_suppress_errors : analyzer -> string list val analyzer : analyzer val angelic_execution : bool -val annotation_reachability : Yojson.Basic.json +val annotation_reachability : bool +val annotation_reachability_custom_pairs : Yojson.Basic.json val array_level : int val ast_file : string option val biabduction : bool @@ -242,6 +243,7 @@ val frontend_stats : bool val generated_classes : string option val headers : bool val icfg_dotty_outfile : string option +val immutable_cast : bool val infer_cache : string option val iphoneos_target_sdk_version : string option val issues_fields : [`Issue_field_bug_class @@ -292,6 +294,7 @@ val print_logs : bool val print_builtins : bool val print_types : bool val print_using_diff : bool +val printf_args : bool val procedures_per_process : int val procs_csv : string option val procs_xml : string option diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index 0d01a4143..f2d3502f2 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -35,7 +35,7 @@ let src_snk_pairs = ([Annotations.no_allocation], dummy_constructor_annot) :: ([Annotations.any_thread; Annotations.for_non_ui_thread], Annotations.ui_thread) :: ([Annotations.ui_thread; Annotations.for_ui_thread], Annotations.for_non_ui_thread) :: - (parse_user_defined_specs Config.annotation_reachability) in + (parse_user_defined_specs Config.annotation_reachability_custom_pairs) in List.map ~f:(fun (src_annot_str_list, snk_annot_str) -> List.map ~f:annotation_of_str src_annot_str_list, annotation_of_str snk_annot_str) diff --git a/infer/src/checkers/registerCheckers.ml b/infer/src/checkers/registerCheckers.ml index a797425c2..e44d8cb89 100644 --- a/infer/src/checkers/registerCheckers.ml +++ b/infer/src/checkers/registerCheckers.ml @@ -31,10 +31,11 @@ let active_procedure_checkers () = Eradicate.callback_eradicate, Config.eradicate; BoundedCallTree.checker, Config.crashcontext; JavaTaintAnalysis.checker, Config.quandary || enabled_by_default; - ImmutableChecker.callback_check_immutable_cast, enabled_by_default; + ImmutableChecker.callback_check_immutable_cast, enabled_by_default + || Config.immutable_cast; RepeatedCallsChecker.callback_check_repeated_calls, Config.checkers_repeated_calls; - PrintfArgs.callback_printf_args, enabled_by_default; - AnnotationReachability.checker, enabled_by_default; + PrintfArgs.callback_printf_args, enabled_by_default || Config.printf_args; + AnnotationReachability.checker, enabled_by_default || Config.annotation_reachability; BufferOverrunChecker.checker, Config.bufferoverrun; ThreadSafety.analyze_procedure, enabled_by_default || Config.threadsafety; Interproc.analyze_procedure, Config.biabduction; diff --git a/infer/tests/codetoanalyze/java/checkers/.inferconfig b/infer/tests/codetoanalyze/java/checkers/.inferconfig index 74b6205eb..15e60379b 100644 --- a/infer/tests/codetoanalyze/java/checkers/.inferconfig +++ b/infer/tests/codetoanalyze/java/checkers/.inferconfig @@ -11,7 +11,7 @@ "method": "findViewById" } ], - "annotation-reachability": [ + "annotation-reachability-custom-pairs": [ { "sources": ["UserDefinedSource1", "UserDefinedSource2"], "sink": "UserDefinedSink"