[quandary] allow regexes in defining quandary sources/sinks in inferconfig

Reviewed By: mburman

Differential Revision: D4478418

fbshipit-source-id: c705b5c
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent 3ee349ee23
commit cc8ffd9d1e

@ -69,7 +69,7 @@ module SourceKind = struct
let procedure = class_name ^ "." ^ method_name in let procedure = class_name ^ "." ^ method_name in
IList.find_map_opt IList.find_map_opt
(fun (source_spec : QuandaryConfig.Source.t) -> (fun (source_spec : QuandaryConfig.Source.t) ->
if String.equal source_spec.procedure procedure if Str.string_match source_spec.procedure procedure 0
then Some (of_string source_spec.kind) then Some (of_string source_spec.kind)
else None) else None)
external_sources external_sources
@ -236,7 +236,7 @@ module SinkKind = struct
let procedure = class_name ^ "." ^ method_name in let procedure = class_name ^ "." ^ method_name in
IList.find_map_opt IList.find_map_opt
(fun (sink_spec : QuandaryConfig.Sink.t) -> (fun (sink_spec : QuandaryConfig.Sink.t) ->
if String.equal sink_spec.procedure procedure if Str.string_match sink_spec.procedure procedure 0
then then
let kind = of_string sink_spec.kind in let kind = of_string sink_spec.kind in
try try

@ -14,38 +14,32 @@ module F = Format
(** utilities for importing JSON specifications of sources/sinks into Quandary *) (** utilities for importing JSON specifications of sources/sinks into Quandary *)
module Source = struct module Source = struct
type t = { procedure : string; kind : string; } type t = { procedure : Str.regexp; kind : string; }
let of_json = function let of_json = function
| `List sources -> | `List sources ->
let parse_source json = let parse_source json =
let open Yojson.Basic.Util in let open Yojson.Basic.Util in
let procedure = json |> member "procedure" |> to_string in let procedure = json |> member "procedure" |> to_string |> Str.regexp in
let kind = json |> member "kind" |> to_string in let kind = json |> member "kind" |> to_string in
{ procedure; kind; } in { procedure; kind; } in
IList.map parse_source sources IList.map parse_source sources
| _ -> | _ ->
[] []
let pp fmt { procedure; kind; } =
F.fprintf fmt "Procedure: %s Kind: %s" procedure kind
end end
module Sink = struct module Sink = struct
type t = { procedure : string; kind : string; index : string} type t = { procedure : Str.regexp; kind : string; index : string}
let of_json = function let of_json = function
| `List sinks -> | `List sinks ->
let parse_sink json = let parse_sink json =
let open Yojson.Basic.Util in let open Yojson.Basic.Util in
let procedure = json |> member "procedure" |> to_string in let procedure = json |> member "procedure" |> to_string |> Str.regexp in
let kind = json |> member "kind" |> to_string in let kind = json |> member "kind" |> to_string in
let index = json |> member "index" |> to_string in let index = json |> member "index" |> to_string in
{ procedure; kind; index; } in { procedure; kind; index; } in
IList.map parse_sink sinks IList.map parse_sink sinks
| _ -> | _ ->
[] []
let pp fmt { procedure; kind; index; } =
F.fprintf fmt "Procedure: %s Kind: %s Index %s" procedure kind index
end end

@ -12,17 +12,13 @@ open! IStd
(** utilities for importing JSON specifications of sources/sinks into Quandary*) (** utilities for importing JSON specifications of sources/sinks into Quandary*)
module Source : sig module Source : sig
type t = { procedure : string; kind : string; } type t = { procedure : Str.regexp; kind : string; }
val of_json : [> `List of Yojson.Basic.json list ] -> t list val of_json : [> `List of Yojson.Basic.json list ] -> t list
val pp : Format.formatter -> t -> unit
end end
module Sink : sig module Sink : sig
type t = { procedure : string; kind : string; index : string; } type t = { procedure : Str.regexp; kind : string; index : string; }
val of_json : [> `List of Yojson.Basic.json list ] -> t list val of_json : [> `List of Yojson.Basic.json list ] -> t list
val pp : Format.formatter -> t -> unit
end end

@ -1,7 +1,7 @@
{ {
"quandary-sources": [ "quandary-sources": [
{ {
"procedure": "codetoanalyze.java.quandary.ExternalSpecs.privateDataSource", "procedure": "codetoanalyze.java.quandary.ExternalSpecs.privateData*",
"kind": "PrivateData" "kind": "PrivateData"
} }
], ],

Loading…
Cancel
Save