コード例 #1
0
        /// <summary>
        /// Gets DMARC failures summarized by message From header.
        /// </summary>
        /// <param name="aggregateReport"></param>
        /// <returns>IEnumerable of <see cref="FromHeaderSummary"/></returns>
        public static IEnumerable <FromHeaderSummary> SummarizeFailuresByHeaderFrom(this AggregateReport aggregateReport)
        {
            var failedRecords = aggregateReport.GetFailureRecords();

            return(failedRecords.GroupBy(r => r.Identifiers.HeaderFrom, r => r.Row.Count,
                                         (h, c) => new FromHeaderSummary {
                HeaderFrom = h, Count = c.Sum()
            }));
        }
コード例 #2
0
        /// <summary>
        /// Gets DMARC failures summarized by IpAddress
        /// </summary>
        /// <param name="aggregateReport"></param>
        /// <returns>IEnumerable of <see cref="SourceIpSummary"/></returns>
        public static IEnumerable <SourceIpSummary> SummarizeFailuresByIpAddress(this AggregateReport aggregateReport)
        {
            var failedRecords = aggregateReport.GetFailureRecords();

            return(failedRecords.GroupBy(r => r.Row.SourceIp, r => r.Row.Count,
                                         (s, c) => new SourceIpSummary {
                IpAddress = IPAddress.Parse(s), Count = c.Sum()
            }));
        }
コード例 #3
0
        public static RequestedReportingPolicy GetRequestedReportingPolicy(this AggregateReport aggregateReport)
        {
            var policy = RequestedReportingPolicy.All;

            if (aggregateReport.Feedback.PolicyPublished.Fo.Contains("1"))
            {
                policy |= RequestedReportingPolicy.Any;
            }

            if (aggregateReport.Feedback.PolicyPublished.Fo.Contains("d"))
            {
                policy |= RequestedReportingPolicy.Dkim;
            }

            if (aggregateReport.Feedback.PolicyPublished.Fo.Contains("s"))
            {
                policy |= RequestedReportingPolicy.Spf;
            }

            return(policy);
        }
コード例 #4
0
 /// <summary>
 /// Gets the total number of failures in this report.
 /// </summary>
 /// <param name="aggregateReport"></param>
 /// <returns>Count of failures.</returns>
 public static int GetFailureCount(this AggregateReport aggregateReport)
 {
     return(aggregateReport.GetFailureRecords().Sum(r => r.Row.Count));
 }
コード例 #5
0
 /// <summary>
 /// Gets the aggregate report records which did not pass DMARC.
 /// </summary>
 /// <param name="aggregateReport"></param>
 /// <returns>IEnumerable of <see cref="RecordType"/></returns>
 public static IEnumerable <RecordType> GetFailureRecords(this AggregateReport aggregateReport)
 {
     return(aggregateReport.Feedback.Record.Where(x =>
                                                  x.Row.PolicyEvaluated.Dkim == DMARCResultType.fail &&
                                                  x.Row.PolicyEvaluated.Spf == DMARCResultType.fail));
 }
コード例 #6
0
 /// <summary>
 /// Gets DMARC failures by the From header domain.
 /// </summary>
 /// <param name="aggregateReport"></param>
 /// <param name="fromHeader">The From header domain to target.</param>
 /// <returns>IEnumerable of <see cref="RecordType"/></returns>
 public static IEnumerable <RecordType> GetFailedRecordsByFromHeader(this AggregateReport aggregateReport,
                                                                     string fromHeader)
 {
     return(aggregateReport.Feedback.Record.Where(x => x.Identifiers.HeaderFrom == fromHeader));
 }
コード例 #7
0
 /// <summary>
 /// Gets DMARC failures by the source IP address
 /// </summary>
 /// <param name="aggregateReport"></param>
 /// <param name="address">The IP address to target</param>
 /// <returns>IEnumerable of <see cref="RecordType"/></returns>
 public static IEnumerable <RecordType> GetFailedRecordsByIpAddress(this AggregateReport aggregateReport, IPAddress address)
 {
     return(aggregateReport.Feedback.Record.Where(x => x.Row.SourceIp == address.ToString()));
 }