aboutsummaryrefslogtreecommitdiffstats
path: root/src/msec/help_draksec.py
blob: 893b12b52f2c21f35267569299373fc79dbc28b7 (plain)
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
#!/usr/bin/python3
#
# This script creates DrakSec help strings from libmsec code docstrings.
#

import sys
import imp
import inspect
import re

import config
from libmsec import MSEC, Log

help_perl_file = 'help.pm'
help_python_file = 'help.py'
help_wiki_file = 'help.wiki'

header_perl = '''package security::help;
# !! THIS FILE WAS AUTO-GENERATED BY draksec_help.py !!
# !! DO NOT MODIFY HERE, MODIFY IN THE *MSEC* CVS !!

use strict;
use common;

our %help = (
'''

header_python = '''# libmsec documentation for python.

import gettext

# localization
try:
    gettext.install('msec')
except IOError:
    _ = str

HELP = {
'''

footer_perl = ''');
'''

header_wiki = '''The following functionality is supported by MSEC:
'''

footer_wiki = '''
'''

header_python = '''# libmsec documentation for python.

import gettext

# localization
try:
    gettext.install('msec')
except IOError:
    _ = str

HELP = {
'''

footer_python = '''}
'''

### strings used in the rewritting
function_str_perl = ''''%s' => N("%s"),
'''

function_str_python = '''
    '%s': _("%s"), '''

function_str_wiki = ''';%s: %s
'''

help_perl = open(help_perl_file, "w")
help_python = open(help_python_file, "w")
help_wiki = open(help_wiki_file, "w")

# process all configuration parameters
log = Log(log_syslog=False, log_file=False)
msec = MSEC(log, plugins='plugins')

print(header_perl, file=help_perl)
print(header_python, file=help_python)
print(header_wiki, file=help_wiki)

for variable in config.SETTINGS:
    callback, params = config.SETTINGS[variable]
    func = msec.get_action(callback)
    if func:
        print(function_str_perl % (variable, func.__doc__.strip()), file=help_perl)
        print(function_str_python % (variable, func.__doc__.strip()), file=help_python)
        print(function_str_wiki % (variable, func.__doc__.strip()), file=help_wiki)

print(footer_perl, file=help_perl)
print(footer_python, file=help_python)
print(footer_wiki, file=help_wiki)

# draksec_help.py ends here