Score as percentages

This commit is contained in:
nemunaire 2025-10-21 12:52:20 +07:00
commit 74aee54432
23 changed files with 1027 additions and 1488 deletions

View file

@ -238,29 +238,14 @@ func (r *RBLChecker) reverseIP(ipStr string) string {
return fmt.Sprintf("%d.%d.%d.%d", ipv4[3], ipv4[2], ipv4[1], ipv4[0])
}
// GetBlacklistScore calculates the blacklist contribution to deliverability (0-20 points)
// Scoring:
// - Not listed on any RBL: 20 points (excellent)
// - Listed on 1 RBL: 10 points (warning)
// - Listed on 2-3 RBLs: 5 points (poor)
// - Listed on 4+ RBLs: 0 points (critical)
func (r *RBLChecker) GetBlacklistScore(results *RBLResults) float32 {
// GetBlacklistScore calculates the blacklist contribution to deliverability
func (r *RBLChecker) GetBlacklistScore(results *RBLResults) int {
if results == nil || len(results.IPsChecked) == 0 {
// No IPs to check, give benefit of doubt
return 20.0
return 100
}
listedCount := results.ListedCount
if listedCount == 0 {
return 20.0
} else if listedCount == 1 {
return 10.0
} else if listedCount <= 3 {
return 5.0
}
return 0.0
return 100 - results.ListedCount*100/len(r.RBLs)
}
// GenerateRBLChecks generates check results for RBL analysis
@ -277,8 +262,8 @@ func (r *RBLChecker) GenerateRBLChecks(results *RBLResults) []api.Check {
Category: api.Blacklist,
Name: "RBL Check",
Status: api.CheckStatusWarn,
Score: 10.0,
Grade: ScoreToCheckGrade((10.0 / 20.0) * 100),
Score: 50,
Grade: ScoreToCheckGrade(50),
Message: "No public IP addresses found to check",
Severity: api.PtrTo(api.CheckSeverityLow),
Advice: api.PtrTo("Unable to extract sender IP from email headers"),
@ -310,7 +295,7 @@ func (r *RBLChecker) generateSummaryCheck(results *RBLResults) api.Check {
score := r.GetBlacklistScore(results)
check.Score = score
check.Grade = ScoreToCheckGrade((score / 20.0) * 100)
check.Grade = ScoreToCheckGrade(score)
totalChecks := len(results.Checks)
listedCount := results.ListedCount
@ -352,8 +337,8 @@ func (r *RBLChecker) generateListingCheck(rblCheck *RBLCheck) api.Check {
Category: api.Blacklist,
Name: fmt.Sprintf("RBL: %s", rblCheck.RBL),
Status: api.CheckStatusFail,
Score: 0.0,
Grade: ScoreToCheckGrade(0.0),
Score: 0,
Grade: ScoreToCheckGrade(0),
}
check.Message = fmt.Sprintf("IP %s is listed on %s", rblCheck.IP, rblCheck.RBL)