Coverage Report

Created: 2025-11-16 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ntopng/include/host_alerts/FlowAnomalyAlert.h
Line
Count
Source
1
/*
2
 *
3
 * (C) 2013-24 - ntop.org
4
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software Foundation,
18
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
 *
20
 */
21
22
#ifndef _FLOW_ANOMALY_ALERT_H_
23
#define _FLOW_ANOMALY_ALERT_H_
24
25
#include "ntop_includes.h"
26
27
class FlowAnomalyAlert : public HostAlert {
28
 private:
29
  bool is_client_alert;
30
  u_int32_t value, lower_bound, upper_bound;
31
32
0
  ndpi_serializer* getAlertJSON(ndpi_serializer* serializer) {
33
0
    if (serializer == NULL) return NULL;
34
0
35
0
    ndpi_serialize_string_boolean(serializer, "is_client_alert",
36
0
                                  is_client_alert);
37
0
    ndpi_serialize_string_uint64(serializer, "value", value);
38
0
    ndpi_serialize_string_uint64(serializer, "lower_bound", lower_bound);
39
0
    ndpi_serialize_string_uint64(serializer, "upper_bound", upper_bound);
40
0
41
0
    return (serializer);
42
0
  }
43
44
 public:
45
  FlowAnomalyAlert(HostCheck* c, Host* h, risk_percentage cli_pctg,
46
                   u_int32_t _value, u_int32_t _lower_bound,
47
                   u_int32_t _upper_bound)
48
0
      : HostAlert(c, h, cli_pctg) {
49
0
    is_client_alert = cli_pctg != CLIENT_NO_RISK_PERCENTAGE;
50
0
    value = _value;
51
0
    lower_bound = _lower_bound;
52
0
    upper_bound = _upper_bound;
53
0
  }
54
0
  ~FlowAnomalyAlert(){};
55
56
0
  static HostAlertType getClassType() {
57
0
    return {host_alert_flows_anomaly, alert_category_network};
58
0
  }
59
0
  HostAlertType getAlertType() const { return getClassType(); }
60
0
  u_int8_t getAlertScore() const { return SCORE_LEVEL_WARNING; };
61
};
62
63
#endif /* _FLOW_ANOMALY_ALERT_H_ */