mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-18 20:58:06 +00:00
Fix issue when deserializing GithubIssueTemplate with hidden secret (#1008)
This commit is contained in:
@ -511,15 +511,26 @@ class GithubIssueTemplate(BaseModel):
|
||||
# validator needed for backward compatibility
|
||||
@validator("auth", pre=True, always=True)
|
||||
def validate_auth(cls, v: Any) -> SecretData:
|
||||
def try_parse_GithubAuth(x: dict) -> Optional[GithubAuth]:
|
||||
try:
|
||||
return GithubAuth.parse_obj(x)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
if isinstance(v, GithubAuth):
|
||||
return SecretData(secret=v)
|
||||
elif isinstance(v, SecretData):
|
||||
return v
|
||||
elif isinstance(v, dict):
|
||||
try:
|
||||
return SecretData(GithubAuth.parse_obj(v))
|
||||
except Exception:
|
||||
return SecretData(GithubAuth.parse_obj(v["secret"]))
|
||||
githubAuth = try_parse_GithubAuth(v)
|
||||
if githubAuth:
|
||||
return SecretData(secret=githubAuth)
|
||||
|
||||
githubAuth = try_parse_GithubAuth(v["secret"])
|
||||
if githubAuth:
|
||||
return SecretData(secret=githubAuth)
|
||||
|
||||
return SecretData(secret=v["secret"])
|
||||
else:
|
||||
raise TypeError(f"invalid datatype {type(v)}")
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
import unittest
|
||||
|
||||
from onefuzztypes.models import Scaleset, SecretData, TeamsTemplate
|
||||
from onefuzztypes.requests import NotificationCreate
|
||||
from onefuzztypes.primitives import PoolName, Region
|
||||
from onefuzztypes.requests import NotificationCreate
|
||||
from pydantic import ValidationError
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user