From 09be60948d308fa0b2c1d07229cfb75daf1a3231 Mon Sep 17 00:00:00 2001 From: Prowler Bot Date: Tue, 15 Apr 2025 12:17:43 +0200 Subject: [PATCH] revert: fix(findings): increase uid max length to 600 (#7529) Co-authored-by: Pepe Fagoaga --- api/CHANGELOG.md | 6 --- api/pyproject.toml | 2 +- .../api/migrations/0017_alter_finding_uid.py | 17 ------ api/src/backend/api/models.py | 2 +- api/src/backend/api/specs/v1.yaml | 4 +- api/src/backend/api/tests/test_models.py | 52 +++++++++---------- api/src/backend/api/v1/views.py | 2 +- 7 files changed, 31 insertions(+), 54 deletions(-) delete mode 100644 api/src/backend/api/migrations/0017_alter_finding_uid.py diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 24530a2f6f..5e92a3025c 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -2,12 +2,6 @@ All notable changes to the **Prowler API** are documented in this file. -## [v1.6.1] (Prowler v5.5.1) - -### 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 2a24d26d1d..bd8be47ca1 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.1" +version = "1.6.0" [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 deleted file mode 100644 index 4c72d1b9a2..0000000000 --- a/api/src/backend/api/migrations/0017_alter_finding_uid.py +++ /dev/null @@ -1,17 +0,0 @@ -# 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 bede403194..69b7ead46a 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=600) + uid = models.CharField(max_length=300) 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 39464648fe..30c9dbb675 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.1 + version: 1.6.0 description: |- Prowler API specification. @@ -6228,7 +6228,7 @@ components: properties: uid: type: string - maxLength: 600 + maxLength: 300 delta: enum: - new diff --git a/api/src/backend/api/tests/test_models.py b/api/src/backend/api/tests/test_models.py index 25ee7d9ad9..c2beeb3583 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 Finding, Resource, ResourceTag, StatusChoices +from api.models import Resource, ResourceTag @pytest.mark.django_db @@ -94,29 +94,29 @@ class TestResourceModel: 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 +# @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() +# 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 40e4c59071..e8dd81ac29 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.1" + spectacular_settings.VERSION = "1.6.0" spectacular_settings.DESCRIPTION = ( "Prowler API specification.\n\nThis file is auto-generated." )