Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update URL handling #214

Merged
merged 1 commit into from
Oct 8, 2024
Merged

Conversation

psyray
Copy link
Contributor

@psyray psyray commented Oct 8, 2024

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:

  • Refactor JavaScript functions to use url_endpoint instead of slug for setting form actions, enhancing flexibility in URL handling.
  • Update HTML templates to use Django's {% url %} template tag for generating URLs dynamically, improving maintainability.
  • Adjust CSS link paths in the notification settings template for better organization.
  • Change URL patterns in urls.py for consistency in endpoint naming.

Chores:

  • Remove an unnecessary filter in the detail_vuln_scan view function to streamline the code.

- Refactored JavaScript functions to use url_endpoint instead of slug for setting form actions, enhancing flexibility in URL handling.
- Updated HTML templates to use Django's {% url %} template tag for generating URLs dynamically, improving maintainability.
Modified Docker development configuration to enable remote debugging and added a new port mapping.
- Adjusted CSS link paths in the notification settings template for better organization.
- Changed URL patterns in urls.py for consistency in endpoint naming.
- Removed an unnecessary filter in the detail_vuln_scan view function to streamline the code.
@psyray psyray self-assigned this Oct 8, 2024
Copy link
Contributor

sourcery-ai bot commented Oct 8, 2024

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
Loading

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
Loading

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 'slug:slug/delete/multiple' to 'slug:slug/multiple/delete'
web/targetApp/urls.py
Removed unnecessary filter in the detail_vuln_scan view function
  • Deleted the line 'history.filter(domain__project__slug=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 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

@psyray psyray requested review from 0b3ud and AnonymousWP October 8, 2024 14:39
@psyray psyray added bug Something isn't working refactor labels Oct 8, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @psyray - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider reviewing the security implications of removing the filter in the detail_vuln_scan view function to ensure proper access control is maintained.
  • Great job on improving URL handling by using Django's {% url %} template tag and refactoring JavaScript functions. This enhances maintainability and flexibility.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

web/targetApp/templates/target/list.html Dismissed Show dismissed Hide dismissed
web/targetApp/templates/target/list.html Dismissed Show dismissed Hide dismissed
@psyray psyray linked an issue Oct 8, 2024 that may be closed by this pull request
3 tasks
@AnonymousWP AnonymousWP merged commit 9b6d787 into release/2.1.0 Oct 8, 2024
5 checks passed
@AnonymousWP AnonymousWP deleted the fix-routes-multiple branch October 8, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(release): 2.1.0 hotfixes
2 participants