How to use Fortify Scan 16.11 to scan dotnet core with project.Json

岁酱吖の 提交于 2020-01-13 11:38:09

问题


I created a default .Net Core 1.0.1 Class library and changed buildOptions in project.json to include debugType: "Full". I used the integrated VS 2015 Fortify Scan using 16.11 and I get the errors below. How should I scan dotnet core to avoid this problem?

Project 'src\providesFileInPackage\providesFileInPackage.xproj' is not configured to output full debug information. SCA Analysis requires full debug symbols. Would you like to ignore project and continue? (Project Properties -> Build -> "Advanced" button -> Debug Info -> "Full" OR Project Properties -> Compile -> Advanced Options -> Debug Info -> "Full" for VB)

My project json looks like

{
  "version": "1.0.0-*",
  "dependencies": {
    "NETStandard.Library": "1.6.0"
  },
  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  },
  "buildOptions": {
    "define": [ "DEBUG" ],
    "debugType": "full"
  }
}

回答1:


I had the same problem. It's blaming the xproj file and not project.json so I tried to add

<DebugType>full</DebugType>

inside the PropertyGroup but to no avail.

In the end I found a workaround by running Fortify from the command line:

msbuild MyApplicationSca.proj /p:Configuration=Release /t:Rebuild /m

My MyApplicationSca.proj looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <MySolution>MyApplication.sln</MySolution>
    <Configuration Condition=" $(Configuration) == '' ">Debug</Configuration>
    <CommonMSBuildProperties>BuildingSolutionFileName=true</CommonMSBuildProperties>
    <RunHPFortify Condition=" '$(RunHPFortify)' == '' ">false</RunHPFortify>
    <HPFortifyPath Condition=" '$(HPFortifyPath)' == '' ">$(ProgramW6432)\HP_Fortify\HP_Fortify_SCA_and_Apps_4.40\</HPFortifyPath>
    <FortifyMSBuildTasks>$(HPFortifyPath)Core\lib\FortifyMSBuildTasks.dll</FortifyMSBuildTasks>
  </PropertyGroup>

  <ItemGroup>
    <Projects Include="$(MySolution)">
      <AdditionalProperties>Platform=Any CPU</AdditionalProperties>
    </Projects>
  </ItemGroup>

  <Target Name="Clean">
    <MSBuild Projects="@(Projects)" Targets="Clean" Properties="$(CommonMSBuildProperties)" />
  </Target>

  <Target Name="Build">
    <MSBuild Projects="@(Projects)" Targets="Build" Properties="$(CommonMSBuildProperties)"
             StopOnFirstFailure="true" />
  </Target>

  <Target Name="Rebuild">
    <MSBuild Projects="@(Projects)" Targets="Rebuild" Properties="$(CommonMSBuildProperties)"
             StopOnFirstFailure="true" />
  </Target>

  <UsingTask TaskName="Fortify.CleanTask" AssemblyFile="$(FortifyMSBuildTasks)" />
  <UsingTask TaskName="Fortify.TranslateTask" AssemblyFile="$(FortifyMSBuildTasks)" />
  <UsingTask TaskName="Fortify.ScanTask" AssemblyFile="$(FortifyMSBuildTasks)" />

  <Target Name="FortifyBuild" AfterTargets="Build;Rebuild" Condition="$(RunHPFortify)">
    <PropertyGroup>
      <BuildID>MyApplication</BuildID>
      <HPFortifyLogsDir>..\HPFortifyLogs\</HPFortifyLogsDir>
      <PackagesDir>$(MSBuildProjectDirectory)\packages\</PackagesDir>
      <OutDir>$(MSBuildProjectDirectory)\MyApplication\bin\$(Configuration)\net452\win7-x64\</OutDir>
      <SCATargetBinary>$(OutDir)MyApplication.exe</SCATargetBinary>
      <FPRFilePath>$(HPFortifyLogsDir)MyApplication.fpr</FPRFilePath>
      <SSCUploadToken Condition=" '$(SSCUploadToken)' == '' ">1cfe9977-905c-4da4-bb57-97e3dcc33099</SSCUploadToken>
    </PropertyGroup>

    <ItemGroup>
      <TranslateTaskReferences Include="$(OutDir)" />
    </ItemGroup>

    <CleanTask BuildID="$(BuildID)" />

    <TranslateTask
      BuildID="$(BuildID)"
      VSVersion="14.0"
      JVMSettings="-Xmx1000M"
      BinariesFolder="$(SCATargetBinary)"
      References="@(TranslateTaskReferences)"
      LogFile="$(HPFortifyLogsDir)sca_translate_task.log">
    </TranslateTask>

    <ScanTask
      BuildID="$(BuildID)"
      JVMSettings="-Xmx1000M"
      LogFile="$(HPFortifyLogsDir)scan_task.log"
      Output="$(FPRFilePath)" />

  </Target>

</Project>

I am not investigating more than that right now but I hope this brings us a bit closer to the answer.



来源:https://stackoverflow.com/questions/40731716/how-to-use-fortify-scan-16-11-to-scan-dotnet-core-with-project-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!