public override string GetExplanation(Mx tConcrete)
        {
            string domain = tConcrete.DomainSpec?.Domain ?? "this domain";

            return(string.Format(SpfExplainerResource.MxExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier), domain,
                                 tConcrete.DualCidrBlock.Ip4CidrBlock.Value.ToString() ?? "invalid", tConcrete.DualCidrBlock.Ip6CidrBlock.Value.ToString() ?? "invalid"));
        }
        public override string GetExplanation(A tConcrete)
        {
            string domain = tConcrete.Domain ?? "this domain";

            return(string.Format(SpfExplainerResource.AExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier), domain,
                                 tConcrete.Ip4Cidr?.ToString() ?? "invalid", tConcrete.Ip6Cidr?.ToString() ?? "invalid"));
        }
        public bool IsErrored(SpfRecord record, out Error error)
        {
            All all = record.Terms.OfType <All>().FirstOrDefault();

            if (all == null || all.Qualifier == Qualifier.Fail || all.Qualifier == Qualifier.SoftFail)
            {
                error = null;
                return(false);
            }

            string errorMessage = string.Format(SpfRulesResource.ShouldHaveHardFailAllEnabledErrorMessage,
                                                _qualifierExplainer.Explain(Qualifier.Fail, true), _qualifierExplainer.Explain(Qualifier.SoftFail, true),
                                                all.Value, _qualifierExplainer.Explain(all.Qualifier, true));

            error = new Error(ErrorType.Warning, errorMessage);
            return(true);
        }
Esempio n. 4
0
        public Task <List <Message> > Evaluate(SpfRecord record)
        {
            All all = record.Terms.OfType <All>().FirstOrDefault();

            List <Message> messages = new List <Message>();

            if (record.IsRoot &&
                all != null &&
                (all.Qualifier == Qualifier.Pass ||
                 all.Qualifier == Qualifier.Neutral ||
                 all.Qualifier == Qualifier.Unknown))
            {
                string failExplanation     = _qualifierExplainer.Explain(Qualifier.Fail, true);
                string softFailExplanation = _qualifierExplainer.Explain(Qualifier.SoftFail, true);
                string allExplanation      = _qualifierExplainer.Explain(all.Qualifier, true);

                string errorMessage = string.Format(SpfRulesResource.ShouldHaveHardFailAllEnabledErrorMessage, failExplanation, softFailExplanation, all.Value, allExplanation);
                string markDown     = string.Format(SpfRulesMarkDownResource.ShouldHaveHardFailAllEnabledErrorMessage, failExplanation, softFailExplanation, all.Value, allExplanation);

                messages.Add(new Message(Id, MessageSources.SpfEvaluator, MessageType.warning, errorMessage, markDown));
            }

            return(Task.FromResult(messages));
        }
Esempio n. 5
0
 public override string GetExplanation(All tConcrete)
 {
     return(string.Format(SpfExplainerResource.AllExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier)));
 }
Esempio n. 6
0
 public override string GetExplanation(Ip4 tConcrete)
 {
     return(string.Format(SpfExplainerResource.IpExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier),
                          tConcrete.IpAddress, tConcrete.CidrBlock.Value.ToString() ?? "invalid"));
 }
Esempio n. 7
0
 public override string GetExplanation(Exists tConcrete)
 {
     return(string.Format(SpfExplainerResource.ExistsExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier), tConcrete.Domain));
 }
Esempio n. 8
0
        public override string GetExplanation(Ptr tConcrete)
        {
            string domain = tConcrete.DomainSpec == null ? "this domain" : tConcrete.DomainSpec.Domain;

            return($"{_qualifierExplainer.Explain(tConcrete.Qualifier)} ip addresses mentioned in PTR record for {domain}.");
        }
 public override string GetExplanation(Ip6 tConcrete)
 {
     return(string.Format(SpfExplainerResource.IpExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier),
                          tConcrete.Ip, tConcrete.Ip6Cidr?.ToString() ?? "invalid"));
 }
 public override string GetExplanation(Include tConcrete)
 {
     return(string.Format(SpfExplainerResource.IncludeExplanation, _qualifierExplainer.Explain(tConcrete.Qualifier), tConcrete.DomainSpec.Domain));
 }