Skip to content
API Documentation
BastionGuard™
LeakNormalizer Class Reference

#include <LeakNormalizer.hpp>

Static Public Member Functions

static LeakRecord::Severity maxSeverity (LeakRecord::Severity a, LeakRecord::Severity b)
static std::vector< LeakRecord > normalize (const std::vector< LeakRecord > &input)

Detailed Description

Definition at line 26 of file LeakNormalizer.hpp.

Member Function Documentation

◆ maxSeverity()

LeakRecord::Severity LeakNormalizer::maxSeverity ( LeakRecord::Severity a,
LeakRecord::Severity b )
static

Definition at line 26 of file LeakNormalizer.cpp.

29{
30 return (static_cast<int>(a) > static_cast<int>(b)) ? a : b;
31}

Referenced by normalize().

◆ normalize()

std::vector< LeakRecord > LeakNormalizer::normalize ( const std::vector< LeakRecord > & input)
static

Definition at line 34 of file LeakNormalizer.cpp.

35{
36 std::vector<LeakRecord> out;
37
38 for (const auto& rec : input) {
39 auto it = std::find_if(
40 out.begin(), out.end(),
41 [&](const LeakRecord& r) {
42 return r.breachName == rec.breachName;
43 });
44
45 if (it == out.end()) {
46 out.push_back(rec);
47 } else {
48 it->severity = maxSeverity(it->severity, rec.severity);
49
50 it->dataClasses.insert(
51 it->dataClasses.end(),
52 rec.dataClasses.begin(),
53 rec.dataClasses.end()
54 );
55 }
56 }
57
58 return out;
59}
static LeakRecord::Severity maxSeverity(LeakRecord::Severity a, LeakRecord::Severity b)

References maxSeverity().

Referenced by LeakAggregator::queryAll().


The documentation for this class was generated from the following files: