Security-Tools-Alliance / rengine-ng

reNgine-ng is an automated reconnaissance framework for web applications with a focus on highly configurable streamlined recon process via Engines, recon data correlation and organization, continuous monitoring, backed by a database, and simple yet intuitive User Interface.
GNU General Public License v3.0
70 stars 12 forks source link

refactor: update URL handling #214

Closed psyray closed 1 month ago

psyray commented 1 month ago

Summary by Sourcery

Refactor URL handling by replacing slug with url_endpoint in JavaScript functions and using Django's {% url %} template tag in HTML templates for dynamic URL generation. Improve CSS organization and ensure consistent URL patterns in urls.py. Streamline the detail_vuln_scan view by removing an unnecessary filter.

Enhancements:

Chores:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request refactors URL handling across the application, improving flexibility and maintainability. It updates JavaScript functions to use dynamic URL endpoints, enhances Django templates with the {% url %} tag, adjusts CSS paths, modifies URL patterns, and removes unnecessary code.

Sequence diagram for updated URL handling in JavaScript functions

sequenceDiagram
    actor User
    participant JS as JavaScript
    participant Form as HTML Form

    User->>JS: Initiate scanMultipleTargets
    JS->>JS: Check if targets are selected
    alt Targets selected
        JS->>Form: Set action to url_endpoint
        Form->>Form: Submit form
    else No targets selected
        JS->>User: Show alert
    end

    User->>JS: Initiate deleteMultipleTargets
    JS->>JS: Check if targets are selected
    alt Targets selected
        JS->>Form: Set action to url_endpoint
        Form->>Form: Submit form
    else No targets selected
        JS->>User: Show alert
    end

Class diagram for updated URL patterns in urls.py

classDiagram
    class URLPattern {
        -slug: slug
        +delete_multiple_targets
        +start_multiple_scan
    }

    class View {
        +delete_targets
        +start_scan
    }

    URLPattern --> View : maps to

    class DetailVulnScanView {
        -id: int
        +get_scan_history()
    }

    URLPattern --> DetailVulnScanView : maps to

File-Level Changes

Change Details Files
Refactored JavaScript functions to use dynamic URL endpoints
  • Changed 'slug' parameter to 'url_endpoint' in scanMultipleTargets and deleteMultipleTargets functions
  • Updated form action setting to use the new url_endpoint parameter
web/targetApp/static/targetApp/js/custom_domain.js
Updated HTML templates to use Django's {% url %} template tag
  • Replaced hardcoded URLs with {% url %} tags in onclick attributes
  • Updated link href to use {% url %} tag for vulnerability scan detail page
web/targetApp/templates/target/list.html
web/dashboard/templates/dashboard/index.html
Adjusted CSS link paths in the notification settings template
  • Changed the path of the custom CSS file from 'assets/css/custom.css' to 'custom/custom.css'
web/scanEngine/templates/scanEngine/settings/notification.html
Modified URL patterns in urls.py for consistency
  • Changed the URL pattern for deleting multiple targets from '/delete/multiple' to '/multiple/delete'
web/targetApp/urls.py
Removed unnecessary filter in the detail_vuln_scan view function
  • Deleted the line 'history.filter(domainprojectslug=slug)' to streamline the code
web/startScan/views.py

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).