Skip to content

feat: Implement Analyzer and AnalyzerMapping models with associated s…#250

Merged
mateodurante merged 6 commits into
developfrom
fix/AnalyzerRefactoring
May 2, 2026
Merged

feat: Implement Analyzer and AnalyzerMapping models with associated s…#250
mateodurante merged 6 commits into
developfrom
fix/AnalyzerRefactoring

Conversation

@ucabrera
Copy link
Copy Markdown
Collaborator

…erializers and views

  • Added Analyzer model with fields for name, type, enabled status, config, and description.
  • Created AnalyzerMapping model with foreign key to Analyzer and fields for mapping_from and mapping_to.
  • Developed serializers for both models to handle validation and representation.
  • Introduced viewsets for Analyzer and AnalyzerMapping, including custom actions for testing connections and retrieving vulnerability choices.
  • Updated event retesting functionality to support analyzer mappings, allowing for dynamic selection of analyzers during event retests.
  • Enhanced frontend component to utilize dropdown for selecting analyzers when retesting events.
  • Added filters for Analyzer and AnalyzerMapping models to improve query capabilities.
  • Implemented migrations for new models and relationships, ensuring database integrity.
  • Created unit tests for Analyzer and AnalyzerMapping models to validate functionality and constraints.

…erializers and views

- Added Analyzer model with fields for name, type, enabled status, config, and description.
- Created AnalyzerMapping model with foreign key to Analyzer and fields for mapping_from and mapping_to.
- Developed serializers for both models to handle validation and representation.
- Introduced viewsets for Analyzer and AnalyzerMapping, including custom actions for testing connections and retrieving vulnerability choices.
- Updated event retesting functionality to support analyzer mappings, allowing for dynamic selection of analyzers during event retests.
- Enhanced frontend component to utilize dropdown for selecting analyzers when retesting events.
- Added filters for Analyzer and AnalyzerMapping models to improve query capabilities.
- Implemented migrations for new models and relationships, ensuring database integrity.
- Created unit tests for Analyzer and AnalyzerMapping models to validate functionality and constraints.

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 00:51
Comment thread ngen/views/analyzer.py Fixed
… through an exception'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class “Analyzer” configuration and “AnalyzerMapping” routing so event retests can run through a selected analyzer adapter (e.g., Kintun/Cortex), with corresponding API endpoints, Celery task updates, and frontend CRUD/UI updates.

Changes:

  • Introduces Analyzer + adapter registry (Kintun/Cortex) and AnalyzerMapping updates to reference analyzers via FK.
  • Adds serializers, filters, and viewsets (including connection test and vulnerability-choice discovery) and wires them into routing.
  • Updates event retest flow (backend task + frontend UI) to select an analyzer mapping at retest time, plus adds unit tests and i18n strings.

Reviewed changes

Copilot reviewed 40 out of 42 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
project/urls.py Registers new Analyzer/AnalyzerMapping endpoints in the API router.
ngen/views/case.py Extends event retest action to accept an analyzer mapping reference.
ngen/views/analyzer_mapping.py Updates AnalyzerMapping search fields and applies model permissions.
ngen/views/analyzer.py Adds Analyzer CRUD endpoints plus test and vuln-choices actions.
ngen/views/init.py Exposes new Analyzer view module via package exports.
ngen/tasks.py Updates retest Celery task to resolve analyzer via mapping and run adapter logic.
ngen/filters.py Adds filters for Analyzer and updated AnalyzerMapping filter fields.
ngen/models/analyzer.py Adds Analyzer model with adapter-backed validation and resolution.
ngen/models/analyzer_mapping.py Switches AnalyzerMapping from analyzer_type string to Analyzer FK.
ngen/models/init.py Exports Analyzer model from the models package.
ngen/serializers/analyzer.py Adds Analyzer serializer with config masking and schema-driven validation.
ngen/serializers/analyzer_mapping.py Adds analyzer_name / analyzer_type computed fields for mappings.
ngen/serializers/init.py Exposes new Analyzer serializer via package exports.
ngen/analyzers/base.py Introduces a base adapter interface for analyzer integrations.
ngen/analyzers/kintun.py Implements Kintun adapter (scan execution, polling, connection test, vuln choices).
ngen/analyzers/cortex.py Implements Cortex adapter (connection test; scan not supported).
ngen/analyzers/registry.py Central registry for adapter types, config schemas, and choices.
ngen/analyzers/init.py Initializes analyzers package.
ngen/migrations/0024_analyzer_model.py Creates Analyzer table.
ngen/migrations/0025_analyzermapping_add_analyzer_fk.py Adds nullable Analyzer FK to mappings and drops analyzer_type.
ngen/migrations/0026_analyzermapping_cascade_analyzer.py Cleans orphan mappings and enforces CASCADE/non-null analyzer FK.
ngen/tests/models/test_analyzer.py Adds unit tests for Analyzer and AnalyzerMapping behaviors/cascades.
ngen/locale/es/LC_MESSAGES/django.po Adds Spanish translations for analyzer-related messages.
frontend/src/config/constant.jsx Adds analyzer API base URL constant.
frontend/src/api/services/analyzer.jsx Adds frontend API client for Analyzer CRUD, test, vuln-choices.
frontend/src/api/services/analyzerMapping.jsx Updates mapping create/update to use analyzer FK and improved duplicate detection.
frontend/src/api/services/eventAnalysis.jsx Improves retest list fetching and sends analyzer_mapping on retest.
frontend/src/views/event/components/SmallRetestTable.jsx Adds dropdown to select analyzer mapping when triggering retest.
frontend/src/views/analyzerMapping/ListAnalyzerMappings.jsx Refreshes list after delete via refreshKey.
frontend/src/views/analyzerMapping/components/TableAnalyzerMapping.jsx Displays analyzer name and triggers parent refresh on delete.
frontend/src/views/analyzerMapping/CreateAnalyzerMapping.jsx Updates create form to select analyzer and show vuln choices dropdown.
frontend/src/views/analyzerMapping/EditAnalyzerMapping.jsx Updates edit form to select analyzer and show vuln choices dropdown.
frontend/src/views/analyzer/ListAnalyzers.jsx Adds Analyzer list page with paging/search.
frontend/src/views/analyzer/components/TableAnalyzer.jsx Adds Analyzer table with details modal + connection test + delete.
frontend/src/views/analyzer/components/FormAnalyzer.jsx Adds Analyzer create/edit form with config fields and validation helpers.
frontend/src/views/analyzer/CreateAnalyzer.jsx Adds Analyzer create page wrapper.
frontend/src/views/analyzer/EditAnalyzer.jsx Adds Analyzer edit page wrapper (placeholder-safe config updates).
frontend/src/routes.jsx Adds routes for analyzer list/create/edit views.
frontend/src/menu-items.jsx Adds “Analyzers” menu item.
frontend/public/locales/es/translation.json Adds Spanish UI strings for analyzers and mapping changes.
frontend/public/locales/en/translation.json Adds English UI strings for analyzers and mapping changes.
.gitignore Ignores CLAUDE.md.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ngen/analyzers/kintun.py
Comment thread ngen/analyzers/kintun.py
Comment thread ngen/analyzers/kintun.py
Comment thread ngen/models/analyzer.py
Comment thread ngen/models/analyzer.py Outdated
Comment thread frontend/src/views/analyzer/components/FormAnalyzer.jsx Outdated
Comment thread frontend/src/views/analyzerMapping/EditAnalyzerMapping.jsx
Comment thread ngen/analyzers/kintun.py
Comment thread ngen/views/analyzer.py
Comment thread frontend/src/views/analyzerMapping/CreateAnalyzerMapping.jsx Outdated
ucabrera and others added 3 commits April 22, 2026 22:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…pping forms; update KintunAdapter to disable redirects and improve error logging

Co-authored-by: Copilot <copilot@github.com>
@ucabrera ucabrera closed this Apr 27, 2026
@ucabrera ucabrera reopened this Apr 27, 2026
@mateodurante mateodurante merged commit b1e4f9b into develop May 2, 2026
8 checks passed
mateodurante added a commit that referenced this pull request May 13, 2026
* feat: Implement Analyzer and AnalyzerMapping models with associated s… (#250)

* feat: Implement Analyzer and AnalyzerMapping models with associated serializers and views

- Added Analyzer model with fields for name, type, enabled status, config, and description.
- Created AnalyzerMapping model with foreign key to Analyzer and fields for mapping_from and mapping_to.
- Developed serializers for both models to handle validation and representation.
- Introduced viewsets for Analyzer and AnalyzerMapping, including custom actions for testing connections and retrieving vulnerability choices.
- Updated event retesting functionality to support analyzer mappings, allowing for dynamic selection of analyzers during event retests.
- Enhanced frontend component to utilize dropdown for selecting analyzers when retesting events.
- Added filters for Analyzer and AnalyzerMapping models to improve query capabilities.
- Implemented migrations for new models and relationships, ensuring database integrity.
- Created unit tests for Analyzer and AnalyzerMapping models to validate functionality and constraints.

Co-authored-by: Copilot <copilot@github.com>

* Potential fix for pull request finding 'CodeQL / Information exposure through an exception'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update ngen/analyzers/kintun.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update frontend/src/views/analyzer/components/FormAnalyzer.jsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* feat: Make analyzer selection required in Create and Edit Analyzer Mapping forms; update KintunAdapter to disable redirects and improve error logging

Co-authored-by: Copilot <copilot@github.com>

* feat: Refactor analyzer configuration to include port and SSL options; update translations and form handling

---------

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* new evidence notification (#251)

* cleanup translations (#252)

* fix: agrega filtro select url (#253)

* fix: agrega filtro select url

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Fix: Avoid raise condition con sending email inside atomic transaction (#254)

* avoid raise condition con sending email inside atomic transaction

* better traceback

* tests fix for transaction on_commit

* fix entity too large nginx upload file

---------

Co-authored-by: Ulises Martín Cabrera <ucabrera@cert.unlp.edu.ar>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants