Skip to content

Commit

Permalink
@GitHK review: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Feb 10, 2022
1 parent b48785f commit 9549694
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Any, Dict, Optional
from typing import Any, Dict, List, Optional

from aiohttp import web
from models_library.basic_types import (
Expand Down Expand Up @@ -161,6 +161,19 @@ def is_plugin(self, field_name: str) -> bool:
return True
return False

def _get_disabled_public_plugins(self) -> List[str]:
plugins_disabled = []
# NOTE: this list is limited for security reasons. An unbounded list
# might reveal critical info on the settings of a deploy to the client.
PUBLIC_PLUGIN_CANDIDATES = [
"WEBSERVER_EXPORTER",
"WEBSERVER_SCICRUNCH",
]
for field_name in PUBLIC_PLUGIN_CANDIDATES:
if self.is_plugin(field_name) and not self.is_enabled(field_name):
plugins_disabled.append(field_name)
return plugins_disabled

def public_dict(self) -> Dict[str, Any]:
"""Data publicaly available"""
return self.dict(
Expand Down Expand Up @@ -188,17 +201,7 @@ def to_client_statics(self) -> Dict[str, Any]:
exclude_none=True,
by_alias=True,
)

# gets names of disabled plugins
plugins_disabled = []
# NOTE: this list is limited for security reasons. An umbounded list
# might reveal critical info on the settings of a deploy.
selected_plugins = ["WEBSERVER_EXPORTER", "WEBSERVER_SCICRUNCH"]
for field_name in selected_plugins:
if self.is_plugin(field_name) and not self.is_enabled(field_name):
plugins_disabled.append(field_name)

data["plugins_disabled"] = plugins_disabled
data["plugins_disabled"] = self._get_disabled_public_plugins()

# Alias in addition MUST be camelcase here
return {snake_to_camel(k): v for k, v in data.items()}
Expand Down
1 change: 0 additions & 1 deletion services/web/server/tests/integration/01/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def client(
postgres_with_template_db: aiopg.sa.engine.Engine,
mock_orphaned_services: mock.Mock,
monkeypatch_setenv_from_app_config: Callable,
monkeypatch,
):
# test config & env vars ----------------------
cfg = deepcopy(app_config)
Expand Down

0 comments on commit 9549694

Please sign in to comment.