@Override public SourceContext clone() { SourceContext sc = new SourceContext(definition, accessPath, stmt, userData); assert sc.equals(this); return sc; }
protected Abstraction(AccessPath apToTaint, SourceContext sourceContext, boolean exceptionThrown, boolean isImplicit) { this.sourceContext = sourceContext; this.accessPath = apToTaint; this.activationUnit = null; this.exceptionThrown = exceptionThrown; this.neighbors = null; this.isImplicit = isImplicit; this.currentStmt = sourceContext == null ? null : sourceContext.getStmt(); }
@Override public int hashCode() { if (this.hashCode != 0) return hashCode; final int prime = 31; int result = 1; // deliberately ignore prevAbs result = prime * result + ((sourceContext == null) ? 0 : sourceContext.hashCode()); result = prime * result + ((accessPath == null) ? 0 : accessPath.hashCode()); result = prime * result + ((activationUnit == null) ? 0 : activationUnit.hashCode()); result = prime * result + (exceptionThrown ? 1231 : 1237); result = prime * result + ((postdominators == null) ? 0 : postdominators.hashCode()); result = prime * result + (dependsOnCutAP ? 1231 : 1237); result = prime * result + (isImplicit ? 1231 : 1237); this.hashCode = result; return this.hashCode; }
/** * Checks whether the given abstraction is a source. If so, a result entry is * created. * * @param abs * The abstraction to check * @param scap * The path leading up to the current abstraction * @return True if the current abstraction is a source, otherwise false */ private boolean checkForSource(Abstraction abs, SourceContextAndPath scap) { if (abs.getPredecessor() != null) return false; // If we have no predecessors, this must be a source assert abs.getSourceContext() != null; assert abs.getNeighbors() == null; // Register the source that we have found SourceContext sourceContext = abs.getSourceContext(); results.addResult(scap.getDefinition(), scap.getAccessPath(), scap.getStmt(), sourceContext.getDefinition(), sourceContext.getAccessPath(), sourceContext.getStmt(), sourceContext.getUserData(), scap.getAbstractionPath()); return true; }
@Override protected boolean checkForSource(Abstraction abs, SourceContextAndPath scap) { // Record the abstraction visitedAbstractions.add(abs); // Source abstractions do not have predecessors if (abs.getPredecessor() != null) return false; // Save the abstraction path SummarySourceContextAndPath sscap = (SummarySourceContextAndPath) scap; SummarySourceInfo ssi = new SummarySourceInfo(abs.getSourceContext().getAccessPath(), abs.getSourceContext().getStmt(), abs.getSourceContext().getUserData(), sscap.getCurrentAccessPath(), sscap.getIsAlias(), !scap.isCallStackEmpty() || sscap.getDepth() != 0); ResultSinkInfo rsi = new ResultSinkInfo(null, scap.getAccessPath(), scap.getStmt()); this.resultInfos.add(new SummaryResultInfo(ssi, rsi)); return true; }
public Abstraction(SourceSinkDefinition definition, AccessPath sourceVal, Stmt sourceStmt, Object userData, boolean exceptionThrown, boolean isImplicit) { this(sourceVal, new SourceContext(definition, sourceVal, sourceStmt, userData), exceptionThrown, isImplicit); }
scap.curAP = abs.getSourceContext().getAccessPath(); scap.validate(); return scap;
public Abstraction injectSourceContext(SourceContext sourceContext) { if (this.sourceContext != null && this.sourceContext.equals(sourceContext)) return this; Abstraction abs = clone(); abs.predecessor = null; abs.neighbors = null; abs.sourceContext = sourceContext; abs.currentStmt = this.currentStmt; return abs; }
@Override public String toString() { return super.toString() + "\n\ton Path: " + getAbstractionPath(); } }
/** * Checks whether the given abstraction is a source. If so, a result entry is * created. * * @param abs The abstraction to check * @param scap The path leading up to the current abstraction * @return True if the current abstraction is a source, otherwise false */ protected boolean checkForSource(Abstraction abs, SourceContextAndPath scap) { if (abs.getPredecessor() != null) return false; // If we have no predecessors, this must be a source assert abs.getSourceContext() != null; // A source should normally never have neighbors, but it can happen // with ICCTA if (abs.getNeighbors() != null) { // we ignore this issue for now, because the neighbor's source // contexts seem to be equal to our own one } // Register the source that we have found SourceContext sourceContext = abs.getSourceContext(); Pair<ResultSourceInfo, ResultSinkInfo> newResult = results.addResult(scap.getDefinition(), scap.getAccessPath(), scap.getStmt(), sourceContext.getDefinition(), sourceContext.getAccessPath(), sourceContext.getStmt(), sourceContext.getUserData(), scap.getAbstractionPath()); // Notify our handlers if (resultAvailableHandlers != null) for (OnPathBuilderResultAvailable handler : resultAvailableHandlers) handler.onResultAvailable(newResult.getO1(), newResult.getO2()); return true; }
processFlowSource(flows, m, a.getAccessPath(), stmt, new SummarySourceInfo( a.getAccessPath(), a.getCurrentStmt(), a.getSourceContext().getUserData(), a.getAccessPath(), isAliasedField(a.getAccessPath(), a.getSourceContext().getAccessPath(), a.getSourceContext().getStmt()), false));
/** * Creates a continuation at a gap. A continuation is a new abstraction without * a predecessor that has the gap definition as its source. * * @param source * The source abstraction that flowed into the gap * @param accessPath * The new acces path that shall be tainted after the gap * @param gap * @param stmt * @return */ private Abstraction getContinuation(Abstraction source, AccessPath accessPath, GapDefinition gap, Stmt stmt) { // Make sure that we don't break anything Abstraction newOutAbs = source.clone().deriveNewAbstraction(accessPath, stmt); // Create the source information pointing to the gap. This may not be unique newOutAbs.setPredecessor(null); // If no longer have a predecessor, we must fake a source context newOutAbs.setSourceContext(new SourceContext(null, accessPath, stmt, getFlowSource(accessPath, stmt, gap))); return newOutAbs; }
if (other.sourceContext != null) return false; } else if (!sourceContext.equals(other.sourceContext)) return false; if (activationUnit == null) {
@Override public void run() { while (!abstractionQueue.isEmpty()) { // Terminate the thread when we run out of memory if (isKilled()) { abstractionQueue.clear(); return; } Abstraction abstraction = abstractionQueue.remove(0); if (abstraction.getSourceContext() != null) { // Register the result results.addResult(flagAbs.getSinkDefinition(), flagAbs.getAbstraction().getAccessPath(), flagAbs.getSinkStmt(), abstraction.getSourceContext().getDefinition(), abstraction.getSourceContext().getAccessPath(), abstraction.getSourceContext().getStmt(), abstraction.getSourceContext().getUserData(), null); // Sources may not have predecessors assert abstraction.getPredecessor() == null; } else if (abstraction.getPredecessor().registerPathFlag(taskId, numTasks)) abstractionQueue.add(abstraction.getPredecessor()); if (abstraction.getNeighbors() != null) for (Abstraction nb : abstraction.getNeighbors()) if (nb.registerPathFlag(taskId, numTasks)) abstractionQueue.add(nb); } } }
&& abs.getSourceContext().getStmt() == stmt) return false;
return super.equals(other);
@Override public int hashCode() { if (hashCode != 0) return hashCode; final int prime = 31; int result = super.hashCode(); if (!InfoflowConfiguration.getPathAgnosticResults()) result = prime * result + ((path == null) ? 0 : path.hashCode()); result = prime * result + ((callStack == null) ? 0 : callStack.hashCode()); this.hashCode = result; return hashCode; }
SourceContextAndPath sourceAndPath = new SourceContextAndPath(curAbs.getSourceContext().getDefinition(), curAbs.getSourceContext().getAccessPath(), curAbs.getSourceContext().getStmt(), curAbs.getSourceContext().getUserData()).extendPath(curAbs); cacheData.add(sourceAndPath);