【问题标题】:SONAR FORTIFY plugin importSONAR FORTIFY 插件导入
【发布时间】:2014-10-30 08:28:24
【问题描述】:

所有, 我正在尝试让声纳导入强化分析报告。 我遇到了代码源目录的问题。

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

 <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>

当插件尝试导入时,显示如下 [调试] [10:34:42.947] 找不到“C:/STA/Source/src/main/java/com/test/Test/TestRequest.java”。尝试相对路径。 [调试] [10:34:42.947] 找不到“/opt/mount/jenkins/jobs/02-TestFortify/workspace/main/java/com/test/TestRequest.java”。您的 Fortify 分析...

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

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

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

安东尼

【问题讨论】:

    标签: sonarqube fortify


    【解决方案1】:

    这里有一些有用的代码。请注意,您不会从结果中获得签名的 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"));
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-21
      • 2015-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多