Beispiel #1
0
        public void Configuration(CommandLineApplication command)
        {
            command.Description = "Run a distance ruleset against the specified input file(s).";
            command.HelpOption("--|-help");
            var profileAssemblyOption = command.Option("-profile <PROFILENAME>", "Specifies assembly that contains a diagnostic profile.", CommandOptionType.MultipleValue);
            var parallelOption        = command.Option("-parallel <NUMBER>", "Sets the degree of parallelism when loading and decoding of input data (-1 means unlimited).", CommandOptionType.SingleValue);
            var decoderClassOption    = command.Option("-decoder <STRING>", "Sets the decoder to use for dissecting packets and load facts. Default is 'Shark'.", CommandOptionType.SingleValue);
            var inputFile             = command.Argument("InputPcapFile", "An input packet capture file to analyze.", false);
            var dumpRete = command.Option("-dumpRete <FILENAME>", "Writes the snapshot of RETE network to specified file using GEXF fileformat.", CommandOptionType.SingleValue);

            command.OnExecute(async() =>
            {
                if (!profileAssemblyOption.HasValue())
                {
                    throw new CommandParsingException(command, "Required options '-profile' is missing.");
                }
                var diagnosticProfileAssemblies = profileAssemblyOption.Values.Select(x => Assembly.LoadFrom(GetAssemblyPath(x))).ToArray();
                var analyzer = new CaptureAnalyzer(diagnosticProfileAssemblies);
                if (parallelOption.HasValue())
                {
                    analyzer.DegreeOfParallelism = Int32.Parse(parallelOption.Value());
                }
                if (dumpRete.HasValue())
                {
                    analyzer.DumpReteToFile(dumpRete.Value());
                }
                await analyzer.AnalyzeCaptureFile(inputFile.Value);
                return(0);
            });
        }
Beispiel #2
0
        public NestedFunctionData GatherNestedFunctions(AstNode node, IDictionary <IVariable, VariableData> allVariables)
        {
            var result = new StructureGatherer(_resolver).GatherNestedFunctions(node);

            var allNestedFunctions = new[] { result }.Concat(result.DirectlyOrIndirectlyNestedFunctions).ToDictionary(f => f.DefinitionNode);

            foreach (var v in allVariables)
            {
                allNestedFunctions[v.Value.DeclaringMethod].DirectlyDeclaredVariables.Add(v.Key);
            }

            var analyzer = new CaptureAnalyzer(_resolver);

            foreach (var f in allNestedFunctions.Values)
            {
                analyzer.Analyze(f.BodyNode);
                f.DirectlyUsesThis = analyzer.UsesThis;
                foreach (var v in analyzer.UsedVariables)
                {
                    f.DirectlyUsedVariables.Add(v);
                }
                f.Freeze();
            }

            return(result);
        }
Beispiel #3
0
            private static bool CanInline(Expression context, ParameterExpression parameter, Expression expression)
            {
                var fvs = FreeVariableScanner.Scan(expression).AsCollection();

                if (fvs.Count > 0)
                {
                    var ca = new CaptureAnalyzer(parameter, fvs);
                    ca.Visit(context);

                    return(!ca.HasCapture);
                }

                return(true);
            }
		public NestedFunctionData GatherNestedFunctions(AstNode node, IDictionary<IVariable, VariableData> allVariables) {
			var result = new StructureGatherer(_resolver).GatherNestedFunctions(node);

			var allNestedFunctions = new[] { result }.Concat(result.DirectlyOrIndirectlyNestedFunctions).ToDictionary(f => f.DefinitionNode);
			foreach (var v in allVariables) {
				allNestedFunctions[v.Value.DeclaringMethod].DirectlyDeclaredVariables.Add(v.Key);
			}

			var analyzer = new CaptureAnalyzer(_resolver);
			foreach (var f in allNestedFunctions.Values) {
				analyzer.Analyze(f.BodyNode);
				f.DirectlyUsesThis = analyzer.UsesThis;
				foreach (var v in analyzer.UsedVariables)
					f.DirectlyUsedVariables.Add(v);
				f.Freeze();
			}

			return result;
		}
Beispiel #5
0
 public void Setup()
 {
     analyzer = new CaptureAnalyzer(Assembly.GetAssembly(typeof(TlsCLientHello)));
 }
Beispiel #6
0
 public void Setup()
 {
     analyzer = new CaptureAnalyzer(Assembly.GetAssembly(typeof(IpPacket)));
 }