[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
IList.find_map_opt
(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)
else None)
external_sources
@ -236,7 +236,7 @@ module SinkKind = struct
let procedure = class_name ^ "." ^ method_name in
IList.find_map_opt
(fun (sink_spec : QuandaryConfig.Sink.t) ->
if String.equal sink_spec.procedure procedure
if Str.string_match sink_spec.procedure procedure 0
then
let kind = of_string sink_spec.kind in
try

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

@ -12,17 +12,13 @@ open! IStd
(** utilities for importing JSON specifications of sources/sinks into Quandary*)
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 pp : Format.formatter -> t -> unit
end
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 pp : Format.formatter -> t -> unit
end

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

Loading…
Cancel
Save