dependency-check-sonar-plugin icon indicating copy to clipboard operation
dependency-check-sonar-plugin copied to clipboard

Html report is broken as it creates frames

Open bpapez opened this issue 4 years ago • 10 comments

Describe the bug Html report is broken as it creates frames after clicking on an internal link

To Reproduce Steps to reproduce the behavior:

  1. Install Dependency Check 2.0.7 through Marketplace
  2. Run the dependency check on the product with passing correct link to the HTML report
  3. Login to Sonarqube, go to project and select More -> Dependency Check in menu
  4. Click on a link of a vulnerable Dependency entry
  5. Error

Current behavior An inner frame is created and it is not scrolled down to the selected vulnerable dependency details

Expected behavior No inner frame should be created, but the link should just scroll down in the HTML to the selected vulnerable dependency details

Screenshots image after clicking on the link indicated by red arrow, we see this: image

Versions (please complete the following information):

  • dependency-check version 6.1.0
  • sonarqube Developer Edition Version 8.6 (build 39681)
  • dependency-check-sonar-plugin 2.0.7
  • tested and reproduced with Chrome 88.0.4324.150 and Firefox 85.0 (64-bit)

Additional context The problem seems to have been already reported once and closed - see #188 . It still happens with the latest version.

bpapez avatar Feb 05 '21 13:02 bpapez

Thank you for your screenshots. I was able to reproduce your problem (thanks to the little red arrow).

Unfortunately, I don't know how to fix this. The whole injecting of the HTML-report is very hacky, that is why I would like to hold on to the iframe. You can find the discussion under https://github.com/dependency-check/dependency-check-sonar-plugin/pull/221

Reamer avatar Feb 05 '21 14:02 Reamer

Would it be possible to just open the report in its own window or make it downloadable? I really like the functionality built into the report, but it is completely useless as it is now. Clicking any link causes a new frame, but still doesn't take you to the linked section of the report.

Thanks!

brileyd avatar Nov 09 '21 21:11 brileyd

This can be done by altering the render() function in the file DependencyCheckReportApp.js to:

// IFrame for warnings, new tab when report available.
  if(!this.state.data.includes("Dependency-Check")){
      // IFrame
      return (<div className="page dependency-check-report-container" >
                <iframe sandbox="allow-scripts allow-same-origin" height={this.state.height} srcDoc={this.state.data} style={{border: "none"}} />
              </div>);
  } else {
        // Open in new tab (avoid endless 'loading...' and present the URL by using an Event Listener)
        const newWindow = window.open('#', "_blank");
        if (newWindow) {
          newWindow.addEventListener('load', () => {
            newWindow.document.open();
            newWindow.document.write(this.state.data);
            newWindow.document.close();
            newWindow.stop();
          }, true);
        }

      return (<center><h1 style={{padding: "250px 0 0 0"}}>Dependency-Check report opened in adjacent tab.</h1></center>);
  }

After that you can click through the anchors correctly.

rupreck avatar Nov 29 '21 06:11 rupreck

@rupreck I would be grateful if you could open a PR for this.

Reamer avatar Dec 17 '21 15:12 Reamer

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Feb 16 '22 02:02 github-actions[bot]

I know this is an older issue, but I agree that it looks bad now. I also agree that opening the report in a new tab would be a much more usable situation.

ctmay4 avatar Jun 03 '22 17:06 ctmay4

I implemented the change @rupreck recommended above on my local test setup and it works well.

Thanks, @rupreck!

brileyd avatar Mar 02 '23 23:03 brileyd

Can you open a pull request with your changes so that others can also benefit from the changes?

Reamer avatar Mar 07 '23 15:03 Reamer

I think that @rupreck is no longer active. Is it possible to apply this change? @Reamer

pippolino avatar Nov 08 '23 21:11 pippolino

You are welcome to take up the PR https://github.com/dependency-check/dependency-check-sonar-plugin/pull/765

Reamer avatar Nov 09 '23 17:11 Reamer