forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEjbFileIO.ql
More file actions
37 lines (34 loc) · 1.38 KB
/
EjbFileIO.ql
File metadata and controls
37 lines (34 loc) · 1.38 KB
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
29
30
31
32
33
34
35
36
37
/**
* @name EJB uses file input/output
* @description An EJB should not attempt to access files or directories in the file system.
* Such use could compromise security and is not a suitable data access method
* for enterprise components.
* @kind problem
* @problem.severity error
* @precision low
* @id java/ejb/file-io
* @tags reliability
* external/cwe/cwe-576
*/
import java
import semmle.code.java.frameworks.javaee.ejb.EJB
import semmle.code.java.frameworks.javaee.ejb.EJBRestrictions
/*
* JSR 220: Enterprise JavaBeansTM,Version 3.0
* EJB Core Contracts and Requirements
* Section 21.1.2 Programming Restrictions
*
* - An enterprise bean must not use the java.io package to attempt to access files and directo-
* ries in the file system.
*
* The file system APIs are not well-suited for business components to access data. Business components
* should use a resource manager API, such as JDBC, to store data.
*
* - The enterprise bean must not attempt to directly read or write a file descriptor.
*
* Allowing the enterprise bean to read and write file descriptors directly could compromise security.
*/
from Callable origin, ForbiddenFileCallable target, Call call
where ejbCalls(origin, target, call)
select origin, "EJB should not access the file system by calling $@.", call,
target.getDeclaringType().getName() + "." + target.getName()