Merge pull request #2079 from github/koesie10/markdown-generation-tests
Add tests for Markdown generation
This commit is contained in:
@@ -2,7 +2,7 @@ import { readJsonSync } from "fs-extra";
|
||||
import { resolve } from "path";
|
||||
import Ajv from "ajv";
|
||||
import { clearLocalDbConfig, DbConfig } from "./db-config";
|
||||
import { findDuplicateStrings } from "../../text-utils";
|
||||
import { findDuplicateStrings } from "../../pure/text-utils";
|
||||
import {
|
||||
DbConfigValidationError,
|
||||
DbConfigValidationErrorKind,
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
generateVariantAnalysisMarkdown,
|
||||
MarkdownFile,
|
||||
RepositorySummary,
|
||||
} from "./remote-queries-markdown-generation";
|
||||
} from "./markdown-generation";
|
||||
import { pluralize } from "../pure/word";
|
||||
import { VariantAnalysisManager } from "./variant-analysis-manager";
|
||||
import { assertNever } from "../pure/helpers-pure";
|
||||
|
||||
@@ -2,20 +2,20 @@ import { CellValue } from "../pure/bqrs-cli-types";
|
||||
import { tryGetRemoteLocation } from "../pure/bqrs-utils";
|
||||
import { createRemoteFileRef } from "../pure/location-link-utils";
|
||||
import { parseHighlightedLine, shouldHighlightLine } from "../pure/sarif-utils";
|
||||
import { convertNonPrintableChars } from "../text-utils";
|
||||
import {
|
||||
import { convertNonPrintableChars } from "../pure/text-utils";
|
||||
import type {
|
||||
AnalysisAlert,
|
||||
AnalysisRawResults,
|
||||
CodeSnippet,
|
||||
FileLink,
|
||||
HighlightedRegion,
|
||||
} from "./shared/analysis-result";
|
||||
import {
|
||||
import type {
|
||||
VariantAnalysis,
|
||||
VariantAnalysisScannedRepository,
|
||||
VariantAnalysisScannedRepositoryResult,
|
||||
} from "./shared/variant-analysis";
|
||||
import { RepositoryWithMetadata } from "./shared/repository";
|
||||
import type { RepositoryWithMetadata } from "./shared/repository";
|
||||
|
||||
export type MarkdownLinkType = "local" | "gist";
|
||||
|
||||
@@ -39,7 +39,7 @@ export interface VariantAnalysisMarkdown {
|
||||
* Generates markdown files with variant analysis results.
|
||||
*/
|
||||
export async function generateVariantAnalysisMarkdown(
|
||||
variantAnalysis: VariantAnalysis,
|
||||
variantAnalysis: Pick<VariantAnalysis, "query">,
|
||||
results: AsyncIterable<
|
||||
[VariantAnalysisScannedRepository, VariantAnalysisScannedRepositoryResult]
|
||||
>,
|
||||
@@ -91,7 +91,7 @@ export async function generateVariantAnalysisMarkdown(
|
||||
|
||||
// Generate summary file with links to individual files
|
||||
const summaryFile: MarkdownFile = generateVariantAnalysisMarkdownSummary(
|
||||
variantAnalysis,
|
||||
variantAnalysis.query,
|
||||
summaries,
|
||||
linkType,
|
||||
);
|
||||
@@ -103,20 +103,16 @@ export async function generateVariantAnalysisMarkdown(
|
||||
}
|
||||
|
||||
export function generateVariantAnalysisMarkdownSummary(
|
||||
variantAnalysis: VariantAnalysis,
|
||||
query: VariantAnalysis["query"],
|
||||
summaries: RepositorySummary[],
|
||||
linkType: MarkdownLinkType,
|
||||
): MarkdownFile {
|
||||
const lines: string[] = [];
|
||||
// Title
|
||||
lines.push(`### Results for "${variantAnalysis.query.name}"`, "");
|
||||
lines.push(`### Results for "${query.name}"`, "");
|
||||
|
||||
// Expandable section containing query text
|
||||
const queryCodeBlock = [
|
||||
"```ql",
|
||||
...variantAnalysis.query.text.split("\n"),
|
||||
"```",
|
||||
];
|
||||
const queryCodeBlock = ["```ql", ...query.text.split("\n"), "```"];
|
||||
lines.push(...buildExpandableMarkdownSection("Query", queryCodeBlock));
|
||||
|
||||
// Padding between sections
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "../../pure/interface-types";
|
||||
import { assertNever } from "../../pure/helpers-pure";
|
||||
import { vscode } from "../vscode-api";
|
||||
import { convertNonPrintableChars } from "../../text-utils";
|
||||
import { convertNonPrintableChars } from "../../pure/text-utils";
|
||||
import { sendTelemetry } from "../common/telemetry";
|
||||
|
||||
export interface ResultTableProps {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "../../pure/bqrs-cli-types";
|
||||
import { tryGetRemoteLocation } from "../../pure/bqrs-utils";
|
||||
import TextButton from "../common/TextButton";
|
||||
import { convertNonPrintableChars } from "../../text-utils";
|
||||
import { convertNonPrintableChars } from "../../pure/text-utils";
|
||||
import { sendTelemetry, useTelemetryOnChange } from "../common/telemetry";
|
||||
|
||||
const numOfResultsInContractedMode = 5;
|
||||
|
||||
@@ -0,0 +1,756 @@
|
||||
[
|
||||
{
|
||||
"repository": {
|
||||
"id": 143040428,
|
||||
"fullName": "github/codeql",
|
||||
"private": false,
|
||||
"stargazersCount": 5703,
|
||||
"updatedAt": "2023-02-15T10:11:45Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 4,
|
||||
"artifactSizeInBytes": 3785,
|
||||
"interpretedResults": [
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This shell command depends on an uncontrolled "
|
||||
},
|
||||
{
|
||||
"t": "location",
|
||||
"text": "absolute path",
|
||||
"location": {
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 4,
|
||||
"startColumn": 35,
|
||||
"endLine": 4,
|
||||
"endColumn": 44
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "t": "text", "text": "." }
|
||||
]
|
||||
},
|
||||
"shortDescription": "This shell command depends on an uncontrolled ,absolute path,.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 3,
|
||||
"endLine": 6,
|
||||
"text": "function cleanupTemp() {\n let cmd = \"rm -rf \" + path.join(__dirname, \"temp\");\n cp.execSync(cmd); // BAD\n}\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 5,
|
||||
"startColumn": 15,
|
||||
"endLine": 5,
|
||||
"endColumn": 18
|
||||
},
|
||||
"codeFlows": [
|
||||
{
|
||||
"threadFlows": [
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 2,
|
||||
"endLine": 6,
|
||||
"text": " path = require(\"path\");\nfunction cleanupTemp() {\n let cmd = \"rm -rf \" + path.join(__dirname, \"temp\");\n cp.execSync(cmd); // BAD\n}\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 4,
|
||||
"startColumn": 35,
|
||||
"endLine": 4,
|
||||
"endColumn": 44
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 2,
|
||||
"endLine": 6,
|
||||
"text": " path = require(\"path\");\nfunction cleanupTemp() {\n let cmd = \"rm -rf \" + path.join(__dirname, \"temp\");\n cp.execSync(cmd); // BAD\n}\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 4,
|
||||
"startColumn": 25,
|
||||
"endLine": 4,
|
||||
"endColumn": 53
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 2,
|
||||
"endLine": 6,
|
||||
"text": " path = require(\"path\");\nfunction cleanupTemp() {\n let cmd = \"rm -rf \" + path.join(__dirname, \"temp\");\n cp.execSync(cmd); // BAD\n}\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 4,
|
||||
"startColumn": 13,
|
||||
"endLine": 4,
|
||||
"endColumn": 53
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 2,
|
||||
"endLine": 6,
|
||||
"text": " path = require(\"path\");\nfunction cleanupTemp() {\n let cmd = \"rm -rf \" + path.join(__dirname, \"temp\");\n cp.execSync(cmd); // BAD\n}\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 4,
|
||||
"startColumn": 7,
|
||||
"endLine": 4,
|
||||
"endColumn": 53
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 3,
|
||||
"endLine": 6,
|
||||
"text": "function cleanupTemp() {\n let cmd = \"rm -rf \" + path.join(__dirname, \"temp\");\n cp.execSync(cmd); // BAD\n}\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 5,
|
||||
"startColumn": 15,
|
||||
"endLine": 5,
|
||||
"endColumn": 18
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This shell command depends on an uncontrolled "
|
||||
},
|
||||
{
|
||||
"t": "location",
|
||||
"text": "absolute path",
|
||||
"location": {
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 6,
|
||||
"startColumn": 36,
|
||||
"endLine": 6,
|
||||
"endColumn": 45
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "t": "text", "text": "." }
|
||||
]
|
||||
},
|
||||
"shortDescription": "This shell command depends on an uncontrolled ,absolute path,.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 4,
|
||||
"endLine": 8,
|
||||
"text": "(function() {\n\tcp.execFileSync('rm', ['-rf', path.join(__dirname, \"temp\")]); // GOOD\n\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 6,
|
||||
"startColumn": 14,
|
||||
"endLine": 6,
|
||||
"endColumn": 54
|
||||
},
|
||||
"codeFlows": [
|
||||
{
|
||||
"threadFlows": [
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 4,
|
||||
"endLine": 8,
|
||||
"text": "(function() {\n\tcp.execFileSync('rm', ['-rf', path.join(__dirname, \"temp\")]); // GOOD\n\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 6,
|
||||
"startColumn": 36,
|
||||
"endLine": 6,
|
||||
"endColumn": 45
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 4,
|
||||
"endLine": 8,
|
||||
"text": "(function() {\n\tcp.execFileSync('rm', ['-rf', path.join(__dirname, \"temp\")]); // GOOD\n\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 6,
|
||||
"startColumn": 26,
|
||||
"endLine": 6,
|
||||
"endColumn": 54
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 4,
|
||||
"endLine": 8,
|
||||
"text": "(function() {\n\tcp.execFileSync('rm', ['-rf', path.join(__dirname, \"temp\")]); // GOOD\n\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 6,
|
||||
"startColumn": 14,
|
||||
"endLine": 6,
|
||||
"endColumn": 54
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This shell command depends on an uncontrolled "
|
||||
},
|
||||
{
|
||||
"t": "location",
|
||||
"text": "absolute path",
|
||||
"location": {
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 8,
|
||||
"startColumn": 36,
|
||||
"endLine": 8,
|
||||
"endColumn": 45
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "t": "text", "text": "." }
|
||||
]
|
||||
},
|
||||
"shortDescription": "This shell command depends on an uncontrolled ,absolute path,.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 6,
|
||||
"endLine": 10,
|
||||
"text": "\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 8,
|
||||
"startColumn": 14,
|
||||
"endLine": 8,
|
||||
"endColumn": 54
|
||||
},
|
||||
"codeFlows": [
|
||||
{
|
||||
"threadFlows": [
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 6,
|
||||
"endLine": 10,
|
||||
"text": "\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 8,
|
||||
"startColumn": 36,
|
||||
"endLine": 8,
|
||||
"endColumn": 45
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 6,
|
||||
"endLine": 10,
|
||||
"text": "\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 8,
|
||||
"startColumn": 26,
|
||||
"endLine": 8,
|
||||
"endColumn": 54
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 6,
|
||||
"endLine": 10,
|
||||
"text": "\tcp.execSync('rm -rf ' + path.join(__dirname, \"temp\")); // BAD\n\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 8,
|
||||
"startColumn": 14,
|
||||
"endLine": 8,
|
||||
"endColumn": 54
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This shell command depends on an uncontrolled "
|
||||
},
|
||||
{
|
||||
"t": "location",
|
||||
"text": "absolute path",
|
||||
"location": {
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 40,
|
||||
"endLine": 9,
|
||||
"endColumn": 49
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "t": "text", "text": "." }
|
||||
]
|
||||
},
|
||||
"shortDescription": "This shell command depends on an uncontrolled ,absolute path,.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 7,
|
||||
"endLine": 11,
|
||||
"text": "\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n\tconst safe = \"\\\"\" + path.join(__dirname, \"temp\") + \"\\\"\";\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 18,
|
||||
"endLine": 9,
|
||||
"endColumn": 58
|
||||
},
|
||||
"codeFlows": [
|
||||
{
|
||||
"threadFlows": [
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 7,
|
||||
"endLine": 11,
|
||||
"text": "\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n\tconst safe = \"\\\"\" + path.join(__dirname, \"temp\") + \"\\\"\";\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 40,
|
||||
"endLine": 9,
|
||||
"endColumn": 49
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 7,
|
||||
"endLine": 11,
|
||||
"text": "\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n\tconst safe = \"\\\"\" + path.join(__dirname, \"temp\") + \"\\\"\";\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 30,
|
||||
"endLine": 9,
|
||||
"endColumn": 58
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b",
|
||||
"filePath": "javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 7,
|
||||
"endLine": 11,
|
||||
"text": "\n\texeca.shell('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\texeca.shellSync('rm -rf ' + path.join(__dirname, \"temp\")); // NOT OK\n\n\tconst safe = \"\\\"\" + path.join(__dirname, \"temp\") + \"\\\"\";\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 18,
|
||||
"endLine": 9,
|
||||
"endColumn": 58
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"repository": {
|
||||
"id": 23578923,
|
||||
"fullName": "test/no-results",
|
||||
"private": false,
|
||||
"stargazersCount": 7289,
|
||||
"updatedAt": "2023-01-01T00:00:00Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 0,
|
||||
"artifactSizeInBytes": 100,
|
||||
"interpretedResults": []
|
||||
},
|
||||
{
|
||||
"repository": {
|
||||
"id": 3214406,
|
||||
"fullName": "meteor/meteor",
|
||||
"private": false,
|
||||
"stargazersCount": 43274,
|
||||
"updatedAt": "2023-02-14T21:06:55Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 1,
|
||||
"artifactSizeInBytes": 2378,
|
||||
"interpretedResults": [
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This shell command depends on an uncontrolled "
|
||||
},
|
||||
{
|
||||
"t": "location",
|
||||
"text": "absolute path",
|
||||
"location": {
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/config.js"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 39,
|
||||
"startColumn": 20,
|
||||
"endLine": 39,
|
||||
"endColumn": 61
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "t": "text", "text": "." }
|
||||
]
|
||||
},
|
||||
"shortDescription": "This shell command depends on an uncontrolled ,absolute path,.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 28,
|
||||
"endLine": 259,
|
||||
"endColumn": 62
|
||||
},
|
||||
"codeFlows": [
|
||||
{
|
||||
"threadFlows": [
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/config.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 37,
|
||||
"endLine": 41,
|
||||
"text": "\nconst meteorLocalFolder = '.meteor';\nconst meteorPath = path.resolve(rootPath, meteorLocalFolder);\n\nmodule.exports = {\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 39,
|
||||
"startColumn": 20,
|
||||
"endLine": 39,
|
||||
"endColumn": 61
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/config.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 37,
|
||||
"endLine": 41,
|
||||
"text": "\nconst meteorLocalFolder = '.meteor';\nconst meteorPath = path.resolve(rootPath, meteorLocalFolder);\n\nmodule.exports = {\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 39,
|
||||
"startColumn": 7,
|
||||
"endLine": 39,
|
||||
"endColumn": 61
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/config.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 42,
|
||||
"endLine": 46,
|
||||
"text": " METEOR_LATEST_VERSION,\n extractPath: rootPath,\n meteorPath,\n release: process.env.INSTALL_METEOR_VERSION || METEOR_LATEST_VERSION,\n rootPath,\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 44,
|
||||
"startColumn": 3,
|
||||
"endLine": 44,
|
||||
"endColumn": 13
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 10,
|
||||
"endLine": 14,
|
||||
"text": "const os = require('os');\nconst {\n meteorPath,\n release,\n startedPath,\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 12,
|
||||
"startColumn": 3,
|
||||
"endLine": 12,
|
||||
"endColumn": 13
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 9,
|
||||
"endLine": 25,
|
||||
"text": "const tmp = require('tmp');\nconst os = require('os');\nconst {\n meteorPath,\n release,\n startedPath,\n extractPath,\n isWindows,\n rootPath,\n sudoUser,\n isSudo,\n isMac,\n METEOR_LATEST_VERSION,\n shouldSetupExecPath,\n} = require('./config.js');\nconst { uninstall } = require('./uninstall');\nconst {\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 11,
|
||||
"startColumn": 7,
|
||||
"endLine": 23,
|
||||
"endColumn": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 42,
|
||||
"endLine": 259,
|
||||
"endColumn": 52
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 42,
|
||||
"endLine": 259,
|
||||
"endColumn": 52
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 42,
|
||||
"endLine": 259,
|
||||
"endColumn": 52
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 42,
|
||||
"endLine": 259,
|
||||
"endColumn": 52
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 42,
|
||||
"endLine": 259,
|
||||
"endColumn": 52
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 28,
|
||||
"endLine": 259,
|
||||
"endColumn": 62
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"threadFlows": [
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/config.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 37,
|
||||
"endLine": 41,
|
||||
"text": "\nconst meteorLocalFolder = '.meteor';\nconst meteorPath = path.resolve(rootPath, meteorLocalFolder);\n\nmodule.exports = {\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 39,
|
||||
"startColumn": 20,
|
||||
"endLine": 39,
|
||||
"endColumn": 61
|
||||
}
|
||||
},
|
||||
{
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec",
|
||||
"filePath": "npm-packages/meteor-installer/install.js"
|
||||
},
|
||||
"codeSnippet": {
|
||||
"startLine": 257,
|
||||
"endLine": 261,
|
||||
"text": " if (isWindows()) {\n //set for the current session and beyond\n child_process.execSync(`setx path \"${meteorPath}/;%path%`);\n return;\n }\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 259,
|
||||
"startColumn": 28,
|
||||
"endLine": 259,
|
||||
"endColumn": 62
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,49 @@
|
||||
### Results for "Shell command built from environment values"
|
||||
|
||||
<details>
|
||||
<summary>Query</summary>
|
||||
|
||||
```ql
|
||||
/**
|
||||
* @name Shell command built from environment values
|
||||
* @description Building a shell command string with values from the enclosing
|
||||
* environment may cause subtle bugs or vulnerabilities.
|
||||
* @kind path-problem
|
||||
* @problem.severity warning
|
||||
* @security-severity 6.3
|
||||
* @precision high
|
||||
* @id js/shell-command-injection-from-environment
|
||||
* @tags correctness
|
||||
* security
|
||||
* external/cwe/cwe-078
|
||||
* external/cwe/cwe-088
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import DataFlow::PathGraph
|
||||
import semmle.javascript.security.dataflow.ShellCommandInjectionFromEnvironmentQuery
|
||||
|
||||
from
|
||||
Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, DataFlow::Node highlight,
|
||||
Source sourceNode
|
||||
where
|
||||
sourceNode = source.getNode() and
|
||||
cfg.hasFlowPath(source, sink) and
|
||||
if cfg.isSinkWithHighlight(sink.getNode(), _)
|
||||
then cfg.isSinkWithHighlight(sink.getNode(), highlight)
|
||||
else highlight = sink.getNode()
|
||||
select highlight, source, sink, "This shell command depends on an uncontrolled $@.", sourceNode,
|
||||
sourceNode.getSourceType()
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br />
|
||||
|
||||
### Summary
|
||||
|
||||
| Repository | Results |
|
||||
| --- | --- |
|
||||
| github/codeql | [4 result(s)](#file-result-1-github-codeql-md) |
|
||||
| meteor/meteor | [1 result(s)](#file-result-2-meteor-meteor-md) |
|
||||
@@ -0,0 +1,195 @@
|
||||
### github/codeql
|
||||
|
||||
[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() {
|
||||
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).*
|
||||
|
||||
#### Paths
|
||||
|
||||
<details>
|
||||
<summary>Path with 5 steps</summary>
|
||||
|
||||
1. [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#L4-L4)
|
||||
<pre><code class="javascript"> path = require("path");
|
||||
function cleanupTemp() {
|
||||
let cmd = "rm -rf " + path.join(<strong>__dirname</strong>, "temp");
|
||||
cp.execSync(cmd); // BAD
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
2. [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#L4-L4)
|
||||
<pre><code class="javascript"> path = require("path");
|
||||
function cleanupTemp() {
|
||||
let cmd = "rm -rf " + <strong>path.join(__dirname, "temp")</strong>;
|
||||
cp.execSync(cmd); // BAD
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
3. [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#L4-L4)
|
||||
<pre><code class="javascript"> path = require("path");
|
||||
function cleanupTemp() {
|
||||
let cmd = <strong>"rm -rf " + path.join(__dirname, "temp")</strong>;
|
||||
cp.execSync(cmd); // BAD
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
4. [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#L4-L4)
|
||||
<pre><code class="javascript"> path = require("path");
|
||||
function cleanupTemp() {
|
||||
let <strong>cmd = "rm -rf " + path.join(__dirname, "temp")</strong>;
|
||||
cp.execSync(cmd); // BAD
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
5. [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() {
|
||||
let cmd = "rm -rf " + path.join(__dirname, "temp");
|
||||
cp.execSync(<strong>cmd</strong>); // BAD
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[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() {
|
||||
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).*
|
||||
|
||||
#### Paths
|
||||
|
||||
<details>
|
||||
<summary>Path with 3 steps</summary>
|
||||
|
||||
1. [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() {
|
||||
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
|
||||
cp.execSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // BAD
|
||||
|
||||
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
</code></pre>
|
||||
|
||||
2. [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() {
|
||||
cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD
|
||||
cp.execSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // BAD
|
||||
|
||||
execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
</code></pre>
|
||||
|
||||
3. [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() {
|
||||
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>
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[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
|
||||
|
||||
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).*
|
||||
|
||||
#### Paths
|
||||
|
||||
<details>
|
||||
<summary>Path with 3 steps</summary>
|
||||
|
||||
1. [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
|
||||
|
||||
execa.shell('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK
|
||||
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
|
||||
</code></pre>
|
||||
|
||||
2. [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
|
||||
|
||||
execa.shell('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK
|
||||
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
|
||||
</code></pre>
|
||||
|
||||
3. [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
|
||||
|
||||
execa.shell(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK
|
||||
execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK
|
||||
|
||||
</code></pre>
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[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).*
|
||||
|
||||
#### Paths
|
||||
|
||||
<details>
|
||||
<summary>Path with 3 steps</summary>
|
||||
|
||||
1. [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('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK
|
||||
|
||||
const safe = "\"" + path.join(__dirname, "temp") + "\"";
|
||||
</code></pre>
|
||||
|
||||
2. [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('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK
|
||||
|
||||
const safe = "\"" + path.join(__dirname, "temp") + "\"";
|
||||
</code></pre>
|
||||
|
||||
3. [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>
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
----------------------------------------
|
||||
@@ -0,0 +1,144 @@
|
||||
### meteor/meteor
|
||||
|
||||
[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()) {
|
||||
//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).*
|
||||
|
||||
#### Paths
|
||||
|
||||
<details>
|
||||
<summary>Path with 11 steps</summary>
|
||||
|
||||
1. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39)
|
||||
<pre><code class="javascript">
|
||||
const meteorLocalFolder = '.meteor';
|
||||
const meteorPath = <strong>path.resolve(rootPath, meteorLocalFolder)</strong>;
|
||||
|
||||
module.exports = {
|
||||
</code></pre>
|
||||
|
||||
2. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39)
|
||||
<pre><code class="javascript">
|
||||
const meteorLocalFolder = '.meteor';
|
||||
const <strong>meteorPath = path.resolve(rootPath, meteorLocalFolder)</strong>;
|
||||
|
||||
module.exports = {
|
||||
</code></pre>
|
||||
|
||||
3. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L44-L44)
|
||||
<pre><code class="javascript"> METEOR_LATEST_VERSION,
|
||||
extractPath: rootPath,
|
||||
<strong>meteorPath</strong>,
|
||||
release: process.env.INSTALL_METEOR_VERSION || METEOR_LATEST_VERSION,
|
||||
rootPath,
|
||||
</code></pre>
|
||||
|
||||
4. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L12-L12)
|
||||
<pre><code class="javascript">const os = require('os');
|
||||
const {
|
||||
<strong>meteorPath</strong>,
|
||||
release,
|
||||
startedPath,
|
||||
</code></pre>
|
||||
|
||||
5. [npm-packages/meteor-installer/install.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/install.js#L11-L23)
|
||||
<pre><code class="javascript">const tmp = require('tmp');
|
||||
const os = require('os');
|
||||
const <strong>{</strong>
|
||||
<strong> meteorPath,</strong>
|
||||
<strong> release,</strong>
|
||||
<strong> startedPath,</strong>
|
||||
<strong> extractPath,</strong>
|
||||
<strong> isWindows,</strong>
|
||||
<strong> rootPath,</strong>
|
||||
<strong> sudoUser,</strong>
|
||||
<strong> isSudo,</strong>
|
||||
<strong> isMac,</strong>
|
||||
<strong> METEOR_LATEST_VERSION,</strong>
|
||||
<strong> shouldSetupExecPath,</strong>
|
||||
<strong>} = require('./config.js')</strong>;
|
||||
const { uninstall } = require('./uninstall');
|
||||
const {
|
||||
</code></pre>
|
||||
|
||||
6. [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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
7. [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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
8. [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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
9. [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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
10. [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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(`setx path "${<strong>meteorPath</strong>}/;%path%`);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(<strong>`setx path "${meteorPath}/;%path%`</strong>);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Path with 2 steps</summary>
|
||||
|
||||
1. [npm-packages/meteor-installer/config.js](https://github.com/meteor/meteor/blob/73b538fe201cbfe89dd0c709689023f9b3eab1ec/npm-packages/meteor-installer/config.js#L39-L39)
|
||||
<pre><code class="javascript">
|
||||
const meteorLocalFolder = '.meteor';
|
||||
const meteorPath = <strong>path.resolve(rootPath, meteorLocalFolder)</strong>;
|
||||
|
||||
module.exports = {
|
||||
</code></pre>
|
||||
|
||||
2. [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()) {
|
||||
//set for the current session and beyond
|
||||
child_process.execSync(<strong>`setx path "${meteorPath}/;%path%`</strong>);
|
||||
return;
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
</details>
|
||||
|
||||
----------------------------------------
|
||||
@@ -0,0 +1,198 @@
|
||||
[
|
||||
{
|
||||
"repository": {
|
||||
"id": 143040428,
|
||||
"fullName": "github/codeql",
|
||||
"private": false,
|
||||
"stargazersCount": 5703,
|
||||
"updatedAt": "2023-02-15T10:11:45Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 1,
|
||||
"artifactSizeInBytes": 1038,
|
||||
"interpretedResults": [
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'aa'."
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortDescription": "This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'aa'.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/d094bbc06d063d0da8d0303676943c345e61de53",
|
||||
"filePath": "javascript/extractor/tests/regexp/input/multipart.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 15,
|
||||
"endLine": 22,
|
||||
"text": "\nvar bad95 = new RegExp(\n \"(a\" + \n \"|\" + \n \"aa)*\" + \n \"b$\"\n);\n\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 17,
|
||||
"startColumn": 6,
|
||||
"endLine": 20,
|
||||
"endColumn": 6
|
||||
},
|
||||
"codeFlows": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"repository": {
|
||||
"id": 3214406,
|
||||
"fullName": "meteor/meteor",
|
||||
"private": false,
|
||||
"stargazersCount": 43274,
|
||||
"updatedAt": "2023-02-14T21:06:55Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 5,
|
||||
"artifactSizeInBytes": 3478,
|
||||
"interpretedResults": [
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '----'."
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortDescription": "This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '----'.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12",
|
||||
"filePath": "packages/deprecated/markdown/showdown.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 413,
|
||||
"endLine": 417,
|
||||
"text": "\t\t/g,hashElement);\n\t*/\n\ttext = text.replace(/(\\n\\n[ ]{0,3}<!(--[^\\r]*?--\\s*)+>[ \\t]*(?=\\n{2,}))/g,hashElement);\n\n\t// PHP and ASP-style processor instructions (<?...?> and <%...%>)\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 415,
|
||||
"startColumn": 41,
|
||||
"endLine": 415,
|
||||
"endColumn": 48
|
||||
},
|
||||
"codeFlows": []
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This part of the regular expression may cause exponential backtracking on strings starting with '<!--' and containing many repetitions of '----'."
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortDescription": "This part of the regular expression may cause exponential backtracking on strings starting with '<!--' and containing many repetitions of '----'.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12",
|
||||
"filePath": "packages/deprecated/markdown/showdown.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 521,
|
||||
"endLine": 525,
|
||||
"text": "\t// Build a regex to find HTML tags and comments. See Friedl's\n\t// \"Mastering Regular Expressions\", 2nd Ed., pp. 200-201.\n\tvar regex = /(<[a-z\\/!$](\"[^\"]*\"|'[^']*'|[^'\">])*>|<!(--.*?--\\s*)+>)/gi;\n\n\ttext = text.replace(regex, function(wholeMatch) {\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 523,
|
||||
"startColumn": 58,
|
||||
"endLine": 523,
|
||||
"endColumn": 61
|
||||
},
|
||||
"codeFlows": []
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This part of the regular expression may cause exponential backtracking on strings starting with ''' and containing many repetitions of '\\&'."
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortDescription": "This part of the regular expression may cause exponential backtracking on strings starting with ''' and containing many repetitions of '\\&'.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12",
|
||||
"filePath": "tools/tests/apps/modules/imports/links/acorn/src/parseutil.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 7,
|
||||
"endLine": 11,
|
||||
"text": "// ## Parser utilities\n\nconst literal = /^(?:'((?:\\\\.|[^'])*?)'|\"((?:\\\\.|[^\"])*?)\")/\npp.strictDirective = function(start) {\n for (;;) {\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 24,
|
||||
"endLine": 9,
|
||||
"endColumn": 38
|
||||
},
|
||||
"codeFlows": []
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This part of the regular expression may cause exponential backtracking on strings starting with '\"' and containing many repetitions of '\\!'."
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortDescription": "This part of the regular expression may cause exponential backtracking on strings starting with '\"' and containing many repetitions of '\\!'.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12",
|
||||
"filePath": "tools/tests/apps/modules/imports/links/acorn/src/parseutil.js"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 9,
|
||||
"endLine": 9,
|
||||
"text": "const literal = /^(?:'((?:\\\\.|[^'])*?)'|\"((?:\\\\.|[^\"])*?)\")/"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 9,
|
||||
"startColumn": 43,
|
||||
"endLine": 9,
|
||||
"endColumn": 57
|
||||
},
|
||||
"codeFlows": []
|
||||
},
|
||||
{
|
||||
"message": {
|
||||
"tokens": [
|
||||
{
|
||||
"t": "text",
|
||||
"text": "This component is implicitly exported."
|
||||
}
|
||||
]
|
||||
},
|
||||
"shortDescription": "This component is implicitly exported.",
|
||||
"fileLink": {
|
||||
"fileLinkPrefix": "https://github.com/AlexRogalskiy/android-nrf-toolbox/blob/034cf3aa7d2a3a4145177de32546ca518a462a66",
|
||||
"filePath": "app/src/main/AndroidManifest.xml"
|
||||
},
|
||||
"severity": "Warning",
|
||||
"codeSnippet": {
|
||||
"startLine": 237,
|
||||
"endLine": 251,
|
||||
"text": "\t\t</service>\n\n\t\t<activity\n\t\t\tandroid:name=\"no.nordicsemi.android.nrftoolbox.dfu.DfuInitiatorActivity\"\n\t\t\tandroid:label=\"@string/dfu_service_title\"\n\t\t\tandroid:noHistory=\"true\"\n\t\t\tandroid:theme=\"@style/AppTheme.Translucent\" >\n\t\t\t<intent-filter>\n\t\t\t\t<action android:name=\"no.nordicsemi.android.action.DFU_UPLOAD\" />\n\n\t\t\t\t<category android:name=\"android.intent.category.DEFAULT\" />\n\t\t\t</intent-filter>\n\t\t</activity>\n\n\t\t<service\n"
|
||||
},
|
||||
"highlightedRegion": {
|
||||
"startLine": 239,
|
||||
"startColumn": 3,
|
||||
"endLine": 249,
|
||||
"endColumn": 15
|
||||
},
|
||||
"codeFlows": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,44 @@
|
||||
### Results for "Inefficient regular expression"
|
||||
|
||||
<details>
|
||||
<summary>Query</summary>
|
||||
|
||||
```ql
|
||||
/**
|
||||
* @name Inefficient regular expression
|
||||
* @description A regular expression that requires exponential time to match certain inputs
|
||||
* can be a performance bottleneck, and may be vulnerable to denial-of-service
|
||||
* attacks.
|
||||
* @kind problem
|
||||
* @problem.severity error
|
||||
* @security-severity 7.5
|
||||
* @precision high
|
||||
* @id js/redos
|
||||
* @tags security
|
||||
* external/cwe/cwe-1333
|
||||
* external/cwe/cwe-730
|
||||
* external/cwe/cwe-400
|
||||
*/
|
||||
|
||||
import javascript
|
||||
import semmle.javascript.security.performance.ReDoSUtil
|
||||
import semmle.javascript.security.performance.ExponentialBackTracking
|
||||
|
||||
from RegExpTerm t, string pump, State s, string prefixMsg
|
||||
where hasReDoSResult(t, pump, s, prefixMsg)
|
||||
select t,
|
||||
"This part of the regular expression may cause exponential backtracking on strings " + prefixMsg +
|
||||
"containing many repetitions of '" + pump + "'."
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br />
|
||||
|
||||
### Summary
|
||||
|
||||
| Repository | Results |
|
||||
| --- | --- |
|
||||
| github/codeql | [1 result(s)](#file-result-1-github-codeql-md) |
|
||||
| meteor/meteor | [5 result(s)](#file-result-2-meteor-meteor-md) |
|
||||
@@ -0,0 +1,17 @@
|
||||
### github/codeql
|
||||
|
||||
[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>
|
||||
<strong> "aa)*" + </strong>
|
||||
<strong> "</strong>b$"
|
||||
);
|
||||
|
||||
</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'aa'.*
|
||||
|
||||
----------------------------------------
|
||||
@@ -0,0 +1,71 @@
|
||||
### meteor/meteor
|
||||
|
||||
[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);
|
||||
*/
|
||||
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 '----'.*
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[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
|
||||
// "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 '----'.*
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[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
|
||||
|
||||
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 '\&'.*
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[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">const literal = /^(?:'((?:\\.|[^'])*?)'|"(<strong>(?:\\.|[^"])*?</strong>)")/</code></pre>
|
||||
|
||||
*This part of the regular expression may cause exponential backtracking on strings starting with '"' and containing many repetitions of '\!'.*
|
||||
|
||||
----------------------------------------
|
||||
|
||||
[app/src/main/AndroidManifest.xml](https://github.com/AlexRogalskiy/android-nrf-toolbox/blob/034cf3aa7d2a3a4145177de32546ca518a462a66/app/src/main/AndroidManifest.xml#L239-L249)
|
||||
|
||||
<pre><code class="javascript"> </service>
|
||||
|
||||
<strong><activity</strong>
|
||||
<strong> android:name="no.nordicsemi.android.nrftoolbox.dfu.DfuInitiatorActivity"</strong>
|
||||
<strong> android:label="@string/dfu_service_title"</strong>
|
||||
<strong> android:noHistory="true"</strong>
|
||||
<strong> android:theme="@style/AppTheme.Translucent" ></strong>
|
||||
<strong> <intent-filter></strong>
|
||||
<strong> <action android:name="no.nordicsemi.android.action.DFU_UPLOAD" /></strong>
|
||||
<strong></strong>
|
||||
<strong> <category android:name="android.intent.category.DEFAULT" /></strong>
|
||||
<strong> </intent-filter></strong>
|
||||
<strong> </activity></strong>
|
||||
|
||||
<service
|
||||
</code></pre>
|
||||
|
||||
*This component is implicitly exported.*
|
||||
|
||||
----------------------------------------
|
||||
@@ -0,0 +1,409 @@
|
||||
[
|
||||
{
|
||||
"repository": {
|
||||
"id": 143040428,
|
||||
"fullName": "github/codeql",
|
||||
"private": false,
|
||||
"stargazersCount": 5703,
|
||||
"updatedAt": "2023-02-15T10:11:45Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 22,
|
||||
"artifactSizeInBytes": 3567,
|
||||
"interpretedResults": [],
|
||||
"rawResults": {
|
||||
"schema": {
|
||||
"name": "#select",
|
||||
"rows": 22,
|
||||
"columns": [
|
||||
{
|
||||
"name": "c",
|
||||
"kind": "e"
|
||||
},
|
||||
{
|
||||
"kind": "i"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resultSet": {
|
||||
"schema": {
|
||||
"name": "#select",
|
||||
"rows": 22,
|
||||
"columns": [
|
||||
{
|
||||
"name": "c",
|
||||
"kind": "e"
|
||||
},
|
||||
{
|
||||
"kind": "i"
|
||||
}
|
||||
]
|
||||
},
|
||||
"rows": [
|
||||
[
|
||||
{
|
||||
"label": "functio ... ght);\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/src/Expressions/examples/CompareIdenticalValues.js",
|
||||
"startLine": 8,
|
||||
"startColumn": 32,
|
||||
"endLine": 13,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
6
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... i-1);\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/src/LanguageFeatures/examples/ArgumentsCallerCallee.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 2,
|
||||
"endLine": 5,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
5
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... i-1);\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/src/LanguageFeatures/examples/ArgumentsCallerCalleeGood.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 2,
|
||||
"endLine": 5,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
5
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... n -1;\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/src/Statements/examples/UselessComparisonTest.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 12,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
12
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... false\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/constants.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 8,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
8
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... \\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/loop.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 12,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
12
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... e\\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/loop.js",
|
||||
"startLine": 14,
|
||||
"startColumn": 1,
|
||||
"endLine": 22,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
9
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... K\\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/loop.js",
|
||||
"startLine": 24,
|
||||
"startColumn": 1,
|
||||
"endLine": 40,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
17
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... e\\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/plus.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 17,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
17
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... alse \\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/plus.js",
|
||||
"startLine": 19,
|
||||
"startColumn": 1,
|
||||
"endLine": 28,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
10
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... true\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/plus.js",
|
||||
"startLine": 30,
|
||||
"startColumn": 1,
|
||||
"endLine": 33,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
4
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... K\\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/tst.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 15,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
15
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... e\\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/tst.js",
|
||||
"startLine": 17,
|
||||
"startColumn": 1,
|
||||
"endLine": 31,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
15
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... false\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/tst.js",
|
||||
"startLine": 33,
|
||||
"startColumn": 1,
|
||||
"endLine": 41,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
9
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... e\\n }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/library-tests/RangeAnalysis/tst.js",
|
||||
"startLine": 43,
|
||||
"startColumn": 1,
|
||||
"endLine": 52,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
10
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... ght);\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/Expressions/CompareIdenticalValues/tst.js",
|
||||
"startLine": 8,
|
||||
"startColumn": 32,
|
||||
"endLine": 13,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
6
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... i-1);\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/tst.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 2,
|
||||
"endLine": 5,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
5
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... }\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/Security/CWE-834/LoopBoundInjectionExitBad.js",
|
||||
"startLine": 17,
|
||||
"startColumn": 1,
|
||||
"endLine": 29,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
13
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... true\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/Statements/UselessComparisonTest/constant.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 4,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
4
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... n -1;\\n}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/Statements/UselessComparisonTest/example.js",
|
||||
"startLine": 1,
|
||||
"startColumn": 1,
|
||||
"endLine": 12,
|
||||
"endColumn": 1
|
||||
}
|
||||
},
|
||||
12
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... turn; }",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js",
|
||||
"startLine": 8,
|
||||
"startColumn": 3,
|
||||
"endLine": 8,
|
||||
"endColumn": 43
|
||||
}
|
||||
},
|
||||
1
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "| functio ... i+1); |}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js",
|
||||
"startLine": 9,
|
||||
"startColumn": 3,
|
||||
"endLine": 9,
|
||||
"endColumn": 52
|
||||
}
|
||||
},
|
||||
1
|
||||
]
|
||||
]
|
||||
},
|
||||
"fileLinkPrefix": "https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b",
|
||||
"capped": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"repository": {
|
||||
"id": 3214406,
|
||||
"fullName": "meteor/meteor",
|
||||
"private": false,
|
||||
"stargazersCount": 43274,
|
||||
"updatedAt": "2023-02-14T21:06:55Z"
|
||||
},
|
||||
"analysisStatus": "succeeded",
|
||||
"resultCount": 2,
|
||||
"artifactSizeInBytes": 1133,
|
||||
"interpretedResults": [],
|
||||
"rawResults": {
|
||||
"schema": {
|
||||
"name": "#select",
|
||||
"rows": 2,
|
||||
"columns": [
|
||||
{
|
||||
"name": "c",
|
||||
"kind": "e"
|
||||
},
|
||||
{
|
||||
"kind": "i"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resultSet": {
|
||||
"schema": {
|
||||
"name": "#select",
|
||||
"rows": 2,
|
||||
"columns": [
|
||||
{
|
||||
"name": "c",
|
||||
"kind": "e"
|
||||
},
|
||||
{
|
||||
"kind": "i"
|
||||
}
|
||||
]
|
||||
},
|
||||
"rows": [
|
||||
[
|
||||
{
|
||||
"label": "functio ... rn H|0}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/packages/logic-solver/minisat.js",
|
||||
"startLine": 7,
|
||||
"startColumn": 91430,
|
||||
"endLine": 7,
|
||||
"endColumn": 105027
|
||||
}
|
||||
},
|
||||
1
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "functio ... ext;\\n\\t}",
|
||||
"url": {
|
||||
"uri": "file:/home/runner/work/bulk-builder/bulk-builder/packages/sha/sha256.js",
|
||||
"startLine": 94,
|
||||
"startColumn": 2,
|
||||
"endLine": 124,
|
||||
"endColumn": 2
|
||||
}
|
||||
},
|
||||
31
|
||||
]
|
||||
]
|
||||
},
|
||||
"fileLinkPrefix": "https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12",
|
||||
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
|
||||
"capped": false
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,41 @@
|
||||
### Results for "Contradictory guard nodes"
|
||||
|
||||
<details>
|
||||
<summary>Query</summary>
|
||||
|
||||
```ql
|
||||
/**
|
||||
* @name Contradictory guard nodes
|
||||
*
|
||||
* @description Snippet from "UselessComparisonTest.ql"
|
||||
*/
|
||||
|
||||
import javascript
|
||||
|
||||
/**
|
||||
* Holds if there are any contradictory guard nodes in `container`.
|
||||
*
|
||||
* We use this to restrict reachability analysis to a small set of containers.
|
||||
*/
|
||||
predicate hasContradictoryGuardNodes(StmtContainer container) {
|
||||
exists(ConditionGuardNode guard |
|
||||
RangeAnalysis::isContradictoryGuardNode(guard) and
|
||||
container = guard.getContainer()
|
||||
)
|
||||
}
|
||||
|
||||
from StmtContainer c
|
||||
where hasContradictoryGuardNodes(c)
|
||||
select c, c.getNumLines()
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br />
|
||||
|
||||
### Summary
|
||||
|
||||
| Repository | Results |
|
||||
| --- | --- |
|
||||
| github/codeql | [22 result(s)](#file-result-1-github-codeql-md) |
|
||||
| meteor/meteor | [2 result(s)](#file-result-2-meteor-meteor-md) |
|
||||
@@ -0,0 +1,26 @@
|
||||
### github/codeql
|
||||
|
||||
| c | |
|
||||
| --- | --- |
|
||||
| [`functio ... ght);\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/src/Expressions/examples/CompareIdenticalValues.js#L8-L13) | `6` |
|
||||
| [`functio ... i-1);\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/src/LanguageFeatures/examples/ArgumentsCallerCallee.js#L1-L5) | `5` |
|
||||
| [`functio ... i-1);\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/src/LanguageFeatures/examples/ArgumentsCallerCalleeGood.js#L1-L5) | `5` |
|
||||
| [`functio ... n -1;\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/src/Statements/examples/UselessComparisonTest.js#L1-L12) | `12` |
|
||||
| [`functio ... false\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/constants.js#L1-L8) | `8` |
|
||||
| [`functio ... \n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/loop.js#L1-L12) | `12` |
|
||||
| [`functio ... e\n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/loop.js#L14-L22) | `9` |
|
||||
| [`functio ... K\n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/loop.js#L24-L40) | `17` |
|
||||
| [`functio ... e\n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/plus.js#L1-L17) | `17` |
|
||||
| [`functio ... alse \n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/plus.js#L19-L28) | `10` |
|
||||
| [`functio ... true\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/plus.js#L30-L33) | `4` |
|
||||
| [`functio ... K\n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/tst.js#L1-L15) | `15` |
|
||||
| [`functio ... e\n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/tst.js#L17-L31) | `15` |
|
||||
| [`functio ... false\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/tst.js#L33-L41) | `9` |
|
||||
| [`functio ... e\n }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/library-tests/RangeAnalysis/tst.js#L43-L52) | `10` |
|
||||
| [`functio ... ght);\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Expressions/CompareIdenticalValues/tst.js#L8-L13) | `6` |
|
||||
| [`functio ... i-1);\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/LanguageFeatures/ArgumentsCallerCallee/tst.js#L1-L5) | `5` |
|
||||
| [`functio ... }\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Security/CWE-834/LoopBoundInjectionExitBad.js#L17-L29) | `13` |
|
||||
| [`functio ... true\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/constant.js#L1-L4) | `4` |
|
||||
| [`functio ... n -1;\n}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/example.js#L1-L12) | `12` |
|
||||
| [`functio ... turn; }`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js#L8-L8) | `1` |
|
||||
| [`\| functio ... i+1); \|}`](https://github.com/github/codeql/blob/cbdd4927cee593b715d8469240ce1d31edaaef9b/javascript/ql/test/query-tests/Statements/UselessComparisonTest/tst.js#L9-L9) | `1` |
|
||||
@@ -0,0 +1,6 @@
|
||||
### meteor/meteor
|
||||
|
||||
| c | |
|
||||
| --- | --- |
|
||||
| [`functio ... rn H\|0}`](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/logic-solver/minisat.js#L7-L7) | `1` |
|
||||
| [`functio ... ext;\n\t}`](https://github.com/meteor/meteor/blob/53f3c4442d3542d3d2a012a854472a0d1bef9d12/packages/sha/sha256.js#L94-L124) | `31` |
|
||||
@@ -0,0 +1,157 @@
|
||||
import { join, resolve } from "path";
|
||||
import { readdir, readFile } from "fs-extra";
|
||||
|
||||
import {
|
||||
generateVariantAnalysisMarkdown,
|
||||
MarkdownFile,
|
||||
} from "../../../src/remote-queries/markdown-generation";
|
||||
import {
|
||||
VariantAnalysisQueryLanguage,
|
||||
VariantAnalysisRepoStatus,
|
||||
VariantAnalysisScannedRepository,
|
||||
VariantAnalysisScannedRepositoryResult,
|
||||
} from "../../../src/remote-queries/shared/variant-analysis";
|
||||
import {
|
||||
AnalysisAlert,
|
||||
AnalysisRawResults,
|
||||
} from "../../../src/remote-queries/shared/analysis-result";
|
||||
|
||||
import pathProblemAnalysesResults from "../data/markdown-generation/interpreted-results/path-problem/analyses-results.json";
|
||||
import problemAnalysesResults from "../data/markdown-generation/interpreted-results/problem/analyses-results.json";
|
||||
import rawResultsAnalysesResults from "../data/markdown-generation/raw-results/analyses-results.json";
|
||||
|
||||
const dataPath = resolve(__dirname, "../data/markdown-generation");
|
||||
|
||||
describe(generateVariantAnalysisMarkdown.name, () => {
|
||||
describe("for path-problem query", () => {
|
||||
it("should generate markdown file for each repo with results", async () => {
|
||||
const actualFiles = await generateVariantAnalysisMarkdown(
|
||||
{
|
||||
query: {
|
||||
name: "Shell command built from environment values",
|
||||
filePath:
|
||||
"c:\\git-repo\\vscode-codeql-starter\\ql\\javascript\\ql\\src\\Security\\CWE-078\\ShellCommandInjectionFromEnvironment.ql",
|
||||
text: '/**\n * @name Shell command built from environment values\n * @description Building a shell command string with values from the enclosing\n * environment may cause subtle bugs or vulnerabilities.\n * @kind path-problem\n * @problem.severity warning\n * @security-severity 6.3\n * @precision high\n * @id js/shell-command-injection-from-environment\n * @tags correctness\n * security\n * external/cwe/cwe-078\n * external/cwe/cwe-088\n */\n\nimport javascript\nimport DataFlow::PathGraph\nimport semmle.javascript.security.dataflow.ShellCommandInjectionFromEnvironmentQuery\n\nfrom\n Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, DataFlow::Node highlight,\n Source sourceNode\nwhere\n sourceNode = source.getNode() and\n cfg.hasFlowPath(source, sink) and\n if cfg.isSinkWithHighlight(sink.getNode(), _)\n then cfg.isSinkWithHighlight(sink.getNode(), highlight)\n else highlight = sink.getNode()\nselect highlight, source, sink, "This shell command depends on an uncontrolled $@.", sourceNode,\n sourceNode.getSourceType()\n',
|
||||
language: VariantAnalysisQueryLanguage.Javascript,
|
||||
},
|
||||
},
|
||||
getResults(pathProblemAnalysesResults),
|
||||
pathProblemAnalysesResults.length,
|
||||
"gist",
|
||||
);
|
||||
|
||||
await checkGeneratedMarkdown(
|
||||
actualFiles.markdownFiles,
|
||||
"interpreted-results/path-problem/expected",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("for problem query", () => {
|
||||
it("should generate markdown file for each repo with results", async () => {
|
||||
const actualFiles = await generateVariantAnalysisMarkdown(
|
||||
{
|
||||
query: {
|
||||
name: "Inefficient regular expression",
|
||||
filePath:
|
||||
"c:\\git-repo\\vscode-codeql-starter\\ql\\javascript\\ql\\src\\Performance\\ReDoS.ql",
|
||||
text: '/**\n * @name Inefficient regular expression\n * @description A regular expression that requires exponential time to match certain inputs\n * can be a performance bottleneck, and may be vulnerable to denial-of-service\n * attacks.\n * @kind problem\n * @problem.severity error\n * @security-severity 7.5\n * @precision high\n * @id js/redos\n * @tags security\n * external/cwe/cwe-1333\n * external/cwe/cwe-730\n * external/cwe/cwe-400\n */\n\nimport javascript\nimport semmle.javascript.security.performance.ReDoSUtil\nimport semmle.javascript.security.performance.ExponentialBackTracking\n\nfrom RegExpTerm t, string pump, State s, string prefixMsg\nwhere hasReDoSResult(t, pump, s, prefixMsg)\nselect t,\n "This part of the regular expression may cause exponential backtracking on strings " + prefixMsg +\n "containing many repetitions of \'" + pump + "\'."\n',
|
||||
language: VariantAnalysisQueryLanguage.Javascript,
|
||||
},
|
||||
},
|
||||
getResults(problemAnalysesResults),
|
||||
problemAnalysesResults.length,
|
||||
"gist",
|
||||
);
|
||||
|
||||
await checkGeneratedMarkdown(
|
||||
actualFiles.markdownFiles,
|
||||
"interpreted-results/problem/expected",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("for non-alert query", () => {
|
||||
it("should generate markdown file for each repo with results", async () => {
|
||||
const actualFiles = await generateVariantAnalysisMarkdown(
|
||||
{
|
||||
query: {
|
||||
name: "Contradictory guard nodes",
|
||||
filePath: "c:\\Users\\foo\\bar\\quick-query.ql",
|
||||
text: '/**\n * @name Contradictory guard nodes\n * \n * @description Snippet from "UselessComparisonTest.ql"\n */\n\nimport javascript\n\n/**\n * Holds if there are any contradictory guard nodes in `container`.\n *\n * We use this to restrict reachability analysis to a small set of containers.\n */\npredicate hasContradictoryGuardNodes(StmtContainer container) {\n exists(ConditionGuardNode guard |\n RangeAnalysis::isContradictoryGuardNode(guard) and\n container = guard.getContainer()\n )\n}\n\nfrom StmtContainer c\nwhere hasContradictoryGuardNodes(c)\nselect c, c.getNumLines()',
|
||||
language: VariantAnalysisQueryLanguage.Javascript,
|
||||
},
|
||||
},
|
||||
getResults(rawResultsAnalysesResults),
|
||||
rawResultsAnalysesResults.length,
|
||||
"gist",
|
||||
);
|
||||
|
||||
await checkGeneratedMarkdown(
|
||||
actualFiles.markdownFiles,
|
||||
"raw-results/expected",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function* getResults(
|
||||
items: typeof pathProblemAnalysesResults | typeof rawResultsAnalysesResults,
|
||||
): AsyncIterable<
|
||||
[VariantAnalysisScannedRepository, VariantAnalysisScannedRepositoryResult]
|
||||
> {
|
||||
for (const item of items) {
|
||||
yield [
|
||||
{
|
||||
...item,
|
||||
analysisStatus: item.analysisStatus as VariantAnalysisRepoStatus,
|
||||
},
|
||||
{
|
||||
repositoryId: item.repository.id,
|
||||
variantAnalysisId: 1,
|
||||
interpretedResults: item.interpretedResults as AnalysisAlert[],
|
||||
rawResults:
|
||||
"rawResults" in item
|
||||
? (item.rawResults as AnalysisRawResults)
|
||||
: undefined,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a test output file and returns it as a string.
|
||||
* Replaces line endings with '\n' for consistency across operating systems.
|
||||
*/
|
||||
async function readTestOutputFile(relativePath: string): Promise<string> {
|
||||
const file = await readFile(join(dataPath, relativePath), "utf8");
|
||||
return file.replace(/\r?\n/g, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the generated (actual) markdown files to the expected markdown files and
|
||||
* checks whether the names and contents are the same.
|
||||
*/
|
||||
async function checkGeneratedMarkdown(
|
||||
actualFiles: MarkdownFile[],
|
||||
testDataBasePath: string,
|
||||
) {
|
||||
const expectedDir = join(dataPath, testDataBasePath);
|
||||
const expectedFiles = await readdir(expectedDir);
|
||||
|
||||
expect(actualFiles.length).toBe(expectedFiles.length);
|
||||
|
||||
const actualFileNames = actualFiles.map((file) => `${file.fileName}.md`);
|
||||
|
||||
for (const expectedFile of expectedFiles) {
|
||||
expect(actualFileNames).toContain(expectedFile);
|
||||
const actualFile = actualFiles.find(
|
||||
(f) => `${f.fileName}.md` === expectedFile,
|
||||
);
|
||||
expect(actualFile).toBeDefined();
|
||||
const expectedContent = await readTestOutputFile(
|
||||
join(testDataBasePath, expectedFile),
|
||||
);
|
||||
expect(actualFile!.content.join("\n").trim()).toBe(expectedContent.trim());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { findDuplicateStrings } from "../../src/text-utils";
|
||||
import { findDuplicateStrings } from "../../src/pure/text-utils";
|
||||
|
||||
describe("findDuplicateStrings", () => {
|
||||
it("should find duplicates strings in an array of strings", () => {
|
||||
|
||||
Reference in New Issue
Block a user