MRVA: Make markdown code snippets look nicer
Remove some extraneous newlines
This commit is contained in:
@@ -113,11 +113,17 @@ function generateMarkdownForCodeSnippet(
|
||||
.map((line, index) =>
|
||||
highlightCodeLines(line, index + snippetStartLine, highlightedRegion)
|
||||
);
|
||||
lines.push(
|
||||
`<pre><code class="${language}">`,
|
||||
...codeLines,
|
||||
'</code></pre>',
|
||||
);
|
||||
|
||||
// Make sure there are no extra newlines before or after the <code> block:
|
||||
if (codeLines.length === 1) {
|
||||
lines.push(`<pre><code class="${language}">${codeLines[0]}</code></pre>`);
|
||||
} else {
|
||||
lines.push(
|
||||
`<pre><code class="${language}">${codeLines[0]}`,
|
||||
...codeLines.slice(1, -1),
|
||||
`${codeLines[codeLines.length - 1]}</code></pre>`,
|
||||
);
|
||||
}
|
||||
lines.push('');
|
||||
return lines;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
[javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5-L5)
|
||||
|
||||
<pre><code class="javascript">
|
||||
function cleanupTemp() {
|
||||
<pre><code class="javascript">function cleanupTemp() {
|
||||
let cmd = "rm -rf " + path.join(__dirname, "temp");
|
||||
cp.execSync(<strong>cmd</strong>); // BAD
|
||||
}
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4).*
|
||||
@@ -16,13 +14,11 @@ function cleanupTemp() {
|
||||
|
||||
[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6)
|
||||
|
||||
<pre><code class="javascript">
|
||||
(function() {
|
||||
<pre><code class="javascript">(function() {
|
||||
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
|
||||
cp.execSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // BAD
|
||||
|
||||
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6).*
|
||||
@@ -31,13 +27,11 @@ function cleanupTemp() {
|
||||
|
||||
[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8)
|
||||
|
||||
<pre><code class="javascript">
|
||||
cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
|
||||
<pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD
|
||||
|
||||
execa.shell(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK
|
||||
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8).*
|
||||
@@ -47,12 +41,10 @@ function cleanupTemp() {
|
||||
[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9)
|
||||
|
||||
<pre><code class="javascript">
|
||||
|
||||
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
execa.shellSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK
|
||||
|
||||
const safe = "\"" + path.join(__dirname, "temp") + "\"";
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9).*
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
[npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L259-L259)
|
||||
|
||||
<pre><code class="javascript">
|
||||
if (isWindows()) {
|
||||
<pre><code class="javascript"> if (isWindows()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(<strong>`setx path "${meteorPath}/;%path%`</strong>);
|
||||
return;
|
||||
}
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This shell command depends on an uncontrolled [absolute path](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39).*
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
[javascript/extractor/tests/regexp/input/multipart.js](https://github.com/github/codeql/blob/d094bbc06d063d0da8d0303676943c345e61de53/javascript/extractor/tests/regexp/input/multipart.js#L17-L20)
|
||||
|
||||
<pre><code class="javascript">
|
||||
|
||||
var bad95 = new RegExp(
|
||||
"<strong>(a" + </strong>
|
||||
<strong> "|" + </strong>
|
||||
@@ -11,7 +10,6 @@ var bad95 = new RegExp(
|
||||
<strong> "</strong>b$"
|
||||
);
|
||||
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'aa'.*
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
|
||||
[packages/deprecated/markdown/showdown.js](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/deprecated/markdown/showdown.js#L415-L415)
|
||||
|
||||
<pre><code class="javascript">
|
||||
/g,hashElement);
|
||||
<pre><code class="javascript"> /g,hashElement);
|
||||
*/
|
||||
text = text.replace(/(\n\n[ ]{0,3}<!(--<strong>[^\r]*?</strong>--\s*)+>[ \t]*(?=\n{2,}))/g,hashElement);
|
||||
|
||||
// PHP and ASP-style processor instructions (<?...?> and <%...%>)
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '----'.*
|
||||
@@ -17,13 +15,11 @@
|
||||
|
||||
[packages/deprecated/markdown/showdown.js](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/deprecated/markdown/showdown.js#L523-L523)
|
||||
|
||||
<pre><code class="javascript">
|
||||
// Build a regex to find HTML tags and comments. See Friedl's
|
||||
<pre><code class="javascript"> // Build a regex to find HTML tags and comments. See Friedl's
|
||||
// "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
|
||||
var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--<strong>.*?</strong>--\s*)+>)/gi;
|
||||
|
||||
text = text.replace(regex, function(wholeMatch) {
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings starting with '<!--' and containing many repetitions of '----'.*
|
||||
@@ -32,13 +28,11 @@
|
||||
|
||||
[tools/tests/apps/modules/imports/links/acorn/src/parseutil.js](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/tools/tests/apps/modules/imports/links/acorn/src/parseutil.js#L9-L9)
|
||||
|
||||
<pre><code class="javascript">
|
||||
// ## Parser utilities
|
||||
<pre><code class="javascript">// ## Parser utilities
|
||||
|
||||
const literal = /^(?:'(<strong>(?:\\.|[^'])*?</strong>)'|"((?:\\.|[^"])*?)")/
|
||||
pp.strictDirective = function(start) {
|
||||
for (;;) {
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings starting with ''' and containing many repetitions of '\&'.*
|
||||
@@ -47,13 +41,11 @@ pp.strictDirective = function(start) {
|
||||
|
||||
[tools/tests/apps/modules/imports/links/acorn/src/parseutil.js](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/tools/tests/apps/modules/imports/links/acorn/src/parseutil.js#L9-L9)
|
||||
|
||||
<pre><code class="javascript">
|
||||
// ## Parser utilities
|
||||
<pre><code class="javascript">// ## Parser utilities
|
||||
|
||||
const literal = /^(?:'((?:\\.|[^'])*?)'|"(<strong>(?:\\.|[^"])*?</strong>)")/
|
||||
pp.strictDirective = function(start) {
|
||||
for (;;) {
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings starting with '"' and containing many repetitions of '\!'.*
|
||||
|
||||
Reference in New Issue
Block a user