Agent: Use SecretStr and SecretBytes instead of SecretField

SecretField is a base type for secrets, but it doesn't seem to be exported. When the agent is ran, this import fails
This commit is contained in:
vakaris_zilius 2022-09-06 12:54:24 +00:00
parent 472ca382f1
commit 9fb2804202
1 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import json import json
from pydantic import BaseModel, SecretField from pydantic import BaseModel, SecretBytes, SecretStr
from common import OperatingSystem from common import OperatingSystem
@ -11,6 +11,6 @@ class TelemetryJSONEncoder(json.JSONEncoder):
return obj.name return obj.name
if issubclass(type(obj), BaseModel): if issubclass(type(obj), BaseModel):
return obj.dict(simplify=True) return obj.dict(simplify=True)
if issubclass(type(obj), SecretField): if issubclass(type(obj), (SecretStr, SecretBytes)):
return obj.get_secret_value() return obj.get_secret_value()
return json.JSONEncoder.default(self, obj) return json.JSONEncoder.default(self, obj)