feat(api): add metadata attributes to ResourceSerializer and tests (#9098)

This commit is contained in:
Rakan Farhouda
2025-11-17 14:10:45 +03:00
committed by GitHub
parent e715b9fbfb
commit 518508d5fe
4 changed files with 177 additions and 77 deletions

View File

@@ -15,6 +15,7 @@ All notable changes to the **Prowler API** are documented in this file.
- Support C5 compliance framework for the GCP provider [(#9097)](https://github.com/prowler-cloud/prowler/pull/9097)
- Support for Amazon Bedrock and OpenAI compatible providers in Lighthouse AI [(#8957)](https://github.com/prowler-cloud/prowler/pull/8957)
- Tenant-wide ThreatScore overview aggregation and snapshot persistence with backfill support [(#9148)](https://github.com/prowler-cloud/prowler/pull/9148)
- Added `metadata`, `details`, and `partition` attributes to `/resources` endpoint & `details`, and `partition` to `/findings` endpoint [(#9098)](https://github.com/prowler-cloud/prowler/pull/9098)
- Support for MongoDB Atlas provider [(#9167)](https://github.com/prowler-cloud/prowler/pull/9167)
### Changed
@@ -28,7 +29,7 @@ All notable changes to the **Prowler API** are documented in this file.
## [1.14.2] (Prowler 5.13.2)
### Fixed
- Update unique constraint for `Provider` model to exclude soft-deleted entries, resolving duplicate errors when re-deleting providers.[(#9054)](https://github.com/prowler-cloud/prowler/pull/9054)
- Update unique constraint for `Provider` model to exclude soft-deleted entries, resolving duplicate errors when re-deleting providers [(#9054)](https://github.com/prowler-cloud/prowler/pull/9054)
- Remove compliance generation for providers without compliance frameworks [(#9208)](https://github.com/prowler-cloud/prowler/pull/9208)
## [1.14.1] (Prowler 5.13.1)

View File

@@ -869,16 +869,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -896,15 +896,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -1407,16 +1408,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -1434,15 +1435,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -1853,16 +1855,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -1880,15 +1882,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -2297,16 +2300,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -2324,15 +2327,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -2729,16 +2733,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -2756,15 +2760,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -4565,16 +4570,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -4592,15 +4597,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -4753,16 +4759,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -4780,15 +4786,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -5007,16 +5014,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -5034,15 +5041,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -5741,16 +5749,16 @@ paths:
name: filter[provider]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -5768,15 +5776,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -5788,6 +5797,7 @@ paths:
* `m365` - M365
* `github` - GitHub
* `mongodbatlas` - MongoDB Atlas
* `iac` - IaC
* `oraclecloud` - Oracle Cloud Infrastructure
explode: false
style: form
@@ -5795,14 +5805,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -5811,6 +5823,8 @@ paths:
* `kubernetes` - Kubernetes
* `m365` - M365
* `github` - GitHub
* `mongodbatlas` - MongoDB Atlas
* `iac` - IaC
* `oraclecloud` - Oracle Cloud Infrastructure
- in: query
name: filter[provider_type__in]
@@ -5818,14 +5832,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -5836,6 +5852,8 @@ paths:
* `kubernetes` - Kubernetes
* `m365` - M365
* `github` - GitHub
* `mongodbatlas` - MongoDB Atlas
* `iac` - IaC
* `oraclecloud` - Oracle Cloud Infrastructure
explode: false
style: form
@@ -6371,6 +6389,9 @@ paths:
- findings
- failed_findings_count
- url
- metadata
- details
- partition
- type
description: endpoint return only specific fields in the response on a per-type
basis by including a fields[TYPE] query parameter.
@@ -6434,16 +6455,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -6461,15 +6482,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -6703,6 +6725,9 @@ paths:
- findings
- failed_findings_count
- url
- metadata
- details
- partition
- type
description: endpoint return only specific fields in the response on a per-type
basis by including a fields[TYPE] query parameter.
@@ -6762,6 +6787,9 @@ paths:
- findings
- failed_findings_count
- url
- metadata
- details
- partition
- type
description: endpoint return only specific fields in the response on a per-type
basis by including a fields[TYPE] query parameter.
@@ -6810,16 +6838,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -6837,15 +6865,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -7087,16 +7116,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -7114,15 +7143,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -7370,16 +7400,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -7397,15 +7427,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -8216,16 +8247,16 @@ paths:
name: filter[provider_type]
schema:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
* `aws` - AWS
@@ -8243,15 +8274,16 @@ paths:
type: array
items:
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
enum:
- aws
- azure
- gcp
- github
- mongodbatlas
- iac
- kubernetes
- m365
- mongodbatlas
- oraclecloud
description: |-
Multiple values may be separated by commas.
@@ -14285,7 +14317,7 @@ components:
type: string
description: GitHub OAuth App token for authentication.
required:
- oauth_app_token
- oauth_app_token
- type: object
title: GitHub App Credentials
properties:
@@ -14298,18 +14330,6 @@ components:
required:
- github_app_id
- github_app_key
- type: object
title: MongoDB Atlas API Key
properties:
atlas_public_key:
type: string
description: MongoDB Atlas API public key.
atlas_private_key:
type: string
description: MongoDB Atlas API private key.
required:
- atlas_public_key
- atlas_private_key
- type: object
title: IaC Repository Credentials
properties:
@@ -14354,6 +14374,18 @@ components:
- fingerprint
- tenancy
- region
- type: object
title: MongoDB Atlas API Key
properties:
atlas_public_key:
type: string
description: MongoDB Atlas API public key.
atlas_private_key:
type: string
description: MongoDB Atlas API private key.
required:
- atlas_public_key
- atlas_private_key
writeOnly: true
required:
- secret
@@ -15349,6 +15381,7 @@ components:
- m365
- github
- mongodbatlas
- iac
- oraclecloud
type: string
description: |-
@@ -15359,8 +15392,9 @@ components:
* `m365` - M365
* `github` - GitHub
* `mongodbatlas` - MongoDB Atlas
* `iac` - IaC
* `oraclecloud` - Oracle Cloud Infrastructure
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
uid:
type: string
title: Unique identifier for the provider, set by the provider
@@ -15473,9 +15507,10 @@ components:
- m365
- github
- mongodbatlas
- iac
- oraclecloud
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
description: |-
Type of provider to create.
@@ -15486,12 +15521,13 @@ components:
* `m365` - M365
* `github` - GitHub
* `mongodbatlas` - MongoDB Atlas
* `iac` - IaC
* `oraclecloud` - Oracle Cloud Infrastructure
uid:
type: string
title: Unique identifier for the provider, set by the provider
description: Unique identifier for the provider, set by the provider,
e.g. AWS account ID, Azure subscription ID, GCP project ID, MongoDB Atlas organization ID, etc.
e.g. AWS account ID, Azure subscription ID, GCP project ID, etc.
maxLength: 250
minLength: 3
required:
@@ -15531,9 +15567,10 @@ components:
- m365
- github
- mongodbatlas
- iac
- oraclecloud
type: string
x-spec-enum-id: 7087703783970b51
x-spec-enum-id: eca8c51e6bd28935
description: |-
Type of provider to create.
@@ -15544,13 +15581,14 @@ components:
* `m365` - M365
* `github` - GitHub
* `mongodbatlas` - MongoDB Atlas
* `iac` - IaC
* `oraclecloud` - Oracle Cloud Infrastructure
uid:
type: string
minLength: 3
title: Unique identifier for the provider, set by the provider
description: Unique identifier for the provider, set by the provider,
e.g. AWS account ID, Azure subscription ID, GCP project ID, MongoDB Atlas organization ID, etc.
e.g. AWS account ID, Azure subscription ID, GCP project ID, etc.
maxLength: 250
required:
- uid
@@ -16295,6 +16333,18 @@ components:
- fingerprint
- tenancy
- region
- type: object
title: MongoDB Atlas API Key
properties:
atlas_public_key:
type: string
description: MongoDB Atlas API public key.
atlas_private_key:
type: string
description: MongoDB Atlas API private key.
required:
- atlas_public_key
- atlas_private_key
writeOnly: true
required:
- secret_type
@@ -16608,6 +16658,18 @@ components:
- fingerprint
- tenancy
- region
- type: object
title: MongoDB Atlas API Key
properties:
atlas_public_key:
type: string
description: MongoDB Atlas API public key.
atlas_private_key:
type: string
description: MongoDB Atlas API private key.
required:
- atlas_public_key
- atlas_private_key
writeOnly: true
required:
- secret_type
@@ -16935,6 +16997,18 @@ components:
- fingerprint
- tenancy
- region
- type: object
title: MongoDB Atlas API Key
properties:
atlas_public_key:
type: string
description: MongoDB Atlas API public key.
atlas_private_key:
type: string
description: MongoDB Atlas API private key.
required:
- atlas_public_key
- atlas_private_key
writeOnly: true
required:
- secret
@@ -17023,6 +17097,18 @@ components:
failed_findings_count:
type: integer
readOnly: true
metadata:
type: string
readOnly: true
nullable: true
details:
type: string
readOnly: true
nullable: true
partition:
type: string
readOnly: true
nullable: true
type:
type: string
readOnly: true

View File

@@ -3545,6 +3545,9 @@ class TestResourceViewSet:
)
assert response.status_code == status.HTTP_200_OK
assert len(response.json()["data"]) == len(resources_fixture)
assert "metadata" in response.json()["data"][0]["attributes"]
assert "details" in response.json()["data"][0]["attributes"]
assert "partition" in response.json()["data"][0]["attributes"]
@pytest.mark.parametrize(
"include_values, expected_resources",

View File

@@ -1167,11 +1167,17 @@ class ResourceSerializer(RLSSerializer):
"findings",
"failed_findings_count",
"url",
"metadata",
"details",
"partition",
]
extra_kwargs = {
"id": {"read_only": True},
"inserted_at": {"read_only": True},
"updated_at": {"read_only": True},
"metadata": {"read_only": True},
"details": {"read_only": True},
"partition": {"read_only": True},
}
included_serializers = {
@@ -1228,11 +1234,15 @@ class ResourceIncludeSerializer(RLSSerializer):
"service",
"type_",
"tags",
"details",
"partition",
]
extra_kwargs = {
"id": {"read_only": True},
"inserted_at": {"read_only": True},
"updated_at": {"read_only": True},
"details": {"read_only": True},
"partition": {"read_only": True},
}
@extend_schema_field(