From: Ernesto Puerta Date: Thu, 20 Aug 2020 12:22:57 +0000 (+0200) Subject: mgr/dashboard: remove racially insensitive terms X-Git-Tag: v16.1.0~1334^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6f8c30b1bc79e10b3f2e260a80534d16dce9cf8d;p=ceph.git mgr/dashboard: remove racially insensitive terms Signed-off-by: Ernesto Puerta --- diff --git a/src/pybind/mgr/dashboard/.pylintrc b/src/pybind/mgr/dashboard/.pylintrc index 404a16a2e6fa..4b79f2351817 100644 --- a/src/pybind/mgr/dashboard/.pylintrc +++ b/src/pybind/mgr/dashboard/.pylintrc @@ -3,13 +3,14 @@ # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code +# TODO: remove racially insensitive terms when this becomes fixed: https://github.com/PyCQA/pylint/issues/3669 extension-pkg-whitelist=rados,rbd,math,cephfs -# Add files or directories to the blacklist. They should be base names, not +# Add files or directories to the blocklist. They should be base names, not # paths. ignore=CVS -# Add files or directories matching the regex patterns to the blacklist. The +# Add files or directories matching the regex patterns to the blocklist. The # regex matches against base names, not paths. ignore-patterns= diff --git a/src/pybind/mgr/dashboard/controllers/auth.py b/src/pybind/mgr/dashboard/controllers/auth.py index fb021be84201..6f28379c6a21 100644 --- a/src/pybind/mgr/dashboard/controllers/auth.py +++ b/src/pybind/mgr/dashboard/controllers/auth.py @@ -59,7 +59,7 @@ class Auth(RESTController): def logout(self): logger.debug('Logout successful') token = JwtManager.get_token_from_header() - JwtManager.blacklist_token(token) + JwtManager.blocklist_token(token) redirect_url = '#/login' if mgr.SSO_DB.protocol == 'saml2': redirect_url = 'auth/saml2/slo' diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts index 46f3c8400cef..606cddb9ac84 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts @@ -34,8 +34,8 @@ import { catchError, map } from 'rxjs/operators'; providedIn: 'root' }) export class ModuleStatusGuardService implements CanActivate, CanActivateChild { - // TODO: Hotfix - remove WHITELIST'ing when a generic ErrorComponent is implemented - static readonly WHITELIST: string[] = ['501']; + // TODO: Hotfix - remove ALLOWLIST'ing when a generic ErrorComponent is implemented + static readonly ALLOWLIST: string[] = ['501']; constructor(private http: HttpClient, private router: Router) {} @@ -48,7 +48,7 @@ export class ModuleStatusGuardService implements CanActivate, CanActivateChild { } private doCheck(route: ActivatedRouteSnapshot) { - if (route.url.length > 0 && ModuleStatusGuardService.WHITELIST.includes(route.url[0].path)) { + if (route.url.length > 0 && ModuleStatusGuardService.ALLOWLIST.includes(route.url[0].path)) { return observableOf(true); } const config = route.data['moduleStatusGuardConfig']; diff --git a/src/pybind/mgr/dashboard/services/auth.py b/src/pybind/mgr/dashboard/services/auth.py index 955b3f9cc6fb..94d3cba55a00 100644 --- a/src/pybind/mgr/dashboard/services/auth.py +++ b/src/pybind/mgr/dashboard/services/auth.py @@ -21,7 +21,7 @@ cherrypy.config.update({ class JwtManager(object): - JWT_TOKEN_BLACKLIST_KEY = "jwt_token_black_list" + JWT_TOKEN_BLOCKLIST_KEY = "jwt_token_block_list" JWT_TOKEN_TTL = 28800 # default 8 hours JWT_ALGORITHM = 'HS256' _secret = None @@ -90,7 +90,7 @@ class JwtManager(object): def get_user(cls, token): try: dtoken = JwtManager.decode_token(token) - if not JwtManager.is_blacklisted(dtoken['jti']): + if not JwtManager.is_blocklisted(dtoken['jti']): user = AuthManager.get_user(dtoken['username']) if user.last_update <= dtoken['iat']: return user @@ -99,7 +99,7 @@ class JwtManager(object): dtoken['iat'], user.last_update ) else: - cls.logger.debug('Token is black-listed') # type: ignore + cls.logger.debug('Token is block-listed') # type: ignore except jwt.ExpiredSignatureError: cls.logger.debug("Token has expired") # type: ignore except jwt.InvalidTokenError: @@ -111,12 +111,12 @@ class JwtManager(object): return None @classmethod - def blacklist_token(cls, token): + def blocklist_token(cls, token): token = jwt.decode(token, verify=False) - blacklist_json = mgr.get_store(cls.JWT_TOKEN_BLACKLIST_KEY) - if not blacklist_json: - blacklist_json = "{}" - bl_dict = json.loads(blacklist_json) + blocklist_json = mgr.get_store(cls.JWT_TOKEN_BLOCKLIST_KEY) + if not blocklist_json: + blocklist_json = "{}" + bl_dict = json.loads(blocklist_json) now = time.time() # remove expired tokens @@ -128,14 +128,14 @@ class JwtManager(object): del bl_dict[jti] bl_dict[token['jti']] = token['exp'] - mgr.set_store(cls.JWT_TOKEN_BLACKLIST_KEY, json.dumps(bl_dict)) + mgr.set_store(cls.JWT_TOKEN_BLOCKLIST_KEY, json.dumps(bl_dict)) @classmethod - def is_blacklisted(cls, jti): - blacklist_json = mgr.get_store(cls.JWT_TOKEN_BLACKLIST_KEY) - if not blacklist_json: - blacklist_json = "{}" - bl_dict = json.loads(blacklist_json) + def is_blocklisted(cls, jti): + blocklist_json = mgr.get_store(cls.JWT_TOKEN_BLOCKLIST_KEY) + if not blocklist_json: + blocklist_json = "{}" + bl_dict = json.loads(blocklist_json) return jti in bl_dict diff --git a/src/pybind/mgr/dashboard/tests/test_rest_tasks.py b/src/pybind/mgr/dashboard/tests/test_rest_tasks.py index e9d7907f0524..3cf87d87d903 100644 --- a/src/pybind/mgr/dashboard/tests/test_rest_tasks.py +++ b/src/pybind/mgr/dashboard/tests/test_rest_tasks.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=blacklisted-name import time @@ -35,13 +34,13 @@ class TaskTest(RESTController): time.sleep(TaskTest.sleep_time) @Task('task/foo', ['{param}']) - @RESTController.Collection('POST') - def foo(self, param): + @RESTController.Collection('POST', path='/foo') + def foo_post(self, param): return {'my_param': param} @Task('task/bar', ['{key}', '{param}']) - @RESTController.Resource('PUT') - def bar(self, key, param=None): + @RESTController.Resource('PUT', path='/bar') + def bar_put(self, key, param=None): return {'my_param': param, 'key': key} @Task('task/query', ['{param}']) diff --git a/src/pybind/mgr/dashboard/tests/test_tools.py b/src/pybind/mgr/dashboard/tests/test_tools.py index 0f27ec8e6346..8a475ad0ca9e 100644 --- a/src/pybind/mgr/dashboard/tests/test_tools.py +++ b/src/pybind/mgr/dashboard/tests/test_tools.py @@ -70,9 +70,8 @@ class FooArgs(RESTController): raise cherrypy.NotFound() -# pylint: disable=blacklisted-name class Root(object): - foo = FooResource() + foo_resource = FooResource() fooargs = FooArgs() diff --git a/src/pybind/mgr/dashboard/tox.ini b/src/pybind/mgr/dashboard/tox.ini index f611ace16234..b147e3d8cafe 100644 --- a/src/pybind/mgr/dashboard/tox.ini +++ b/src/pybind/mgr/dashboard/tox.ini @@ -47,6 +47,7 @@ deps = {[base]deps} {[base-test]deps} {[base-lint]deps} +# TODO: replace with allowlist_external tox=>16.1 (https://github.com/tox-dev/tox/pull/1601) whitelist_externals = * commands = {posargs}