/usr/lib/python3/dist-packages/preludecorrelator/config.py is in prelude-correlator 4.1.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | # Copyright (C) 2009-2017 CS-SI. All Rights Reserved.
# Author: Yoann Vandoorselaere <yoann.v@prelude-ids.com>
#
# This file is part of the Prelude-Correlator program.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import os
import glob
from io import StringIO
try:
import configparser
except:
import ConfigParser as configparser
class Config(configparser.ConfigParser):
def __init__(self, filename):
configparser.ConfigParser.__init__(self, allow_no_value=True)
self.read(filename)
# Allow inclusion of additional configuration files in
# prelude-correlator.conf.
# These additional configuration files can be used by plugins.
if self.has_section('include'):
dataset = []
includes = self.items('include')
confdir = os.path.dirname(os.path.abspath(filename))
for fpattern, _dummy in includes:
fpattern = os.path.join(confdir, fpattern)
# Files are loaded in alphabetical order
for fname in sorted(glob.glob(fpattern)):
dataset.append(fname)
self.read(dataset)
def get(self, section, option, raw=None, vars=None, fallback=None, type=str):
try:
return type(configparser.ConfigParser.get(self, section, option, raw=raw, vars=vars))
except configparser.NoSectionError:
return fallback
except configparser.NoOptionError:
return fallback
def getAsBool(self, section, option, raw=None, vars=None, fallback=None):
b = self.get(section, option, raw, vars, fallback)
if type(b) is bool:
return b
b = b.strip().lower()
if b == "true" or b == "yes":
return True
return False
def read(self, filename):
if not isinstance(filename, list):
filename = [filename]
for fname in filename:
try:
f = open(fname, 'r')
except IOError:
continue
self.readfp(StringIO('[prelude]\n' + f.read()))
f.close()
|