Basic global hash whitelist

This commit is contained in:
Sotirios Pupakis
2025-09-27 02:14:38 +02:00
parent bf3ea1bf62
commit ed9489b01a
5 changed files with 53 additions and 3 deletions

View File

@@ -73,10 +73,23 @@ func GetDuplicates(c *gin.Context) {
return
}
// Extract all hashes from source addon files
// Get all whitelisted hashes
var whitelistedHashes []string
if err := initializers.DB.Model(&models.WhitelistedHash{}).Pluck("hash", &whitelistedHashes).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch whitelisted hashes"})
return
}
// Create a map for faster lookup
whitelistMap := make(map[string]bool)
for _, hash := range whitelistedHashes {
whitelistMap[hash] = true
}
// Extract all hashes from source addon files, excluding whitelisted ones
var sourceHashes []string
for _, file := range sourceAddon.AddonFiles {
if file.Hash != "" {
if file.Hash != "" && !whitelistMap[file.Hash] {
sourceHashes = append(sourceHashes, file.Hash)
}
}