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

Does not work for multimodule project #2

Closed
sellersj opened this issue Jun 24, 2015 · 9 comments
Closed

Does not work for multimodule project #2

sellersj opened this issue Jun 24, 2015 · 9 comments
Assignees
Labels

Comments

@sellersj
Copy link

The sonar:sonar step will fail on a multimodule project where the top level has packaging of "pom"

You get an error like this:
Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project MyTopModuleName: Dependency-Check report does not exist. Please check property sonar.dependencyCheck.reportPath: dependency-check-report.xml

@stevespringett stevespringett self-assigned this Jun 30, 2015
@stevespringett
Copy link
Contributor

The Dependency-Check report must exist in the workspace that is being scanned. By default, the Dependency-Check Sonar plugin will use 'dependency-check-report.xml' if sonar.dependencyCheck.reportPath is not specified.

You may have to specify sonar.dependencyCheck.reportPath if the report is in a subdirectory or has another name.

@oers
Copy link

oers commented Jul 2, 2015

A report is not generated when no dependencies were found. This consequently breaks the sonar plugin, as it always expects the XML file.

@sellersj
Copy link
Author

sellersj commented Jul 2, 2015

Maybe I've configured it incorrectly.

In our corporate parent pom, I've configured the reporting section something like this

      <reporting>
        <plugins>
          <plugin>
            <groupId>org.owasp</groupId>
            <artifactId>dependency-check-maven</artifactId>
            <reportSets>
              <reportSet>
                <reports>
                  <report>check</report>
                  <report>aggregate</report>
                </reports>
              </reportSet>
            </reportSets>
            <configuration>
              <skipProvidedScope>true</skipProvidedScope>
              <format>ALL</format>
            </configuration>
          </plugin>
        </plugins>
      </reporting>

A typical project has a parent (that inherits from the corporate parent pom) and then a ear and war module. Both ear and war have dependencies, the project pom does not.

After doing a site build, a listing of the dependency check created artifacts look like this

./EAR_MODULE/target/site/dependency-check-report.html
./EAR_MODULE/target/site/dependency-check-report.xml
./EAR_MODULE/target/site/dependency-check-vulnerability.html
./EAR_MODULE/target/dependency-check.ser
./WAR_MODULE/target/site/dependency-check-report.html
./WAR_MODULE/target/site/dependency-check-report.xml
./WAR_MODULE/target/site/dependency-check-vulnerability.html
./WAR_MODULE/target/dependency-check.ser
./target/site/dependency-check-report.html
./target/dependency-check.ser

@stevespringett
Copy link
Contributor

I checked in a fix for a defect I discovered that would produce the 'does not exist' message when no report was specified or existed. d7fc427

I've tested it using a Sonar config similar to the following:

sonar.modules=parent,module1,module2
parent.sonar.projectBaseDir=target
parent.sonar.sources=site
module1.sonar.sources=src
module2.sonar.sources=src
parent.sonar.dependencyCheck.reportPath=site/dependency-check-report.xml

In this scenario, the aggregated Dependency-Check report will show up in the 'parent' module. Not sure if there's a better way to do this or not.

Test the code in the master branch and see if that solves the reported issue.

stevespringett referenced this issue Jul 7, 2015
…nalyzed contains a dependency check report file and will fail if it doesn't.
@sellersj
Copy link
Author

sellersj commented Jul 7, 2015

  1. Just to confirm, is it valid to have both "check" and "aggregate" reports in the same config?
  2. And if so, then in the top level ./target/site/ directory shouldn't it also have a dependency-check-report.xml file?

Thanks so much for all the work.

@stevespringett
Copy link
Contributor

I've never see both check and aggregate in the same config like that. I typically use the check goal in <build><plugins> - usually on a single module or project. For a multi-module project I only use the aggregate goal when running a site report. Refer to https://jeremylong.github.io/DependencyCheck/dependency-check-maven/configuration.html

The aggregate will produce the report in ./target/site.

This is the aggregate config I usually use:

<reporting>
    <plugins>
        <plugin>
            <groupId>org.owasp</groupId>
            <artifactId>dependency-check-maven</artifactId>
            <version>1.2.11</version>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>aggregate</report>
                    </reports>
                </reportSet>
            </reportSets>
            <configuration>
                <format>ALL</format>
            </configuration>
        </plugin>
    </plugins>
</reporting>

@sellersj
Copy link
Author

sellersj commented Jul 7, 2015

So maybe I'm trying to do something that's not possible (yet). Our setup is that we have one corporate parent pom that configures all plugins, reports, etc. Then ~150 projects inherit from that with 3-25+ modules per project. That way each project typically only has to specify their dependencies.

@stevespringett
Copy link
Contributor

What you're attempting to do should be possible and in fact is a very common way to standardize and simplify Maven builds.

From the file listing you provided, it appears that the XML report is not being generated in ./target/site like it should be. This is unusual and I'm unable to reproduce this.

If you're having difficulties producing the report, you may want to head over to https://github.com/jeremylong/DependencyCheck/issues or https://groups.google.com/forum/#!forum/dependency-check and ask around.

When you're at a point where the report is being produced, go ahead and try the sonar plugin again and let me know if you have any issues.

@stevespringett
Copy link
Contributor

I've tested the plugin with multiple multi-module projects and the current release appears to work. I'm closing the ticket. If you experience issues again with multi-module projects not working, feel free to reopen the ticket.

Reamer added a commit that referenced this issue Nov 25, 2020
* Correct sonar target

* Rename build to build and add badge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants