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
68 stars 11 forks source link

fix: apply github-advanced-security recommendations #220

Closed psyray closed 3 weeks ago

psyray commented 3 weeks ago

Summary by Sourcery

Apply GitHub Advanced Security recommendations by enhancing error logging and standardizing error responses in user management functions, improving file handling, and removing duplicate code. Initialize URL variables in JavaScript to prevent issues and clarify KeyError handling in the API vault delete function.

Bug Fixes:

Enhancements:

Chores:

sourcery-ai[bot] commented 3 weeks ago

Reviewer's Guide by Sourcery

This PR implements several security and code quality improvements recommended by GitHub Advanced Security. The changes focus on enhancing error handling, improving file operations safety, removing code duplication, and fixing potential JavaScript issues. The implementation includes better error logging with descriptive messages, safer file handling using context managers, and initialization of variables to prevent undefined references.

Sequence diagram for enhanced error logging in user management

sequenceDiagram
    actor User
    participant System
    User->>System: Request to delete/update/create user
    alt Successful operation
        System-->>User: Return success response
    else Error occurs
        System->>System: Log error with descriptive message
        System-->>User: Return error response with standardized message
    end

Class diagram for improved file handling in get_cms_details

classDiagram
    class FileHandler {
        +open(filePath: String, mode: String)
        +read()
        +close()
    }
    class CMSDetails {
        +get_cms_details(url: String)
    }
    CMSDetails --> FileHandler : uses
    note for CMSDetails "Improved file handling using context manager"

File-Level Changes

Change Details Files
Enhanced error logging and standardized error responses in user management functions
  • Added descriptive error messages to logger.error() calls
  • Standardized error response messages to be more user-friendly
  • Removed exposure of raw error messages in JSON responses
web/dashboard/views.py
Improved file handling safety using context managers
  • Replaced direct file open/read with context manager (with statement)
  • Added proper file resource cleanup
web/reNgine/common_func.py
Removed duplicate code in settings configuration
  • Eliminated duplicate version file reading code
web/reNgine/settings.py
Fixed potential undefined variable issues in JavaScript modal functions
  • Initialized 'url' variable before conditional blocks
  • Added proper variable declarations using 'let'
web/startScan/static/startScan/js/detail_scan.js
Added documentation for error handling
  • Added clarifying comment about KeyError handling in vault deletion
web/scanEngine/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).