Incorporate DNSWL (whitelist) grade into blacklist scoring
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
CalculateScore now accepts a forWhitelist flag to handle whitelist scoring logic separately. The final blacklist grade combines both RBL and DNSWL results using MinGrade for a more accurate reputation assessment.
This commit is contained in:
parent
dfa38e8a26
commit
16b7dcb057
4 changed files with 20 additions and 5 deletions
|
|
@ -138,7 +138,7 @@ func (a *APIAdapter) CheckBlacklistIP(ip string) ([]api.BlacklistCheck, []api.Bl
|
|||
IPsChecked: []string{ip},
|
||||
ListedCount: listedCount,
|
||||
}
|
||||
score, grade := a.analyzer.generator.rblChecker.CalculateScore(results)
|
||||
score, grade := a.analyzer.generator.rblChecker.CalculateScore(results, false)
|
||||
|
||||
// Check the IP against all configured DNSWLs (informational only)
|
||||
whitelists, _, err := a.analyzer.generator.dnswlChecker.CheckIP(ip)
|
||||
|
|
|
|||
|
|
@ -300,7 +300,19 @@ func (r *DNSListChecker) reverseIP(ipStr string) string {
|
|||
|
||||
// CalculateScore calculates the list contribution to deliverability.
|
||||
// Informational lists are not counted in the score.
|
||||
func (r *DNSListChecker) CalculateScore(results *DNSListResults) (int, string) {
|
||||
func (r *DNSListChecker) CalculateScore(results *DNSListResults, forWhitelist bool) (int, string) {
|
||||
scoringListCount := len(r.Lists) - len(r.informationalSet)
|
||||
|
||||
if forWhitelist {
|
||||
if results.ListedCount >= scoringListCount {
|
||||
return 100, "A++"
|
||||
} else if results.ListedCount > 0 {
|
||||
return 100, "A+"
|
||||
} else {
|
||||
return 95, "A"
|
||||
}
|
||||
}
|
||||
|
||||
if results == nil || len(results.IPsChecked) == 0 {
|
||||
return 100, ""
|
||||
}
|
||||
|
|
@ -309,7 +321,6 @@ func (r *DNSListChecker) CalculateScore(results *DNSListResults) (int, string) {
|
|||
return 100, "A+"
|
||||
}
|
||||
|
||||
scoringListCount := len(r.Lists) - len(r.informationalSet)
|
||||
percentage := 100 - results.RelevantListedCount*100/scoringListCount
|
||||
return percentage, ScoreToGrade(percentage)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,8 +141,10 @@ func (r *ReportGenerator) GenerateReport(testID uuid.UUID, results *AnalysisResu
|
|||
|
||||
blacklistScore := 0
|
||||
var blacklistGrade string
|
||||
var whitelistGrade string
|
||||
if results.RBL != nil {
|
||||
blacklistScore, blacklistGrade = r.rblChecker.CalculateScore(results.RBL)
|
||||
blacklistScore, blacklistGrade = r.rblChecker.CalculateScore(results.RBL, false)
|
||||
_, whitelistGrade = r.dnswlChecker.CalculateScore(results.DNSWL, true)
|
||||
}
|
||||
|
||||
saScore, saGrade := r.spamAnalyzer.CalculateSpamAssassinScore(results.SpamAssassin)
|
||||
|
|
@ -173,7 +175,7 @@ func (r *ReportGenerator) GenerateReport(testID uuid.UUID, results *AnalysisResu
|
|||
AuthenticationScore: authScore,
|
||||
AuthenticationGrade: api.ScoreSummaryAuthenticationGrade(authGrade),
|
||||
BlacklistScore: blacklistScore,
|
||||
BlacklistGrade: api.ScoreSummaryBlacklistGrade(blacklistGrade),
|
||||
BlacklistGrade: api.ScoreSummaryBlacklistGrade(MinGrade(blacklistGrade, whitelistGrade)),
|
||||
ContentScore: contentScore,
|
||||
ContentGrade: api.ScoreSummaryContentGrade(contentGrade),
|
||||
HeaderScore: headerScore,
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ func ScoreToReportGrade(score int) api.ReportGrade {
|
|||
// gradeRank returns a numeric rank for a grade (lower = worse)
|
||||
func gradeRank(grade string) int {
|
||||
switch grade {
|
||||
case "A++":
|
||||
return 7
|
||||
case "A+":
|
||||
return 6
|
||||
case "A":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue