Xiaoven / codegex

A light-weight tools like spotbugs
GNU Lesser General Public License v2.1
1 stars 0 forks source link

FN and FP for ES_COMPARING_STRINGS_WITH_EQ with special character #65

Closed Xiaoven closed 3 years ago

Xiaoven commented 3 years ago

False Negative

com/alibaba/fastjson/parser/deserializer/FieldDeserializer.java

if (collection == Collections.emptySet()
                                    || collection == Collections.emptyList()
                                    || collectionClassName == "java.util.ImmutableCollections$ListN"
                                    || collectionClassName == "java.util.ImmutableCollections$List12"
                                    || collectionClassName.startsWith("java.util.Collections$Unmodifiable")) {
                                // skip
                                return;
                            }

原因

现在的pattern为

r'((?:(?P<aux1>\((?:[^()]++|(?&aux1))*\))|[\w."])++)\s*[!=]=\s*((?:(?&aux1)|[\w."])+)'

其中 [\w."] 部分不能匹配 $ 符号(java 命名规则允许使用字符中比较少用的字符)

False Positive

nanohttpd/websocket/src/test/java/org/nanohttpd/junit/protocols/websockets/WebSocketResponseHandlerTest.java

this.headers.put("sec-websocket-key", "x3JJHMbDL1EzLkh9GBhXDw==");

原因

等号两边匹配结果 "x3JJHMbDL1EzLkh9GBhXDw".

is_str_with_quotes 方法现在只判断字符串开头和结尾字符是否为 ", 没有判断字符串长度,导致只包含" 的字符串蒙混过关。

Wrong line number for switch-case

switch (c) {
        case 'a':
        case 'A':
            if (csName == "ASCII" || equalEncodings(csName, "ASCII")) {
                return CS_US_ASCII;
            }
            break;

        case 'c':