Fixes: #16292 - Properly restrict GraphQL queries for querys with pk set (#17244)

* Fixes: #16292 - Properly restrict GraphQL queries for querys with pk set

* Update netbox/netbox/settings.py

* Apply schema adaptations across all apps

* Extend GraphQL API tests

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
Daniel Sheppard
2024-08-28 11:23:25 -05:00
committed by GitHub
parent 765a12378d
commit bc97b12bd2
14 changed files with 171 additions and 352 deletions

View File

@@ -3,38 +3,25 @@ from typing import List
import strawberry
import strawberry_django
from virtualization import models
from .types import *
@strawberry.type
@strawberry.type(name="Query")
class VirtualizationQuery:
@strawberry.field
def cluster(self, id: int) -> ClusterType:
return models.Cluster.objects.get(pk=id)
cluster: ClusterType = strawberry_django.field()
cluster_list: List[ClusterType] = strawberry_django.field()
@strawberry.field
def cluster_group(self, id: int) -> ClusterGroupType:
return models.ClusterGroup.objects.get(pk=id)
cluster_group: ClusterGroupType = strawberry_django.field()
cluster_group_list: List[ClusterGroupType] = strawberry_django.field()
@strawberry.field
def cluster_type(self, id: int) -> ClusterTypeType:
return models.ClusterType.objects.get(pk=id)
cluster_type: ClusterTypeType = strawberry_django.field()
cluster_type_list: List[ClusterTypeType] = strawberry_django.field()
@strawberry.field
def virtual_machine(self, id: int) -> VirtualMachineType:
return models.VirtualMachine.objects.get(pk=id)
virtual_machine: VirtualMachineType = strawberry_django.field()
virtual_machine_list: List[VirtualMachineType] = strawberry_django.field()
@strawberry.field
def vm_interface(self, id: int) -> VMInterfaceType:
return models.VMInterface.objects.get(pk=id)
vm_interface: VMInterfaceType = strawberry_django.field()
vm_interface_list: List[VMInterfaceType] = strawberry_django.field()
@strawberry.field
def virtual_disk(self, id: int) -> VirtualDiskType:
return models.VirtualDisk.objects.get(pk=id)
virtual_disk: VirtualDiskType = strawberry_django.field()
virtual_disk_list: List[VirtualDiskType] = strawberry_django.field()