├── .gitignore
├── LICENSE
├── README.md
├── ipa_log_config.py
└── pylintrc
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 |
5 | # C extensions
6 | *.so
7 |
8 | # Distribution / packaging
9 | .Python
10 | env/
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | *.egg-info/
23 | .installed.cfg
24 | *.egg
25 |
26 | # PyInstaller
27 | # Usually these files are written by a python script from a template
28 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
29 | *.manifest
30 | *.spec
31 |
32 | # Installer logs
33 | pip-log.txt
34 | pip-delete-this-directory.txt
35 |
36 | # Unit test / coverage reports
37 | htmlcov/
38 | .tox/
39 | .coverage
40 | .coverage.*
41 | .cache
42 | nosetests.xml
43 | coverage.xml
44 | *,cover
45 |
46 | # Translations
47 | *.mo
48 | *.pot
49 |
50 | # Django stuff:
51 | *.log
52 |
53 | # Sphinx documentation
54 | docs/_build/
55 |
56 | # PyBuilder
57 | target/
58 |
59 | # Eclipse
60 | .project
61 | .pydevproject
62 | .settings
63 |
64 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
341 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ipa-log-config
2 |
3 | A tool for log forwarding configuration on IPA servers and clients. Configures rsyslog to collect and forward selected log files to desired remote server. For more information about this effort and some inspiration what can be done with those logs, visit [this page](https://www.freeipa.org/page/Centralized_Logging).
4 |
5 | ## Usage
6 |
7 | ```
8 | # ./ipa_log_config.py --target
9 | ```
10 |
11 | To revert changes done by this script, use the `--revert` option:
12 |
13 | ```
14 | # ./ipa_log_config.py --revert
15 | ```
16 |
17 | ## Supported platforms
18 |
19 | Currently, only RHEL 7 / CentOS 7 and derivates are supported.
20 |
21 | ## Requirements
22 |
23 | The script requires `python2-sssdconfig` package.
24 |
25 | ## Detailed description
26 |
27 | This tool tries to be as not invasive as possible. The rsyslog configuration is done in the separate files, which could be easily removed. Besides that, it configures debug level of SSSD and enables audisp syslog plugin. All logs are written to their original destination AND sent to the remote server, so no logs are lost from the local machine.
28 |
29 | ### Forwarded logs
30 |
31 | ```
32 | /var/log/audit/audit.log
33 | /var/log/secure
34 | /var/log/httpd/access_log
35 | /var/log/httpd/error_log
36 | /var/log/kadmind.log
37 | /var/log/krb5kdc.log
38 | /var/log/pki/pki-tomcat/ca/transactions
39 | /var/log/dirsrv/slapd-/access
40 | /var/log/dirsrv/slapd-/audit
41 | /var/log/dirsrv/slapd-/errors
42 | /var/log/sssd/sssd.log
43 | /var/log/sssd/krb5_child.log
44 | /var/log/sssd/ldap_child.log
45 | /var/log/sssd/selinux_child.log
46 | /var/log/sssd/gpo_child.log
47 | /var/log/sssd/sssd_nss.log
48 | /var/log/sssd/sssd_pam.log
49 | /var/log/sssd/sssd_pac.log
50 | /var/log/sssd/sssd_autofs.log
51 | /var/log/sssd/sssd_ssh.log
52 | /var/log/sssd/sssd_sudo.log
53 | /var/log/sssd/sssd_ifp.log
54 | /var/log/sssd/sssd_.log
55 | ```
56 |
57 | Most of the logs are forwarded using rsyslog imfile module. The only exceptions are audit and secure logs. Audit is sent to rsyslog using audisp syslog plugin and secure log is written directly by rsyslog, so only forwarding is added for this one.
58 |
--------------------------------------------------------------------------------
/ipa_log_config.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | # Tool for log forwarding configuration on IPA servers and clients
5 | # Copyright (C) 2015 Red Hat, Inc.
6 | #
7 | # This program is free software; you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation; either version 2 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program. If not, see .
19 |
20 | import os
21 | import string
22 | import sys
23 |
24 | from argparse import ArgumentParser, RawDescriptionHelpFormatter
25 | from random import SystemRandom
26 | from subprocess import call
27 |
28 | from SSSDConfig import SSSDConfig
29 |
30 |
31 | _CONFIG_RSYSLOG_CONF_DIR = '/etc/rsyslog.d'
32 | _CONFIG_SSSD_CONF_FILE = '/etc/sssd/sssd.conf'
33 |
34 |
35 | class ExternalCommandError(Exception):
36 | pass
37 |
38 |
39 | class SSSD(object):
40 | """SSSD"""
41 |
42 | def __init__(self, config_file=_CONFIG_SSSD_CONF_FILE):
43 | self._sssdconfig = SSSDConfig()
44 | self._sssdconfig.import_config(config_file)
45 |
46 | def _get_service_objects(self):
47 | return [self._sssdconfig.get_service(service_name)
48 | for service_name in self._sssdconfig.list_services()]
49 |
50 | def _get_domain_objects(self):
51 | return [self._sssdconfig.get_domain(domain_name)
52 | for domain_name in self._sssdconfig.list_domains()]
53 |
54 | def _debug_all_services(self, debug_level, leave_higher=True):
55 | for srv in self._get_service_objects():
56 | if leave_higher and 'debug_level' in srv.options \
57 | and srv.options['debug_level'] >= debug_level:
58 | continue
59 | srv.set_option('debug_level', debug_level)
60 | self._sssdconfig.save_service(srv)
61 |
62 | def _debug_all_domains(self, debug_level, leave_higher=True):
63 | for dom in self._get_domain_objects():
64 | if leave_higher and 'debug_level' in dom.options \
65 | and dom.options['debug_level'] >= debug_level:
66 | continue
67 | dom.set_option('debug_level', debug_level)
68 | self._sssdconfig.save_domain(dom)
69 |
70 | def _write(self):
71 | self._sssdconfig.write()
72 |
73 | def _restart(self):
74 | print 'Condrestarting SSSD'
75 | if call(['systemctl', 'condrestart', 'sssd']) != 0:
76 | raise ExternalCommandError('Failed to condrestart SSSD')
77 |
78 | def get_domains(self):
79 | domains = self._sssdconfig.list_domains()
80 | print 'SSSD domains: ' + ', '.join(domains)
81 | return domains
82 |
83 | def get_realms(self):
84 | realms = []
85 | for dom in self._get_domain_objects():
86 | if 'ipa_domain' in dom.options:
87 | realms.append(dom.options['ipa_domain'].upper())
88 | else:
89 | realms.append(dom.name.upper())
90 | print 'Realms: ' + ', '.join(realms)
91 | return realms
92 |
93 | def is_server(self):
94 | for dom in self._get_domain_objects():
95 | if 'ipa_server_mode' in dom.options \
96 | and dom.options['ipa_server_mode']:
97 | print 'SSSD is running in server mode'
98 | return True
99 | print 'SSSD is running in client mode'
100 | return False
101 |
102 | def enable_debug(self, debug_level=2, leave_higher=True):
103 | print 'Setting SSSD debug level to ' + str(debug_level)
104 | self._debug_all_services(debug_level, leave_higher)
105 | self._debug_all_domains(debug_level, leave_higher)
106 | self._write()
107 | self._restart()
108 |
109 |
110 | class Auditd(object):
111 | """Auditd"""
112 |
113 | _AUDITD_SYSLOG_CONF = '/etc/audisp/plugins.d/syslog.conf'
114 |
115 | def _restart(self):
116 | # why not systemctl?
117 | # https://bugzilla.redhat.com/show_bug.cgi?id=1026648
118 | print 'Restarting auditd'
119 | if call(['service', 'auditd', 'restart']) != 0:
120 | raise ExternalCommandError('Failed to restart auditd')
121 |
122 | def log_to_syslog(self):
123 | print 'Enabling audisp syslog plugin'
124 | if call(['sed', '-i', 's/active = no/active = yes/',
125 | self._AUDITD_SYSLOG_CONF]) != 0:
126 | raise ExternalCommandError(
127 | 'Failed to run sed on file: ' + self._AUDITD_SYSLOG_CONF)
128 | self._restart()
129 |
130 | def revert(self):
131 | print 'Disabling audisp syslog plugin'
132 | if call(['sed', '-i', 's/active = yes/active = no/',
133 | self._AUDITD_SYSLOG_CONF]) != 0:
134 | raise ExternalCommandError(
135 | 'Failed to run sed on file: ' + self._AUDITD_SYSLOG_CONF)
136 | self._restart()
137 |
138 |
139 | class RequirementError(Exception):
140 | pass
141 |
142 | class Requirements(object):
143 | """Check (and meet if possible) requirements for this script"""
144 |
145 | def check_rsyslog(self):
146 | if not os.path.isdir(_CONFIG_RSYSLOG_CONF_DIR):
147 | raise RequirementError('Rsyslog config directory "{0}" does not '
148 | 'exist. Is rsyslog installed?'.format(_CONFIG_RSYSLOG_CONF_DIR))
149 | if not os.access(_CONFIG_RSYSLOG_CONF_DIR, os.W_OK):
150 | raise RequirementError('You do not have write permission to the '
151 | 'rsyslog config directory "{0}". You probably need to run this '
152 | 'script as root or with sudo.'.format(_CONFIG_RSYSLOG_CONF_DIR))
153 |
154 | def check_sssd(self):
155 | if not os.path.isfile(_CONFIG_SSSD_CONF_FILE):
156 | raise RequirementError('SSSD config file "{0}" does not exist. '
157 | 'Does this machine belong to an IPA domain?'.format(
158 | _CONFIG_SSSD_CONF_FILE))
159 |
160 | def check_all(self):
161 | self.check_rsyslog()
162 | self.check_sssd()
163 |
164 |
165 | class RsyslogError(Exception):
166 | pass
167 |
168 | class Rsyslog(object):
169 | """Rsyslog"""
170 |
171 | _REMOTE_RULESET = 'remote_ipa_elastic'
172 |
173 | _STATIC_CONF_FILES = [
174 | '00.load-imfile-module',
175 | '00.remote-ipa-elastic-ruleset',
176 | '01.ipa-auditd',
177 | '01.ipa-authpriv',
178 | '01.ipa-httpd',
179 | '01.ipa-krb5',
180 | '01.ipa-389',
181 | '01.ipa-ca',
182 | '10.ipa-sssd-processes',
183 | '11.ipa-sssd-domains',
184 | ]
185 |
186 | _IMFILE_LOAD = 'module(load="imfile" pollingInterval="2")'
187 |
188 | _AUDITD_FORWARD_RULE = 'if ($syslogtag == "audispd:") then {{\n' \
189 | ' call {ruleset}\n' \
190 | ' stop\n' \
191 | '}}'
192 |
193 | _AUTHPRIV_FORWARD_RULE = 'if ($syslogfacility-text == "authpriv") ' \
194 | 'then {{\n' \
195 | ' call {ruleset}\n' \
196 | '}}'
197 |
198 | _IMFILE_RULE_TEMPLATE = 'input(type="imfile"\n' \
199 | ' ruleset="{ruleset}"\n' \
200 | ' file="{log_file}"\n' \
201 | ' tag="{tag}")\n'
202 |
203 | _ELASTIC_REMOTE_RULESET_TEMPLATE = 'ruleset(name="{ruleset}") {{\n' \
204 | ' action(type="omfwd"\n' \
205 | ' target="{target}"\n' \
206 | ' port="{target_port}"\n' \
207 | ' protocol="tcp"\n' \
208 | ' queue.type="linkedlist"\n' \
209 | ' queue.size="4000"\n' \
210 | ' queue.dequeuebatchsize="200"\n' \
211 | ' queue.saveOnShutdown="on"\n' \
212 | ' action.resumeRetryCount="-1")\n' \
213 | '}}\n' \
214 | '$WorkDirectory /var/lib/rsyslog\n\n'
215 |
216 | _STATIC_LOG_DATA = {
217 | '/var/log/httpd/access_log':
218 | {'tag': 'httpdaccess', 'conf_file': '01.ipa-httpd'},
219 | '/var/log/httpd/error_log':
220 | {'tag': 'httpderror', 'conf_file': '01.ipa-httpd'},
221 | '/var/log/kadmind.log':
222 | {'tag': 'krb5-kadmin', 'conf_file': '01.ipa-krb5'},
223 | '/var/log/krb5kdc.log':
224 | {'tag': 'krb5-kdc', 'conf_file': '01.ipa-krb5'},
225 | '/var/log/pki/pki-tomcat/ca/transactions':
226 | {'tag': 'ipa-ca-transaction', 'conf_file': '01.ipa-ca'},
227 | '/var/log/sssd/sssd.log':
228 | {'tag': '-monitor', 'conf_file': '10.ipa-sssd-processes'},
229 | '/var/log/sssd/krb5_child.log':
230 | {'tag': '-krb5-child', 'conf_file': '10.ipa-sssd-processes'},
231 | '/var/log/sssd/ldap_child.log':
232 | {'tag': '-ldap-child', 'conf_file': '10.ipa-sssd-processes'},
233 | '/var/log/sssd/selinux_child.log':
234 | {'tag': '-selinux-child', 'conf_file': '10.ipa-sssd-processes'},
235 | '/var/log/sssd/gpo_child.log':
236 | {'tag': '-gpo-child', 'conf_file': '10.ipa-sssd-processes'},
237 | '/var/log/sssd/sssd_nss.log':
238 | {'tag': '-nss', 'conf_file': '10.ipa-sssd-processes'},
239 | '/var/log/sssd/sssd_pam.log':
240 | {'tag': '-pam', 'conf_file': '10.ipa-sssd-processes'},
241 | '/var/log/sssd/sssd_pac.log':
242 | {'tag': '-pac', 'conf_file': '10.ipa-sssd-processes'},
243 | '/var/log/sssd/sssd_autofs.log':
244 | {'tag': '-autofs', 'conf_file': '10.ipa-sssd-processes'},
245 | '/var/log/sssd/sssd_ssh.log':
246 | {'tag': '-ssh', 'conf_file': '10.ipa-sssd-processes'},
247 | '/var/log/sssd/sssd_sudo.log':
248 | {'tag': '-sudo', 'conf_file': '10.ipa-sssd-processes'},
249 | '/var/log/sssd/sssd_ifp.log':
250 | {'tag': '-ifp', 'conf_file': '10.ipa-sssd-processes'},
251 | }
252 |
253 | def _create_conf_file_full_path(self, f):
254 | if not f in self._get_conf_files():
255 | raise RsyslogError('Invalid rsyslog config file: {0}'.format(f))
256 | return '{0}/{1}.conf'.format(_CONFIG_RSYSLOG_CONF_DIR, f)
257 |
258 | def _get_conf_files(self):
259 | return self._STATIC_CONF_FILES
260 |
261 | def _get_conf_files_full_path(self):
262 | return [self._create_conf_file_full_path(f)
263 | for f in self._get_conf_files()]
264 |
265 | def _create_imfile_rule(self, log_file, tag):
266 | state_file = '{0}-{1}'.format(tag, ''.join(SystemRandom().choice(
267 | string.ascii_letters + string.digits) for _ in range(3)))
268 | return self._IMFILE_RULE_TEMPLATE.format(ruleset=self._REMOTE_RULESET,
269 | log_file=log_file, tag=tag, state_file=state_file)
270 |
271 | def _get_log_data(self):
272 | logs = self._STATIC_LOG_DATA
273 | sssd = SSSD()
274 | sssd_server = sssd.is_server()
275 | to_remove = []
276 | # Add sssd domain logs
277 | for d in sssd.get_domains():
278 | logs['/var/log/sssd/sssd_{0}.log'.format(d)] = \
279 | {'tag': '-domain', 'conf_file': '11.ipa-sssd-domains'}
280 | # Add 389 logs according to the current realms
281 | for r in sssd.get_realms():
282 | log_dir = '/var/log/dirsrv/slapd-{0}/'.format(r.replace('.', '-'))
283 | logs[log_dir + 'access'] = \
284 | {'tag': 'ipa-389-access', 'conf_file': '01.ipa-389'}
285 | logs[log_dir + 'audit'] = \
286 | {'tag': 'ipa-389-audit', 'conf_file': '01.ipa-389'}
287 | logs[log_dir + 'errors'] = \
288 | {'tag': 'ipa-389-errors', 'conf_file': '01.ipa-389'}
289 | for f, v in logs.iteritems():
290 | # Process tags for sssd
291 | if f.startswith('/var/log/sssd/'):
292 | if sssd_server:
293 | logs[f]['tag'] = 'sssd-server' + v['tag']
294 | else:
295 | logs[f]['tag'] = 'sssd' + v['tag']
296 | # Filter log data for non-existent log files. Skip sssd logs
297 | # as sssd is on both, server and client.
298 | else:
299 | if not os.path.isfile(f):
300 | to_remove.append(f)
301 | for f in to_remove:
302 | print 'Rsyslog: skipping "{0}", log file not found.'.format(f)
303 | del logs[f]
304 | return logs
305 |
306 | def _write_imfile_load(self):
307 | cfpath = self._create_conf_file_full_path('00.load-imfile-module')
308 | print 'Rsyslog: enabling imfile module [{0}]'.format(cfpath)
309 | with open(cfpath, 'w') as cf:
310 | cf.write(self._IMFILE_LOAD)
311 |
312 | def _write_auditd_fwd_rule(self):
313 | cfpath = self._create_conf_file_full_path('01.ipa-auditd')
314 | print 'Rsyslog: forwarding auditd logs to remote ruleset [{0}]'.format(
315 | cfpath)
316 | with open(cfpath, 'w') as cf:
317 | cf.write(self._AUDITD_FORWARD_RULE.format(
318 | ruleset=self._REMOTE_RULESET))
319 |
320 | def _write_authpriv_fwd_rule(self):
321 | cfpath = self._create_conf_file_full_path('01.ipa-authpriv')
322 | print 'Rsyslog: forwarding authpriv logs to remote ruleset ' \
323 | '[{0}]'.format(cfpath)
324 | with open(cfpath, 'w') as cf:
325 | cf.write(self._AUTHPRIV_FORWARD_RULE.format(
326 | ruleset=self._REMOTE_RULESET))
327 |
328 | def _write_elastic_remote_rule(self, target, target_port):
329 | cfpath = self._create_conf_file_full_path(
330 | '00.remote-ipa-elastic-ruleset')
331 | print 'Rsyslog: creating ruleset for forwarding logs [{0}]'.format(
332 | cfpath)
333 | with open(cfpath, 'w') as cf:
334 | cf.write(self._ELASTIC_REMOTE_RULESET_TEMPLATE.format(
335 | ruleset=self._REMOTE_RULESET, target=target, target_port=target_port))
336 |
337 | def _restart(self):
338 | print 'Enabling and restarting rsyslog service.'
339 | if call(['systemctl', 'enable', 'rsyslog']) != 0:
340 | raise ExternalCommandError('Failed to enable rsyslog service')
341 | if call(['systemctl', 'restart', 'rsyslog']) != 0:
342 | raise ExternalCommandError('Failed to restart rsyslog service')
343 |
344 | def _clean_config(self):
345 | config_files = self._get_conf_files_full_path()
346 | print 'Rsyslog: cleaning up config files:\n ' + \
347 | '\n '.join(config_files)
348 | for f in config_files:
349 | try:
350 | os.remove(f)
351 | except OSError:
352 | #print 'Could not remove file "{0}": {1}'.format(f, e)
353 | pass
354 |
355 | def write_config(self, target, target_port):
356 | self._clean_config()
357 | self._write_imfile_load()
358 | self._write_elastic_remote_rule(target, target_port)
359 | self._write_auditd_fwd_rule()
360 | self._write_authpriv_fwd_rule()
361 | for f, v in self._get_log_data().iteritems():
362 | cfpath = self._create_conf_file_full_path(v['conf_file'])
363 | print 'Rsyslog: including "{0}" log [{1}]'.format(f, cfpath)
364 | with open(cfpath, 'a') as cf:
365 | cf.write(self._create_imfile_rule(f, v['tag']))
366 | self._restart()
367 |
368 | def revert(self):
369 | self._clean_config()
370 | self._restart()
371 |
372 |
373 | def main():
374 | """Entry-point for script"""
375 |
376 | parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
377 | description='Configure log forwarding on IPA servers and clients\nto '
378 | 'the remote server.',
379 | epilog=os.path.basename(__file__) + ' Copyright (C) 2015 '
380 | 'Red Hat, Inc.\nThis program comes with ABSOLUTELY NO WARRANTY.\n'
381 | 'This is free software, and you are welcome to redistribute it\n'
382 | 'under certain conditions; see LICENSE file for details.')
383 | parser.add_argument('-t', '--target',
384 | help='destination address of target central logging server. Can be '
385 | 'either a domain name or IP address')
386 | parser.add_argument('-p', '--target-port',
387 | help='destination port to access central logging server. If left out '
388 | 'a default of 514 will be choosen',
389 | default=514,
390 | dest='target_port')
391 |
392 | parser.add_argument('-r', '--revert', action='store_true',
393 | help='revert configuration done by this script - return to the '
394 | 'default state')
395 | args = parser.parse_args()
396 |
397 | if not args.target and not args.revert:
398 | print 'One of the --target or --revert options must be specified'
399 | sys.exit(1)
400 | elif args.target and args.revert:
401 | print 'Only one of the --target or --revert option can be specified'
402 | sys.exit(1)
403 |
404 | try:
405 | Requirements().check_all()
406 | if args.target:
407 | SSSD().enable_debug()
408 | Auditd().log_to_syslog()
409 | Rsyslog().write_config(args.target, args.target_port)
410 | print 'Configuration completed successfully, IPA logs are ' \
411 | 'forwarded to ' + args.target + ':' + str(args.target_port)
412 | elif args.revert:
413 | SSSD().enable_debug(1, False)
414 | Auditd().revert()
415 | Rsyslog().revert()
416 | print 'Configuration successfully reverted to the default state'
417 | except RequirementError as e:
418 | print 'Failed requirement: ' + str(e)
419 | sys.exit(1)
420 | except ExternalCommandError as e:
421 | print 'Failed to execute external command: ' + str(e)
422 | sys.exit(1)
423 |
424 | sys.exit(0)
425 |
426 |
427 | if __name__ == '__main__':
428 | main()
429 |
--------------------------------------------------------------------------------
/pylintrc:
--------------------------------------------------------------------------------
1 | [MASTER]
2 |
3 | # Specify a configuration file.
4 | #rcfile=
5 |
6 | # Python code to execute, usually for sys.path manipulation such as
7 | # pygtk.require().
8 | #init-hook=
9 |
10 | # Profiled execution.
11 | profile=no
12 |
13 | # Add files or directories to the blacklist. They should be base names, not
14 | # paths.
15 | ignore=CVS
16 |
17 | # Pickle collected data for later comparisons.
18 | persistent=yes
19 |
20 | # List of plugins (as comma separated values of python modules names) to load,
21 | # usually to register additional checkers.
22 | load-plugins=
23 |
24 |
25 | [MESSAGES CONTROL]
26 |
27 | # Enable the message, report, category or checker with the given id(s). You can
28 | # either give multiple identifier separated by comma (,) or put this option
29 | # multiple time. See also the "--disable" option for examples.
30 | #enable=
31 |
32 | # Disable the message, report, category or checker with the given id(s). You
33 | # can either give multiple identifiers separated by comma (,) or put this
34 | # option multiple times (only on the command line, not in the configuration
35 | # file where it should appear only once).You can also use "--disable=all" to
36 | # disable everything first and then reenable specific checks. For example, if
37 | # you want to run only the similarities checker, you can use "--disable=all
38 | # --enable=similarities". If you want to run only the classes checker, but have
39 | # no Warning level messages displayed, use"--disable=all --enable=classes
40 | # --disable=W"
41 | disable=bad-continuation,missing-docstring,no-self-use,invalid-name
42 |
43 |
44 | [REPORTS]
45 |
46 | # Set the output format. Available formats are text, parseable, colorized, msvs
47 | # (visual studio) and html. You can also give a reporter class, eg
48 | # mypackage.mymodule.MyReporterClass.
49 | output-format=colorized
50 |
51 | # Put messages in a separate file for each module / package specified on the
52 | # command line instead of printing them on stdout. Reports (if any) will be
53 | # written in a file name "pylint_global.[txt|html]".
54 | files-output=no
55 |
56 | # Tells whether to display a full report or only the messages
57 | reports=yes
58 |
59 | # Python expression which should return a note less than 10 (10 is the highest
60 | # note). You have access to the variables errors warning, statement which
61 | # respectively contain the number of errors / warnings messages and the total
62 | # number of statements analyzed. This is used by the global evaluation report
63 | # (RP0004).
64 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
65 |
66 | # Add a comment according to your evaluation note. This is used by the global
67 | # evaluation report (RP0004).
68 | comment=no
69 |
70 | # Template used to display messages. This is a python new-style format string
71 | # used to format the message information. See doc for all details
72 | #msg-template=
73 |
74 |
75 | [FORMAT]
76 |
77 | # Maximum number of characters on a single line.
78 | max-line-length=80
79 |
80 | # Regexp for a line that is allowed to be longer than the limit.
81 | ignore-long-lines=^\s*(# )??$
82 |
83 | # Allow the body of an if to be on the same line as the test if there is no
84 | # else.
85 | single-line-if-stmt=no
86 |
87 | # List of optional constructs for which whitespace checking is disabled
88 | no-space-check=trailing-comma,dict-separator
89 |
90 | # Maximum number of lines in a module
91 | max-module-lines=1000
92 |
93 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
94 | # tab).
95 | indent-string=' '
96 |
97 | # Number of spaces of indent required inside a hanging or continued line.
98 | indent-after-paren=4
99 |
100 |
101 | [VARIABLES]
102 |
103 | # Tells whether we should check for unused import in __init__ files.
104 | init-import=no
105 |
106 | # A regular expression matching the name of dummy variables (i.e. expectedly
107 | # not used).
108 | dummy-variables-rgx=_$|dummy
109 |
110 | # List of additional names supposed to be defined in builtins. Remember that
111 | # you should avoid to define new builtins when possible.
112 | additional-builtins=
113 |
114 |
115 | [BASIC]
116 |
117 | # Required attributes for module, separated by a comma
118 | required-attributes=
119 |
120 | # List of builtins function names that should not be used, separated by a comma
121 | bad-functions=map,filter,apply,input,file
122 |
123 | # Good variable names which should always be accepted, separated by a comma
124 | good-names=i,j,k,ex,Run,_
125 |
126 | # Bad variable names which should always be refused, separated by a comma
127 | bad-names=foo,bar,baz,toto,tutu,tata
128 |
129 | # Colon-delimited sets of names that determine each other's naming style when
130 | # the name regexes allow several styles.
131 | name-group=
132 |
133 | # Include a hint for the correct naming format with invalid-name
134 | include-naming-hint=no
135 |
136 | # Regular expression matching correct function names
137 | function-rgx=[a-z_][a-z0-9_]{2,30}$
138 |
139 | # Naming hint for function names
140 | function-name-hint=[a-z_][a-z0-9_]{2,30}$
141 |
142 | # Regular expression matching correct variable names
143 | variable-rgx=[a-z_][a-z0-9_]{2,30}$
144 |
145 | # Naming hint for variable names
146 | variable-name-hint=[a-z_][a-z0-9_]{2,30}$
147 |
148 | # Regular expression matching correct constant names
149 | const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
150 |
151 | # Naming hint for constant names
152 | const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
153 |
154 | # Regular expression matching correct attribute names
155 | attr-rgx=[a-z_][a-z0-9_]{2,30}$
156 |
157 | # Naming hint for attribute names
158 | attr-name-hint=[a-z_][a-z0-9_]{2,30}$
159 |
160 | # Regular expression matching correct argument names
161 | argument-rgx=[a-z_][a-z0-9_]{2,30}$
162 |
163 | # Naming hint for argument names
164 | argument-name-hint=[a-z_][a-z0-9_]{2,30}$
165 |
166 | # Regular expression matching correct class attribute names
167 | class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
168 |
169 | # Naming hint for class attribute names
170 | class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
171 |
172 | # Regular expression matching correct inline iteration names
173 | inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
174 |
175 | # Naming hint for inline iteration names
176 | inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
177 |
178 | # Regular expression matching correct class names
179 | class-rgx=[A-Z_][a-zA-Z0-9]+$
180 |
181 | # Naming hint for class names
182 | class-name-hint=[A-Z_][a-zA-Z0-9]+$
183 |
184 | # Regular expression matching correct module names
185 | module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
186 |
187 | # Naming hint for module names
188 | module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
189 |
190 | # Regular expression matching correct method names
191 | method-rgx=[a-z_][a-z0-9_]{2,30}$
192 |
193 | # Naming hint for method names
194 | method-name-hint=[a-z_][a-z0-9_]{2,30}$
195 |
196 | # Regular expression which should only match function or class names that do
197 | # not require a docstring.
198 | no-docstring-rgx=__.*__
199 |
200 | # Minimum line length for functions/classes that require docstrings, shorter
201 | # ones are exempt.
202 | docstring-min-length=-1
203 |
204 |
205 | [LOGGING]
206 |
207 | # Logging modules to check that the string format arguments are in logging
208 | # function parameter format
209 | logging-modules=logging
210 |
211 |
212 | [TYPECHECK]
213 |
214 | # Tells whether missing members accessed in mixin class should be ignored. A
215 | # mixin class is detected if its name ends with "mixin" (case insensitive).
216 | ignore-mixin-members=yes
217 |
218 | # List of module names for which member attributes should not be checked
219 | # (useful for modules/projects where namespaces are manipulated during runtime
220 | # and thus existing member attributes cannot be deduced by static analysis
221 | ignored-modules=
222 |
223 | # List of classes names for which member attributes should not be checked
224 | # (useful for classes with attributes dynamically set).
225 | ignored-classes=SQLObject
226 |
227 | # When zope mode is activated, add a predefined set of Zope acquired attributes
228 | # to generated-members.
229 | zope=no
230 |
231 | # List of members which are set dynamically and missed by pylint inference
232 | # system, and so shouldn't trigger E0201 when accessed. Python regular
233 | # expressions are accepted.
234 | generated-members=REQUEST,acl_users,aq_parent
235 |
236 |
237 | [SIMILARITIES]
238 |
239 | # Minimum lines number of a similarity.
240 | min-similarity-lines=4
241 |
242 | # Ignore comments when computing similarities.
243 | ignore-comments=yes
244 |
245 | # Ignore docstrings when computing similarities.
246 | ignore-docstrings=yes
247 |
248 | # Ignore imports when computing similarities.
249 | ignore-imports=no
250 |
251 |
252 | [MISCELLANEOUS]
253 |
254 | # List of note tags to take in consideration, separated by a comma.
255 | notes=FIXME,XXX,TODO
256 |
257 |
258 | [IMPORTS]
259 |
260 | # Deprecated modules which should not be used, separated by a comma
261 | deprecated-modules=regsub,TERMIOS,Bastion,rexec
262 |
263 | # Create a graph of every (i.e. internal and external) dependencies in the
264 | # given file (report RP0402 must not be disabled)
265 | import-graph=
266 |
267 | # Create a graph of external dependencies in the given file (report RP0402 must
268 | # not be disabled)
269 | ext-import-graph=
270 |
271 | # Create a graph of internal dependencies in the given file (report RP0402 must
272 | # not be disabled)
273 | int-import-graph=
274 |
275 |
276 | [CLASSES]
277 |
278 | # List of interface methods to ignore, separated by a comma. This is used for
279 | # instance to not check methods defines in Zope's Interface base class.
280 | ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
281 |
282 | # List of method names used to declare (i.e. assign) instance attributes.
283 | defining-attr-methods=__init__,__new__,setUp
284 |
285 | # List of valid names for the first argument in a class method.
286 | valid-classmethod-first-arg=cls
287 |
288 | # List of valid names for the first argument in a metaclass class method.
289 | valid-metaclass-classmethod-first-arg=mcs
290 |
291 |
292 | [DESIGN]
293 |
294 | # Maximum number of arguments for function / method
295 | max-args=5
296 |
297 | # Argument names that match this expression will be ignored. Default to name
298 | # with leading underscore
299 | ignored-argument-names=_.*
300 |
301 | # Maximum number of locals for function / method body
302 | max-locals=15
303 |
304 | # Maximum number of return / yield for function / method body
305 | max-returns=6
306 |
307 | # Maximum number of branch for function / method body
308 | max-branches=12
309 |
310 | # Maximum number of statements in function / method body
311 | max-statements=50
312 |
313 | # Maximum number of parents for a class (see R0901).
314 | max-parents=7
315 |
316 | # Maximum number of attributes for a class (see R0902).
317 | max-attributes=7
318 |
319 | # Minimum number of public methods for a class (see R0903).
320 | min-public-methods=2
321 |
322 | # Maximum number of public methods for a class (see R0904).
323 | max-public-methods=20
324 |
325 |
326 | [EXCEPTIONS]
327 |
328 | # Exceptions that will emit a warning when being caught. Defaults to
329 | # "Exception"
330 | overgeneral-exceptions=Exception
331 |
--------------------------------------------------------------------------------