总之,我正在尝试让声纳导入防御工事分析报告。我在代码源目录中遇到了一个问题。
我的分析是在单独的机器上运行并生成一个报告,如下所示
<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>当插件尝试导入它时,显示为follow DEBUG Unable to find "C:/STA/Source/src/main/java/com/test/Test/TestRequest.java".正在尝试相对路径。调试找不到"/opt/mount/jenkins/jobs/02-TestFortify/workspace/main/java/com/test/TestRequest.java".你的防御工事分析。
查看导入过程代码,它首先检查sourceBasePath + vulnerability.getPath(),然后检查基本项目dir + vulnerability.getPath()
问题,源路径位于不同的${project.build.sourceDirectory}中。
在继续之前,我可以考虑构建一个指向源路径的sym链接,但我想知道是否有更好的解决方案。
安托万
发布于 2014-09-06 02:54:27
下面是一些有用的代码。请注意,您不会从结果中获得带签名的FPR。这应该很好,因为您只是将其用于Sonar。
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"));
}
}https://stackoverflow.com/questions/25684960
复制相似问题