12850.4.1
by j.c.sackett
Added audit-security.py script. |
1 |
#! /usr/bin/python -S
|
2 |
||
3 |
# Copyright 2011 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
6 |
"""Check that everything is alright in security.cfg
|
|
7 |
||
8 |
Usage hint:
|
|
9 |
||
10 |
% utilities/audit-security.py
|
|
11 |
"""
|
|
12850.4.2
by j.c.sackett
Functional auditing script; finds duplicate settings. |
12 |
__metatype__ = type |
12850.4.1
by j.c.sackett
Added audit-security.py script. |
13 |
|
14612.2.6
by William Grant
utilities |
14 |
import _pythonpath |
15 |
||
12850.4.1
by j.c.sackett
Added audit-security.py script. |
16 |
import os |
12907.2.1
by j.c.sackett
Broke out the auditor into its own file so it can be tested well, as it's going to get more complicated. |
17 |
|
12907.2.7
by j.c.sackett
Settings auditor. |
18 |
from lp.scripts.utilities.settingsauditor import SettingsAuditor |
12907.2.1
by j.c.sackett
Broke out the auditor into its own file so it can be tested well, as it's going to get more complicated. |
19 |
|
12850.4.6
by j.c.sackett
Renamed audit-security to audit-security-settings, since that's more accurate. |
20 |
|
12850.4.2
by j.c.sackett
Functional auditing script; finds duplicate settings. |
21 |
BRANCH_ROOT = os.path.split( |
22 |
os.path.dirname(os.path.abspath(__file__)))[0] |
|
23 |
SECURITY_PATH = os.path.join( |
|
24 |
BRANCH_ROOT, 'database', 'schema', 'security.cfg') |
|
25 |
||
12907.2.9
by j.c.sackett
Lint fixes. |
26 |
|
12907.2.7
by j.c.sackett
Settings auditor. |
27 |
def main(): |
28 |
data = file(SECURITY_PATH).read() |
|
29 |
auditor = SettingsAuditor(data) |
|
30 |
settings = auditor.audit() |
|
31 |
file(SECURITY_PATH, 'w').write(settings) |
|
12907.2.1
by j.c.sackett
Broke out the auditor into its own file so it can be tested well, as it's going to get more complicated. |
32 |
print auditor.error_data |
12850.4.2
by j.c.sackett
Functional auditing script; finds duplicate settings. |
33 |
|
34 |
if __name__ == '__main__': |
|
12907.2.1
by j.c.sackett
Broke out the auditor into its own file so it can be tested well, as it's going to get more complicated. |
35 |
main() |