Sonarqube 声纳强化插件导入

Sonarqube 声纳强化插件导入,sonarqube,fortify,Sonarqube,Fortify,全部,, 我正试图让声纳导入加固分析报告。 我面临代码源目录的问题 我的分析是在一台单独的机器上运行,并生成如下报告 <SourceBasePath>C:/STA/Source/src</SourceBasePath> <SourceFiles> <File size="2409" timestamp="1409914148012" loc="12" type="java" encoding="windows-1252">

全部,, 我正试图让声纳导入加固分析报告。 我面临代码源目录的问题

我的分析是在一台单独的机器上运行,并生成如下报告

 <SourceBasePath>C:/STA/Source/src</SourceBasePath>
  <SourceFiles>
    <File size="2409" timestamp="1409914148012" loc="12" type="java" encoding="windows-1252">
      <Name>main/java/com/test/Test/TestRequest.java</Name>
      <LOC type="Fortify">12</LOC>
      <LOC type="Line Count">135</LOC>
      <LOC type="Source Code">57</LOC>
      <LOC type="Comments">59</LOC>
      <LOC type="Comments and Source Code">0</LOC>
      <LOC type="White Space">19</LOC>
C:/STA/Source/src
main/java/com/test/test/TestRequest.java
12
135
57
59
0
19
当插件尝试导入时,显示如下 [DEBUG][10:34:42.947]找不到“C:/STA/Source/src/main/java/com/test/test/TestRequest.java”。正在尝试相对路径。 [DEBUG][10:34:42.947]找不到“/opt/mount/jenkins/jobs/02 TestFortify/workspace/main/java/com/test/TestRequest.java”。你的强化分析

查看导入过程代码,它首先检查 sourceBasePath+漏洞。getPath() 那么 基本项目目录+漏洞。getPath()

问题,源路径位于${project.build.sourceDirectory}中,这是不同的

在继续之前,我可以考虑构建指向源路径的sym链接,但我想知道是否有更好的解决方案


Antoine

以下是一些有用的代码。请注意,您不会从结果中获得签名的FPR。这应该是好的,因为你只是使用它的声纳

import java.io.*;
import com.fortify.io.fvdl.FVDL;
import com.fortify.io.fvdl.FVDLUtil;
import org.exolab.castor.xml.XMLContext;
import com.fortify.ui.model.Project;
import com.fortify.ui.model.util.integration.IntegrationStubFactory;
import com.fortify.ui.model.util.integration.IntegrationUtil;
import com.fortify.ui.model.xml.interfaces.Product;
import com.fortify.util.SystemUtil;

public class FPRMod{
  public static void SetFPRSourceBasePath(String FPRPath, String NewSourceBasePath) throws Exception {
    //Initialize Fortify
    SystemUtil.setInstallRoot();
    IntegrationUtil.initializeFrameworkIntegration(IntegrationStubFactory.getFrameworkIntegrationUtil(), null, false);

    //Load the FPR and FVDL
    Project fpr = IntegrationUtil.loadProjectWithProgress(new File(FPRPath));
    FVDL fvdl = FVDL.unmarshalFVDL(FVDLUtil.getFVDLReader(FPRPath));

    //Set the SourceBasePath in the FPR and FVDL
    fpr.setSourceBasePath(NewSourceBasePath, true);
    fvdl.getBuild().setSourceBasePath(NewSourceBasePath);

    //Save the new FVDL
    fvdl.marshal(new FileWriter(FPRPath + ".mod.fvdl"));

    //Set the FPR to use the new FVDL
    fpr.getProjectInfo(Product.SCA).setEntryName(null);
    fpr.getProjectInfo(Product.SCA).setPath(new File(FPRPath + ".mod.fvdl"));

    //Save the new FPR
    fpr.saveProjectAs(new File(FPRPath + ".mod.fpr"));
  }
}