]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: remove racially insensitive terms
authorErnesto Puerta <epuertat@redhat.com>
Thu, 20 Aug 2020 12:22:57 +0000 (14:22 +0200)
committerNeha Ojha <nojha@redhat.com>
Mon, 24 Aug 2020 19:53:08 +0000 (19:53 +0000)
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
src/pybind/mgr/dashboard/.pylintrc
src/pybind/mgr/dashboard/controllers/auth.py
src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts
src/pybind/mgr/dashboard/services/auth.py
src/pybind/mgr/dashboard/tests/test_rest_tasks.py
src/pybind/mgr/dashboard/tests/test_tools.py
src/pybind/mgr/dashboard/tox.ini

index 404a16a2e6fa9a269ad2e869527c93f69158c77e..4b79f2351817899ba2dd4944bdbe5fafd59739f3 100644 (file)
@@ -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=
 
index fb021be84201d436c4ea0e5016176a3e5fc6a5c7..6f28379c6a213629aa9f1239a3dbf7fa6b671471 100644 (file)
@@ -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'
index 46f3c8400cefd9df2210bbf6259720a91ea35354..606cddb9ac84fa5c2ac037375cd70ff6c9cd851d 100644 (file)
@@ -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'];
index 955b3f9cc6fb08ea247f7e5cc79caab78c63c9fc..94d3cba55a00f207083d853232a7faec694c6f94 100644 (file)
@@ -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
 
 
index e9d7907f0524bdc246bd8392908fe761398652df..3cf87d87d90338613eed6ef4bd6925aace3e2b48 100644 (file)
@@ -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}'])
index 0f27ec8e634670b849819589f8c0187f28a880a9..8a475ad0ca9e06f2e3725a8bdd7f27ba7e373e80 100644 (file)
@@ -70,9 +70,8 @@ class FooArgs(RESTController):
         raise cherrypy.NotFound()
 
 
-# pylint: disable=blacklisted-name
 class Root(object):
-    foo = FooResource()
+    foo_resource = FooResource()
     fooargs = FooArgs()
 
 
index f611ace16234b8c6aced2d998a81afb794eb8f14..b147e3d8cafe5f0f4faaca933e576c0630d0a847 100644 (file)
@@ -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}