Coverage Report

Created: 2026-04-27 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest.c
Line
Count
Source
1
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
2
 */
3
4
/* Extensions spamtest, spamtestplus and virustest
5
 * -----------------------------------------------
6
 *
7
 * Authors: Stephan Bosch
8
 * Specification: RFC 5235
9
 * Implementation: full
10
 * Status: testing
11
 *
12
 */
13
14
#include "lib.h"
15
#include "array.h"
16
17
#include "sieve-common.h"
18
19
#include "sieve-extensions.h"
20
#include "sieve-commands.h"
21
22
#include "sieve-validator.h"
23
24
#include "ext-spamvirustest-common.h"
25
26
/*
27
 * Extensions
28
 */
29
30
/* Spamtest */
31
32
static bool ext_spamvirustest_validator_load
33
(const struct sieve_extension *ext, struct sieve_validator *validator);
34
35
const struct sieve_extension_def spamtest_extension = {
36
  .name = "spamtest",
37
  .load = ext_spamvirustest_load,
38
  .unload = ext_spamvirustest_unload,
39
  .validator_load = ext_spamvirustest_validator_load,
40
  SIEVE_EXT_DEFINE_OPERATION(spamtest_operation)
41
};
42
43
const struct sieve_extension_def spamtestplus_extension = {
44
  .name = "spamtestplus",
45
  .load = ext_spamvirustest_load,
46
  .unload = ext_spamvirustest_unload,
47
  .validator_load = ext_spamvirustest_validator_load,
48
  SIEVE_EXT_DEFINE_OPERATION(spamtest_operation)
49
};
50
51
const struct sieve_extension_def virustest_extension = {
52
  .name = "virustest",
53
  .load = ext_spamvirustest_load,
54
  .unload = ext_spamvirustest_unload,
55
  .validator_load = ext_spamvirustest_validator_load,
56
  SIEVE_EXT_DEFINE_OPERATION(virustest_operation)
57
};
58
59
/*
60
 * Implementation
61
 */
62
63
static bool ext_spamtest_validator_check_conflict
64
  (const struct sieve_extension *ext,
65
    struct sieve_validator *valdtr, void *context,
66
    struct sieve_ast_argument *require_arg,
67
    const struct sieve_extension *ext_other,
68
    bool required);
69
70
const struct sieve_validator_extension spamtest_validator_extension = {
71
  .ext = &spamtest_extension,
72
  .check_conflict = ext_spamtest_validator_check_conflict
73
};
74
75
static bool ext_spamvirustest_validator_load
76
(const struct sieve_extension *ext, struct sieve_validator *valdtr)
77
0
{
78
  /* Register new test */
79
80
0
  if ( sieve_extension_is(ext, virustest_extension) ) {
81
0
    sieve_validator_register_command(valdtr, ext, &virustest_test);
82
0
  } else {
83
0
    if ( sieve_extension_is(ext, spamtest_extension) ) {
84
      /* Register validator extension to warn for duplicate */
85
0
      sieve_validator_extension_register
86
0
        (valdtr, ext, &spamtest_validator_extension, NULL);
87
0
    }
88
89
0
    sieve_validator_register_command(valdtr, ext, &spamtest_test);
90
0
  }
91
92
0
  return TRUE;
93
0
}
94
95
static bool ext_spamtest_validator_check_conflict
96
(const struct sieve_extension *ext ATTR_UNUSED,
97
  struct sieve_validator *valdtr, void *context ATTR_UNUSED,
98
  struct sieve_ast_argument *require_arg,
99
  const struct sieve_extension *ext_other,
100
  bool required ATTR_UNUSED)
101
0
{
102
0
  if ( sieve_extension_name_is(ext_other, "spamtestplus") ) {
103
0
    sieve_argument_validate_warning(valdtr, require_arg,
104
0
      "the spamtest and spamtestplus extensions should "
105
0
      "not be specified at the same time");
106
0
  }
107
108
0
  return TRUE;
109
0
}
110
111