forked from Prelude-SIEM/prelude-correlator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
160 lines (135 loc) · 5.89 KB
/
setup.py
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env python
# Copyright (C) 2009-2017 CS-SI. All Rights Reserved.
# Author: Yoann Vandoorselaere <[email protected]>
#
# 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.
# flake8: noqa: E402 (ignore "module level import not at top of file" because of ez_setup)
import os
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.sdist import sdist
try:
import urllib.request as urlreq
except:
import urllib2 as urlreq
PRELUDE_CORRELATOR_VERSION = "4.1.0"
class my_sdist(sdist):
user_options = sdist.user_options + [('disabledl', None, "Disable the download of databases")]
disabledl = False
def _downloadDatabase(self, dname, url, filename):
print("Downloading %s database, this might take a while..." % (dname))
req = urlreq.Request(url)
req.add_header('User-agent', 'Mozilla 5.10')
r = urlreq.urlopen(req)
fd = open(filename, "w")
fd.write(r.read())
fd.close()
def __init__(self, *args, **kwargs):
fin = os.popen('git log --summary --stat --no-merges --date=short', 'r')
fout = open('ChangeLog', 'w')
fout.write(fin.read())
fout.close()
sdist.__init__(self, *args)
def run(self):
if self.disabledl:
print("Automatic downloading of databases is disabled.")
print("As a result, they won't be included in the generated source distribution.")
else:
self._downloadDatabase("DShield", "http://www.dshield.org/ipsascii.html?limit=10000", "rules/dshield.dat")
self._downloadDatabase("Spamhaus", "http://www.spamhaus.org/drop/drop.lasso", "rules/spamhaus_drop.dat")
self._downloadDatabase("CIArmy", "http://cinsscore.com/list/ci-badguys.txt", "rules/ciarmy.dat")
sdist.run(self)
class my_install(install):
def run(self):
for dirname, flist in self.distribution.data_files:
prefix = self.prefix
if self.prefix == "/usr":
prefix = os.sep
destdir = os.path.join(os.path.normpath((self.root or '') + prefix), dirname)
self.mkpath(destdir)
for f in flist:
dest = os.path.join(destdir, os.path.basename(f))
if dest[-4:] == "conf" and os.path.exists(dest):
dest += "-dist"
self.copy_file(f, destdir)
self.distribution.data_files = []
self.init_siteconfig(prefix)
install.run(self)
os.remove("preludecorrelator/siteconfig.py")
def init_siteconfig(self, prefix):
config = open("preludecorrelator/siteconfig.py", "w")
config.write("conf_dir = '%s'\n" % os.path.abspath(prefix + "/etc/prelude-correlator"))
config.write("lib_dir = '%s'\n" % os.path.abspath(prefix + "/var/lib/prelude-correlator"))
config.close()
setup(
name="prelude-correlator",
version=PRELUDE_CORRELATOR_VERSION,
maintainer="Prelude Team",
maintainer_email="[email protected]",
author="Yoann Vandoorselaere",
author_email="[email protected]",
license="GPL",
url="https://www.prelude-siem.org",
download_url="https://www.prelude-siem.org/projects/prelude/files",
description="Prelude-Correlator perform real time correlation of events received by Prelude",
long_description="""
Prelude-Correlator perform real time correlation of events received by Prelude.
Several isolated alerts, generated from different sensors, can thus
trigger a single CorrelationAlert should the events be related. This
CorrelationAlert then appears within the Prewikka interface and
indicates the potential target information via the set of correlation
rules.
Signature creation with Prelude-Correlator is based on the Python
programming language. Prelude's integrated correlation engine is
distributed with a default set of correlation rules, yet you still
have the opportunity to modify and create any correlation rule that
suits your needs.
""",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Security",
"Topic :: System :: Monitoring"
],
packages=find_packages(".", exclude=["rules"]),
entry_points={
'console_scripts': [
'prelude-correlator = preludecorrelator.main:main',
],
'preludecorrelator.plugins': [
]
},
package_data={},
data_files=[
("etc/prelude-correlator", ["prelude-correlator.conf"]),
("etc/prelude-correlator/conf.d", ['data/conf.d/README']),
("etc/prelude-correlator/rules/python", [os.path.join('rules', x) for x in os.listdir('rules') if x.endswith('.py')]),
("var/lib/prelude-correlator/prelude-correlator", [os.path.join('rules', x) for x in os.listdir('rules') if x.endswith('.dat')])
],
install_requires=["prelude >= 4.1.0"],
cmdclass={
'sdist': my_sdist,
'install': my_install
}
)