Skip to content

[Bug] Fix Scanner Crash: "Cannot access 'totalScans' before initialization" and missing renderFamilyTree function #161

@omprakash-sahu-code

Description

@omprakash-sahu-code

Problem

While trying to scan a URL, the application crashes and shows some JavaScript ReferenceErrors. Because of this, the scan does not complete and an error message appears on the screen.

Expected vs Actual Behavior

Expected: The URL should be scanned successfully, the dashboard stats should update, and the Typosquatting Family Tree should be displayed.

Actual: The scan fails and shows "Scan Error: An unexpected error occurred" "Error: Cannot access 'totalScans' before initialization". When checking the browser console, multiple JavaScript errors can be seen.

Steps to Reproduce

Method 1: Using the Deployed Application

  1. Open the deployed Cybershield application in a browser.
  2. Enter any valid URL (for example: https://github.com/Mrinalray/Cybershield_URL) in the input field.
  3. Click on Scan URL.
  4. Observe the error message displayed on the page.
  5. Open the browser developer tools (F12) and check the console for errors.

Method 2: Using a Local Development Environment

  1. Clone the repository and set up the project locally.
  2. Run the application and open it in a browser.
  3. Enter any valid URL in the scanner input field.
  4. Click on Scan URL.
  5. Observe the error message displayed on the page.
  6. Open the browser developer tools (F12) and check the console for errors.

Current Behavior

The following errors appear:

  1. ``

    • The script crashes during initialization because it tries to access a DOM element (#teamGrid) that is not available.
    • Due to this, variables like totalScans are not initialized properly.
  2. ``

    • The code calls renderFamilyTree(data.typosquatting) while displaying Typosquatting results.
    • However, the function does not seem to be defined, which stops further execution.

Expected Behavior

  • URL scanning should work without crashing.
  • Dashboard statistics such as "URLs Scanned" and "Threats Blocked" should update correctly.

Environment

  • Browser: Chrome / Edge
  • OS: Windows
  • Device: Desktop

Screenshots

Image

Additional Context

While looking into the issue, I already found the solution for it
I would like you to assign this issue under GSSoC to me so that I can submit a PR to fix it.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions