/// <summary> /// Initializer which sets environment for tests before analyzing /// </summary> /// <param name="outSet"></param> private static void initialize(FlowOutputSet outSet) { outSet.Snapshot.SetMode(SnapshotMode.InfoLevel); var POSTVar = outSet.GetVariable(new VariableIdentifier("_POST"), true); var POST = outSet.CreateInfo(true); POSTVar.WriteMemory(outSet.Snapshot, new MemoryEntry(POST)); POSTVar = outSet.GetVariable(new VariableIdentifier("_POST"), true); POST = outSet.CreateInfo(true); POSTVar.WriteMemory(outSet.Snapshot, new MemoryEntry(POST)); }
private void initTaintedVariable(FlowOutputSet outSet, String name) { outSet.Snapshot.SetMode(SnapshotMode.InfoLevel); var TaintedVar = outSet.GetVariable(new VariableIdentifier(name), true); var taint = new TaintInfo(); taint.taint = new Taint(true); taint.priority = new TaintPriority(true); taint.tainted = true; var Taint = outSet.CreateInfo(taint); //TaintedVar.WriteMemory(outSet.Snapshot, new MemoryEntry(Taint)); var entry = TaintedVar.ReadIndex(EntryInput.Snapshot, MemberIdentifier.getAnyMemberIdentifier()); entry.WriteMemory(EntryInput.Snapshot, new MemoryEntry(Taint)); /* * TaintedVar = outSet.GetVariable(new VariableIdentifier(name), true); * Taint = outSet.CreateInfo(taint); * * TaintedVar.WriteMemory(outSet.Snapshot, new MemoryEntry(Taint));*/ }
/// <inheritdoc /> public override void TryScopeStart(FlowOutputSet outSet, IEnumerable <CatchBlockDescription> catchBlockStarts) { var catchBlocks = outSet.GetControlVariable(new VariableName(".catchBlocks")); List <Value> result = new List <Value>(); foreach (var stack in catchBlocks.ReadMemory(outSet.Snapshot).PossibleValues) { result.Add(outSet.CreateInfo(new TryBlockStack((stack as InfoValue <TryBlockStack>).Data, catchBlockStarts))); } catchBlocks.WriteMemory(outSet.Snapshot, new MemoryEntry(result)); }
public override void TryScopeStart(FlowOutputSet outSet, IEnumerable <CatchBlockDescription> catchBlockStarts) { var blockStarts = new List <InfoValue>(); //NOTE this is only simple implementation without resolving try block stack foreach (var blockStart in catchBlockStarts) { var blockValue = outSet.CreateInfo(blockStart); blockStarts.Add(blockValue); } var catchBlocks = outSet.GetControlVariable(CatchBlocks_Storage); catchBlocks.WriteMemory(outSet.Snapshot, new MemoryEntry(blockStarts)); }
/// <inheritdoc /> public override void Catch(CatchPoint catchPoint, FlowOutputSet outSet) { if (catchPoint.CatchDescription.CatchedType.QualifiedName.Equals(new QualifiedName(new Name("")))) { return; } var catchBlocks = outSet.GetControlVariable(new VariableName(".catchBlocks")); var stack = new List <HashSet <CatchBlockDescription> >(); foreach (var value in catchBlocks.ReadMemory(outSet.Snapshot).PossibleValues) { if (stack.Count == 0) { for (int i = 0; i < (value as InfoValue <TryBlockStack>).Data.blocks.Count; i++) { stack.Add(new HashSet <CatchBlockDescription>()); } } for (int i = 0; i < (value as InfoValue <TryBlockStack>).Data.blocks.Count; i++) { foreach (var block in (value as InfoValue <TryBlockStack>).Data.blocks[i]) { stack[i].Add(block); } } } for (int i = stack.Count - 1; i >= 0; i--) { if (stack[i].Where(a => a.CatchedType.QualifiedName.Equals(catchPoint.CatchDescription.CatchedType.QualifiedName)).Count() > 0) { stack.RemoveLast(); break; } stack.RemoveLast(); } outSet.GetControlVariable(new VariableName(".catchBlocks")).WriteMemory(outSet.Snapshot, new MemoryEntry(outSet.CreateInfo(new TryBlockStack(stack)))); outSet.GetVariable(catchPoint.CatchDescription.CatchVariable).WriteMemory(outSet.Snapshot, catchPoint.ThrowedValue); }