|
| 1 | +# Generated by Django 5.1.14 on 2025-11-19 13:03 |
| 2 | + |
| 3 | +import uuid |
| 4 | + |
| 5 | +import django.db.models.deletion |
| 6 | +from django.db import migrations, models |
| 7 | + |
| 8 | +import api.rls |
| 9 | + |
| 10 | + |
| 11 | +class Migration(migrations.Migration): |
| 12 | + dependencies = [ |
| 13 | + ("api", "0059_compliance_overview_summary"), |
| 14 | + ] |
| 15 | + |
| 16 | + operations = [ |
| 17 | + migrations.CreateModel( |
| 18 | + name="AttackSurfaceOverview", |
| 19 | + fields=[ |
| 20 | + ( |
| 21 | + "id", |
| 22 | + models.UUIDField( |
| 23 | + default=uuid.uuid4, |
| 24 | + editable=False, |
| 25 | + primary_key=True, |
| 26 | + serialize=False, |
| 27 | + ), |
| 28 | + ), |
| 29 | + ("inserted_at", models.DateTimeField(auto_now_add=True)), |
| 30 | + ( |
| 31 | + "attack_surface_type", |
| 32 | + models.CharField( |
| 33 | + choices=[ |
| 34 | + ("internet-exposed", "Internet Exposed"), |
| 35 | + ("secrets", "Exposed Secrets"), |
| 36 | + ("privilege-escalation", "Privilege Escalation"), |
| 37 | + ("ec2-imdsv1", "EC2 IMDSv1 Enabled"), |
| 38 | + ], |
| 39 | + max_length=50, |
| 40 | + ), |
| 41 | + ), |
| 42 | + ("total_findings", models.IntegerField(default=0)), |
| 43 | + ("failed_findings", models.IntegerField(default=0)), |
| 44 | + ("muted_failed_findings", models.IntegerField(default=0)), |
| 45 | + ], |
| 46 | + options={ |
| 47 | + "db_table": "attack_surface_overviews", |
| 48 | + "abstract": False, |
| 49 | + }, |
| 50 | + ), |
| 51 | + migrations.AddField( |
| 52 | + model_name="attacksurfaceoverview", |
| 53 | + name="scan", |
| 54 | + field=models.ForeignKey( |
| 55 | + on_delete=django.db.models.deletion.CASCADE, |
| 56 | + related_name="attack_surface_overviews", |
| 57 | + related_query_name="attack_surface_overview", |
| 58 | + to="api.scan", |
| 59 | + ), |
| 60 | + ), |
| 61 | + migrations.AddField( |
| 62 | + model_name="attacksurfaceoverview", |
| 63 | + name="tenant", |
| 64 | + field=models.ForeignKey( |
| 65 | + on_delete=django.db.models.deletion.CASCADE, to="api.tenant" |
| 66 | + ), |
| 67 | + ), |
| 68 | + migrations.AddIndex( |
| 69 | + model_name="attacksurfaceoverview", |
| 70 | + index=models.Index( |
| 71 | + fields=["tenant_id", "scan_id"], name="attack_surf_tenant_scan_idx" |
| 72 | + ), |
| 73 | + ), |
| 74 | + migrations.AddConstraint( |
| 75 | + model_name="attacksurfaceoverview", |
| 76 | + constraint=models.UniqueConstraint( |
| 77 | + fields=("tenant_id", "scan_id", "attack_surface_type"), |
| 78 | + name="unique_attack_surface_per_scan", |
| 79 | + ), |
| 80 | + ), |
| 81 | + migrations.AddConstraint( |
| 82 | + model_name="attacksurfaceoverview", |
| 83 | + constraint=api.rls.RowLevelSecurityConstraint( |
| 84 | + "tenant_id", |
| 85 | + name="rls_on_attacksurfaceoverview", |
| 86 | + statements=["SELECT", "INSERT", "UPDATE", "DELETE"], |
| 87 | + ), |
| 88 | + ), |
| 89 | + ] |
0 commit comments