Skip to content

refactor(reorg): extract every type of class into modules [10/10]#14987

Open
valentijnscholten wants to merge 40 commits into
devfrom
reorg/peripheral-misc
Open

refactor(reorg): extract every type of class into modules [10/10]#14987
valentijnscholten wants to merge 40 commits into
devfrom
reorg/peripheral-misc

Conversation

@valentijnscholten

@valentijnscholten valentijnscholten commented Jun 9, 2026

Copy link
Copy Markdown
Member

Stacked PRs

This is one of a stacked series that reorganizes dojo/ into self-contained dojo/{module}/ packages (matching the dojo/url/ reference). They are stacked — each PR is based on the previous one — so review and merge bottom-up in this order:

  1. refactor(product_type): Extra ProductType models into dojo/product_type/ module [1/10] #14970 — product_type
  2. refactor(test): Extract Test models into dojo/test/ module [2/10] #14971 — test
  3. refactor(engagement): Extract Test models into dojo/test/ module [3/10] #14972 — engagement
  4. refactor(product): Extract Product module into dojo/product/ [4/10] #14973 — product
  5. refactor(finding): Reorganize finding into self-contained dojo/finding/ package [5/10] #14974 — finding (+ CWE & BurpRawRequestResponse fold-in)
  6. refactor(reorg): extract user + system_settings modules [6/10] #14981 — peripheral: user + system_settings
  7. refactor(reorg): extract endpoint + tool_type/tool_config/tool_product modules [7/10] #14982 — peripheral: endpoint + tool_type/tool_config/tool_product
  8. refactor(reorg): extract survey + benchmark modules [8/10] #14983 — peripheral: survey + benchmark
  9. refactor(reorg): extract notes/note_type/file_uploads/reports/risk_acceptance [9/10] #14986 — peripheral: notes/note_type + file_uploads + reports + risk_acceptance
  10. refactor(reorg): extract every type of class into modules [10/10] #14987 — peripheral: regulations + banner + announcement + development_environment + object ◀ this PR

Merge #14970 first; each following branch is rebased onto the updated base and merged in turn. This PR is the top of the stack (on top of #14986) — full implementation brief is the Phase 10 section in AGENTS.md.

Summary

Reorganizes the regulations, banner, announcement, development_environment, and object domains into self-contained dojo/{module}/ packages with ui/ (and, where an API exists, api/) sub-packages, matching the dojo/url/ reference layout. Pure code-movement: no behaviour or migration changes; backward-compat re-exports keep external consumers working.

regulations / development_environment / announcement (have API layers)

  • Move Regulation, Development_Environment, Announcement, UserAnnouncement into their {models,admin}.py (string-ref FKs). The ANNOUNCEMENT_STYLE_CHOICES constant moves into dojo/announcement/models.py (re-exported from dojo.models).
  • Move RegulationSerializer/DevelopmentEnvironmentSerializer/AnnouncementSerializer into each module's api/serializer.py (re-exported from api_v2/serializers.py for prefetcher discovery), and RegulationsViewSet/DevelopmentEnvironmentViewSet/AnnouncementViewSet into api/views.py with add_*_urls, preserving routes/basenames.
  • Move the forms into each module's ui/forms.py and views.py/urls.py into ui/; announcement/os_message.py and signals.py stay.

banner / object (no API layer)

  • Move BannerConf and Objects_Review/Objects_Product into their {models,admin}.py (string-ref FKs; the tagulous.admin.register(Objects_Product.tags) registration moves to dojo/object/admin.py). Move LoginBanner and the object settings forms into each module's ui/forms.py, and views.py/urls.py into ui/.

@valentijnscholten valentijnscholten changed the title refactor(reorg): extract regulations/banner/announcement/development_environment/object [Phase 10 PR 10/10] refactor(reorg): extract regulations/banner/announcement/development_environment/object [10/10] Jun 9, 2026
@Maffooch Maffooch added this to the 3.1.0 milestone Jun 16, 2026
@valentijnscholten valentijnscholten force-pushed the reorg/peripheral-notes-files branch from 446a238 to 8639d9e Compare June 17, 2026 12:23
@valentijnscholten valentijnscholten force-pushed the reorg/peripheral-notes-files branch from 8639d9e to 13ab179 Compare June 17, 2026 20:15
@valentijnscholten valentijnscholten changed the title refactor(reorg): extract regulations/banner/announcement/development_environment/object [10/10] refactor(reorg): extract every type of class into modules [10/10] Jun 17, 2026
@valentijnscholten valentijnscholten changed the base branch from reorg/peripheral-notes-files to dev June 17, 2026 20:30
@valentijnscholten valentijnscholten marked this pull request as ready for review June 17, 2026 21:03
@valentijnscholten

Copy link
Copy Markdown
Member Author

As all the classes/methods are still re-exported from their old locations, the dojo-pro codebase still builds and runs fine.

@dryrunsecurity

dryrunsecurity Bot commented Jun 17, 2026

Copy link
Copy Markdown

DryRun Security

This pull request introduces a high-severity security vulnerability by missing authorization checks in the configure_announcement view, allowing any authenticated user to access, modify, or delete site-wide announcements that should be restricted to administrative staff.

🟠 Missing Authorization Checks in dojo/announcement/ui/views.py (drs_cc8fc769)
Vulnerability Missing Authorization Checks
Description The announcement management view 'configure_announcement' lacks any authorization decorators or explicit permission checks. This allows any authenticated user to access, modify, or delete site-wide announcements, which should be restricted to administrative or staff users.

from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
from dojo.announcement.models import Announcement, UserAnnouncement
from dojo.announcement.ui.forms import AnnouncementCreateForm, AnnouncementRemoveForm
from dojo.utils import add_breadcrumb
logger = logging.getLogger(__name__)


Comment to provide feedback on these findings.

Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]

Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing

All finding details can be found in the DryRun Security Dashboard.

…type/

Phase 1 of module reorg per AGENTS.md. Move Product_Type class + admin
registration into dojo/product_type/{models,admin}.py with backward-compat
re-export in dojo/models.py. No migration change (app_label unchanged).
…/ui/ [Phase 3,4]

Phase 3+4 of module reorg per AGENTS.md. Move Product_TypeForm,
Delete_Product_TypeForm, Add_Product_Type_AuthorizedUsersForm into ui/forms.py
(re-export from dojo/forms.py) and ProductTypeFilter into ui/filters.py. The filter
keeps its DojoFilter base; its only consumer is the product_type view, so no
dojo/filters.py re-export is kept (matches the url module) — avoids the
extracted-filter<->dojo.filters circular import.
valentijnscholten and others added 27 commits June 18, 2026 21:33
…,8,9]

Move 8 Test-domain serializers into api/serializer.py (TestSerializer re-exported
from api_v2/serializers.py for ReportGenerateSerializer; rest omitted, sole consumers
were the moved viewsets), ApiTestFilter/TestImportAPIFilter into api/filters.py, and
TestsViewSet/TestTypesViewSet/TestImportViewSet into api/views.py. api/urls.py adds
add_test_urls() preserving routes tests/test_types/test_imports + basenames
test/test_type/test_imports. Viewset re-exports omitted (would cycle); dojo/urls.py +
test_rest_framework updated. Finding* serializers left in place.
Full rest_framework suite green (871 tests).
…to dojo/engagement/

Phase 1 of module reorg per AGENTS.md. Move Engagement, Engagement_Presets +
admin registrations into dojo/engagement/{models,admin}.py. Cross-module FKs use
string refs to avoid circular imports; ENGAGEMENT_STATUS_CHOICES single-sourced
with re-export. No migration change.
…py [Phase 2 pilot]

Phase 2 of module reorg per AGENTS.md. Move the engagement copy workflow (copy +
product grade recalc + notification) out of the copy_engagement view into an
HTTP-free copy_engagement(engagement, user) service, so both UI and (future) API
can reuse it. The inline notification carried a TODO asking for exactly this.
View is thinned to call the service. Add a unit test for the service (the workflow
was previously untested). Notification URL uses relative reverse() to match the
codebase convention.
…iguration into dojo/product/

Phase 1 of module reorg per AGENTS.md. Move Product, Product_Line,
Product_API_Scan_Configuration + admin registrations into dojo/product/{models,admin}.py.
Cross-module FKs use string refs to avoid circular imports. Product_Type re-export
now pure backward-compat (F401). No migration change.
…ding_Template into dojo/finding/

Phase 1 of module reorg per AGENTS.md. Move Finding (+ custom FindingAdmin),
Vulnerability_Id, Finding_Group, Finding_Template + admin registrations into
dojo/finding/{models,admin}.py. Cross-module FKs use string refs; date/util field
defaults imported from dojo.models to preserve migration serialization path; restore
load-bearing parse_cvss_data re-export for dojo.location side-effect registration.
No migration change.
…ettings/ [system_settings Phase 1,3,5,6,8,9]
…eptance/ [risk_acceptance Phase 1,3,6,7,8,9]
External consumers (notably the dojo-pro plugin, a separate repo) still
import several symbols from their pre-reorg locations. Add the missing
backward-compat re-exports following the patterns already used on this
branch:

- dojo.forms: user forms (UserContactInfoForm, DojoUserForm, ...) + FindingForm
- dojo.api_v2.serializers: TestType/TestCreate/EngagementCheckList serializers
- dojo.api_v2.views: ViewSets moved into per-module api packages, exposed
  lazily via PEP 562 __getattr__ to avoid entry-order circular imports
- dojo.filters: filters moved into per-module ui/api packages, exposed
  lazily via __getattr__ (they import dojo.filters base classes), plus
  BooleanFilter and Product_API_Scan_Configuration
- dojo.auditlog: TAG_MODEL_MAPPING added to the lazy export table
- dojo/<module>/views.py: pure re-export shims to dojo/<module>/ui/views.py
  (matching the existing dojo/api_v2/permissions.py / pghistory_* shims)
…module

The reorg moved FindingCreateSerializer (and its dojo_dispatch_task call
for the finding_added notification) from dojo/api_v2/serializers.py to
dojo/finding/api/serializer.py. Three TestNotificationTriggersApi tests
still patched dojo.api_v2.serializers.dojo_dispatch_task, which no longer
has that attribute -> AttributeError at patch time. Point them at the
module where the dispatch now resolves.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The DojoMetaViewSet extraction re-added an active
@extend_schema_view(**schema_with_prefetch()) above the intentionally
commented-out original. This re-enabled prefetch schema generation for
the DojoMeta endpoint, which emits a $ref to a Location component that
is not registered when V3_FEATURE_LOCATIONS=False, breaking the
openapi-generator schema validation integration test
(PaginatedMetaList.Location is not of type schema).

@mtesauro mtesauro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants