强化与 Maven 的集成 - 安装

Fortify integration with Maven - install

我想 运行 针对 Maven Eclipse 项目进行 Fortify 扫描。

我应该从哪里开始?

我知道我需要更新我的 pom.xml 文件以包含 Fortify 插件,但是我是否还需要在我的机器上安装 Fortify SCA? (我 运行ning MacOS X)。我一直试图找到一个下载 Fortify SCA 的地方,但一直找不到。

如果有人可以分享一些链接以指导我完成设置的正确方向,我将不胜感激。

我认为不需要安装 Fortify,但没有它很难获得 maven sca 插件。如果你在另一台机器上安装,你可以只复制插件,但是你不会有 Audit Workbench 应用程序来处理生成的 FPR。正如@Eric 所说,您必须通过 HP 获得它,没有许可证将无法使用。

安装完成后,将配置文件添加到 pom.xml 以执行 sca 目标:

<profile>
  <id>sca-clean</id>
  <activation>
    <activeByDefault>false</activeByDefault>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>com.fortify.ps.maven.plugin</groupId>
        <artifactId>sca-maven-plugin</artifactId>
        <version>4.30</version>
        <configuration>
          <jre64>true</jre64>
          <buildId>myproject</buildId>
          <toplevelArtifactId>myproject.parent</toplevelArtifactId>
          <skipTests>true</skipTests>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>


<profile>
  <id>sca-translate</id>
  <activation>
    <activeByDefault>false</activeByDefault>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>com.fortify.ps.maven.plugin</groupId>
        <artifactId>sca-maven-plugin</artifactId>
        <version>4.30</version>
        <configuration>
          <jre64>true</jre64>
          <jreStack>8M</jreStack>
          <maxHeap>12000M</maxHeap>
          <verbose>true</verbose>
          <buildId>myproject</buildId>
          <toplevelArtifactId>myproject.parent</toplevelArtifactId>
          <skipTests>true</skipTests>
          <failOnSCAError>true</failOnSCAError>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>translate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>


<profile>
  <id>sca-scan</id>
  <activation>
    <activeByDefault>false</activeByDefault>
  </activation>
  <build>
    <plugins>
      <plugin>
        <groupId>com.fortify.ps.maven.plugin</groupId>
        <artifactId>sca-maven-plugin</artifactId>
        <version>4.30</version>
        <configuration>
          <jre64>true</jre64>
          <jreStack>8M</jreStack>
          <maxHeap>12000M</maxHeap>
          <verbose>true</verbose>
          <buildId>myproject</buildId>
          <toplevelArtifactId>myproject.parent</toplevelArtifactId>
          <failOnSCAError>true</failOnSCAError>
          <upload>false</upload>
          <projectName>My Project Main Development</projectName>
          <projectVersion>${project.version}</projectVersion>
        </configuration>
      </plugin>
    </plugins>
  </build>
</profile>

运行 从命令行扫描:

mvn -Dmaven.test.skip=true -Dfortify.sca.buildId=myproject -Dfortify.sca.toplevel.artifactId=myproject.parent com.fortify.ps.maven.plugin:sca-maven-plugin:clean

显然,您必须弄清楚 buildId 和 artifactId 的命名方式,这取决于您使用的是父级、聚合器还是什么都不用。

实际上不需要配置文件,只需要插件配置。

<build>
    <plugins> 
        <plugin>
            <groupId>com.fortify.ps.maven.plugin</groupId>
            <artifactId>sca-maven-plugin</artifactId>
            <version>4.30</version>
            <configuration>
                <findbugs>true</findbugs>
                <htmlReport>true</htmlReport>
                <maxHeap>800M</maxHeap>
                <source>myJavaVersion</source>
                <buildId>myBuildId</buildId>
                <verbose>true</verbose>
                <skipTests>true</skipTests>
                <toplevelArtifactId>myTopLevelId</toplevelArtifactId>
            </configuration>
        </plugin>
    </plugins>
</build>

通过使用单个 Jenkins 作业,您可以编写一个 shell 脚本作为准备步骤:

mvn clean sca:clean -DskipTests
mvn sca:translate -DskipTests

然后定义实际的"Goals and options"为:

install sca:scan -DskipTests

将它们作为单独的命令行是在一个 Jenkins 作业中完成 sca-clean、翻译和扫描(以及将报告文件发送到 Fortify)的唯一方法。

希望这对你也有用!