Skip to content

Commit

Permalink
Fix: Too eager schema for FileItemResponseSchema.latest_config field (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Jun 8, 2024
1 parent 20b40b9 commit 10982df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions mwdb/schema/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ class ConfigListResponseSchema(
__envelope_key__ = "configs"


class ConfigLatestItemResponseSchema(ObjectListItemResponseSchema):
"""
Limited ConfigItemResponseSchema that doesn't fetch relationships
and other extra metadata.
Used by FileItemResponseSchema.latest_config field.
"""

family = fields.Str(required=True, allow_none=False)
config_type = fields.Str(required=True, allow_none=False)
cfg = fields.Dict(required=True, allow_none=False)


class ConfigItemResponseSchema(ObjectItemResponseSchema):
family = fields.Str(required=True, allow_none=False)
config_type = fields.Str(required=True, allow_none=False)
Expand Down
4 changes: 2 additions & 2 deletions mwdb/schema/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from marshmallow import Schema, fields, pre_load

from .config import ConfigItemResponseSchema
from .config import ConfigLatestItemResponseSchema
from .object import (
ObjectCreateRequestSchemaBase,
ObjectItemResponseSchema,
Expand Down Expand Up @@ -67,7 +67,7 @@ class FileItemResponseSchema(ObjectItemResponseSchema):
ssdeep = fields.Str(required=True, allow_none=True)

latest_config = fields.Nested(
ConfigItemResponseSchema, required=True, allow_none=True
ConfigLatestItemResponseSchema, required=True, allow_none=True
)


Expand Down

0 comments on commit 10982df

Please sign in to comment.