FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/javascript/ql/src/NodeJS/InvalidExport.ql at codeql-cli/v2.25.6 · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
998
Pull requests
460
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
javascript
/
ql
/
src
/
NodeJS
/
InvalidExport.ql
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (46 loc) · 1.63 KB
Breadcrumbs
codeql
/
javascript
/
ql
/
src
/
NodeJS
/
InvalidExport.ql
Copy path
File metadata and controls
50 lines (46 loc) · 1.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @name Assignment to exports variable
* @description Assigning to the special 'exports' variable only overwrites its value and does not export
* anything. Such an assignment is hence most likely unintentional.
* @kind problem
* @problem.severity warning
* @id js/node/assignment-to-exports-variable
* @tags quality
* reliability
* correctness
* frameworks/node.js
* external/cwe/cwe-563
* @precision very-high
*/
import
javascript
/**
* Holds if `assign` assigns the value of `nd` to `exportsVar`, which is an `exports` variable
*/
predicate
exportsAssign
(
Assignment
assign
,
Variable
exportsVar
,
DataFlow
::
Node
nd
)
{
exists
(
NodeModule
m
|
exportsVar
=
m
.
getScope
(
)
.
getVariable
(
"exports"
)
and
assign
.
getLhs
(
)
=
exportsVar
.
getAnAccess
(
)
and
nd
=
assign
.
getRhs
(
)
.
flow
(
)
)
or
exportsAssign
(
assign
,
exportsVar
,
nd
.
getASuccessor
(
)
)
}
/**
* Holds if `pw` assigns the value of `nd` to `module.exports`.
*/
predicate
moduleExportsAssign
(
DataFlow
::
PropWrite
pw
,
DataFlow
::
Node
nd
)
{
pw
.
getBase
(
)
.
asExpr
(
)
instanceof
ModuleAccess
and
pw
.
getPropertyName
(
)
=
"exports"
and
nd
=
pw
.
getRhs
(
)
or
moduleExportsAssign
(
pw
,
nd
.
getASuccessor
(
)
)
}
from
Assignment
assgn
,
Variable
exportsVar
,
DataFlow
::
Node
exportsVal
where
exportsAssign
(
assgn
,
exportsVar
,
exportsVal
)
and
not
exists
(
exportsVal
.
getAPredecessor
(
)
)
and
// this is OK if `exportsVal` flows into `module.exports`
not
moduleExportsAssign
(
_
,
exportsVal
)
and
// export assignments do work in closure modules
not
assgn
.
getTopLevel
(
)
instanceof
Closure
::
ClosureModule
select
assgn
,
"Assigning to 'exports' does not export anything."
Back
|
FazBrowse Home
|
New Git URL