Skip to content

Commit 17f1974

Browse files
Apply suggestions from code review
Co-Authored-By: mc <42146119+mchammer01@users.noreply.github.com>
1 parent a872d7c commit 17f1974

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

change-notes/1.24/analysis-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
| Missing await (`js/missing-await`) | correctness | Highlights expressions that operate directly on a promise object in a nonsensical way, instead of awaiting its result. Results are shown on LGTM by default. |
4040
| Prototype pollution in utility function (`js/prototype-pollution-utility`) | security, external/cwe/cwe-400, external/cwe/cwe-471 | Highlights recursive copying operations that are susceptible to prototype pollution. Results are shown on LGTM by default. |
4141
| Unsafe jQuery plugin (`js/unsafe-jquery-plugin`) | Highlights potential XSS vulnerabilities in unsafely designed jQuery plugins. Results are shown on LGTM by default. |
42-
| Useless use of cat (`js/useless-use-of-cat`) | correctness, security, maintainability | Highlights command executions of cat where the fs API should be used instead. Results are shown on LGTM by default. |
42+
| Useless use of cat (`js/useless-use-of-cat`) | correctness, security, maintainability | Highlights command executions of `cat` where the fs API should be used instead. Results are shown on LGTM by default. |
4343

4444

4545
## Changes to existing queries

javascript/ql/src/Security/CWE-078/UselessUseOfCat.qhelp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"qhelp.dtd">
44
<qhelp>
55
<overview>
6-
<p>Using the unix command <code>cat</code> to simply read a file is a
7-
unnecessarily complex way to achieve something that can be done simpler and
8-
safer using the Node.js <code>fs.readFile</code> API.
6+
<p>Using the unix command <code>cat</code> only to read a file is a
7+
an unnecessarily complex way to achieve something that can be done in a simpler and
8+
safer manner using the Node.js <code>fs.readFile</code> API.
99
</p>
1010
<p>
1111
The use of <code>cat</code> for simple file reads leads to code that is
@@ -25,12 +25,11 @@ from the file system.
2525

2626
<sample src="examples/useless-cat.js"/>
2727

28-
<p>The code in the example will break if the input <code>name</code> contain
29-
special characters (including space), the code does not work on windows,
30-
and if the input is user controlled a command injection attack can happen.</p>
28+
<p>The code in the example will break if the input <code>name</code> contains
29+
special characters (including space). Additionally, it does not work on Windows
30+
and if the input is user-controlled, a command injection attack can happen.</p>
3131

32-
<p>To avoid these potential issues the <code>fs.readFile</code> API can be
33-
used instead: </p>
32+
<p>The <code>fs.readFile</code> API should be used to avoid these potential issues:
3433

3534
<sample src="examples/useless-cat-fixed.js"/>
3635

javascript/ql/src/Security/CWE-078/UselessUseOfCat.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Useless use of cat
3-
* @description Using `cat`-process to simply read a file is unnecessarily complex, inefficient, unportable, can lead to subtle bugs, or even security vulnerabilities.
3+
* @description Using the `cat` process to read a file is unnecessarily complex, inefficient, unportable, and can lead to subtle bugs, or even security vulnerabilities.
44
* @kind problem
55
* @problem.severity error
66
* @precision high
@@ -22,4 +22,4 @@ where
2222
if cat.isSync()
2323
then message = " Can be replaced with a call to fs.readFileSync(..)."
2424
else message = " Can be replaced with a call to fs.readFile(..)."
25-
select cat.asExpr().(FirstLineOf), "Useless use of `cat`." + message
25+
select cat.asExpr().(FirstLineOf), "Useless use of `cat`." + message

0 commit comments

Comments
 (0)