forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEqualsArray.ql
More file actions
28 lines (26 loc) · 791 Bytes
/
EqualsArray.ql
File metadata and controls
28 lines (26 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* @name Equals or hashCode on arrays
* @description The 'equals' and 'hashCode' methods on arrays only consider object identity, not
* array contents, which is unlikely to be what is intended.
* @kind problem
* @problem.severity error
* @precision very-high
* @id java/equals-on-arrays
* @suites security-and-quality
* @tags reliability
* correctness
*/
import java
from MethodCall ma, Array recvtype, Method m
where
recvtype = ma.getQualifier().getType() and
m = ma.getMethod() and
(
m instanceof HashCodeMethod
or
m instanceof EqualsMethod and
haveIntersection(recvtype, ma.getArgument(0).getType().(Array))
)
select ma,
"The " + m.getName() +
" method on arrays only considers object identity and ignores array contents."