Skip to content

Commit 265277a

Browse files
committed
Adds intelmq-manager sources. Just copypasted.
1 parent 40a3518 commit 265277a

File tree

145 files changed

+101075
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+101075
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2020 IntelMQ Team
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
Alias /intelmq-manager /usr/share/intelmq_manager/html/
6+
7+
<Directory /usr/share/intelmq_manager/html>
8+
<IfModule mod_headers.c>
9+
Header set Content-Security-Policy "script-src 'self'"
10+
Header set X-Content-Security-Policy "script-src 'self'"
11+
</IfModule>
12+
Require all granted
13+
</Directory>

intelmq/app/webgui/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Python __init__ file that provides the path to the module
2+
3+
SPDX-FileCopyrightText: 2020 IntelMQ Team <intelmq-team@cert.at>
4+
SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
"""
7+
import pathlib
8+
from .version import __version__, __version_info__ # noqa
9+
10+
path = pathlib.Path(__file__).parent

intelmq/app/webgui/build.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
Build statically rendered files.
3+
4+
SPDX-FileCopyrightText: 2021 Birger Schacht <schacht@cert.at>, Mikk Margus Möll <mikk@cert.ee>, Sebastian Wagner <wagner@cert.at>
5+
SPDX-License-Identifier: AGPL-3.0-or-later
6+
"""
7+
import argparse
8+
import pathlib
9+
import shutil
10+
from mako.lookup import TemplateLookup
11+
12+
13+
def render_page(pagename: str, **template_args) -> str:
14+
template_dir = pathlib.Path(__file__).parent / 'templates'
15+
template_lookup = TemplateLookup(directories=[template_dir], default_filters=["h"], input_encoding='utf8')
16+
template = template_lookup.get_template(f'{pagename}.mako')
17+
18+
return template.render(pagename=pagename, **template_args)
19+
20+
21+
def buildhtml(outputdir: pathlib.Path = pathlib.Path('html')):
22+
outputdir.mkdir(parents=True, exist_ok=True)
23+
24+
htmlfiles = ["configs", "management", "monitor", "check", "about", "index"]
25+
for filename in htmlfiles:
26+
print(f"Rendering {filename}.html")
27+
html = render_page(filename)
28+
outputdir.joinpath(f"{filename}.html").write_text(html)
29+
30+
staticfiles = ["css", "images", "js", "plugins", "less"]
31+
for filename in staticfiles:
32+
print(f"Copying {filename} recursively")
33+
src = pathlib.Path(__file__).parent / 'static' / filename
34+
dst = outputdir / filename
35+
if dst.exists():
36+
shutil.rmtree(dst)
37+
shutil.copytree(src, dst)
38+
39+
print('rendering dynvar.js')
40+
rendered = render_page('dynvar', allowed_path='/opt/intelmq/var/lib/bots/', controller_cmd='intelmq')
41+
outputdir.joinpath('js/dynvar.js').write_text(rendered)
42+
43+
44+
def main():
45+
parser = argparse.ArgumentParser(
46+
prog='intelmq-manager-build',
47+
description='Build statically rendered files for intelmq-manager.',
48+
epilog='This command renders and saves all files required for IntelMQ Manager at the given directory, which can be served by Webservers statically',
49+
formatter_class=argparse.RawDescriptionHelpFormatter,
50+
)
51+
52+
parser.add_argument('--output-dir', '-o', default='html',
53+
type=pathlib.Path,
54+
help='The destination directory, will be created if needed.')
55+
args = parser.parse_args()
56+
buildhtml(outputdir=args.output_dir)
57+
58+
59+
if __name__ == '__main__':
60+
main()

intelmq/app/webgui/static/css/management.css

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

intelmq/app/webgui/static/css/management.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)