Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BitTheByte committed Apr 12, 2024
1 parent 1d74176 commit 32b0ad2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
28 changes: 28 additions & 0 deletions monitorizer/inventory/migrations/0002_alter_domainscan_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0.4 on 2024-04-12 20:28

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("inventory", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="domainscan",
name="status",
field=models.CharField(
choices=[
("pending", "Pending"),
("running", "Running"),
("success", "Success"),
("error", "Error"),
],
db_index=True,
default="pending",
max_length=32,
),
),
]
5 changes: 4 additions & 1 deletion monitorizer/inventory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ class ScanStatus(models.TextChoices):

domain = models.ForeignKey(SeedDomain, on_delete=models.CASCADE, blank=True)
status = models.CharField(
choices=ScanStatus.choices, max_length=32, default=ScanStatus.PENDING
choices=ScanStatus.choices,
max_length=32,
default=ScanStatus.PENDING,
db_index=True,
)
command_tpl = models.ForeignKey(CommandTemplate, on_delete=models.CASCADE)
command_tpl_vars = models.JSONField(null=True, blank=True)
Expand Down
9 changes: 9 additions & 0 deletions monitorizer/inventory/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def execute_scan_descriptor(descriptor_pk):
descriptor = models.ScanAutoSubmitter.objects.get(pk=descriptor_pk)
if not descriptor.domain.enabled:
return

if (
models.DomainScan.objects.filter(
status=models.DomainScan.ScanStatus.PENDING
).count()
> 1500
):
return

for command in descriptor.commands.all():
models.DomainScan.objects.create(
descriptor=descriptor,
Expand Down

0 comments on commit 32b0ad2

Please sign in to comment.