LCOV - code coverage report
Current view: top level - source3/modules - vfs_virusfilter_dummy.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 12 13 92.3 %
Date: 2024-04-21 15:09:00 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Samba-VirusFilter VFS modules
       3             :    Dummy scanner with infected files support.
       4             :    Copyright (C) 2022 Pavel Filipenský <pfilipen@redhat.com>
       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, see <http://www.gnu.org/licenses/>.
      18             : */
      19             : 
      20             : #include "modules/vfs_virusfilter_utils.h"
      21             : 
      22           4 : static virusfilter_result virusfilter_dummy_scan(
      23             :         struct vfs_handle_struct *handle,
      24             :         struct virusfilter_config *config,
      25             :         const struct files_struct *fsp,
      26             :         char **reportp)
      27             : {
      28             :         bool ok;
      29             : 
      30           4 :         DBG_INFO("Scanning file: %s\n", fsp_str_dbg(fsp));
      31           4 :         ok = is_in_path(fsp->fsp_name->base_name,
      32             :                         config->infected_files,
      33             :                         false);
      34           4 :         return ok ? VIRUSFILTER_RESULT_INFECTED : VIRUSFILTER_RESULT_CLEAN;
      35             : }
      36             : 
      37             : static struct virusfilter_backend_fns virusfilter_backend_dummy = {
      38             :         .connect = NULL,
      39             :         .disconnect = NULL,
      40             :         .scan_init = NULL,
      41             :         .scan = virusfilter_dummy_scan,
      42             :         .scan_end = NULL,
      43             : };
      44             : 
      45           4 : int virusfilter_dummy_init(struct virusfilter_config *config)
      46             : {
      47           4 :         struct virusfilter_backend *backend = NULL;
      48             : 
      49           4 :         backend = talloc_zero(config, struct virusfilter_backend);
      50           4 :         if (backend == NULL) {
      51           0 :                 return -1;
      52             :         }
      53             : 
      54           4 :         backend->fns = &virusfilter_backend_dummy;
      55           4 :         backend->name = "dummy";
      56           4 :         config->backend = backend;
      57           4 :         return 0;
      58             : }

Generated by: LCOV version 1.14