Esempio n. 1
0
        /// <summary>
        /// This method adds a check result to the list view.
        /// </summary>
        /// <param name="resultSeverity">The severity of the finding.</param>
        /// <param name="sessionId">The ID of the Fiddler Session where the finding was discovered.</param>
        /// <param name="sessionUrl">The URL where the finding was discovered.</param>
        /// <param name="checkName">The name of the check that performed the analysis.</param>
        /// <param name="resultDescription">The description of the finding.</param>
        /// <param name="compliesWith">Standards implemented by Watcher that this check conforms to.</param>
        /// <param name="count">The number of times the finding was discovered.</param>
        public void AddAlert(WatcherResultSeverity resultSeverity, int sessionId, String sessionUrl, String checkName, String resultDescription, WatcherCheckStandardsCompliance compliesWith, int count, String reflink)
        {
            AlertListViewItem alvi = null;

            int highincrement               = 0;
            int mediumincrement             = 0;
            int lowincrement                = 0;
            int informationalincrement      = 0;
            int highissueincrement          = 0;
            int mediumissueincrement        = 0;
            int lowissueincrement           = 0;
            int informationalissueincrement = 0;

            switch (resultSeverity)
            {
            case WatcherResultSeverity.High:
                alvi               = new AlertListViewItem(resultSeverity, sessionId, checkName, sessionUrl, resultDescription, count, reflink);
                alvi.ForeColor     = Color.Red;
                highissueincrement = count;
                highincrement++;
                break;

            case WatcherResultSeverity.Medium:
                alvi                 = new AlertListViewItem(resultSeverity, sessionId, checkName, sessionUrl, resultDescription, count, reflink);
                alvi.ForeColor       = Color.Orange;
                mediumissueincrement = count;
                mediumincrement++;
                break;

            case WatcherResultSeverity.Low:
                alvi              = new AlertListViewItem(resultSeverity, sessionId, checkName, sessionUrl, resultDescription, count, reflink);
                alvi.ForeColor    = Color.Blue;
                lowissueincrement = count;
                lowincrement++;
                break;

            case WatcherResultSeverity.Informational:
                alvi           = new AlertListViewItem(resultSeverity, sessionId, checkName, sessionUrl, resultDescription, count, reflink);
                alvi.ForeColor = Color.Green;
                informationalissueincrement = count;
                informationalincrement++;
                break;

            default:
                Debug.Assert(false, "Alert severity not specified.");
                break;
            }

            // Remove dupes
            // Testing if this is necessary
            for (int x = 0; x < this.alertListView.Items.Count; ++x)
            {
                AlertListViewItem tlvi = (AlertListViewItem)this.alertListView.Items[x];

                if (tlvi != null)
                {
                    if (tlvi.Equals(alvi))
                    {
                        return;
                    }
                }
            }

            // Update count after dealing with duplicates
            highcount           = highcount + highincrement;
            mediumcount         = mediumcount + mediumincrement;
            lowcount            = lowcount + lowincrement;
            informationalcount  = informationalcount + informationalincrement;
            highissues          = highissues + highissueincrement;
            mediumissues        = mediumissues + mediumissueincrement;
            lowissues           = lowissues + lowissueincrement;
            informationalissues = informationalissues + informationalissueincrement;
            total = total + informationalincrement + lowincrement + mediumincrement + highincrement;

            RenderCount();

            alvi.SubItems.Add(sessionId.ToString());
            alvi.SubItems.Add(checkName);
            alvi.SubItems.Add(sessionUrl);

            alerts.Add(alvi);

            if (this.noisereduction <= resultSeverity)
            {
                this.alertListView.BeginUpdate();
                this.alertListView.Items.Add(alvi);
                if (autoscroll)
                {
                    this.alertListView.EnsureVisible(alertListView.Items.Count - 1);
                }
                this.alertListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                this.alertListView.EndUpdate();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// This method indicates whether the specified compliance flag is supported by this check.
 /// </summary>
 /// <param name="e">The compliance flag to check.</param>
 /// <returns>True if the check complies with the specified flag; False otherwise.</returns>
 private Boolean IsCompliant(WatcherCheckStandardsCompliance e)
 {
     return((StandardsCompliance & e) == e);
 }
Esempio n. 3
0
 /// <summary>
 /// TODO: fixup documentation for this function.
 /// </summary>
 /// <param name="resultSeverity"></param>
 /// <param name="sessionId"></param>
 /// <param name="sessionUrl"></param>
 /// <param name="checkName"></param>
 /// <param name="resultDescription"></param>
 /// <param name="compliesWith"></param>
 /// <param name="num"></param>
 public void Add(WatcherResultSeverity resultSeverity, Int32 sessionId, String sessionUrl, String checkName, String resultDescription, WatcherCheckStandardsCompliance compliesWith, Int32 num)
 {
     Add(resultSeverity, sessionId, sessionUrl, checkName, resultDescription, compliesWith, num, String.Empty);
 }
Esempio n. 4
0
 /// <summary>
 /// This method retreives the user-visible, canonical description of the specified compliance flag from the resource file.
 /// </summary>
 /// <param name="e">The compliance flag to retrieve.</param>
 /// <returns>The canonical description of the specified standard.</returns>
 private String GetResourceComplianceString(WatcherCheckStandardsCompliance e)
 {
     return(Properties.Resources.ResourceManager.GetString(String.Format("WatcherCheckStandardsCompliance_{0}", e.ToString())));
 }
Esempio n. 5
0
        /// <summary>
        /// This method adds a result from a check to the UI result control.
        /// </summary>
        /// <param name="resultSeverity">The severity of the finding.</param>
        /// <param name="sessionId">The ID of the Fiddler Session where the finding was discovered.</param>
        /// <param name="sessionUrl">The URL where the finding was discovered.</param>
        /// <param name="checkName">The name of the check that performed the analysis.</param>
        /// <param name="resultDescription">The description of the finding.</param>
        /// <param name="compliesWith">Standards implemented by Watcher that this check conforms to.</param>
        /// <param name="count">The number of times the finding was discovered.</param>
        public void Add(WatcherResultSeverity resultSeverity, Int32 sessionId, String sessionUrl, String checkName, String resultDescription, WatcherCheckStandardsCompliance compliesWith, Int32 count, String refLink)
        {
            WatcherResultsControl control = WatcherEngine.UI.WatcherResultsControl;

            // A control cannot be updated from a non-UI thread.  If the InvokeRequired property is set,
            // we are on a non-UI thread and must post a message to the UI thread to handle the update on
            // our behalf.  According to Richter, this is one of the few instances where BeginInvoke can
            // be called without a corresponding EndInvoke().
            if (control.InvokeRequired)
            {
                // We're not the UI thread: marshall an update to the control asynchronously
                control.BeginInvoke(new AddAlertCallback(control.AddAlert), new Object[] { resultSeverity, sessionId, sessionUrl, checkName, resultDescription, compliesWith, count, refLink });
            }
            else
            {
                // We're the UI thread, update the control directly
                control.AddAlert(resultSeverity, sessionId, sessionUrl, checkName, resultDescription, compliesWith, count, refLink);
            }
        }