Fortify 源分析器和 Apache Lenya

发布于 2024-07-27 16:36:13 字数 996 浏览 5 评论 0原文

我正在尝试将 Fortify 源代码分析器用于我学校的一个研究项目,以测试开源 Java Web 应用程序的安全性。 我目前正在研究 Apache Lenya。 我正在使用最新的稳定版本(Lenya v2.0.2)。

根目录中有一个名为 build.sh 的文件。 调用此文件以使用发行版附带的 Ant 版本(在 tools/bin 文件夹中)构建 Lenya。 当我运行 ./build.sh 时,我可以很好地构建 Lenya。 因此,假设在 Fortify 中运行以下命令可以工作:

sourceanalyzer -b lenya -Xmx1200M touchless ./build.sh

但是,当我尝试运行:

sourceanayzer -b lenya -Xmx1200M -scan -f lenya.fpr

我得到:

未找到构建 ID Lenya。

我查看了 buid.sh 文件,注意到它只是重置当前的 ant home、classpath 和 ant options 变量,运行 ant build 命令,并将这些值重置回默认值。 因此,我手动重置所有变量(没有脚本),而不是运行脚本并运行:

sourceanalyzer -b lenya -Xmx1200M touchless tools/bin/ant -logger org.apache.tools.ant.NoBannerLogger

然后我运行 :

sourceanalyzer -b lenya -Xmx1200M -scan -f lenya.fpr

但我得到了相同的错误。 我不确定这是因为我做错了什么,还是 Fortify 做得不正确。 任何见解都会很棒。

I am trying to use Fortify Source Code Analyzer for a research project at my school to test the security for open source Java web applications. I am currently working on Apache Lenya. I am working with the last stable release (Lenya v2.0.2).

Inside the root directory there is a file named build.sh. This file is called to build Lenya using the version of Ant that ships with the release (in the tools/bin folder). I can build Lenya just fine when I run ./build.sh. So, it would be assumed that running the following command in Fortify would work :

sourceanalyzer -b lenya -Xmx1200M touchless ./build.sh

However, when I try and run:

sourceanayzer -b lenya -Xmx1200M -scan -f lenya.fpr

I get:

build id Lenya not found.

I looked at the buid.sh file and noticed that it was just resetting the current ant home, classpath, and ant options variables, running the ant build command, and resetting the values back to their defaults. So I reset all of the variables manually (without the script) instead of running the script and ran:

sourceanalyzer -b lenya -Xmx1200M touchless tools/bin/ant -logger org.apache.tools.ant.NoBannerLogger

Then I ran :

sourceanalyzer -b lenya -Xmx1200M -scan -f lenya.fpr

but I got the same error. I'm not sure if this is because I am doing something wrong or if it is something that Fortify is not doing correctly. Any insight will be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

何处潇湘 2024-08-03 16:36:13

我不确定您是否有权访问 Fortify 文档,但这肯定会有所帮助。 您应该参阅《SCA 用户指南》以了解如何使用 sourceanalyzer 可执行文件。

简而言之,有两种获取 FPR 文件的方法:(

  1. 长方法)通过提供源代码的路径和源分析器可执行文件的类路径来编写脚本来翻译和分析源代码。
  2. (简短的方法)使用 SCACompiler 而不是 javac 作为编译器。 您需要为此修改构建脚本。

我更喜欢前者,因为它在处理大型代码库时具有可定制性。

PS:这是哪个版本的Fortify?

I'm not sure whether you have access to the Fortify documentation, but that will definitely help. You should refer to the SCA User's Guide to understand how to use the sourceanalyzer executable.

To cut things short, there are two ways of getting the FPR file:

  1. (The long way) Write a script to translate and analyse the source code by providing the path of the source code and the classpath to the sourceanalyzer executable.
  2. (The short way) Use the SCACompiler instead of javac as the compiler. You'll need to modify the build script for this.

I prefer the former due to its customizability when handling large code bases.

PS: Which version of Fortify is this?

亢潮 2024-08-03 16:36:13

不要使用非接触式命令,该命令用于 C/C++ 集成。 由于 Lenya 是用 Java 编写的,因此您最好使用其他命令。 尝试执行您的第一个翻译步骤(从您的基本 lenya 目录运行):

sourceanalyzer -b lenya -Xmx1200M -source 1.5 -cp "**/*.jar" "**/*"

Don't use the touchless command, that is for C/C++ Integration. Since Lenya is written in Java, you're better off with other commands. Try this for your first translation step (run from your base lenya dir):

sourceanalyzer -b lenya -Xmx1200M -source 1.5 -cp "**/*.jar" "**/*"
若相惜即相离 2024-08-03 16:36:13

您使用的命令实际上可以与 Java 构建一起使用,但它有一些限制。 使用非接触式构建包装器会创建许多编译器包装器(例如 javac),并将包装器放在 PATH 环境变量的前面。

如果您的 build.sh 脚本包含对 javac 的完全限定引用,例如 /usr/java/bin/javac,则非接触式构建集成将不起作用。

user233276 的说明是最广泛有用的。 如果您想尝试 Fortify SCA 构建集成,我建议该技术是修改 build.sh(请参阅 http://svn.apache.org/viewvc/lenya/trunk/build.sh?view=markup&pathrev=400414)并更改第 43 行from:

"$ANT_HOME/bin/ant" -logger org.apache.tools.ant.NoBannerLogger -emacs $@

to:

sourceanalyzer -b Lenya "$ANT_HOME/bin/ant" -logger org.apache.tools.ant.NoBannerLogger -emacs $@

请参阅《Fortify SCA 用户指南》了解三种类型的 ant 集成:

  1. 覆盖 build.compiler 属性:

    ant -lib sourceanalyzer.jar {Fortify ant options} {ant options}

  2. 上图:

    sourceanalyzer -b {Fortify options} ant {ant options}

  3. 或者,如果您将自定义 build.xml 制作为见附录:

    ant -lib sourceanalyzer.jar {ant options}

The command you used actually could work with Java builds, except that it has some limitations. Using the touchless build wrapper creates a number of compiler wrappers, e.g. for javac, and puts the wrappers at the front of the PATH environment variable.

If your build.sh script contains fully qualified references to javac, for example /usr/java/bin/javac, then the touchless build integration will not work.

user233276's instructions are the most broadly useful. If you want to experiment with Fortify SCA build integration, I would suggest the technique would be to modify build.sh (see http://svn.apache.org/viewvc/lenya/trunk/build.sh?view=markup&pathrev=400414) and change line 43 from:

"$ANT_HOME/bin/ant" -logger org.apache.tools.ant.NoBannerLogger -emacs $@

to:

sourceanalyzer -b Lenya "$ANT_HOME/bin/ant" -logger org.apache.tools.ant.NoBannerLogger -emacs $@

See the Fortify SCA User Guide for the three types of ant integration:

  1. Override the build.compiler property:

    ant -lib sourceanalyzer.jar {Fortify ant options} {ant options}

  2. Shortcut to the above:

    sourceanalyzer -b {Fortify options} ant {ant options}

  3. Or, if you make a custom build.xml as shown in the appendix:

    ant -lib sourceanalyzer.jar {ant options}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文