/** * Checks whether there is a path between the given source and sink. * * @param sink The sink to which there may be a path * @param source The source from which there may be a path * @return True if there is a path between the given source and sink, false otherwise */ public boolean isPathBetween(String sink, String source) { for (SinkInfo si : this.results.keySet()) if (si.getSink().toString().equals(sink)) { Set<SourceInfo> sources = this.results.get(si); for (SourceInfo src : sources) if (src.source.toString().equals(source)) return true; } return false; }
/** * Finds the entry for a sink method with the given signature * * @param sinkSignature The sink's method signature to look for * @return The key of the entry with the given method signature if such an entry has been found, * otherwise null. */ private List<SinkInfo> findSinkByMethodSignature(String sinkSignature) { List<SinkInfo> sinkVals = new ArrayList<SinkInfo>(); for (SinkInfo si : this.results.keySet()) if (si.getSink() instanceof InvokeExpr) { InvokeExpr expr = (InvokeExpr) si.getSink(); if (expr.getMethod().getSignature().equals(sinkSignature)) sinkVals.add(si); } return sinkVals; }
/** * Checks whether there is a path between the given source and sink. * * @param sink The sink to which there may be a path * @param source The source from which there may be a path * @return True if there is a path between the given source and sink, false otherwise */ public boolean isPathBetween(Value sink, Value source) { Set<SourceInfo> sources = null; for (SinkInfo sI : this.results.keySet()) { if (sI.getSink().equals(sink)) { sources = this.results.get(sI); break; } } if (sources == null) return false; for (SourceInfo src : sources) if (src.source.equals(source)) return true; return false; }
/** * Checks whether this result object contains a sink that exactly matches the given value. * * @param sink The sink to check for * @return True if this result contains the given value as a sink, otherwise false. */ public boolean containsSink(Value sink) { for (SinkInfo si : this.results.keySet()) if (si.getSink().equals(sink)) return true; return false; }