Example #1
0
        public string GetDigest(string uri, string method)
        {
            _nc++;

            var values = new Dictionary<string, string>(_values)
            {
                {"uri", uri},
                {"method", method},
                {"nc", _nc.ToString("00000000")},
            };

            var a1 = GetHash(GetKeys(values,
                "username", "realm", "password"));
            values.AddOrSet("a1", a1);

            var a2 = GetHash(GetKeys(
                values, "method", "uri"));
            values.AddOrSet("a2", a2);

            var response = GetHash(GetKeys(values,
                "a1", "nonce", "nc", "cnonce", "qop", "a2"));
            values.AddOrSet("response", response);

            return GetDigest(values,
                "username", "realm", "nonce", "uri",
                "response", "opaque", "qop", "nc", "cnonce");
        }
Example #2
0
        public void PrepareEvent(Dictionary<string, object> logEvent)
        {
            var key = _key.Format(logEvent);
            var value = _value.Format(logEvent);

            if (Overwrite)
            {
                logEvent[key] = value;
            }
            else
            {
                logEvent.AddOrSet(key, value);
            }
        }
Example #3
0
        internal static void GeInstalledNuGetPackages(PackageJson package, string requiredVersion, string minimumVersion, string maximumVersion, Dictionary<string, SoftwareIdentity> fastPackReftable, PackageSourceListRequest request)
        { 
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            request.Debug(Resources.Messages.DebugInfoCallMethod, Constants.ProviderName, string.Format(CultureInfo.InvariantCulture, "GeInstalledNuGetPackages' - name='{0}', requiredVersion='{1}',minimumVersion='{2}', maximumVersion='{3}'", package.Name, requiredVersion, minimumVersion, maximumVersion));

            //clone the request
            //nuget provider may not know the location of the package gets installed.
            //we need to pass around the destination path to nuget provider
            var installedRequest = PackageSourceListRequest.ExtendRequest(
                   new Dictionary<string, string[]> {
                        {"Destination", new[] { package.Destination ?? ""}}
                   }, null, package.IsTrustedSource, request);

            var provider = PackageSourceListRequest.FindProvider(request, package.Type, request);
            if (provider != null)
            {
                //calling NuGet provider
                var packagesInstalled = provider.GetInstalledPackages(package.Name, requiredVersion, minimumVersion, maximumVersion, installedRequest);
                if (packagesInstalled != null)
                {
                    foreach (var i in packagesInstalled)
                    {
                        request.Debug("Found an installed package '{0}.{1} from {2}' ", i.Name, i.Version, i.Source);
                        var info = PackageSourceListRequest.MakeFastPathComplex(i.Source, i.Name, "", i.Version, "");

                        fastPackReftable.AddOrSet(info, i);

                        // make it semver because in find-package we use semver
                        var version = i.Version.CompareVersion(package.Version) ? package.Version : i.Version;
                        request.YieldSoftwareIdentity(info, i.Name, version, i.VersionScheme, i.Summary, i.Source, i.SearchKey, i.FullPath, i.PackageFilename);

                    }
                }
            }
        }
Example #4
0
        protected void ScanMessage(Dictionary<string, object> logEvent, string input)
        {
            var match = _regex.Match(input);
            
            if (!match.Success)
            {
                logEvent.AddTag(FailedGrok);
            }

            foreach (var groupName in _groupNames)
            {
                var key = match.Groups[groupName];
                if (!key.Success) continue;

                if (Overwrite)
                {
                    logEvent[groupName] = key.Value;
                }
                else
                {
                    logEvent.AddOrSet(groupName, key.Value);
                }
            }
        }
Example #5
0
            public Cache(ImmutableList<Record> records)
            {
                if (records.IsEmpty)
                {
                    _observerRowsMap = ImmutableDictionary.Create<UniqueAddress, ImmutableDictionary<UniqueAddress, Record>>();
                    _allTerminated = ImmutableHashSet.Create<UniqueAddress>();
                    _allUnreachable = ImmutableHashSet.Create<UniqueAddress>();
                }
                else
                {
                    var mapBuilder = new Dictionary<UniqueAddress, ImmutableDictionary<UniqueAddress, Record>>();
                    var terminatedBuilder = ImmutableHashSet.CreateBuilder<UniqueAddress>();
                    var unreachableBuilder = ImmutableHashSet.CreateBuilder<UniqueAddress>();

                    foreach (var r in records)
                    {
                        ImmutableDictionary<UniqueAddress, Record> m;
                        if(mapBuilder.TryGetValue(r.Observer, out m))
                        {
                            m = m.SetItem(r.Subject, r);                            
                        }
                        else
                        {
                            //TODO: Other collections take items for Create. Create unnecessary array here
                            m = ImmutableDictionary.CreateRange(new[] { new KeyValuePair<UniqueAddress, Record>(r.Subject, r) });
                        }
                        mapBuilder.AddOrSet(r.Observer, m);

                        if (r.Status == ReachabilityStatus.Unreachable) unreachableBuilder.Add(r.Subject);
                        else if (r.Status == ReachabilityStatus.Terminated) terminatedBuilder.Add(r.Subject);
                    }

                    _observerRowsMap = ImmutableDictionary.CreateRange(mapBuilder);
                    _allTerminated = terminatedBuilder.ToImmutable();
                    _allUnreachable = unreachableBuilder.ToImmutable().Except(AllTerminated);
                }

                _allUnreachableOrTerminated = _allTerminated.IsEmpty
                    ? AllUnreachable
                    : AllUnreachable.Union(AllTerminated);
            }
        internal static void GeInstalledPowershellArtifacts(PackageJson package, string requiredVersion, string minimumVersion, string maximumVersion, Dictionary<string, SoftwareIdentity> fastPackReftable, PackageSourceListRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            request.Debug(Resources.Messages.DebugInfoCallMethod, Constants.ProviderName, string.Format(CultureInfo.InvariantCulture, "GeInstalledPowershellArtifacts' - name='{0}', requiredVersion='{1}',minimumVersion='{2}', maximumVersion='{3}'", package.Name, requiredVersion, minimumVersion, maximumVersion));

            var provider = PackageSourceListRequest.FindProvider(request, package.Type, request);
            if (provider == null) return;

            //calling the PowerShellGet provider
            request.Debug("Calling '{0}' provider to get installed packages '{1}.{2}'", provider.Name, package.Name, package.Version);

            var packagesInstalled = provider.GetInstalledPackages(package.Name, requiredVersion, minimumVersion, maximumVersion, request).ToArray();

            if (packagesInstalled == null || !packagesInstalled.Any())
            {
                request.Verbose(Resources.Messages.NumberOfPackagesRecevied, 0, provider.Name, "GetInstalledPackages");
                return;
            }          
            
            foreach (var i in packagesInstalled)
            {
                request.Debug("Found an installed package '{0}.{1} from {2}' ", i.Name, i.Version, i.Source);
                var info = PackageSourceListRequest.MakeFastPathComplex(i.Source, i.Name, "", i.Version, "");

                fastPackReftable.AddOrSet(info, i);

                // check if the installed version matches with the one specified in the PSL.json.
                // If so, we choose PSL.json.
                var version = i.Version.CompareVersion(package.Version) ? package.Version : i.Version;
                request.YieldSoftwareIdentity(info, i.Name, version, i.VersionScheme, i.Summary, i.Source, i.SearchKey, i.FullPath, i.PackageFilename);
            }                       
        }
Example #7
0
        private void ProcessValueAndStore(Dictionary<string, object> logEvent, string key, string value)
        {   
            if (Recursive)
            {
                var innerEvent = new Dictionary<string, object>();
                ScanMessage(innerEvent, value);

                if (innerEvent.Count > 0)
                {
                    logEvent.AddOrSet(key, innerEvent);
                    return;
                }
            }

            logEvent.AddOrSet(key, value);
        }
Example #8
0
        static void Main(string[] args)
        {
            var test = ConfigurationManager.GetSection("akka");
            var section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka");
            _clusterConfig = section.AkkaConfig;

            Console.WriteLine(_instructions);

            var backendNodes = new Dictionary<string, ActorSystem>();
            var frontendNodes = new Dictionary<string, ActorSystem>();

            while (true)
            {
                var line = Console.ReadLine();
                var command = line.Split(' ')[0];
                var arguments = line.Split(' ').Drop(1);
                var quit = false;
                var port = "0";
                if(arguments.Count() >= 0)
                    port = arguments.Head();

                switch (command)
                {
                    case "help":
                        Console.WriteLine(_instructions);
                        break;
                    case "quit":
                        quit = true;
                        break;
                    case "start-back":
                        if (backendNodes.ContainsKey(port))
                        {
                            backendNodes[port].AwaitTermination();
                        }
                        backendNodes.AddOrSet(port, LaunchBackend(port));
                        break;
                    case "start-front":
                        if (frontendNodes.ContainsKey(port))
                        {
                            frontendNodes[port].AwaitTermination();
                        }
                        frontendNodes.AddOrSet(port, LaunchFrontend(port));
                        break;
                    case "stop-back":
                        if (backendNodes.ContainsKey(port))
                        {
                            backendNodes[port].Shutdown();
                            backendNodes.Remove(port);
                        }
                        break;
                    case "stop-front":
                        if (frontendNodes.ContainsKey(port))
                        {
                            frontendNodes[port].Shutdown();
                            frontendNodes.Remove(port);
                        }
                        break;
                    case "stop-all":
                        backendNodes.Values.ForEach(node => node.Shutdown());
                        frontendNodes.Values.ForEach(node => node.Shutdown());

                        backendNodes = new Dictionary<string, ActorSystem>();
                        frontendNodes = new Dictionary<string, ActorSystem>();
                        break;
                    case "status":
                        ActorSystem statusNode = null;
                        if (backendNodes.ContainsKey(port))
                        {
                            statusNode = backendNodes[port];
                            Console.WriteLine("node on port {0} is of backend type", port);
                        }
                        else if (frontendNodes.ContainsKey(port))
                        {
                            statusNode = frontendNodes[port];
                            Console.WriteLine("node on port {0} is of frontend type", port);
                        }
                        if (statusNode == null)
                        {
                            Console.WriteLine("No node with such a port");
                        }
                        else
                        {
                            Console.WriteLine("Node - ActorSystem: {0}", statusNode);
                            Console.WriteLine("Name: {0}", statusNode.Name);
                        }
                        break;
                    default:
                        Console.WriteLine("Unknown instruction, type 'help' to display instructions");
                        break;
                }

                if (quit)
                    break;
            }

            backendNodes.Values.ForEach(node => node.Shutdown());
            frontendNodes.Values.ForEach(node => node.Shutdown());

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }