forfify 问题咨询

fortify 无法扫描编译器clang++的代码,没有报出错误。

“付费悬赏”

关键字:Fortify Android Ninja clang++

  1. ninja 是 Google 的一名程序员推出的注重速度的构建工具.
    一般在Unix/Linux上的程序通过 make/makefile 来构建编译,
    而 ninja 通过将编译任务并行组织,大大提高了构建速度
  2. clang++: 编译工具链

那可能是不支持 clang++,或者因为 clang++ 的代码编写方式与 Fortify 的扫描方式不兼容。又没有错误日志,具体问题也说不上来。

Fortify不扫描Clang++代码并且不产生任何错误消息的问题可能是由于多种原因造成的:

1.Fortify 不支持 Clang++:Fortify 可能无法扫描和分析由 Clang++ 编译的代码。您应该查看产品文档以查看是否支持 Clang++。

2.配置不正确:如果 Fortify 支持 Clang++,则可能是配置不正确。验证正确的设置是否已到位,例如 Clang++ 编译器的路径和用于代码分析的相应选项。

3.代码兼容性问题:使用 Fortify 扫描程序扫描的代码的兼容性可能存在问题。某些代码结构可能无法被扫描程序识别并导致其失败。

4.资源限制:如果正在扫描的代码特别大或特别复杂,Fortify 扫描程序可能没有足够的资源来完成扫描。这可能会导致扫描以静默方式失败,而不会生成任何错误消息。

该回答引用ChatGPT
请参考下面的解决方案,如果有帮助,还请点击 “采纳” 感谢支持!

方案
您可以采取以下步骤来解决问题:

1、确保Fortify支持Clang++编译器:您需要检查Fortify的版本和文档,确保它支持Clang++编译器。

2、安装所需的插件:如果Clang++编译器不是Fortify默认支持的编译器,您可能需要安装所需的插件。

3、检查编译选项:您需要确保在编译代码时使用正确的选项,以确保Fortify能够扫描代码。

一般来说,Fortify 可以扫描使用 C++ 编写的代码,但扫描的能力可能受到编译器的影响。您可以检查 Fortify 是否支持您所使用的 Clang++ 编译器版本。您还可以检查是否存在任何兼容性问题,例如编译选项的不同等。

此外,如果 Fortify 没有报出错误,可能是因为代码本身并没有问题。请检查 Fortify 的扫描结果,确保它没有遗漏任何可能存在的安全漏洞。

如果仍然有问题,您可以考虑以下解决方案:

1、升级 Fortify 软件至最新版本,以确保它兼容您使用的 Clang++ 编译器版本。

2、使用不同的编译选项,以确保 Fortify 可以扫描代码。

3、与 Fortify 技术支持联系,以获得更详细的帮助。

尝试使用其他代码审核工具,例如 Clang 自带的 Clang-Tidy。

如果您需要使用 Fortify 扫描 C++ 代码,请注意:

1、Fortify 可能需要在特定的编译环境中运行,以便获得正确的结果。因此,请确保您的编译环境是适当的。

2、Fortify 可以对编译后的代码进行扫描,因此,请确保代码已经编译并且存在于适当的位置。

3、Fortify 可以扫描源代码,并生成扫描报告,请确保您已经配置了适当的扫描选项。

4、Fortify 可以检测多种不同的安全漏洞,但并不能保证能检测到所有的安全问题。因此,请使用多种工具来评估代码的安全性。

望采纳。

如果Fortify无法扫描Clang++编译器的代码,可能是因为以下原因:

  1. Fortify不支持Clang++:Fortify可能不支持Clang++编译器,您需要查询Fortify官方网站以确认是否支持。

  2. Clang++编译器版本问题:Fortify可能不支持您使用的Clang++编译器版本,您需要查询Fortify官方网站以确认是否支持。

  3. 文件格式问题:Fortify可能不支持Clang++编译器生成的文件格式,您需要查询Fortify官方网站以确认是否支持。

  4. 配置问题:Fortify可能需要特殊的配置才能扫描Clang++编译器的代码,您需要查询Fortify官方文档以确认配置方法。

Fortify 是一种静态代码分析工具,它扫描代码并寻找安全漏洞。如果 Fortify 无法扫描 clang++ 编译器的代码,并且没有生成任何错误,那么可能是因为以下几种原因之一:

clang++ 代码不兼容:Fortify 可能不支持 clang++ 编译器生成的代码。

配置问题:Fortify 的配置可能不正确,导致无法扫描 clang++ 编译器生成的代码。

插件问题:Fortify 可能需要与 clang++ 配合使用的插件,但未正确安装或配置。

Fortify无法扫描编译器clang++的代码,因为它不支持C++的语言特性。为了正确的扫描这些代码,您需要使用一个支持C++语言特性的工具,如Coverity或SonarQube。

Fortify静态代码扫描常见问题及修复
1、Portability Flaw: Locale Dependent Comparison (Code Quality, Control Flow)
2、Access Specifier Manipulation (Input Validation and Representation, Semantic)
3、Poor Style: Value Never Read (Code Quality, Structural)
4、Build Misconfiguration: External Maven Dependency Repository (Environment, Configuration)
5、Code Correctness: Byte Array to String Conversion (Code Quality, Semantic)
6、Code Correctness: Erroneous String Compare (Code Quality, Structural)
7、Dead Code: Expression is Always false (Code Quality, Structural)
8、Dead Code: Unused Method (Code Quality, Structural)
9、Denial of Service: Parse Double (Input Validation and Representation, Data Flow)
10、HTML5: Overly Permissive CORS Policy (Encapsulation, Semantic)
11、J2EE Bad Practices: Leftover Debug Code (Encapsulation, Structural)
12、Missing Check against Null (API Abuse, Control Flow)
13、Password Management: Password in Comment (Security Features, Structural)
14、Poor Error Handling: Overly Broad Catch (Errors, Structural)
15、Access Control: Database (Security Features, Data Flow)
16、Header Manipulation (Input Validation and Representation, Data Flow)
17、Null Dereference (Code Quality, Control Flow)
18、Unreleased Resource: Streams (Code Quality, Control Flow)
19、Cross-Site Scripting: Persistent (Input Validation and Representation, Data Flow)
1、Portability Flaw: Locale Dependent Comparison (Code Quality, Control Flow)
移植性缺陷:地区依赖比较(代码质量,控制流)

if (tag.toUpperCase().equals("SCRIPT")){
  return null;
}

if (tag.toUpperCase(Locale.ENGLISH).equals("SCRIPT")){
  return null;
}
if (tag.equalsIgnoreCase("SCRIPT")){
    return null;
}

2、Access Specifier Manipulation (Input Validation and Representation, Semantic)
访问说明符操作(输入验证和表示,语义)

field.setAccessible(true);
修改为使用spring提供的类
import org.springframework.util.ReflectionUtils;
ReflectionUtils.makeAccessible(field);

3、Poor Style: Value Never Read (Code Quality, Structural)
糟糕的风格:值从未使用(代码质量,结构)

4、Build Misconfiguration: External Maven Dependency Repository (Environment, Configuration)
构建错误配置:外部Maven依赖库(环境,配置)
这一 Maven 编译脚本依赖于外部数据源,这会导致攻击者能够将恶意代码插入最终产品中,或者控制编译计算机。

5、Code Correctness: Byte Array to String Conversion (Code Quality, Semantic)
代码正确性:字节数组到字符串的转换(代码质量,语义)

public class ByteSerializerUtils extends JsonSerializer<byte[]>{
    @Override
    public void serialize(byte[] bytes, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
        jsonGenerator.writeString(new String(bytes));
    }
}
修改为
new String(bytes,"UTF-8")

6、Code Correctness: Erroneous String Compare (Code Quality, Structural)
代码正确性:错误字符串的比较(代码质量,结构)

7、Dead Code: Expression is Always false (Code Quality, Structural)
死代码:表达式总是假的(代码质量,结构)

8、Dead Code: Unused Method (Code Quality, Structural)
死代码:未使用的方法(代码质量,结构)

9、Denial of Service: Parse Double (Input Validation and Representation, Data Flow)
拒绝服务:解析Double(输入验证和表示,数据流)

10、HTML5: Overly Permissive CORS Policy (Encapsulation, Semantic)
HTML5: 过于宽松的CORS策略(封装、语义)
程序会定义过于宽松的跨源资源共享 (CORS) 策略。

11、J2EE Bad Practices: Leftover Debug Code (Encapsulation, Structural)
J2EE Bad Practices:剩余的调试代码(封装,结构)

12、Missing Check against Null (API Abuse, Control Flow)
缺少对Null的检查(API滥用,控制流)

13、Password Management: Password in Comment (Security Features, Structural)
密码管理:密码在评论中(安全功能,结构)
以明文形式在系统或系统代码中存储密码或密码详细信息可能会以无法轻松修复的方式危及系统安全。

14、Poor Error Handling: Overly Broad Catch (Errors, Structural)
糟糕的错误处理:过于宽泛的捕获(错误,结构性)
不要捕获广泛的异常类,例如exception、Throwable、Error或RuntimeException,除非是在程序或线程的最高层。

15、Access Control: Database (Security Features, Data Flow)
访问控制:数据库(安全特性,数据流)
Rather than relying on the presentation layer to restrict values submitted by the user, access control should be handled by the application and database layers. Under no circumstances should a user be allowed to retrieve or modify a row in the database without the appropriate permissions. Every query that accesses the database should enforce this policy, which can often be accomplished by simply including the current authenticated username as part of the query.

访问控制应该由应用程序层和数据库层处理,而不是依赖表示层来限制用户提交的值。在任何情况下,都不允许用户在没有适当权限的情况下检索或修改数据库中的行。每个访问数据库的查询都应该执行此策略,通常只需将当前经过身份验证的用户名作为查询的一部分即可完成此策略。

16、Header Manipulation (Input Validation and Representation, Data Flow)
报头操作(输入验证和表示,数据流)

17、Null Dereference (Code Quality, Control Flow)
空引用(代码质量,控制流)

18、Unreleased Resource: Streams (Code Quality, Control Flow)
未发布的资源:流(代码质量,控制流)

19、Cross-Site Scripting: Persistent (Input Validation and Representation, Data Flow)
风险类型 原因
Code Correctness: Erroneous String Compare 字符串的对比使用错误方法
Cross-Site Scripting Web浏览器发送非法数据,导致浏览器执行恶意代码
Dead Code: Expression is Always true 表达式的判断总是true
Dead Code: Unused Method 没有使用的方法
HTTP Response Splitting 含有未验证的数据
J2EE Bad Practices: Leftover Debug Code 在部署的Web应用程序中建立了一些想象不到的入口点
Missing Check against Null 有可能返回了null
Poor Error Handling: Empty Catch Block 有些异常备忽略,可能会导致程序无法发现意外状况
Poor Error Handling: Overly Broad Catch Catch块可以处理的异常种类比较多,往往会过多的考虑不应该在此位置处理各种问题或故障而困扰
Poor Error Handling: Overly Broad Throws Throws了一个过于笼统的异常,从而使调用者很难处理和修复发生的错误
Poor Error Handling: Return inside Finally 可能会导致异常丢失
Poor Logging Practice: Use of a System output stream 使用system.out或system.err不是专门的日志记录工具,会导致难以监控程序的运行状况
Poor Style: Value Never Read 没有使用赋给变量的值
System Information Leak: HTML Comment in JSP 注释所包含的任何信息都有可能帮助攻击者了解系统并制定相应的攻击方案
Unchecked Return Value 忽略了某些方法的返回值
J2EE Bad Practices: Threads 禁止在某些环境下使用Web应用程序的线程管理
JavaScript Hijacking: Ad Hoc Ajax 使用Javascript符号传递敏感数据会存在漏洞
Denial of Service 读取文件可能会使攻击者造成程序崩溃
System Information Leak printstackTrace()来提示系统数据有助于攻击者制定攻击计划
Insecure Randomness 产生的随机数不能抵挡加密攻击
Null Dereference 引用了空指针
Unreleased Resource: Streams 无法成功释放FileInputStream()函数分配的系统资源
Redundant Null Check 引用了空指针
Dead Code: Unused Field 没有使用的字段
Axis 2 Misconfiguration: Debug Information 借助SOAP Monitor模块,攻击者可截取SOAP信息流
Poor Error Handling: Program Catches nullpointerexception 可捕获NullPointException,通常来说不是一个好方法
Poor Style: Confusing Naming 重复命名
Dead Code: Expression is Always false 表达式的判断总是false
J2EE Misconfiguration: Incomplete Error handing 配置默认的错误页面,来处理那些未被捕获的异常
Path Manipulation 攻击者可控制File路径参数,借此访问或修改其他受保护的文件
Poor Logging Practice: Logger Not Declared static final 应该将日志记录器声明为固定且最终的记录器
Poor Style: Redundant Initialization 没有使用赋给变量的值
Code Correctness: null Argument to equals() 表达式obj.equals(null)将总是false
Privacy Violation:Heap Inspection
J2EE Bad Practices:Leftover Debug Code
Poor Error Handling:Overly Broad Throws
Password Management Password in Configuration File
Build Misconfiguration:External Maven Dependency Repository

你的window系统会产生报警,安装的条件什么的。Microsoft的 Visual Studio也可以用clang,建议下对应版本的sdk试一下。看看是不是软件问题。

使用 clang 编译器来编译 C++ 代码,支持 C++11 及更高版本的标准,通常被认为是比 GCC 更快、更稳定的编译器。

回到 Fortify 无法扫描 clang ++ 代码的问题,可以考虑以下几种解决方法:

尝试在编译代码之前使用不同的编译选项。例如,试图通过使用 -O0 选项(禁用优化)来编译代码以获得更好的扫描结果。

检查 Fortify 的技术支持文档,以确保支持扫描 clang ++ 代码。

由于Fortify是安全扫描工具,只能扫描源代码,而 ninja 和 clang ++ 是构建和编译应用代码的工具,所以无法扫描代码,也就无法发现出错误