Skip to content

Commit b20e852

Browse files
committed
add default message if not pretty printed call can be created
1 parent b72404d commit b20e852

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import javascript
1414
import semmle.javascript.security.UselessUseOfCat
1515
import semmle.javascript.RestrictedLocations
1616

17-
1817
from UselessCat cat, string message
19-
where
20-
message = " Can be replaced with: " + PrettyPrintCatCall::createReadFileCall(cat)
21-
or
22-
not exists(PrettyPrintCatCall::createReadFileCall(cat)) and message = ""
18+
where
19+
message = " Can be replaced with: " + PrettyPrintCatCall::createReadFileCall(cat)
20+
or
21+
not exists(PrettyPrintCatCall::createReadFileCall(cat)) and
22+
if cat.isSync()
23+
then message = " Can be replaced with a call to fs.readFileSync(..)."
24+
else message = " Can be replaced with a call to fs.readFile(..)."
2325
select cat.asExpr().(FirstLineOf), "Useless use of `cat`." + message

0 commit comments

Comments
 (0)