Reviewed By: jberdine Differential Revision: D4448458 fbshipit-source-id: 5aa30c5master
parent
b1421bc27f
commit
5bddb1e548
@ -0,0 +1,32 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
module F = Format
|
||||||
|
|
||||||
|
(** utilities for importing JSON specifications of sources/sinks into Quandary*)
|
||||||
|
|
||||||
|
module Source = struct
|
||||||
|
type t = { procedure : string; 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 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
|
@ -0,0 +1,20 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) 2016 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
|
||||||
|
(** utilities for importing JSON specifications of sources/sinks into Quandary*)
|
||||||
|
|
||||||
|
module Source : sig
|
||||||
|
type t = { procedure : string; kind : string; }
|
||||||
|
|
||||||
|
val of_json : [> `List of Yojson.Basic.json list ] -> t list
|
||||||
|
|
||||||
|
val pp : Format.formatter -> t -> unit
|
||||||
|
end
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"quandary-sources": [
|
||||||
|
{
|
||||||
|
"procedure": "codetoanalyze.java.quandary.ExternalSpecs.privateDataSource",
|
||||||
|
"kind": "PrivateData"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the BSD style license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package codetoanalyze.java.quandary;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.facebook.infer.builtins.InferTaint;
|
||||||
|
|
||||||
|
/** Testing that sources and sinks specified in external JSON work correctly */
|
||||||
|
|
||||||
|
public class ExternalSpecs {
|
||||||
|
|
||||||
|
// we specify this as a source with kind PrivateData in .inferconfig
|
||||||
|
private static Object privateDataSource() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void logExternalSourceBad() {
|
||||||
|
Log.e("", (String) privateDataSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
// we specified that this is a private data source, so passing it an intent sink like
|
||||||
|
// startActivity() is fine
|
||||||
|
public static void externalSourceAsIntentOk(Activity activity) {
|
||||||
|
activity.startActivity((Intent) privateDataSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue