Skip to content

Commit ed82d93

Browse files
grievejiafacebook-github-bot
authored andcommitted
Add new analyze command (3/4) -- static analysis configuration
Reviewed By: dkgi Differential Revision: D30466703 fbshipit-source-id: beeaf906352463868a5dfe5e2cd9d4ef9e642d85
1 parent 72c30a7 commit ed82d93

File tree

1 file changed

+104
-3
lines changed

1 file changed

+104
-3
lines changed

source/command/newAnalyzeCommand.ml

Lines changed: 104 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,112 @@ module AnalyzeConfiguration = struct
8181
| Undefined (message, _) ->
8282
Result.Error message
8383
| other_exception -> Result.Error (Exn.to_string other_exception)
84+
85+
86+
let analysis_configuration_of
87+
{
88+
base =
89+
{
90+
NewCommandStartup.BaseConfiguration.source_paths;
91+
search_paths;
92+
excludes;
93+
checked_directory_allowlist;
94+
checked_directory_blocklist;
95+
extensions;
96+
log_path;
97+
global_root;
98+
local_root;
99+
debug;
100+
python_version = { Configuration.PythonVersion.major; minor; micro };
101+
parallel;
102+
number_of_workers;
103+
shared_memory =
104+
{ Configuration.SharedMemory.heap_size; dependency_table_power; hash_table_power };
105+
remote_logging = _;
106+
profiling_output = _;
107+
memory_profiling_output = _;
108+
};
109+
dump_call_graph;
110+
dump_model_query_results;
111+
find_missing_flows;
112+
maximum_tito_depth;
113+
maximum_trace_length;
114+
no_verify;
115+
rule_filter;
116+
save_results_to;
117+
strict;
118+
taint_model_paths;
119+
use_cache;
120+
inline_decorators = _;
121+
repository_root = _;
122+
}
123+
=
124+
let source_path =
125+
match source_paths with
126+
| Configuration.SourcePaths.Simple source_paths -> source_paths
127+
| Buck { Configuration.Buck.artifact_root; _ } -> [SearchPath.Root artifact_root]
128+
in
129+
let configuration =
130+
Configuration.Analysis.create
131+
~parallel
132+
~analyze_external_sources:false
133+
~filter_directories:checked_directory_allowlist
134+
~ignore_all_errors:checked_directory_blocklist
135+
~number_of_workers
136+
~local_root:(Option.value local_root ~default:global_root)
137+
~project_root:global_root
138+
~search_path:(List.map search_paths ~f:SearchPath.normalize)
139+
~taint_model_paths
140+
~strict
141+
~debug
142+
~show_error_traces:false
143+
~excludes
144+
~extensions
145+
~incremental_style:Configuration.Analysis.FineGrained
146+
~include_hints:false
147+
~perform_autocompletion:false
148+
~log_directory:(Path.absolute log_path)
149+
~python_major_version:major
150+
~python_minor_version:minor
151+
~python_micro_version:micro
152+
~shared_memory_heap_size:heap_size
153+
~shared_memory_dependency_table_power:dependency_table_power
154+
~shared_memory_hash_table_power:hash_table_power
155+
~source_path
156+
()
157+
in
158+
{
159+
Configuration.StaticAnalysis.configuration;
160+
result_json_path = save_results_to;
161+
dump_call_graph;
162+
verify_models = not no_verify;
163+
rule_filter;
164+
find_missing_flows;
165+
dump_model_query_results;
166+
use_cache;
167+
maximum_trace_length;
168+
maximum_tito_depth;
169+
}
84170
end
85171

86-
let run_analyze _analyze_configuraiton =
87-
Log.warning "Coming soon...";
88-
Lwt.return ExitStatus.Ok
172+
let run_taint_analysis ~configuration:_ ~build_system:_ ~inline_decorators:_ ~repository_root:_ () =
173+
Log.warning "Coming soon..."
174+
175+
176+
let run_analyze analyze_configuration =
177+
let {
178+
AnalyzeConfiguration.base = { NewCommandStartup.BaseConfiguration.source_paths; _ };
179+
inline_decorators;
180+
repository_root;
181+
_;
182+
}
183+
=
184+
analyze_configuration
185+
in
186+
Newserver.BuildSystem.with_build_system source_paths ~f:(fun build_system ->
187+
let configuration = AnalyzeConfiguration.analysis_configuration_of analyze_configuration in
188+
run_taint_analysis ~configuration ~build_system ~inline_decorators ~repository_root ();
189+
Lwt.return ExitStatus.Ok)
89190

90191

91192
let run_analyze configuration_file =

0 commit comments

Comments
 (0)