-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge-breaches.js
More file actions
80 lines (63 loc) · 3.14 KB
/
Copy pathmerge-breaches.js
File metadata and controls
80 lines (63 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const fs = require('fs');
const path = require('path');
const dataPath = 'source/_data/breaches.json';
const secondaryPath = 'source/data/breaches.json';
if (!fs.existsSync(dataPath)) {
console.log("Fichier non trouvé:", dataPath);
process.exit(1);
}
const data = JSON.parse(fs.readFileSync(dataPath, 'utf8'));
let breaches = data.breaches;
// Paires de fusion (Garder le nom, supprimer l'autre)
// Note: Les indices peuvent changer, donc on utilise le nom exact
const pairs = [
{ keep: "BreachForums (2025)", remove: "BreachForums2025" },
{ keep: "France Travail (Missions Locales / Jeunes)", remove: "france travail fuite du 2025-12-1" },
{ keep: "France Travail (Dump #3)", remove: "france travail fuite du 2025-10-6" },
{ keep: "France Travail (Dump #2)", remove: "france travail fuite du 2025-9-25" },
{ keep: "Canada Goose", remove: "CanadaGoose" },
{ keep: "E-Pal", remove: "EPal" },
{ keep: "AbuseWith.us", remove: "AbuseWithUs" },
{ keep: "KM.RU", remove: "KMRU" },
{ keep: "Fédération Française de Basket-Ball", remove: "fédération française de basketball" }
];
console.log('--- Début de la fusion des doublons ---');
const toRemove = new Set();
pairs.forEach(pair => {
const target = breaches.find(b => b && b.Name === pair.keep);
const source = breaches.find(b => b && b.Name === pair.remove);
if (target && source) {
console.log(`Fusion de '${pair.remove}' vers '${pair.keep}'...`);
// Fusion intelligente
target.PwnCount = Math.max(target.PwnCount || 0, source.PwnCount || 0);
target.Description = target.Description || source.Description;
target.Attribution = target.Attribution || source.Attribution;
target.LogoPath = target.LogoPath || source.LogoPath;
target.Domain = target.Domain || source.Domain;
// Fusion des DataClasses
const mergedDataClasses = new Set([...(target.DataClasses || []), ...(source.DataClasses || [])]);
target.DataClasses = Array.from(mergedDataClasses);
// Fusion des catégories
const mergedCategories = new Set([...(target.categories || []), ...(source.categories || [])]);
target.categories = Array.from(mergedCategories);
if (source.lien && !target.lien) target.lien = source.lien;
if (source.source && !target.source) target.source = source.source;
// Marquer pour suppression
toRemove.add(source.Name);
} else {
console.log(`[!] Paire non trouvée: '${pair.keep}' (${!!target}) ou '${pair.remove}' (${!!source})`);
}
});
// Nettoyage et recalcul des index
const initialLength = breaches.length;
data.breaches = breaches.filter(b => !toRemove.has(b.Name));
data.breaches.forEach((b, i) => { b.index = i; });
data.totalBreaches = data.breaches.length;
data.lastUpdated = new Date().toISOString();
console.log(`\nFusion terminée. ${initialLength - data.breaches.length} entrées supprimées.`);
// Sauvegarde
fs.writeFileSync(dataPath, JSON.stringify(data, null, 2));
if (fs.existsSync(secondaryPath)) {
fs.writeFileSync(secondaryPath, JSON.stringify(data, null, 2));
}
console.log('Fichiers mis à jour avec succès.');