Skip to content

Commit

Permalink
Merge pull request #330 from muralov/sanitize-sensitive-info
Browse files Browse the repository at this point in the history
feat: sanitize sensitive information
  • Loading branch information
kyma-bot authored Jan 21, 2025
2 parents d542d27 + 39283b8 commit 7cf8a5b
Show file tree
Hide file tree
Showing 25 changed files with 3,293 additions and 1,396 deletions.
1,351 changes: 842 additions & 509 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ pytest-rerunfailures = "^15.0"
python-decouple = "^3.8"
redis = "^5.0.8"
requests = "^2.32.3"
scrubadub = {extras = ["all"], version = "^2.0.1"}
tiktoken = "^0.7.0"

[tool.poetry.group.test.dependencies]
deepeval = "^2.0.6"
deepeval = "^2.1.2"
fakeredis = "^2.23.3"
prettytable = "^3.10.2"
pytest = "^8.2.2"
Expand Down
7 changes: 3 additions & 4 deletions src/agents/k8s/tools/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from langgraph.prebuilt import InjectedState
from pydantic import BaseModel

from services.k8s import DataSanitizer, IK8sClient
from services.k8s import IK8sClient


class K8sQueryToolArgs(BaseModel):
Expand All @@ -26,15 +26,14 @@ def k8s_query_tool(
The returned data is sanitized to remove any sensitive information.
For example, it will always remove the `data` field of a `Secret` object."""
try:
response = k8s_client.execute_get_api_request(uri)
result = response.json()
result = k8s_client.execute_get_api_request(uri)
if not isinstance(result, list) and not isinstance(result, dict):
raise Exception(
f"failed executing k8s_query_tool with URI: {uri}."
f"The result is not a list or dict, but a {type(result)}"
)

return DataSanitizer.sanitize(result)
return result
except Exception as e:
raise Exception(
f"failed executing k8s_query_tool with URI: {uri},"
Expand Down
7 changes: 3 additions & 4 deletions src/agents/kyma/tools/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from langgraph.prebuilt import InjectedState
from pydantic import BaseModel

from services.k8s import DataSanitizer, IK8sClient
from services.k8s import IK8sClient


class KymaQueryToolArgs(BaseModel):
Expand All @@ -28,15 +28,14 @@ def kyma_query_tool(
- /apis/serverless.kyma-project.io/v1alpha2/namespaces/default/functions
- /apis/gateway.kyma-project.io/v1beta1/namespaces/default/apirules"""
try:
response = k8s_client.execute_get_api_request(uri)
result = response.json()
result = k8s_client.execute_get_api_request(uri)
if not isinstance(result, list) and not isinstance(result, dict):
raise Exception(
f"failed executing kyma_query_tool with URI: {uri}."
f"The result is not a list or dict, but a {type(result)}"
)

return DataSanitizer.sanitize(result)
return result
except Exception as e:
raise Exception(
f"failed executing kyma_query_tool with URI: {uri},"
Expand Down
Loading

0 comments on commit 7cf8a5b

Please sign in to comment.