Coverage Report

Created: 2026-09-21 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zeek/src/conn_key/Manager.cc
Line
Count
Source
1
// See the file "COPYING" in the main distribution directory for copyright.
2
3
#include "zeek/conn_key/Manager.h"
4
5
#include "zeek/conn_key/Component.h"
6
7
using namespace zeek::conn_key;
8
9
66
Manager::Manager() : plugin::ComponentManager<zeek::conn_key::Component>("ConnKey", "Tag") {}
10
11
66
void Manager::InitPostScript() {
12
66
    const auto& factory_val = id::find_val<zeek::EnumVal>("ConnKey::factory");
13
66
    factory = InstantiateFactory(factory_val);
14
66
}
15
16
66
FactoryPtr Manager::InstantiateFactory(const zeek::EnumValPtr& tag) {
17
66
    Component* c = Lookup(tag);
18
19
66
    if ( ! c ) {
20
0
        reporter->FatalError(
21
0
            "request to instantiate unknown connection tuple factory %s, please review ConnTuple::factory value",
22
0
            tag->GetType()->AsEnumType()->Lookup(tag->Get()));
23
0
    }
24
25
66
    if ( ! c->Factory() ) {
26
0
        reporter->FatalError("factory %s cannot be instantiated dynamically", GetComponentName(tag).c_str());
27
0
    }
28
29
66
    FactoryPtr factory = c->Factory()();
30
31
66
    if ( ! factory ) {
32
0
        reporter->FatalError("factory instantiation failed");
33
0
    }
34
35
    // Could add validation of actual tag vs obtained one here, as we do e.g. in
36
    // the packet_analysis Manager.
37
38
66
    return factory;
39
66
}