【问题标题】:HP Fortify ASP.Net Web FormsHP Fortify ASP.Net Web 表单
【发布时间】:2017-02-08 20:26:53
【问题描述】:

我有这个 .bat 文件,它可以扫描我工作中的一个应用程序。

我正在比较生成 .fpr 文件的两种方式:

  • 使用扫描向导
  • 使用适用于 Visual Studio 的 HP Fortify 插件。

发生的情况是,当扫描向导的 .bat 文件生成 .fpr 文件时,它似乎完全忽略了我在应用程序中的所有 .aspx、aspx.cs 和 .cs 文件。

我的应用是旧的 Web 窗体,为了发布它,我们需要在 Visual Studio 中选择预编译选项。

我已经在帖子中尝试过 Eric 的解决方案。 HP Fortify scans get ASP Pre-Compilation error

但还是一无所获。

我已经尝试在发布前后生成 bat 文件,但两者返回的漏洞数量相同。 15左右的东西。 发布后,它会为所有页面生成 dll,这意味着理论上它应该检测所有应用程序代码。

另一方面,当我通过 Visual Studio 插件生成 .fpr 文件时,它返回给我大约 600 个漏洞。

我真正的问题是我们需要运行 .bat 文件,而不是 Visual Studio,因为我们有一个持续集成过程,我们在其中构建应用程序、运行代码分析,然后运行 ​​HP Fortify 以完成该过程,所以我需要运行插件时返回的漏洞数量与使用 .bat 文件运行时返回的漏洞数量相同。

任何帮助将不胜感激。

感谢您的宝贵时间!

【问题讨论】:

    标签: asp.net webforms fortify


    【解决方案1】:

    您可以选择几种不同的方法。

    1) 在安装了 Fortify 插件的 CI 机器上安装 Visual Studio。这是我使用 Visual Studio 扫描 WebGoat.Net 的示例批处理文件

    sourceanalyzer -b test -clean
    
    sourceanalyzer -b test -Xmx6G -verbose -debug -logfile vs_translate.txt "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe" NewWebForms.sln /REBUILD Debug
    
    sourceanalyzer -b test -show-files > vs_files.txt
    
    sourceanalyzer -b test -show-build-warnings > vs_warnings.txt
    
    sourceanalyzer -b test -verbose -debug -logfile vs_scanlog.txt -scan -f vs_scan.fpr
    
    fprutility -information -categoryIssueCounts -project vs_scan.fpr
    

    2) 使用最新版本的 Fortify (16.20),您可以直接扫描 .Net 代码。这是我创建的用于扫描 WebGoat.Net 的批处理文件

    sourceanalyzer -b test -clean
    
    sourceanalyzer -b test -dotnet-version 4.5.2 -cs-extern-alias "global=C:\Samples\NewWebForms\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.1\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll;global=C:\Samples\NewWebForms\packages\Microsoft.AspNet.Identity.Core.2.2.1\lib\net45\Microsoft.AspNet.Identity.Core.dll;global=C:\Samples\NewWebForms\packages\Microsoft.AspNet.Identity.Owin.2.2.1\lib\net45\Microsoft.AspNet.Identity.Owin.dll;global=C:\Samples\NewWebForms\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll" -dotnetwebroot NewWebForms\ -libdirs packages\**/*.dll;NewWebForms\bin\*.dll NewWebForms\**/*
    
    sourceanalyzer -b test -show-files > cmd_files.txt
    
    sourceanalyzer -b test -show-build-warnings > cmd_warnings.txt
    
    sourceanalyzer -b test -Xmx6G -verbose -debug -logfile cmd_scanlog.txt -scan -f cmd_scan.fpr
    
    fprutility -information -categoryIssueCounts -project cmd_scan.fpr
    

    3) 如果需要,您还可以扫描项目的编译 .dll。这是我扫描 WebGoat.Net 所做的工作

    sourceanalyzer -b test -Xmx8G -vsversion 14.0 
                   @excludelist.txt 
                   -Dcom.fortify.sca.SourceFiles=WebGoat.NET\WebGoat 
                   -libdirs WebGoat.NET\WebGoat\bin WebGoat.NET\**/*.dll
                   WebGoat.NET/**/*
    

    要更详细地了解这一点,请查看我在 Fortify to scan 3rd party dll's 上的回答

    【讨论】:

    • 当我尝试在您的答案中使用选项 2 扫描 WebGoat.Net 时,第三方 .dll 不会使用通配符拾取。任何想法为什么会这样?我注意到您在回答中使用了正斜杠-libdirs packages\**/*.dll;,这有必要吗?
    • 正斜杠是旧习惯,它曾经很重要,只是经过测试,现在看起来像正向或反向工作。为什么你认为它没有拿起你的第三方 dll?你可以对你运行的命令提出问题吗?
    • 当我使用通配符扫描后在 AWB 中检查 fpr 时,第三方库未列出,如果我单独指定它们。
    • 对不起,我没有 atm 命令,我在工作中运行它。命令和你的一样,只是我没有使用-cs-extern-alias 标志。
    • 以下是我使用的命令sourceanalyzer -b test -dotnet-version 4.5.2 -dotnetwebroot C:\projects\WebGoat\ -libdirs C:\projects\WebGoat\packages\**\*.dll;C:\projects\WebGoat\bin\*.dll C:\projects\WebGoat\**\* 如果我将路径添加到 dll 所在的目录或每个单独 dll 的路径,它可以工作,但上述命令中的通配符不起作用。知道为什么吗?非常感谢任何帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-12
    • 1970-01-01
    • 2017-06-26
    • 1970-01-01
    相关资源
    最近更新 更多