Summary: When extracting summaries, ask PulseFormula to work harder to prove that path-conditions are unsat. This reduces the number of false positives. Reviewed By: jvillard Differential Revision: D25270609 fbshipit-source-id: 61ef5e8acmaster
parent
3478a8828f
commit
f8aa139b88
@ -0,0 +1,13 @@
|
|||||||
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the MIT license found in the
|
||||||
|
# LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
|
TESTS_DIR = ../../../..
|
||||||
|
|
||||||
|
INFER_OPTIONS = --topl-properties Taint.topl --pulse-only
|
||||||
|
INFERPRINT_OPTIONS = --issues-tests
|
||||||
|
|
||||||
|
SOURCES = $(wildcard *.java)
|
||||||
|
|
||||||
|
include $(TESTS_DIR)/javac.make
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
abstract class Taint {
|
||||||
|
abstract String badString();
|
||||||
|
|
||||||
|
abstract void sendToDb(String arg);
|
||||||
|
|
||||||
|
void fOk() {
|
||||||
|
String s0 = badString();
|
||||||
|
String s1 = "foo";
|
||||||
|
if (s0 == s1) return; // Hint for Pulse.
|
||||||
|
sendToDb(s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fBad() {
|
||||||
|
String s0 = badString();
|
||||||
|
if (s0 == null) return;
|
||||||
|
String s1 = "foo" + s0 + "bar";
|
||||||
|
if (s1 == s0) return;
|
||||||
|
String s2 = "oops" + s1;
|
||||||
|
if (s2 == s1 || s2 == s0) return;
|
||||||
|
String s3 = s1 + s1;
|
||||||
|
if (s3 == s0 || s3 == s1 || s3 == s2) return;
|
||||||
|
sendToDb(s2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
property TaintTrack
|
||||||
|
prefix "StringBuilder"
|
||||||
|
prefix "Taint"
|
||||||
|
nondet (start building track)
|
||||||
|
|
||||||
|
// We start tracking when we see calls to Taint.badString
|
||||||
|
start -> start: *
|
||||||
|
start -> track: badString(IgnoreThis, Ret) => s := Ret
|
||||||
|
|
||||||
|
// Whatever we track, we'll keep tracking forever ...
|
||||||
|
track -> track: *
|
||||||
|
|
||||||
|
// ... but we also keep an eye for derived strings
|
||||||
|
track -> building: StringBuilder(Builder, Void) => b := Builder
|
||||||
|
building -> building: *
|
||||||
|
building -> dirty: append(Builder, S) when S == s
|
||||||
|
dirty -> track: toString(Builder, S) => s := S
|
||||||
|
|
||||||
|
// If anything we track is sent to Taint.sendToDb, we warn
|
||||||
|
track -> error: sendToDb(IgnoreThis, S, Void) when S == s
|
@ -0,0 +1 @@
|
|||||||
|
codetoanalyze/java/topl/taint/Taint.java, Taint.fBad():void, 0, TOPL_PULSE_ERROR, no_bucket, ERROR, [call to String Taint.badString(),call to StringBuilder.<init>(),call to StringBuilder StringBuilder.append(String),call to String StringBuilder.toString(),call to StringBuilder.<init>(),call to StringBuilder StringBuilder.append(String),call to String StringBuilder.toString(),call to void Taint.sendToDb(String)]
|
Loading…
Reference in new issue