diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index b16062e5af..6596bbf86e 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the **Prowler API** are documented in this file. +## [v1.6.1] (Prowler UNRELEASED) + +### Changed +- Changed `findings.uid` field length from `varchar(300)` to `varchar(600)` [(#7498)](https://github.com/prowler-cloud/prowler/pull/7498). + --- ## [v1.6.0] (Prowler v5.5.0) diff --git a/api/pyproject.toml b/api/pyproject.toml index bd8be47ca1..2a24d26d1d 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -35,7 +35,7 @@ name = "prowler-api" package-mode = false # Needed for the SDK compatibility requires-python = ">=3.11,<3.13" -version = "1.6.0" +version = "1.6.1" [project.scripts] celery = "src.backend.config.settings.celery" diff --git a/api/src/backend/api/migrations/0017_alter_finding_uid.py b/api/src/backend/api/migrations/0017_alter_finding_uid.py new file mode 100644 index 0000000000..4c72d1b9a2 --- /dev/null +++ b/api/src/backend/api/migrations/0017_alter_finding_uid.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1.7 on 2025-04-14 06:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("api", "0016_finding_compliance_resource_details_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="finding", + name="uid", + field=models.CharField(max_length=600), + ), + ] diff --git a/api/src/backend/api/models.py b/api/src/backend/api/models.py index 69b7ead46a..bede403194 100644 --- a/api/src/backend/api/models.py +++ b/api/src/backend/api/models.py @@ -641,7 +641,7 @@ class Finding(PostgresPartitionedModel, RowLevelSecurityProtectedModel): updated_at = models.DateTimeField(auto_now=True, editable=False) first_seen_at = models.DateTimeField(editable=False, null=True) - uid = models.CharField(max_length=300) + uid = models.CharField(max_length=600) delta = FindingDeltaEnumField( choices=DeltaChoices.choices, blank=True, diff --git a/api/src/backend/api/specs/v1.yaml b/api/src/backend/api/specs/v1.yaml index 30c9dbb675..39464648fe 100644 --- a/api/src/backend/api/specs/v1.yaml +++ b/api/src/backend/api/specs/v1.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: title: Prowler API - version: 1.6.0 + version: 1.6.1 description: |- Prowler API specification. @@ -6228,7 +6228,7 @@ components: properties: uid: type: string - maxLength: 300 + maxLength: 600 delta: enum: - new diff --git a/api/src/backend/api/tests/test_models.py b/api/src/backend/api/tests/test_models.py index b6ef1a66c9..25ee7d9ad9 100644 --- a/api/src/backend/api/tests/test_models.py +++ b/api/src/backend/api/tests/test_models.py @@ -1,6 +1,6 @@ import pytest -from api.models import Resource, ResourceTag +from api.models import Finding, Resource, ResourceTag, StatusChoices @pytest.mark.django_db @@ -92,3 +92,31 @@ class TestResourceModel: assert len(resource.tags.filter(tenant_id=tenant_id)) == 0 assert resource.get_tags(tenant_id=tenant_id) == {} + + +@pytest.mark.django_db +class TestFindingModel: + def test_add_finding_with_long_uid( + self, providers_fixture, scans_fixture, resources_fixture + ): + provider, *_ = providers_fixture + tenant_id = provider.tenant_id + + long_uid = "1" * 500 + _ = Finding.objects.create( + tenant_id=tenant_id, + uid=long_uid, + delta=Finding.DeltaChoices.NEW, + check_metadata={}, + status=StatusChoices.PASS, + status_extended="", + severity="high", + impact="high", + raw_result={}, + check_id="test_check", + scan=scans_fixture[0], + first_seen_at=None, + muted=False, + compliance={}, + ) + assert Finding.objects.filter(uid=long_uid).exists() diff --git a/api/src/backend/api/v1/views.py b/api/src/backend/api/v1/views.py index e8dd81ac29..40e4c59071 100644 --- a/api/src/backend/api/v1/views.py +++ b/api/src/backend/api/v1/views.py @@ -247,7 +247,7 @@ class SchemaView(SpectacularAPIView): def get(self, request, *args, **kwargs): spectacular_settings.TITLE = "Prowler API" - spectacular_settings.VERSION = "1.6.0" + spectacular_settings.VERSION = "1.6.1" spectacular_settings.DESCRIPTION = ( "Prowler API specification.\n\nThis file is auto-generated." )