Open yogurtearl opened 2 years ago
Searching for lastIndexOf
doesn't yield any matches in this repo:
https://github.com/evanw/node-source-map-support/search?q=lastIndexOf
Are you sure that the code is from this package, and could you point me to the code in question in that case? ☺️
as far as I can tell... it was in a sourcemap-register.js file which I think was generated by node-source-map-support ?
I am not clear on where sourcemap-register.js
is coming from or where the lastIndexOf
in the file is coming from.
sourcemap-register.js
was being generated by running this command:
ncc build src/main.ts --out dist/main --source-map && ncc build src/post.ts --out dist/post --source-map
adding --no-source-map-register
got rid of the sourcemap-register.js
file altogether.
The heuristic looks like it might apply to indexOf
as well (though the example only mentions lastIndexOf
).
It looks like it may be this block its complaining about:
Copied from v8 almost 9 years ago 😅
I'm seeing the same issue specifically pointed at indexOf
:
This suffix check is missing a length comparison to correctly handle indexOf returning -1.
The
indexOf
andlastIndexOf
methods are sometimes used to check if a substring occurs at a certain position in a string. However, if the returned index is compared to an expression that might evaluate to -1, the check may pass in some cases where the substring was not found at all.
The flagged code is the minified version of what @calebboyd referenced above:
I think this
sourcemap-register.js
file is an output of this module: https://raw.githubusercontent.com/gradle/gradle-build-action/aeb3e0fcd750be80d74f07ee94363abdf2b51020/dist/post/sourcemap-register.jswhich contains this:
Which causes Github advanced security to issue this "high" severity error:
https://codeql.github.com/codeql-query-help/javascript/js-incorrect-suffix-check/
Would be great if you can confirm if this is related to node-source-map-support
If it is related, can you add the suggested fix here: https://codeql.github.com/codeql-query-help/javascript/js-incorrect-suffix-check/ to avoid the error from GH advanced security. :)