【问题标题】:How to use Fortify Scan 16.11 to scan dotnet core with project.Json如何使用 Fortify Scan 16.11 通过 project.Json 扫描 dotnet core
【发布时间】:2017-04-05 12:42:39
【问题描述】:

我创建了一个默认的 .Net Core 1.0.1 类库并更改了 project.json 中的 buildOptions 以包含 debugType: "Full"。我使用 16.11 使用集成的 VS 2015 Fortify Scan,我收到以下错误。我应该如何扫描 dotnet core 来避免这个问题?

Project 'src\providesFileInPackage\providesFileInPackage.xproj' 未配置为输出完整的调试信息。 SCA 分析需要完整的调试符号。您想忽略项目并继续吗? (项目属性->构建->“高级”按钮->调试信息->“完整” 要么 项目属性 -> 编译 -> 高级选项 -> 调试信息 -> VB 的“完整”)

我的项目 json 看起来像

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

【问题讨论】:

  • 很想知道解决方案,因为我正面临着确切的问题。

标签: fortify .net-core


【解决方案1】:

我遇到了同样的问题。它责备xproj文件而不是project.json所以我尝试添加

<DebugType>full</DebugType>

PropertyGroup 内但无济于事。

最后我通过从命令行运行 Fortify 找到了解决方法:

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

我的MyApplicationSca.proj 看起来像这样:

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

我现在没有调查更多,但我希望这能让我们更接近答案。

【讨论】:

  • 你好@KevinG,%BUILD_CONFIG% 是什么,我怎样才能获得 MSBuild.GlobalRelay.targets?你能帮助这个解决方案工作的示例项目吗?
  • @yayadavid 我意识到我的示例文件中有一些无用的东西。我已编辑我的答案以解决您的问题,但我现在无法创建示例项目 - 我正在做笔记以稍后改进我的答案
猜你喜欢
  • 1970-01-01
  • 2017-12-30
  • 2015-03-06
  • 1970-01-01
  • 2020-08-31
  • 2019-04-10
  • 1970-01-01
  • 1970-01-01
  • 2015-04-14
相关资源
最近更新 更多