Skip to content

Commit

Permalink
Merge branch 'feature/report-recipe' of github.com:minvws/nl-kat-coor…
Browse files Browse the repository at this point in the history
…dination into feature/schedule-report
  • Loading branch information
Rieven committed Sep 25, 2024
2 parents f46ebb1 + 5a5dc78 commit f68be57
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 16 additions & 1 deletion octopoes/octopoes/models/ooi/reports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Literal
from typing import Any, Literal
from uuid import UUID

from octopoes.models import OOI, Reference
Expand Down Expand Up @@ -39,10 +39,25 @@ class Report(OOI):

observed_at: datetime
parent_report: Reference | None = ReferenceField("Report", default=None)
report_recipe: Reference | None = ReferenceField("ReportRecipe", default=None)
has_parent: bool

_natural_key_attrs = ["report_id"]

@classmethod
def format_reference_human_readable(cls, reference: Reference) -> str:
return f"Report {reference.tokenized.report_id}"


class ReportRecipe(OOI):
object_type: Literal["ReportRecipe"] = "ReportRecipe"

recipe_id: UUID

report_name_format: str
subreport_name_format: str

input_recipe: dict[str, Any] # can contain a query which maintains a live set of OOIs or manually picked OOIs.
report_types: list[str]

cron_expression: str
3 changes: 2 additions & 1 deletion octopoes/octopoes/models/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Network,
)
from octopoes.models.ooi.question import Question
from octopoes.models.ooi.reports import Report, ReportData
from octopoes.models.ooi.reports import Report, ReportData, ReportRecipe
from octopoes.models.ooi.scans import ExternalScan
from octopoes.models.ooi.service import IPService, Service, TLSCipher
from octopoes.models.ooi.software import Software, SoftwareInstance
Expand Down Expand Up @@ -163,6 +163,7 @@
| ScanType
| Report
| GeographicPoint
| ReportRecipe
)

OOIType = ConcreteOOIType | NetworkType | FindingTypeType
Expand Down
2 changes: 1 addition & 1 deletion rocky/reports/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def post(self, request, *args, **kwargs):
return PostRedirect(self.get_next())
return self.get(request, *args, **kwargs)

def all_plugins_enabled(self):
def all_plugins_enabled(self) -> bool:
enabled_plugins = self.plugins_enabled()
return enabled_plugins["required"] and enabled_plugins["optional"]

Expand Down

0 comments on commit f68be57

Please sign in to comment.