Esempio n. 1
0
        public void HostEntry_Differences()
        {
            HostEntry a = new HostEntry("demo.de", "https");
            a.SetIP("1.1.1.1");
            a.SetRanking("C");
            a.SetFingerPrintCert("SHA1");
            a.SetExpirationDate(DateTime.Now.ToLongDateString());

            HostEntry b = new HostEntry("demo.de", "https");
            b.SetIP("1.1.1.2");
            b.SetRanking("C");
            b.SetFingerPrintCert("SHA1");
            b.SetExpirationDate(DateTime.Now.ToLongDateString());

            a.CheckDifferences(b);
            Assert.IsTrue(a.Differences.Count >= 2);
            Assert.IsTrue(a.HasDifference("IP"));
            Assert.IsTrue(a.HasDifference("URL"));
        }
Esempio n. 2
0
        /// <summary>
        /// Iterates through the whole list of parsed HostEntries and starts an analysis on each item.
        /// The current iteration will be saved into the _current object to make a callable outside this SSLAnalzer.
        /// After a single analysis is complete, a fresh HostEntry will be created with the information of the analysis.
        /// The differences between _current on the fresh HostEntry will be added to _current.
        /// If a stop signal is set from the outside, the analysis will be stopped.
        /// </summary>
        private void analyze()
        {
            for (int i=0; i < _entries.Count; i+=1)
            {
                _current = _entries[i];
                string url = string.Format("{0}://{1}", 
                    _current.Protocol.ToString().ToLower(), _current.URL);

                Analyze analyzed = _service.AutomaticAnalyze(url, 
                    Settings.Static.AnalyzerSettings.Publish, 
                    SSLLabsApiService.StartNew.On,
                    Settings.Static.AnalyzerSettings.FromCache, 
                    24, 
                    SSLLabsApiService.All.On,
                    Settings.Static.AnalyzerSettings.IgnoreMismatch, 
                    200, _waitInterval);

                HostEntry fresh = extractInfoFromAnalysis(analyzed, _current);
                if (fresh != null)
                {
                    _current.CheckDifferences(fresh);
                    _current = addMetaNotes(analyzed, _current);
                    fresh.AddCustomAttribute(_current.CustomAttributes);
                    _analyzedEntries.Add(fresh);
                }

                if (_stopSignal)
                {
                    _stopSignal = false;
                    break;
                }

                notify();
            }

            if (OnAnalyzeComplete != null) OnAnalyzeComplete();
        }