Remove tests for remote query history
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @name MRVA Integration test 1
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @id javascript/integration-test-1
|
||||
*/
|
||||
import javascript
|
||||
|
||||
from MemberDeclaration md
|
||||
where md.getName() = "dispose"
|
||||
select md, "Dispose method"
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @name MRVA Integration test 2
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @id javascript/integration-test-2
|
||||
*/
|
||||
import javascript
|
||||
|
||||
from MemberDeclaration md
|
||||
where md.getName() = "refresh"
|
||||
select md, "Refresh method"
|
||||
@@ -1 +0,0 @@
|
||||
other/hucairz
|
||||
@@ -1 +0,0 @@
|
||||
15
|
||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
||||
"md","col1"
|
||||
"dispose ... ();\n }","Dispose method"
|
||||
"readonl ... > void;","Dispose method"
|
||||
"async d ... }\n }","Dispose method"
|
||||
"dispose(): any;","Dispose method"
|
||||
"public ... }\n }","Dispose method"
|
||||
"dispose: () => void;","Dispose method"
|
||||
"dispose ... ');\n }","Dispose method"
|
||||
"dispose ... ();\n }","Dispose method"
|
||||
"public ... ();\n }","Dispose method"
|
||||
"readonl ... > void;","Dispose method"
|
||||
"dispose(): unknown","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
|
@@ -1,19 +0,0 @@
|
||||
## github/vscode-codeql
|
||||
|
||||
| - | Message |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
||||
| [dispose ... ();\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/cli.ts#L211) | Dispose method |
|
||||
| [readonl ... > void;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/extension.ts#L166) | Dispose method |
|
||||
| [async d ... }\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/logging.ts#L151) | Dispose method |
|
||||
| [dispose(): any;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/pure/disposable-object.ts#L5) | Dispose method |
|
||||
| [public ... }\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/pure/disposable-object.ts#L65) | Dispose method |
|
||||
| [dispose: () => void;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/query-results.ts#L54) | Dispose method |
|
||||
| [dispose ... ');\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/queryserver-client.ts#L32) | Dispose method |
|
||||
| [dispose ... ();\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/telemetry.ts#L129) | Dispose method |
|
||||
| [public ... ();\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/test-ui.ts#L54) | Dispose method |
|
||||
| [readonl ... > void;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/run-queries.ts#L327) | Dispose method |
|
||||
| [dispose(): unknown](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/vscode-tests/no-workspace/helpers.test.ts#L150) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L12) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L13) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L14) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L15) | Dispose method |
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
github/vscode-codeql
|
||||
@@ -1 +0,0 @@
|
||||
15
|
||||
Binary file not shown.
@@ -1,16 +0,0 @@
|
||||
"md","col1"
|
||||
"dispose ... ();\n }","Dispose method"
|
||||
"readonl ... > void;","Dispose method"
|
||||
"async d ... }\n }","Dispose method"
|
||||
"dispose(): any;","Dispose method"
|
||||
"public ... }\n }","Dispose method"
|
||||
"dispose: () => void;","Dispose method"
|
||||
"dispose ... ');\n }","Dispose method"
|
||||
"dispose ... ();\n }","Dispose method"
|
||||
"public ... ();\n }","Dispose method"
|
||||
"readonl ... > void;","Dispose method"
|
||||
"dispose(): unknown","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
"dispose ... inonSpy","Dispose method"
|
||||
|
@@ -1,19 +0,0 @@
|
||||
## github/vscode-codeql
|
||||
|
||||
| - | Message |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
||||
| [dispose ... ();\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/cli.ts#L211) | Dispose method |
|
||||
| [readonl ... > void;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/extension.ts#L166) | Dispose method |
|
||||
| [async d ... }\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/logging.ts#L151) | Dispose method |
|
||||
| [dispose(): any;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/pure/disposable-object.ts#L5) | Dispose method |
|
||||
| [public ... }\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/pure/disposable-object.ts#L65) | Dispose method |
|
||||
| [dispose: () => void;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/query-results.ts#L54) | Dispose method |
|
||||
| [dispose ... ');\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/queryserver-client.ts#L32) | Dispose method |
|
||||
| [dispose ... ();\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/telemetry.ts#L129) | Dispose method |
|
||||
| [public ... ();\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/test-ui.ts#L54) | Dispose method |
|
||||
| [readonl ... > void;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/run-queries.ts#L327) | Dispose method |
|
||||
| [dispose(): unknown](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/vscode-tests/no-workspace/helpers.test.ts#L150) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L12) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L13) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L14) | Dispose method |
|
||||
| [dispose ... inonSpy](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/test/pure-tests/disposable-object.test.ts#L15) | Dispose method |
|
||||
File diff suppressed because one or more lines are too long
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"executionEndTime": 1645645080281,
|
||||
"analysisSummaries": [
|
||||
{
|
||||
"nwo": "github/vscode-codeql",
|
||||
"resultCount": 15,
|
||||
"starCount": 1,
|
||||
"lastUpdated": 1653447088649,
|
||||
"fileSizeInBytes": 191025,
|
||||
"downloadLink": {
|
||||
"id": "171543249",
|
||||
"urlPath": "/repos/avocado-corp/hucairz/actions/artifacts/171543249",
|
||||
"innerFilePath": "results.sarif",
|
||||
"queryId": "MRVA Integration test 1-6sBi6oaky_fxqXW2NA4bx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"nwo": "other/hucairz",
|
||||
"resultCount": 15,
|
||||
"starCount": 1,
|
||||
"lastUpdated": 1653447088649,
|
||||
"fileSizeInBytes": 191025,
|
||||
"downloadLink": {
|
||||
"id": "11111111",
|
||||
"urlPath": "/repos/avocado-corp/hucairz/actions/artifacts/11111111",
|
||||
"innerFilePath": "results.sarif",
|
||||
"queryId": "MRVA Integration test 1-6sBi6oaky_fxqXW2NA4bx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"nwo": "hucairz/i-dont-exist",
|
||||
"resultCount": 5,
|
||||
"starCount": 1,
|
||||
"fileSizeInBytes": 81237,
|
||||
"downloadLink": {
|
||||
"id": "999999",
|
||||
"urlPath": "/these/results/will/never/be/downloaded/999999",
|
||||
"innerFilePath": "results.sarif",
|
||||
"queryId": "MRVA Integration test 2-UL-vbKAjP8ffObxjsp7hN"
|
||||
}
|
||||
}
|
||||
],
|
||||
"analysisFailures": [],
|
||||
"queryId": "MRVA Integration test 1-6sBi6oaky_fxqXW2NA4bx"
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"queryName": "MRVA Integration test 1",
|
||||
"queryFilePath": "PLACEHOLDER/q0.ql",
|
||||
"queryText": "/**\n * @name MRVA Integration test 1\n * @kind problem\n * @problem.severity warning\n * @id javascript/integration-test-1\n */\nimport javascript\n\nfrom MemberDeclaration md\nwhere md.getName() = \"dispose\"\nselect md, \"Dispose method\"\n",
|
||||
"controllerRepository": {
|
||||
"owner": "dsp-testing",
|
||||
"name": "qc-run2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"owner": "github",
|
||||
"name": "vscode-codeql"
|
||||
}
|
||||
],
|
||||
"executionStartTime": 1645644967533,
|
||||
"actionsWorkflowRunId": 1889315769
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
1645644971870
|
||||
@@ -1 +0,0 @@
|
||||
github/vscode-codeql
|
||||
@@ -1 +0,0 @@
|
||||
5
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
"md","col1"
|
||||
"refresh ... d);\n }","Refresh method"
|
||||
"refresh ... <void>;","Refresh method"
|
||||
"public ... }\n }","Refresh method"
|
||||
"public ... }\n }","Refresh method"
|
||||
"refresh ... d);\n }","Refresh method"
|
||||
|
@@ -1,9 +0,0 @@
|
||||
## github/vscode-codeql
|
||||
|
||||
| - | Message |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------- |
|
||||
| [refresh ... d);\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/astViewer.ts#L58) | Refresh method |
|
||||
| [refresh ... <void>;](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/databases.ts#L234) | Refresh method |
|
||||
| [public ... }\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/databases.ts#L354) | Refresh method |
|
||||
| [public ... }\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/discovery.ts#L21) | Refresh method |
|
||||
| [refresh ... d);\n }](https://github.com/github/vscode-codeql/blob/c943c89fc694a06e95845c0b7b7c4e71983dd8c4/extensions/ql-vscode/src/query-history.ts#L268) | Refresh method |
|
||||
File diff suppressed because one or more lines are too long
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"executionEndTime": 1645645150738,
|
||||
"analysisSummaries": [
|
||||
{
|
||||
"nwo": "github/vscode-codeql",
|
||||
"resultCount": 5,
|
||||
"starCount": 1,
|
||||
"lastUpdated": 1653447088649,
|
||||
"fileSizeInBytes": 81237,
|
||||
"downloadLink": {
|
||||
"id": "171544171",
|
||||
"urlPath": "/repos/avocado-corp/hucairz/actions/artifacts/171544171",
|
||||
"innerFilePath": "results.sarif",
|
||||
"queryId": "MRVA Integration test 2-UL-vbKAjP8ffObxjsp7hN"
|
||||
}
|
||||
}
|
||||
],
|
||||
"analysisFailures": [],
|
||||
"queryId": "MRVA Integration test 2-UL-vbKAjP8ffObxjsp7hN"
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"queryName": "MRVA Integration test 2",
|
||||
"queryFilePath": "PLACEHOLDER/q1.ql",
|
||||
"queryText": "/**\n * @name MRVA Integration test 2\n * @kind problem\n * @problem.severity warning\n * @id javascript/integration-test-2\n */\nimport javascript\n\nfrom MemberDeclaration md\nwhere md.getName() = \"refresh\"\nselect md, \"Refresh method\"\n",
|
||||
"controllerRepository": {
|
||||
"owner": "dsp-testing",
|
||||
"name": "qc-run2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"owner": "github",
|
||||
"name": "vscode-codeql"
|
||||
}
|
||||
],
|
||||
"executionStartTime": 1645644973911,
|
||||
"actionsWorkflowRunId": 1889316048
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
1645644974055
|
||||
@@ -1,462 +0,0 @@
|
||||
[
|
||||
{
|
||||
"nwo": "github/codeql",
|
||||
"status": "Completed",
|
||||
"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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nwo": "test/no-results",
|
||||
"status": "Completed",
|
||||
"interpretedResults": []
|
||||
},
|
||||
{
|
||||
"nwo": "meteor/meteor",
|
||||
"status": "Completed",
|
||||
"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": 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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"queryName": "Shell command built from environment values",
|
||||
"queryFilePath": "c:\\git-repo\\vscode-codeql-starter\\ql\\javascript\\ql\\src\\Security\\CWE-078\\ShellCommandInjectionFromEnvironment.ql",
|
||||
"queryText": "/**\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": "javascript",
|
||||
"controllerRepository": { "owner": "dsp-testing", "name": "qc-controller" },
|
||||
"executionStartTime": 1649419081990,
|
||||
"actionsWorkflowRunId": 2115000864,
|
||||
"repositoryCount": 10
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
{
|
||||
"version": 1,
|
||||
"queries": [
|
||||
{
|
||||
"t": "remote",
|
||||
"status": "Completed",
|
||||
"completed": true,
|
||||
"queryId": "MRVA Integration test 1-6sBi6oaky_fxqXW2NA4bx",
|
||||
"label": "MRVA Integration test 1",
|
||||
"remoteQuery": {
|
||||
"queryName": "MRVA Integration test 1",
|
||||
"queryFilePath": "PLACEHOLDER/q0.ql",
|
||||
"queryText": "/**\n * @name MRVA Integration test 1\n * @kind problem\n * @problem.severity warning\n * @id javascript/integration-test-1\n */\nimport javascript\n\nfrom MemberDeclaration md\nwhere md.getName() = \"dispose\"\nselect md, \"Dispose method\"\n",
|
||||
"controllerRepository": {
|
||||
"owner": "dsp-testing",
|
||||
"name": "qc-run2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"owner": "github",
|
||||
"name": "vscode-codeql"
|
||||
}
|
||||
],
|
||||
"executionStartTime": 1645644967533,
|
||||
"actionsWorkflowRunId": 1889315769
|
||||
}
|
||||
},
|
||||
{
|
||||
"t": "remote",
|
||||
"status": "Completed",
|
||||
"completed": true,
|
||||
"queryId": "MRVA Integration test 2-UL-vbKAjP8ffObxjsp7hN",
|
||||
"label": "MRVA Integration test 2",
|
||||
"remoteQuery": {
|
||||
"queryName": "MRVA Integration test 2",
|
||||
"queryFilePath": "PLACEHOLDER/q1.ql",
|
||||
"queryText": "/**\n * @name MRVA Integration test 2\n * @kind problem\n * @problem.severity warning\n * @id javascript/integration-test-2\n */\nimport javascript\n\nfrom MemberDeclaration md\nwhere md.getName() = \"refresh\"\nselect md, \"Refresh method\"\n",
|
||||
"controllerRepository": {
|
||||
"owner": "dsp-testing",
|
||||
"name": "qc-run2"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"owner": "github",
|
||||
"name": "vscode-codeql"
|
||||
}
|
||||
],
|
||||
"executionStartTime": 1645644973911,
|
||||
"actionsWorkflowRunId": 1889316048
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,537 +0,0 @@
|
||||
import {
|
||||
readJSONSync,
|
||||
ensureDir,
|
||||
copy,
|
||||
remove,
|
||||
readFileSync,
|
||||
writeFileSync,
|
||||
} from "fs-extra";
|
||||
import { join } from "path";
|
||||
|
||||
import {
|
||||
CancellationToken,
|
||||
ExtensionContext,
|
||||
TextDocument,
|
||||
TextEditor,
|
||||
Uri,
|
||||
window,
|
||||
workspace,
|
||||
} from "vscode";
|
||||
import { QueryHistoryConfig } from "../../../../src/config";
|
||||
import { DatabaseManager } from "../../../../src/databases";
|
||||
import { tmpDir, walkDirectory } from "../../../../src/helpers";
|
||||
import { AnalysesResultsManager } from "../../../../src/remote-queries/analyses-results-manager";
|
||||
import { RemoteQueryResult } from "../../../../src/remote-queries/shared/remote-query-result";
|
||||
import { DisposableBucket } from "../../disposable-bucket";
|
||||
import { testDisposeHandler } from "../../test-dispose-handler";
|
||||
import { HistoryItemLabelProvider } from "../../../../src/query-history/history-item-label-provider";
|
||||
import { RemoteQueriesManager } from "../../../../src/remote-queries/remote-queries-manager";
|
||||
import { ResultsView } from "../../../../src/interface";
|
||||
import { EvalLogViewer } from "../../../../src/eval-log-viewer";
|
||||
import { QueryRunner } from "../../../../src/queryRunner";
|
||||
import { VariantAnalysisManager } from "../../../../src/remote-queries/variant-analysis-manager";
|
||||
import { App } from "../../../../src/common/app";
|
||||
import { createMockApp } from "../../../__mocks__/appMock";
|
||||
import { testCredentialsWithStub } from "../../../factories/authentication";
|
||||
import { QueryHistoryManager } from "../../../../src/query-history/query-history-manager";
|
||||
|
||||
// set a higher timeout since recursive delete may take a while, expecially on Windows.
|
||||
jest.setTimeout(120000);
|
||||
|
||||
/**
|
||||
* Tests for remote queries and how they interact with the query history manager.
|
||||
*/
|
||||
|
||||
describe("Remote queries and query history manager", () => {
|
||||
const EXTENSION_PATH = join(__dirname, "../../../../");
|
||||
const STORAGE_DIR = Uri.file(join(tmpDir.name, "remote-queries")).fsPath;
|
||||
const asyncNoop = async () => {
|
||||
/** noop */
|
||||
};
|
||||
|
||||
const mockOctokit = jest.fn();
|
||||
let app: App;
|
||||
let qhm: QueryHistoryManager;
|
||||
const localQueriesResultsViewStub = {
|
||||
showResults: jest.fn(),
|
||||
} as any as ResultsView;
|
||||
let rawQueryHistory: any;
|
||||
let remoteQueryResult0: RemoteQueryResult;
|
||||
let remoteQueryResult1: RemoteQueryResult;
|
||||
let disposables: DisposableBucket;
|
||||
|
||||
const rehydrateRemoteQueryStub = jest.fn();
|
||||
const removeRemoteQueryStub = jest.fn();
|
||||
const openRemoteQueryResultsStub = jest.fn();
|
||||
|
||||
const remoteQueriesManagerStub = {
|
||||
onRemoteQueryAdded: jest.fn(),
|
||||
onRemoteQueryRemoved: jest.fn(),
|
||||
onRemoteQueryStatusUpdate: jest.fn(),
|
||||
rehydrateRemoteQuery: rehydrateRemoteQueryStub,
|
||||
removeRemoteQuery: removeRemoteQueryStub,
|
||||
openRemoteQueryResults: openRemoteQueryResultsStub,
|
||||
} as any as RemoteQueriesManager;
|
||||
|
||||
const variantAnalysisManagerStub = {
|
||||
onVariantAnalysisAdded: jest.fn(),
|
||||
onVariantAnalysisStatusUpdated: jest.fn(),
|
||||
onVariantAnalysisRemoved: jest.fn(),
|
||||
} as any as VariantAnalysisManager;
|
||||
|
||||
let showTextDocumentSpy: jest.SpiedFunction<typeof window.showTextDocument>;
|
||||
let openTextDocumentSpy: jest.SpiedFunction<
|
||||
typeof workspace.openTextDocument
|
||||
>;
|
||||
|
||||
beforeEach(async () => {
|
||||
// Since these tests change the state of the query history manager, we need to copy the original
|
||||
// to a temporary folder where we can manipulate it for tests
|
||||
await copyHistoryState();
|
||||
|
||||
disposables = new DisposableBucket();
|
||||
|
||||
rawQueryHistory = readJSONSync(
|
||||
join(STORAGE_DIR, "workspace-query-history.json"),
|
||||
).queries;
|
||||
remoteQueryResult0 = readJSONSync(
|
||||
join(
|
||||
STORAGE_DIR,
|
||||
"queries",
|
||||
rawQueryHistory[0].queryId,
|
||||
"query-result.json",
|
||||
),
|
||||
);
|
||||
remoteQueryResult1 = readJSONSync(
|
||||
join(
|
||||
STORAGE_DIR,
|
||||
"queries",
|
||||
rawQueryHistory[1].queryId,
|
||||
"query-result.json",
|
||||
),
|
||||
);
|
||||
|
||||
app = createMockApp({ credentials: testCredentialsWithStub(mockOctokit) });
|
||||
qhm = new QueryHistoryManager(
|
||||
app,
|
||||
{} as QueryRunner,
|
||||
{} as DatabaseManager,
|
||||
localQueriesResultsViewStub,
|
||||
remoteQueriesManagerStub,
|
||||
variantAnalysisManagerStub,
|
||||
{} as EvalLogViewer,
|
||||
STORAGE_DIR,
|
||||
{
|
||||
globalStorageUri: Uri.file(STORAGE_DIR),
|
||||
extensionPath: EXTENSION_PATH,
|
||||
} as ExtensionContext,
|
||||
{
|
||||
onDidChangeConfiguration: () => new DisposableBucket(),
|
||||
} as unknown as QueryHistoryConfig,
|
||||
new HistoryItemLabelProvider({} as QueryHistoryConfig),
|
||||
asyncNoop,
|
||||
);
|
||||
disposables.push(qhm);
|
||||
|
||||
showTextDocumentSpy = jest
|
||||
.spyOn(window, "showTextDocument")
|
||||
.mockResolvedValue(undefined as unknown as TextEditor);
|
||||
openTextDocumentSpy = jest
|
||||
.spyOn(workspace, "openTextDocument")
|
||||
.mockResolvedValue(undefined as unknown as TextDocument);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await deleteHistoryState();
|
||||
disposables.dispose(testDisposeHandler);
|
||||
});
|
||||
|
||||
it("should read query history", async () => {
|
||||
await qhm.readQueryHistory();
|
||||
|
||||
// Should have added the query history. Contents are directly from the file
|
||||
expect(rehydrateRemoteQueryStub).toBeCalledTimes(2);
|
||||
expect(rehydrateRemoteQueryStub).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
rawQueryHistory[0].queryId,
|
||||
rawQueryHistory[0].remoteQuery,
|
||||
rawQueryHistory[0].status,
|
||||
);
|
||||
expect(rehydrateRemoteQueryStub).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
rawQueryHistory[1].queryId,
|
||||
rawQueryHistory[1].remoteQuery,
|
||||
rawQueryHistory[1].status,
|
||||
);
|
||||
|
||||
expect(qhm.treeDataProvider.allHistory[0]).toEqual(rawQueryHistory[0]);
|
||||
expect(qhm.treeDataProvider.allHistory[1]).toEqual(rawQueryHistory[1]);
|
||||
expect(qhm.treeDataProvider.allHistory.length).toBe(2);
|
||||
});
|
||||
|
||||
it("should remove and then add query from history", async () => {
|
||||
await qhm.readQueryHistory();
|
||||
|
||||
// Remove the first query
|
||||
await qhm.handleRemoveHistoryItem(qhm.treeDataProvider.allHistory[0]);
|
||||
|
||||
expect(removeRemoteQueryStub).toHaveBeenCalledWith(
|
||||
rawQueryHistory[0].queryId,
|
||||
);
|
||||
expect(rehydrateRemoteQueryStub).toBeCalledTimes(2);
|
||||
expect(rehydrateRemoteQueryStub).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
rawQueryHistory[0].queryId,
|
||||
rawQueryHistory[0].remoteQuery,
|
||||
rawQueryHistory[0].status,
|
||||
);
|
||||
expect(rehydrateRemoteQueryStub).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
rawQueryHistory[1].queryId,
|
||||
rawQueryHistory[1].remoteQuery,
|
||||
rawQueryHistory[1].status,
|
||||
);
|
||||
expect(openRemoteQueryResultsStub).toHaveBeenCalledWith(
|
||||
rawQueryHistory[1].queryId,
|
||||
);
|
||||
expect(qhm.treeDataProvider.allHistory).toEqual(rawQueryHistory.slice(1));
|
||||
|
||||
// Add it back
|
||||
qhm.addQuery(rawQueryHistory[0]);
|
||||
expect(removeRemoteQueryStub).toBeCalledTimes(1);
|
||||
expect(rehydrateRemoteQueryStub).toBeCalledTimes(2);
|
||||
expect(qhm.treeDataProvider.allHistory).toEqual([
|
||||
rawQueryHistory[1],
|
||||
rawQueryHistory[0],
|
||||
]);
|
||||
});
|
||||
|
||||
it("should remove two queries from history", async () => {
|
||||
await qhm.readQueryHistory();
|
||||
|
||||
// Remove the both queries
|
||||
// Just for fun, let's do it in reverse order
|
||||
await qhm.handleRemoveHistoryItem(undefined!, [
|
||||
qhm.treeDataProvider.allHistory[1],
|
||||
qhm.treeDataProvider.allHistory[0],
|
||||
]);
|
||||
|
||||
expect(removeRemoteQueryStub).toHaveBeenCalledTimes(2);
|
||||
expect(removeRemoteQueryStub).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
rawQueryHistory[1].queryId,
|
||||
);
|
||||
expect(removeRemoteQueryStub).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
rawQueryHistory[0].queryId,
|
||||
);
|
||||
expect(qhm.treeDataProvider.allHistory).toEqual([]);
|
||||
|
||||
// also, both queries should be removed from on disk storage
|
||||
expect(
|
||||
readJSONSync(join(STORAGE_DIR, "workspace-query-history.json")),
|
||||
).toEqual({
|
||||
version: 2,
|
||||
queries: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle a click", async () => {
|
||||
await qhm.readQueryHistory();
|
||||
|
||||
await qhm.handleItemClicked(qhm.treeDataProvider.allHistory[0], []);
|
||||
expect(openRemoteQueryResultsStub).toHaveBeenCalledWith(
|
||||
rawQueryHistory[0].queryId,
|
||||
);
|
||||
});
|
||||
|
||||
it("should get the query text", async () => {
|
||||
await qhm.readQueryHistory();
|
||||
await qhm.handleShowQueryText(qhm.treeDataProvider.allHistory[0], []);
|
||||
|
||||
expect(showTextDocumentSpy).toBeCalledTimes(1);
|
||||
expect(openTextDocumentSpy).toBeCalledTimes(1);
|
||||
|
||||
const uri: Uri = openTextDocumentSpy.mock.calls[0][0] as Uri;
|
||||
expect(uri.scheme).toBe("codeql");
|
||||
const params = new URLSearchParams(uri.query);
|
||||
expect(params.get("isQuickEval")).toBe("false");
|
||||
expect(params.get("queryText")).toBe(
|
||||
rawQueryHistory[0].remoteQuery.queryText,
|
||||
);
|
||||
});
|
||||
|
||||
describe("AnalysisResultsManager", () => {
|
||||
let mockLogger: any;
|
||||
let mockCliServer: any;
|
||||
let arm: AnalysesResultsManager;
|
||||
|
||||
beforeEach(() => {
|
||||
mockLogger = {
|
||||
log: jest.fn(),
|
||||
};
|
||||
mockCliServer = {
|
||||
bqrsInfo: jest.fn(),
|
||||
bqrsDecode: jest.fn(),
|
||||
};
|
||||
|
||||
arm = new AnalysesResultsManager(
|
||||
app,
|
||||
mockCliServer,
|
||||
join(STORAGE_DIR, "queries"),
|
||||
mockLogger,
|
||||
);
|
||||
});
|
||||
|
||||
it("should avoid re-downloading an analysis result", async () => {
|
||||
// because the analysis result is already in on disk, it should not be downloaded
|
||||
const publisher = jest.fn();
|
||||
const analysisSummary = remoteQueryResult0.analysisSummaries[0];
|
||||
await arm.downloadAnalysisResults(analysisSummary, publisher);
|
||||
|
||||
// Should not have made the request since the analysis result is already on disk
|
||||
expect(mockOctokit).not.toBeCalled();
|
||||
|
||||
// result should have been published twice
|
||||
expect(publisher).toHaveBeenCalledTimes(2);
|
||||
|
||||
// first time, it is in progress
|
||||
expect(publisher).toHaveBeenNthCalledWith(1, [
|
||||
expect.objectContaining({
|
||||
nwo: "github/vscode-codeql",
|
||||
status: "InProgress",
|
||||
interpretedResults: expect.anything(), // avoid checking the interpretedResults object since it is complex
|
||||
}),
|
||||
]);
|
||||
|
||||
// second time, it has the path to the sarif file.
|
||||
expect(publisher).toHaveBeenNthCalledWith(2, [
|
||||
expect.objectContaining({
|
||||
nwo: "github/vscode-codeql",
|
||||
status: "Completed",
|
||||
interpretedResults: expect.anything(), // avoid checking the interpretedResults object since it is complex
|
||||
}),
|
||||
]);
|
||||
|
||||
// result should be stored in the manager
|
||||
expect(
|
||||
arm.getAnalysesResults(rawQueryHistory[0].queryId)[0],
|
||||
).toMatchObject({
|
||||
nwo: "github/vscode-codeql",
|
||||
status: "Completed",
|
||||
// interpretedResults: ... avoid checking the interpretedResults object since it is complex
|
||||
});
|
||||
publisher.mockClear();
|
||||
|
||||
// now, let's try to download it again. This time, since it's already in memory,
|
||||
// it should not even be re-published
|
||||
await arm.downloadAnalysisResults(analysisSummary, publisher);
|
||||
expect(publisher).not.toBeCalled();
|
||||
});
|
||||
|
||||
it("should download two artifacts at once", async () => {
|
||||
const publisher = jest.fn();
|
||||
const analysisSummaries = [
|
||||
remoteQueryResult0.analysisSummaries[0],
|
||||
remoteQueryResult0.analysisSummaries[1],
|
||||
];
|
||||
await arm.loadAnalysesResults(analysisSummaries, undefined, publisher);
|
||||
|
||||
const trimmed = publisher.mock.calls
|
||||
.map((call) => call[0])
|
||||
.map((args) => {
|
||||
args.forEach(
|
||||
(analysisResult: any) => delete analysisResult.interpretedResults,
|
||||
);
|
||||
return args;
|
||||
});
|
||||
|
||||
// As before, but now both summaries should have been published
|
||||
expect(trimmed[0]).toEqual([
|
||||
{
|
||||
nwo: "github/vscode-codeql",
|
||||
status: "InProgress",
|
||||
resultCount: 15,
|
||||
lastUpdated: 1653447088649,
|
||||
starCount: 1,
|
||||
},
|
||||
]);
|
||||
|
||||
expect(trimmed[1]).toEqual([
|
||||
{
|
||||
nwo: "github/vscode-codeql",
|
||||
status: "InProgress",
|
||||
resultCount: 15,
|
||||
lastUpdated: 1653447088649,
|
||||
starCount: 1,
|
||||
},
|
||||
{
|
||||
nwo: "other/hucairz",
|
||||
status: "InProgress",
|
||||
resultCount: 15,
|
||||
lastUpdated: 1653447088649,
|
||||
starCount: 1,
|
||||
},
|
||||
]);
|
||||
|
||||
// there is a third call. It is non-deterministic if
|
||||
// github/vscode-codeql is completed first or other/hucairz is.
|
||||
// There is not much point in trying to test it if the other calls are correct.
|
||||
|
||||
expect(trimmed[3]).toEqual([
|
||||
{
|
||||
nwo: "github/vscode-codeql",
|
||||
status: "Completed",
|
||||
resultCount: 15,
|
||||
lastUpdated: 1653447088649,
|
||||
starCount: 1,
|
||||
},
|
||||
{
|
||||
nwo: "other/hucairz",
|
||||
status: "Completed",
|
||||
resultCount: 15,
|
||||
lastUpdated: 1653447088649,
|
||||
starCount: 1,
|
||||
},
|
||||
]);
|
||||
|
||||
expect(publisher).toBeCalledTimes(4);
|
||||
});
|
||||
|
||||
it("should avoid publishing when the request is cancelled", async () => {
|
||||
const publisher = jest.fn();
|
||||
const analysisSummaries = [...remoteQueryResult0.analysisSummaries];
|
||||
|
||||
await expect(
|
||||
arm.loadAnalysesResults(
|
||||
analysisSummaries,
|
||||
{
|
||||
isCancellationRequested: true,
|
||||
} as CancellationToken,
|
||||
publisher,
|
||||
),
|
||||
).rejects.toThrow(/cancelled/);
|
||||
|
||||
expect(publisher).not.toBeCalled();
|
||||
});
|
||||
|
||||
it("should get the analysis results", async () => {
|
||||
const publisher = jest.fn();
|
||||
const analysisSummaries0 = [
|
||||
remoteQueryResult0.analysisSummaries[0],
|
||||
remoteQueryResult0.analysisSummaries[1],
|
||||
];
|
||||
const analysisSummaries1 = [...remoteQueryResult1.analysisSummaries];
|
||||
|
||||
await arm.loadAnalysesResults(analysisSummaries0, undefined, publisher);
|
||||
await arm.loadAnalysesResults(analysisSummaries1, undefined, publisher);
|
||||
|
||||
const result0 = arm.getAnalysesResults(rawQueryHistory[0].queryId);
|
||||
const result0Again = arm.getAnalysesResults(rawQueryHistory[0].queryId);
|
||||
|
||||
// Shoule be equal, but not equivalent
|
||||
expect(result0).toEqual(result0Again);
|
||||
expect(result0).not.toBe(result0Again);
|
||||
|
||||
const result1 = arm.getAnalysesResults(rawQueryHistory[1].queryId);
|
||||
const result1Again = arm.getAnalysesResults(rawQueryHistory[1].queryId);
|
||||
expect(result1).toEqual(result1Again);
|
||||
expect(result1).not.toBe(result1Again);
|
||||
});
|
||||
|
||||
// This test is failing on windows in CI.
|
||||
it.skip("should read sarif", async () => {
|
||||
const publisher = jest.fn();
|
||||
const analysisSummaries0 = [remoteQueryResult0.analysisSummaries[0]];
|
||||
await arm.loadAnalysesResults(analysisSummaries0, undefined, publisher);
|
||||
|
||||
const sarif = readJSONSync(
|
||||
join(
|
||||
STORAGE_DIR,
|
||||
"queries",
|
||||
rawQueryHistory[0].queryId,
|
||||
"171543249",
|
||||
"results.sarif",
|
||||
),
|
||||
);
|
||||
const queryResults = sarif.runs
|
||||
.flatMap((run: any) => run.results)
|
||||
.map((result: any) => ({ message: result.message.text }));
|
||||
|
||||
expect(publisher).toHaveBeenNthCalledWith(2, [
|
||||
{
|
||||
results: queryResults,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should check if an artifact is downloaded and not in memory", async () => {
|
||||
// Load remoteQueryResult0.analysisSummaries[1] into memory
|
||||
await arm.downloadAnalysisResults(
|
||||
remoteQueryResult0.analysisSummaries[1],
|
||||
() => Promise.resolve(),
|
||||
);
|
||||
|
||||
// on disk
|
||||
expect(
|
||||
await (arm as any).isAnalysisDownloaded(
|
||||
remoteQueryResult0.analysisSummaries[0],
|
||||
),
|
||||
).toBe(true);
|
||||
|
||||
// in memory
|
||||
expect(
|
||||
await (arm as any).isAnalysisDownloaded(
|
||||
remoteQueryResult0.analysisSummaries[1],
|
||||
),
|
||||
).toBe(true);
|
||||
|
||||
// not downloaded
|
||||
expect(
|
||||
await (arm as any).isAnalysisDownloaded(
|
||||
remoteQueryResult0.analysisSummaries[2],
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should load downloaded artifacts", async () => {
|
||||
await arm.loadDownloadedAnalyses(remoteQueryResult0.analysisSummaries);
|
||||
const queryId = rawQueryHistory[0].queryId;
|
||||
const analysesResultsNwos = arm
|
||||
.getAnalysesResults(queryId)
|
||||
.map((ar) => ar.nwo)
|
||||
.sort();
|
||||
expect(analysesResultsNwos[0]).toBe("github/vscode-codeql");
|
||||
expect(analysesResultsNwos[1]).toBe("other/hucairz");
|
||||
expect(analysesResultsNwos.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
async function copyHistoryState() {
|
||||
await ensureDir(STORAGE_DIR);
|
||||
await ensureDir(join(tmpDir.name, "remote-queries"));
|
||||
await copy(
|
||||
join(__dirname, "../data/remote-queries/"),
|
||||
join(tmpDir.name, "remote-queries"),
|
||||
);
|
||||
|
||||
// also, replace the files with "PLACEHOLDER" so that they have the correct directory
|
||||
for await (const p of walkDirectory(STORAGE_DIR)) {
|
||||
replacePlaceholder(join(p));
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteHistoryState() {
|
||||
await remove(STORAGE_DIR);
|
||||
}
|
||||
|
||||
function replacePlaceholder(filePath: string) {
|
||||
if (filePath.endsWith(".json")) {
|
||||
const newContents = readFileSync(filePath, "utf8").replaceAll(
|
||||
"PLACEHOLDER",
|
||||
STORAGE_DIR.replaceAll("\\", "/"),
|
||||
);
|
||||
writeFileSync(filePath, newContents, "utf8");
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user