You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

/*
* 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.
*/
package codetoanalyze.java.quandary;
import com.facebook.infer.builtins.InferTaint;
public class Recursion {
public static void divergeOk() {
divergeOk();
}
public static void callSinkThenDiverge(Object param) {
InferTaint.inferSensitiveSink(param);
callSinkThenDiverge(param);
}
public static void callSinkThenDivergeBad() {
callSinkThenDiverge(InferTaint.inferSecretSource());
}
public static void safeRecursionCallSink(int i, Object param) {
if (i == 0) return;
InferTaint.inferSensitiveSink(param);
safeRecursionCallSink(i - 1, param);
}
public static void safeRecursionCallSinkBad() {
safeRecursionCallSink(5, InferTaint.inferSecretSource());
}
// TODO (#16595757): Requires support for recursion in Ondemand
public static void FN_recursionBad(int i, Object param) {
if (i == 0) return;
InferTaint.inferSensitiveSink(param);
FN_recursionBad(i - 1, InferTaint.inferSecretSource());
}
}