Univention Bugzilla – Attachment 7734 Details for
Bug 33737
Check UCS code for localization of standard accounts like "Administrator"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Rough check for common AD names in ucslint
9017-use-libs.py (text/plain), 2.30 KB, created by
Sönke Schwardt-Krummrich
on 2016-06-13 10:45:03 CEST
(
hide
)
Description:
Rough check for common AD names in ucslint
Filename:
MIME Type:
Creator:
Sönke Schwardt-Krummrich
Created:
2016-06-13 10:45:03 CEST
Size:
2.30 KB
patch
obsolete
># -*- coding: utf-8 -*- > >try: > import univention.ucslint.base as uub >except ImportError: > import ucslint.base as uub >import os >import re > >class UniventionPackageCheck(uub.UniventionPackageCheckDebian): > def __init__(self): > super(UniventionPackageCheck, self).__init__() > self.name = '9017-Use-internal-libraries' > > def getMsgIds(self): > return { '9017-1': [ uub.RESULT_WARN, 'cannot open file' ], > '9017-2': [ uub.RESULT_WARN, 'found well-known LDAP object but no custom_groupname' ], > } > > def postinit(self, path): > """ checks to be run before real check or to create precalculated data for several runs. Only called once! """ > pass > > def check(self, path): > """ the real check """ > super(UniventionPackageCheck, self).check(path) > > for fn in uub.FilteredDirWalkGenerator(path): > # skip all files larger than 30kiB > try: > extension = fn.rsplit('.',1)[-1] > # skip images, python binaries > if extension in ('svg', 'png', 'jpg', 'gif', 'pyc'): > continue > # check only small files but all js/py/sh files > if os.stat(fn).st_size > 50*1024 and extension not in ('js', 'py', 'sh', ): > continue > content = open(fn, 'r').read() > except (IOError, OSError): > self.addmsg( '9017-1', 'failed to open and read file', fn ) > continue > > for txt in ['Domain Users', 'Domain Admins', 'Administrator', 'Windows Hosts']: > regex = '(?!custom_groupname)[^\n]+%s' % (txt,) > for (line, pos) in self._regexSearchString(content, regex, re.I | re.M): > self.addmsg('9017-2', 'line contains "%s" without custom_groupname() call' % txt, fn, line, pos) > > def _regexSearchString(self, content, regex, regex_flags=0): > pattern = re.compile(regex, regex_flags) > result = [] > pos = 0 > while True: > match = pattern.search(content, pos) > if not match: > break > else: > line = content.count('\n', 0, match.start()) + 1 > linepos = match.start() - content.rfind('\n', 0, match.start()) > pos = match.end() - 1 > result.append( (line, linepos) ) > return result > > def _searchString(self, content, txt): > result = [] > pos = 0 > while True: > fpos = content.lower().find( txt.lower(), pos ) > if fpos < 0: > break > else: > line = content.count('\n', 0, fpos) + 1 > linepos = fpos - content.rfind('\n', 0, fpos) > pos = fpos + len(txt) - 1 > result.append( (line, linepos) ) > return result
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 33737
: 7734