Compare commits
14 Commits
v1.14.0
...
mh-refacto
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
390dfeb087 | ||
|
|
012e597d4a | ||
|
|
cd568db7b4 | ||
|
|
dc745dd8e1 | ||
|
|
29d6b127e2 | ||
|
|
1cbfba32a0 | ||
|
|
c2b2d10591 | ||
|
|
1fe4abf6e8 | ||
|
|
efaef8a2cb | ||
|
|
a8d61a605a | ||
|
|
e44024763d | ||
|
|
9a6aa52a40 | ||
|
|
c106903f01 | ||
|
|
d40cda150c |
4
.github/workflows/e2e-tests.yml
vendored
4
.github/workflows/e2e-tests.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
|
||||
- name: Start containers
|
||||
working-directory: extensions/ql-vscode/test/e2e
|
||||
run: docker compose -f "docker-compose.yml" up -d --build
|
||||
run: docker-compose -f "docker-compose.yml" up -d --build
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
working-directory: extensions/ql-vscode
|
||||
@@ -43,4 +43,4 @@ jobs:
|
||||
- name: Stop containers
|
||||
working-directory: extensions/ql-vscode/test/e2e
|
||||
if: always()
|
||||
run: docker compose -f "docker-compose.yml" down -v
|
||||
run: docker-compose -f "docker-compose.yml" down -v
|
||||
|
||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -111,4 +111,10 @@
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
},
|
||||
"github.copilot.advanced": {
|
||||
|
||||
|
||||
},
|
||||
"codeQL.variantAnalysis.enableGhecDr": true,
|
||||
"github-enterprise.uri": "http://server:8080/"
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ const baseConfig = {
|
||||
"@typescript-eslint/no-throw-literal": "error",
|
||||
"@typescript-eslint/consistent-type-imports": "error",
|
||||
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
||||
curly: ["error", "all"],
|
||||
// curly: ["error", "all"],
|
||||
"escompat/no-regexp-lookbehind": "off",
|
||||
"etc/no-implicit-any-catch": "error",
|
||||
"filenames/match-regex": "off",
|
||||
|
||||
@@ -1 +1 @@
|
||||
v20.14.0
|
||||
v20.9.0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from "react";
|
||||
import { addons } from "@storybook/manager-api";
|
||||
import { Addon_TypesEnum } from "storybook/internal/types";
|
||||
import { Addon_TypesEnum } from "@storybook/types";
|
||||
import { ThemeSelector } from "./ThemeSelector";
|
||||
|
||||
const ADDON_ID = "vscode-theme-addon";
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
# CodeQL for Visual Studio Code: Changelog
|
||||
|
||||
## 1.14.0 - 7 August 2024
|
||||
|
||||
- Add Python support to the CodeQL Model Editor. [#3676](https://github.com/github/vscode-codeql/pull/3676)
|
||||
- Update variant analysis view to display the length of the shortest path for path queries. [#3671](https://github.com/github/vscode-codeql/pull/3671)
|
||||
- Remove support for CodeQL CLI versions older than 2.15.5. [#3681](https://github.com/github/vscode-codeql/pull/3681)
|
||||
## [UNRELEASED]
|
||||
|
||||
## 1.13.1 - 29 May 2024
|
||||
|
||||
|
||||
@@ -77,8 +77,5 @@ export function copyWasmFiles() {
|
||||
// to configure the path to the WASM file. So, source-map will always load the file from `__dirname/mappings.wasm`.
|
||||
// In version 0.8.0, it may be possible to do this properly by calling SourceMapConsumer.initialize by
|
||||
// using the "browser" field in source-map's package.json to load the WASM file from a given file path.
|
||||
return src("node_modules/source-map/lib/mappings.wasm", {
|
||||
// WASM is a binary format, so don't try to re-encode it as text.
|
||||
encoding: false,
|
||||
}).pipe(dest("out"));
|
||||
return src("node_modules/source-map/lib/mappings.wasm").pipe(dest("out"));
|
||||
}
|
||||
|
||||
6585
extensions/ql-vscode/package-lock.json
generated
6585
extensions/ql-vscode/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
"description": "CodeQL for Visual Studio Code",
|
||||
"author": "GitHub",
|
||||
"private": true,
|
||||
"version": "1.14.0",
|
||||
"version": "1.13.2",
|
||||
"publisher": "GitHub",
|
||||
"license": "MIT",
|
||||
"icon": "media/VS-marketplace-CodeQL-icon.png",
|
||||
@@ -14,7 +14,7 @@
|
||||
},
|
||||
"engines": {
|
||||
"vscode": "^1.82.0",
|
||||
"node": "^20.14.0",
|
||||
"node": "^20.9.0",
|
||||
"npm": ">=7.20.6"
|
||||
},
|
||||
"categories": [
|
||||
@@ -339,13 +339,6 @@
|
||||
"title": "Variant analysis",
|
||||
"order": 5,
|
||||
"properties": {
|
||||
"codeQL.variantAnalysis.controllerRepo": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
"pattern": "^$|^(?:[a-zA-Z0-9]+-)*[a-zA-Z0-9]+/[a-zA-Z0-9-_]+$",
|
||||
"patternErrorMessage": "Please enter a valid GitHub repository",
|
||||
"markdownDescription": "[For internal use only] The name of the GitHub repository in which the GitHub Actions workflow is run when using the \"Run Variant Analysis\" command. The repository should be of the form `<owner>/<repo>`)."
|
||||
},
|
||||
"codeQL.variantAnalysis.defaultResultsFilter": {
|
||||
"type": "string",
|
||||
"default": "all",
|
||||
@@ -1790,7 +1783,8 @@
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.trimCache"
|
||||
"command": "codeQL.trimCache",
|
||||
"when": "codeql.supportsTrimCache"
|
||||
}
|
||||
],
|
||||
"editor/context": [
|
||||
@@ -1930,11 +1924,6 @@
|
||||
{
|
||||
"view": "codeQLEvalLogViewer",
|
||||
"contents": "Run the 'Show Evaluator Log (UI)' command on a CodeQL query run in the Query History view."
|
||||
},
|
||||
{
|
||||
"view": "codeQLVariantAnalysisRepositories",
|
||||
"contents": "Set up a controller repository to start using variant analysis. [Learn more](https://codeql.github.com/docs/codeql-for-visual-studio-code/running-codeql-queries-at-scale-with-mrva#controller-repository) about controller repositories. \n[Set up controller repository](command:codeQLVariantAnalysisRepositories.setupControllerRepository)",
|
||||
"when": "!config.codeQL.variantAnalysis.controllerRepo"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -1971,7 +1960,7 @@
|
||||
"@octokit/plugin-retry": "^6.0.1",
|
||||
"@octokit/plugin-throttling": "^8.0.0",
|
||||
"@octokit/rest": "^20.0.2",
|
||||
"@vscode/codicons": "^0.0.36",
|
||||
"@vscode/codicons": "^0.0.35",
|
||||
"@vscode/debugadapter": "^1.59.0",
|
||||
"@vscode/debugprotocol": "^1.65.0",
|
||||
"@vscode/webview-ui-toolkit": "^1.0.1",
|
||||
@@ -1997,35 +1986,35 @@
|
||||
"tmp-promise": "^3.0.2",
|
||||
"tree-kill": "^1.2.2",
|
||||
"vscode-extension-telemetry": "^0.1.6",
|
||||
"vscode-jsonrpc": "^8.2.1",
|
||||
"vscode-jsonrpc": "^8.0.2",
|
||||
"vscode-languageclient": "^8.0.2",
|
||||
"yauzl": "^2.10.0",
|
||||
"zip-a-folder": "^3.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.6",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.24.7",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
|
||||
"@babel/preset-env": "^7.24.4",
|
||||
"@babel/preset-react": "^7.24.1",
|
||||
"@babel/preset-typescript": "^7.21.4",
|
||||
"@faker-js/faker": "^8.4.1",
|
||||
"@github/markdownlint-github": "^0.6.2",
|
||||
"@playwright/test": "^1.40.1",
|
||||
"@storybook/addon-a11y": "^8.2.7",
|
||||
"@storybook/addon-actions": "^8.2.7",
|
||||
"@storybook/addon-essentials": "^8.2.7",
|
||||
"@storybook/addon-interactions": "^8.2.7",
|
||||
"@storybook/addon-links": "^8.2.7",
|
||||
"@storybook/addon-a11y": "^8.1.10",
|
||||
"@storybook/addon-actions": "^8.1.10",
|
||||
"@storybook/addon-essentials": "^8.1.10",
|
||||
"@storybook/addon-interactions": "^8.1.10",
|
||||
"@storybook/addon-links": "^8.1.10",
|
||||
"@storybook/blocks": "^8.0.2",
|
||||
"@storybook/components": "^8.2.7",
|
||||
"@storybook/csf": "^0.1.11",
|
||||
"@storybook/icons": "^1.2.10",
|
||||
"@storybook/manager-api": "^8.2.7",
|
||||
"@storybook/react": "^8.2.7",
|
||||
"@storybook/react-vite": "^8.2.7",
|
||||
"@storybook/theming": "^8.2.4",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/jest-dom": "^6.4.8",
|
||||
"@storybook/components": "^8.0.2",
|
||||
"@storybook/csf": "^0.1.8",
|
||||
"@storybook/icons": "^1.2.9",
|
||||
"@storybook/manager-api": "^8.1.10",
|
||||
"@storybook/react": "^8.1.10",
|
||||
"@storybook/react-vite": "^8.1.10",
|
||||
"@storybook/theming": "^8.1.10",
|
||||
"@testing-library/dom": "^10.1.0",
|
||||
"@testing-library/jest-dom": "^6.4.6",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@testing-library/user-event": "^14.5.2",
|
||||
"@types/child-process-promise": "^2.2.1",
|
||||
@@ -2038,7 +2027,7 @@
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/js-yaml": "^4.0.6",
|
||||
"@types/nanoid": "^3.0.0",
|
||||
"@types/node": "20.14.*",
|
||||
"@types/node": "20.9.*",
|
||||
"@types/node-fetch": "^2.5.2",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
@@ -2070,14 +2059,14 @@
|
||||
"eslint-plugin-jest-dom": "^5.2.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-react": "^7.34.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-storybook": "^0.8.0",
|
||||
"glob": "^10.0.0",
|
||||
"gulp": "^5.0.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-esbuild": "^0.12.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-typescript": "^5.0.1",
|
||||
"husky": "^9.0.11",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^29.0.3",
|
||||
"jest-environment-jsdom": "^29.0.3",
|
||||
"jest-runner-vscode": "^3.0.1",
|
||||
@@ -2087,7 +2076,7 @@
|
||||
"npm-run-all": "^4.1.5",
|
||||
"patch-package": "^8.0.0",
|
||||
"prettier": "^3.2.5",
|
||||
"storybook": "^8.2.7",
|
||||
"storybook": "^8.1.10",
|
||||
"tar-stream": "^3.1.7",
|
||||
"through2": "^4.0.2",
|
||||
"ts-jest": "^29.1.4",
|
||||
|
||||
@@ -12,7 +12,6 @@ interface VersionResult {
|
||||
export interface CliFeatures {
|
||||
featuresInVersionResult?: boolean;
|
||||
mrvaPackCreate?: boolean;
|
||||
generateSummarySymbolMap?: boolean;
|
||||
}
|
||||
|
||||
export interface VersionAndFeatures {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -290,7 +290,6 @@ export type DatabasePanelCommands = {
|
||||
"codeQLVariantAnalysisRepositories.openConfigFile": () => Promise<void>;
|
||||
"codeQLVariantAnalysisRepositories.addNewDatabase": () => Promise<void>;
|
||||
"codeQLVariantAnalysisRepositories.addNewList": () => Promise<void>;
|
||||
"codeQLVariantAnalysisRepositories.setupControllerRepository": () => Promise<void>;
|
||||
|
||||
"codeQLVariantAnalysisRepositories.setSelectedItem": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
|
||||
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu": TreeViewContextSingleSelectionCommandFunction<DbTreeViewItem>;
|
||||
|
||||
@@ -147,21 +147,6 @@ interface SetStateMsg {
|
||||
parsedResultSets: ParsedResultSets;
|
||||
}
|
||||
|
||||
export interface UserSettings {
|
||||
/** Whether to display links to the dataflow models that generated particular nodes in a flow path. */
|
||||
shouldShowProvenance: boolean;
|
||||
}
|
||||
|
||||
export const DEFAULT_USER_SETTINGS: UserSettings = {
|
||||
shouldShowProvenance: false,
|
||||
};
|
||||
|
||||
/** Message indicating that the user's configuration settings have changed. */
|
||||
interface SetUserSettingsMsg {
|
||||
t: "setUserSettings";
|
||||
userSettings: UserSettings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Message indicating that the results view should display interpreted
|
||||
* results.
|
||||
@@ -206,7 +191,6 @@ interface UntoggleShowProblemsMsg {
|
||||
export type IntoResultsViewMsg =
|
||||
| ResultsUpdatingMsg
|
||||
| SetStateMsg
|
||||
| SetUserSettingsMsg
|
||||
| ShowInterpretedPageMsg
|
||||
| NavigateMsg
|
||||
| UntoggleShowProblemsMsg;
|
||||
@@ -224,15 +208,13 @@ export type FromResultsViewMsg =
|
||||
| OpenFileMsg;
|
||||
|
||||
/**
|
||||
* Message from the results view to open a source
|
||||
* Message from the results view to open a database source
|
||||
* file at the provided location.
|
||||
*/
|
||||
interface ViewSourceFileMsg {
|
||||
t: "viewSourceFile";
|
||||
loc: UrlValueResolvable;
|
||||
/** URI of the database whose source archive contains the file, or `undefined` to open a file from
|
||||
* the local disk. The latter case is used for opening links to data extension model files. */
|
||||
databaseUri: string | undefined;
|
||||
databaseUri: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,8 +341,7 @@ interface ChangeCompareMessage {
|
||||
|
||||
export type ToCompareViewMessage =
|
||||
| SetComparisonQueryInfoMessage
|
||||
| SetComparisonsMessage
|
||||
| SetUserSettingsMsg;
|
||||
| SetComparisonsMessage;
|
||||
|
||||
/**
|
||||
* Message to the compare view that sets the metadata of the compared queries.
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
import type { Log } from "sarif";
|
||||
import type { Log, Tool } from "sarif";
|
||||
import { createReadStream } from "fs-extra";
|
||||
import { connectTo } from "stream-json/Assembler";
|
||||
import { getErrorMessage } from "./helpers-pure";
|
||||
import { withParser } from "stream-json/filters/Ignore";
|
||||
import { withParser } from "stream-json/filters/Pick";
|
||||
|
||||
const DUMMY_TOOL: Tool = { driver: { name: "" } };
|
||||
|
||||
export async function sarifParser(
|
||||
interpretedResultsPath: string,
|
||||
): Promise<Log> {
|
||||
try {
|
||||
// Parse the SARIF file into token streams, filtering out some of the larger subtrees that we
|
||||
// don't need.
|
||||
// Parse the SARIF file into token streams, filtering out only the results array.
|
||||
const pipeline = createReadStream(interpretedResultsPath).pipe(
|
||||
withParser({
|
||||
// We don't need to run's `artifacts` property, nor the driver's `notifications` property.
|
||||
filter: /^runs\.\d+\.(artifacts|tool\.driver\.notifications)/,
|
||||
}),
|
||||
withParser({ filter: "runs.0.results" }),
|
||||
);
|
||||
|
||||
// Creates JavaScript objects from the token stream
|
||||
@@ -40,17 +38,15 @@ export async function sarifParser(
|
||||
});
|
||||
|
||||
asm.on("done", (asm) => {
|
||||
const log = asm.current;
|
||||
|
||||
// Do some trivial validation. This isn't a full validation of the SARIF file, but it's at
|
||||
// least enough to ensure that we're not trying to parse complete garbage later.
|
||||
if (log.runs === undefined || log.runs.length < 1) {
|
||||
reject(
|
||||
new Error(
|
||||
"Invalid SARIF file: expecting at least one run with result.",
|
||||
),
|
||||
);
|
||||
}
|
||||
const log: Log = {
|
||||
version: "2.1.0",
|
||||
runs: [
|
||||
{
|
||||
tool: DUMMY_TOOL,
|
||||
results: asm.current ?? [],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
resolve(log);
|
||||
alreadyDone = true;
|
||||
|
||||
@@ -33,7 +33,6 @@ import {
|
||||
getResultSetNames,
|
||||
} from "./result-set-names";
|
||||
import { compareInterpretedResults } from "./interpreted-results";
|
||||
import { isCanary } from "../config";
|
||||
|
||||
interface ComparePair {
|
||||
from: CompletedLocalQueryInfo;
|
||||
@@ -117,13 +116,6 @@ export class CompareView extends AbstractWebview<
|
||||
panel.reveal(undefined, true);
|
||||
await this.waitForPanelLoaded();
|
||||
|
||||
await this.postMessage({
|
||||
t: "setUserSettings",
|
||||
userSettings: {
|
||||
shouldShowProvenance: isCanary(),
|
||||
},
|
||||
});
|
||||
|
||||
await this.postMessage({
|
||||
t: "setComparisonQueryInfo",
|
||||
stats: {
|
||||
|
||||
@@ -112,7 +112,9 @@ export function hasEnterpriseUri(): boolean {
|
||||
* Does the uri look like GHEC-DR?
|
||||
*/
|
||||
function isGhecDrUri(uri: Uri | undefined): boolean {
|
||||
return uri !== undefined && uri.authority.toLowerCase().endsWith(".ghe.com");
|
||||
return (
|
||||
uri !== undefined && !uri.authority.toLowerCase().endsWith("github.com")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,27 +593,7 @@ export const NO_CACHE_CONTEXTUAL_QUERIES = new Setting(
|
||||
// Settings for variant analysis
|
||||
const VARIANT_ANALYSIS_SETTING = new Setting("variantAnalysis", ROOT_SETTING);
|
||||
|
||||
/**
|
||||
* The name of the "controller" repository that you want to use with the "Run Variant Analysis" command.
|
||||
* Note: This command is only available for internal users.
|
||||
*
|
||||
* This setting should be a GitHub repository of the form `<owner>/<repo>`.
|
||||
*/
|
||||
const REMOTE_CONTROLLER_REPO = new Setting(
|
||||
"controllerRepo",
|
||||
VARIANT_ANALYSIS_SETTING,
|
||||
);
|
||||
|
||||
export function getRemoteControllerRepo(): string | undefined {
|
||||
return REMOTE_CONTROLLER_REPO.getValue<string>() || undefined;
|
||||
}
|
||||
|
||||
export async function setRemoteControllerRepo(repo: string | undefined) {
|
||||
await REMOTE_CONTROLLER_REPO.updateValue(repo, ConfigurationTarget.Global);
|
||||
}
|
||||
|
||||
export interface VariantAnalysisConfig {
|
||||
controllerRepo: string | undefined;
|
||||
showSystemDefinedRepositoryLists: boolean;
|
||||
/**
|
||||
* This uses a URL instead of a URI because the URL class is available in
|
||||
@@ -632,10 +614,6 @@ export class VariantAnalysisConfigListener
|
||||
);
|
||||
}
|
||||
|
||||
public get controllerRepo(): string | undefined {
|
||||
return getRemoteControllerRepo();
|
||||
}
|
||||
|
||||
public get showSystemDefinedRepositoryLists(): boolean {
|
||||
return !hasEnterpriseUri();
|
||||
}
|
||||
@@ -840,6 +818,7 @@ const LLM_GENERATION_DEV_ENDPOINT = new Setting(
|
||||
const MODEL_EVALUATION = new Setting("evaluation", MODEL_SETTING);
|
||||
const MODEL_PACK_LOCATION = new Setting("packLocation", MODEL_SETTING);
|
||||
const MODEL_PACK_NAME = new Setting("packName", MODEL_SETTING);
|
||||
const ENABLE_PYTHON = new Setting("enablePython", MODEL_SETTING);
|
||||
|
||||
export type ModelConfigPackVariables = {
|
||||
database: string;
|
||||
@@ -856,6 +835,7 @@ export interface ModelConfig {
|
||||
variables: ModelConfigPackVariables,
|
||||
): string;
|
||||
getPackName(languageId: string, variables: ModelConfigPackVariables): string;
|
||||
enablePython: boolean;
|
||||
}
|
||||
|
||||
export class ModelConfigListener extends ConfigListener implements ModelConfig {
|
||||
@@ -917,6 +897,10 @@ export class ModelConfigListener extends ConfigListener implements ModelConfig {
|
||||
variables,
|
||||
);
|
||||
}
|
||||
|
||||
public get enablePython(): boolean {
|
||||
return !!ENABLE_PYTHON.getValue<boolean>();
|
||||
}
|
||||
}
|
||||
|
||||
const GITHUB_DATABASE_SETTING = new Setting("githubDatabase", ROOT_SETTING);
|
||||
|
||||
@@ -37,12 +37,11 @@ export const shownLocationLineDecoration =
|
||||
/**
|
||||
* Resolves the specified CodeQL location to a URI into the source archive.
|
||||
* @param loc CodeQL location to resolve. Must have a non-empty value for `loc.file`.
|
||||
* @param databaseItem Database in which to resolve the file location, or `undefined` to resolve
|
||||
* from the local file system.
|
||||
* @param databaseItem Database in which to resolve the file location.
|
||||
*/
|
||||
function resolveFivePartLocation(
|
||||
loc: UrlValueLineColumnLocation,
|
||||
databaseItem: DatabaseItem | undefined,
|
||||
databaseItem: DatabaseItem,
|
||||
): Location {
|
||||
// `Range` is a half-open interval, and is zero-based. CodeQL locations are closed intervals, and
|
||||
// are one-based. Adjust accordingly.
|
||||
@@ -53,10 +52,7 @@ function resolveFivePartLocation(
|
||||
Math.max(1, loc.endColumn),
|
||||
);
|
||||
|
||||
return new Location(
|
||||
databaseItem?.resolveSourceFile(loc.uri) ?? Uri.parse(loc.uri),
|
||||
range,
|
||||
);
|
||||
return new Location(databaseItem.resolveSourceFile(loc.uri), range);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,26 +62,22 @@ function resolveFivePartLocation(
|
||||
*/
|
||||
function resolveWholeFileLocation(
|
||||
loc: UrlValueWholeFileLocation,
|
||||
databaseItem: DatabaseItem | undefined,
|
||||
databaseItem: DatabaseItem,
|
||||
): Location {
|
||||
// A location corresponding to the start of the file.
|
||||
const range = new Range(0, 0, 0, 0);
|
||||
return new Location(
|
||||
databaseItem?.resolveSourceFile(loc.uri) ?? Uri.parse(loc.uri),
|
||||
range,
|
||||
);
|
||||
return new Location(databaseItem.resolveSourceFile(loc.uri), range);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to resolve the specified CodeQL location to a URI into the source archive. If no exact location
|
||||
* can be resolved, returns `undefined`.
|
||||
* @param loc CodeQL location to resolve
|
||||
* @param databaseItem Database in which to resolve the file location, or `undefined` to resolve
|
||||
* from the local file system.
|
||||
* @param databaseItem Database in which to resolve the file location.
|
||||
*/
|
||||
export function tryResolveLocation(
|
||||
loc: UrlValueResolvable | undefined,
|
||||
databaseItem: DatabaseItem | undefined,
|
||||
databaseItem: DatabaseItem,
|
||||
): Location | undefined {
|
||||
if (!loc) {
|
||||
return;
|
||||
@@ -103,7 +95,7 @@ export function tryResolveLocation(
|
||||
|
||||
export async function showResolvableLocation(
|
||||
loc: UrlValueResolvable,
|
||||
databaseItem: DatabaseItem | undefined,
|
||||
databaseItem: DatabaseItem,
|
||||
logger: Logger,
|
||||
): Promise<void> {
|
||||
try {
|
||||
@@ -159,14 +151,13 @@ export async function showLocation(location?: Location) {
|
||||
}
|
||||
|
||||
export async function jumpToLocation(
|
||||
databaseUri: string | undefined,
|
||||
databaseUri: string,
|
||||
loc: UrlValueResolvable,
|
||||
databaseManager: DatabaseManager,
|
||||
logger: Logger,
|
||||
) {
|
||||
const databaseItem =
|
||||
databaseUri !== undefined
|
||||
? databaseManager.findDatabaseItem(Uri.parse(databaseUri))
|
||||
: undefined;
|
||||
await showResolvableLocation(loc, databaseItem, logger);
|
||||
const databaseItem = databaseManager.findDatabaseItem(Uri.parse(databaseUri));
|
||||
if (databaseItem !== undefined) {
|
||||
await showResolvableLocation(loc, databaseItem, logger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import type { DbManager } from "../db-manager";
|
||||
import { DbTreeDataProvider } from "./db-tree-data-provider";
|
||||
import type { DbTreeViewItem } from "./db-tree-view-item";
|
||||
import { getGitHubUrl } from "./db-tree-view-item-action";
|
||||
import { getControllerRepo } from "../../variant-analysis/run-remote-query";
|
||||
import { getErrorMessage } from "../../common/helpers-pure";
|
||||
import type { DatabasePanelCommands } from "../../common/commands";
|
||||
import type { App } from "../../common/app";
|
||||
import { QueryLanguage } from "../../common/query-language";
|
||||
@@ -74,9 +72,6 @@ export class DbPanel extends DisposableObject {
|
||||
this.addNewRemoteDatabase.bind(this),
|
||||
"codeQLVariantAnalysisRepositories.addNewList":
|
||||
this.addNewList.bind(this),
|
||||
"codeQLVariantAnalysisRepositories.setupControllerRepository":
|
||||
this.setupControllerRepository.bind(this),
|
||||
|
||||
"codeQLVariantAnalysisRepositories.setSelectedItem":
|
||||
this.setSelectedItem.bind(this),
|
||||
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu":
|
||||
@@ -427,22 +422,4 @@ export class DbPanel extends DisposableObject {
|
||||
|
||||
await this.app.commands.execute("vscode.open", Uri.parse(githubUrl));
|
||||
}
|
||||
|
||||
private async setupControllerRepository(): Promise<void> {
|
||||
try {
|
||||
// This will also validate that the controller repository is valid
|
||||
await getControllerRepo(this.app.credentials);
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof UserCancellationException) {
|
||||
return;
|
||||
}
|
||||
|
||||
void showAndLogErrorMessage(
|
||||
this.app.logger,
|
||||
`An error occurred while setting up the controller repository: ${getErrorMessage(
|
||||
e,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +83,6 @@ export class DbTreeDataProvider
|
||||
}
|
||||
|
||||
private createTree(): DbTreeViewItem[] {
|
||||
// Returning an empty tree here will show the welcome view
|
||||
if (!this.variantAnalysisConfig.controllerRepo) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const dbItemsResult = this.dbManager.getDbItems();
|
||||
|
||||
if (dbItemsResult.isFailure) {
|
||||
|
||||
@@ -537,14 +537,6 @@ export class ResultsView extends AbstractWebview<
|
||||
resultSetNames,
|
||||
};
|
||||
|
||||
await this.postMessage({
|
||||
t: "setUserSettings",
|
||||
userSettings: {
|
||||
// Only show provenance info in canary mode for now.
|
||||
shouldShowProvenance: isCanary(),
|
||||
},
|
||||
});
|
||||
|
||||
await this.postMessage({
|
||||
t: "setState",
|
||||
interpretation: interpretationPage,
|
||||
|
||||
@@ -33,7 +33,6 @@ export function decodeBqrsToMethods(
|
||||
let libraryVersion: string | undefined;
|
||||
let type: ModeledMethodType;
|
||||
let classification: CallClassification;
|
||||
let endpointKindColumn: string | BqrsEntityValue | undefined;
|
||||
let endpointType: EndpointType | undefined = undefined;
|
||||
|
||||
if (mode === Mode.Application) {
|
||||
@@ -48,7 +47,6 @@ export function decodeBqrsToMethods(
|
||||
libraryVersion,
|
||||
type,
|
||||
classification,
|
||||
endpointKindColumn,
|
||||
] = tuple as ApplicationModeTuple;
|
||||
} else {
|
||||
[
|
||||
@@ -60,7 +58,6 @@ export function decodeBqrsToMethods(
|
||||
supported,
|
||||
library,
|
||||
type,
|
||||
endpointKindColumn,
|
||||
] = tuple as FrameworkModeTuple;
|
||||
|
||||
classification = CallClassification.Unknown;
|
||||
@@ -71,18 +68,13 @@ export function decodeBqrsToMethods(
|
||||
}
|
||||
|
||||
if (definition.endpointTypeForEndpoint) {
|
||||
endpointType = definition.endpointTypeForEndpoint(
|
||||
{
|
||||
endpointType,
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
methodParameters,
|
||||
},
|
||||
typeof endpointKindColumn === "object"
|
||||
? endpointKindColumn.label
|
||||
: endpointKindColumn,
|
||||
);
|
||||
endpointType = definition.endpointTypeForEndpoint({
|
||||
endpointType,
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
methodParameters,
|
||||
});
|
||||
}
|
||||
|
||||
if (endpointType === undefined) {
|
||||
|
||||
@@ -174,14 +174,11 @@ export type ModelsAsDataLanguage = {
|
||||
* be determined by heuristics.
|
||||
* @param method The method to get the endpoint type for. The endpoint type can be undefined if the
|
||||
* query does not return an endpoint type.
|
||||
* @param endpointKind An optional column that may be provided by the query to help determine the
|
||||
* endpoint type.
|
||||
*/
|
||||
endpointTypeForEndpoint?: (
|
||||
method: Omit<MethodDefinition, "endpointType"> & {
|
||||
endpointType: EndpointType | undefined;
|
||||
},
|
||||
endpointKind: string | undefined,
|
||||
) => EndpointType | undefined;
|
||||
predicates: ModelsAsDataLanguagePredicates;
|
||||
modelGeneration?: ModelsAsDataLanguageModelGeneration;
|
||||
|
||||
@@ -4,26 +4,7 @@ import { EndpointType } from "../../method";
|
||||
|
||||
const memberTokenRegex = /^Member\[(.+)]$/;
|
||||
|
||||
// In Python, the type can contain both the package name and the type name.
|
||||
export function parsePythonType(type: string) {
|
||||
// The first part is always the package name. All remaining parts are the type
|
||||
// name.
|
||||
|
||||
const parts = type.split(".");
|
||||
const packageName = parts.shift() ?? "";
|
||||
|
||||
return {
|
||||
packageName,
|
||||
typeName: parts.join("."),
|
||||
};
|
||||
}
|
||||
|
||||
// The type name can also be specified in the type, so this will combine
|
||||
// the already parsed type name and the type name from the access path.
|
||||
export function parsePythonAccessPath(
|
||||
path: string,
|
||||
shortTypeName: string,
|
||||
): {
|
||||
export function parsePythonAccessPath(path: string): {
|
||||
typeName: string;
|
||||
methodName: string;
|
||||
endpointType: EndpointType;
|
||||
@@ -32,12 +13,8 @@ export function parsePythonAccessPath(
|
||||
const tokens = parseAccessPathTokens(path);
|
||||
|
||||
if (tokens.length === 0) {
|
||||
const typeName = shortTypeName.endsWith("!")
|
||||
? shortTypeName.slice(0, -1)
|
||||
: shortTypeName;
|
||||
|
||||
return {
|
||||
typeName,
|
||||
typeName: "",
|
||||
methodName: "",
|
||||
endpointType: EndpointType.Method,
|
||||
path: "",
|
||||
@@ -46,10 +23,6 @@ export function parsePythonAccessPath(
|
||||
|
||||
const typeParts = [];
|
||||
let endpointType = EndpointType.Function;
|
||||
// If a short type name was given and it doesn't end in a `!`, then this refers to a method.
|
||||
if (shortTypeName !== "" && !shortTypeName.endsWith("!")) {
|
||||
endpointType = EndpointType.Method;
|
||||
}
|
||||
|
||||
let remainingTokens: typeof tokens = [];
|
||||
|
||||
@@ -59,7 +32,6 @@ export function parsePythonAccessPath(
|
||||
if (memberMatch) {
|
||||
typeParts.push(memberMatch[1]);
|
||||
} else if (token.text === "Instance") {
|
||||
// Alternative way of specifying that this refers to a method.
|
||||
endpointType = EndpointType.Method;
|
||||
} else {
|
||||
remainingTokens = tokens.slice(i);
|
||||
@@ -68,22 +40,9 @@ export function parsePythonAccessPath(
|
||||
}
|
||||
|
||||
const methodName = typeParts.pop() ?? "";
|
||||
let typeName = typeParts.join(".");
|
||||
const typeName = typeParts.join(".");
|
||||
const remainingPath = remainingTokens.map((token) => token.text).join(".");
|
||||
|
||||
if (shortTypeName !== "") {
|
||||
if (shortTypeName.endsWith("!")) {
|
||||
// The actual type name is the name without the `!`.
|
||||
shortTypeName = shortTypeName.slice(0, -1);
|
||||
}
|
||||
|
||||
if (typeName !== "") {
|
||||
typeName = `${shortTypeName}.${typeName}`;
|
||||
} else {
|
||||
typeName = shortTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
methodName,
|
||||
typeName,
|
||||
@@ -92,59 +51,53 @@ export function parsePythonAccessPath(
|
||||
};
|
||||
}
|
||||
|
||||
export function parsePythonTypeAndPath(
|
||||
type: string,
|
||||
path: string,
|
||||
): {
|
||||
packageName: string;
|
||||
typeName: string;
|
||||
methodName: string;
|
||||
endpointType: EndpointType;
|
||||
path: string;
|
||||
} {
|
||||
const { packageName, typeName: shortTypeName } = parsePythonType(type);
|
||||
const {
|
||||
typeName,
|
||||
methodName,
|
||||
endpointType,
|
||||
path: remainingPath,
|
||||
} = parsePythonAccessPath(path, shortTypeName);
|
||||
|
||||
return {
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
endpointType,
|
||||
path: remainingPath,
|
||||
};
|
||||
}
|
||||
|
||||
export function pythonMethodSignature(typeName: string, methodName: string) {
|
||||
return `${typeName}#${methodName}`;
|
||||
}
|
||||
|
||||
export function pythonType(
|
||||
packageName: string,
|
||||
typeName: string,
|
||||
endpointType: EndpointType,
|
||||
) {
|
||||
if (typeName !== "" && packageName !== "") {
|
||||
return `${packageName}.${typeName}${endpointType === EndpointType.Function ? "!" : ""}`;
|
||||
}
|
||||
|
||||
return `${packageName}${typeName}`;
|
||||
}
|
||||
|
||||
export function pythonMethodPath(methodName: string) {
|
||||
if (methodName === "") {
|
||||
function pythonTypePath(typeName: string) {
|
||||
if (typeName === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return `Member[${methodName}]`;
|
||||
return typeName
|
||||
.split(".")
|
||||
.map((part) => `Member[${part}]`)
|
||||
.join(".");
|
||||
}
|
||||
|
||||
export function pythonPath(methodName: string, path: string) {
|
||||
const methodPath = pythonMethodPath(methodName);
|
||||
export function pythonMethodPath(
|
||||
typeName: string,
|
||||
methodName: string,
|
||||
endpointType: EndpointType,
|
||||
) {
|
||||
if (methodName === "") {
|
||||
return pythonTypePath(typeName);
|
||||
}
|
||||
|
||||
const typePath = pythonTypePath(typeName);
|
||||
|
||||
let result = typePath;
|
||||
if (typePath !== "" && endpointType === EndpointType.Method) {
|
||||
result += ".Instance";
|
||||
}
|
||||
|
||||
if (result !== "") {
|
||||
result += ".";
|
||||
}
|
||||
|
||||
result += `Member[${methodName}]`;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function pythonPath(
|
||||
typeName: string,
|
||||
methodName: string,
|
||||
endpointType: EndpointType,
|
||||
path: string,
|
||||
) {
|
||||
const methodPath = pythonMethodPath(typeName, methodName, endpointType);
|
||||
if (methodPath === "") {
|
||||
return path;
|
||||
}
|
||||
@@ -158,24 +111,7 @@ export function pythonPath(methodName: string, path: string) {
|
||||
|
||||
export function pythonEndpointType(
|
||||
method: Omit<MethodDefinition, "endpointType">,
|
||||
endpointKind: string | undefined,
|
||||
): EndpointType {
|
||||
switch (endpointKind) {
|
||||
case "Function":
|
||||
return EndpointType.Function;
|
||||
case "InstanceMethod":
|
||||
return EndpointType.Method;
|
||||
case "ClassMethod":
|
||||
return EndpointType.ClassMethod;
|
||||
case "StaticMethod":
|
||||
return EndpointType.StaticMethod;
|
||||
case "InitMethod":
|
||||
return EndpointType.Constructor;
|
||||
case "Class":
|
||||
return EndpointType.Class;
|
||||
}
|
||||
|
||||
// Legacy behavior for when the kind column is missing.
|
||||
if (
|
||||
method.methodParameters.startsWith("(self,") ||
|
||||
method.methodParameters === "(self)"
|
||||
@@ -184,12 +120,3 @@ export function pythonEndpointType(
|
||||
}
|
||||
return EndpointType.Function;
|
||||
}
|
||||
|
||||
export function hasPythonSelfArgument(endpointType: EndpointType): boolean {
|
||||
// Instance methods and class methods both use `Argument[self]` for the first parameter. The first
|
||||
// parameter after self is called `Argument[0]`.
|
||||
return (
|
||||
endpointType === EndpointType.Method ||
|
||||
endpointType === EndpointType.ClassMethod
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,48 +4,44 @@ import { Mode } from "../../shared/mode";
|
||||
import type { MethodArgument } from "../../method";
|
||||
import { EndpointType, getArgumentsList } from "../../method";
|
||||
import {
|
||||
hasPythonSelfArgument,
|
||||
parsePythonTypeAndPath,
|
||||
parsePythonAccessPath,
|
||||
pythonEndpointType,
|
||||
pythonMethodPath,
|
||||
pythonMethodSignature,
|
||||
pythonPath,
|
||||
pythonType,
|
||||
} from "./access-paths";
|
||||
|
||||
export const python: ModelsAsDataLanguage = {
|
||||
availableModes: [Mode.Framework],
|
||||
createMethodSignature: ({ typeName, methodName }) =>
|
||||
`${typeName}#${methodName}`,
|
||||
endpointTypeForEndpoint: (method, endpointKind) =>
|
||||
pythonEndpointType(method, endpointKind),
|
||||
endpointTypeForEndpoint: (method) => pythonEndpointType(method),
|
||||
predicates: {
|
||||
source: {
|
||||
extensiblePredicate: sharedExtensiblePredicates.source,
|
||||
supportedKinds: sharedKinds.source,
|
||||
supportedEndpointTypes: [
|
||||
EndpointType.Method,
|
||||
EndpointType.Function,
|
||||
EndpointType.Constructor,
|
||||
EndpointType.ClassMethod,
|
||||
EndpointType.StaticMethod,
|
||||
],
|
||||
supportedEndpointTypes: [EndpointType.Method, EndpointType.Function],
|
||||
// extensible predicate sourceModel(
|
||||
// string type, string path, string kind
|
||||
// );
|
||||
generateMethodDefinition: (method) => [
|
||||
pythonType(method.packageName, method.typeName, method.endpointType),
|
||||
pythonPath(method.methodName, method.output),
|
||||
method.packageName,
|
||||
pythonPath(
|
||||
method.typeName,
|
||||
method.methodName,
|
||||
method.endpointType,
|
||||
method.output,
|
||||
),
|
||||
method.kind,
|
||||
],
|
||||
readModeledMethod: (row) => {
|
||||
const packageName = row[0] as string;
|
||||
const {
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
endpointType,
|
||||
path: output,
|
||||
} = parsePythonTypeAndPath(row[0] as string, row[1] as string);
|
||||
} = parsePythonAccessPath(row[1] as string);
|
||||
return {
|
||||
type: "source",
|
||||
output,
|
||||
@@ -63,31 +59,30 @@ export const python: ModelsAsDataLanguage = {
|
||||
sink: {
|
||||
extensiblePredicate: sharedExtensiblePredicates.sink,
|
||||
supportedKinds: sharedKinds.sink,
|
||||
supportedEndpointTypes: [
|
||||
EndpointType.Method,
|
||||
EndpointType.Function,
|
||||
EndpointType.Constructor,
|
||||
EndpointType.ClassMethod,
|
||||
EndpointType.StaticMethod,
|
||||
],
|
||||
supportedEndpointTypes: [EndpointType.Method, EndpointType.Function],
|
||||
// extensible predicate sinkModel(
|
||||
// string type, string path, string kind
|
||||
// );
|
||||
generateMethodDefinition: (method) => {
|
||||
return [
|
||||
pythonType(method.packageName, method.typeName, method.endpointType),
|
||||
pythonPath(method.methodName, method.input),
|
||||
method.packageName,
|
||||
pythonPath(
|
||||
method.typeName,
|
||||
method.methodName,
|
||||
method.endpointType,
|
||||
method.input,
|
||||
),
|
||||
method.kind,
|
||||
];
|
||||
},
|
||||
readModeledMethod: (row) => {
|
||||
const packageName = row[0] as string;
|
||||
const {
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
endpointType,
|
||||
path: input,
|
||||
} = parsePythonTypeAndPath(row[0] as string, row[1] as string);
|
||||
} = parsePythonAccessPath(row[1] as string);
|
||||
return {
|
||||
type: "sink",
|
||||
input,
|
||||
@@ -105,26 +100,25 @@ export const python: ModelsAsDataLanguage = {
|
||||
summary: {
|
||||
extensiblePredicate: sharedExtensiblePredicates.summary,
|
||||
supportedKinds: sharedKinds.summary,
|
||||
supportedEndpointTypes: [
|
||||
EndpointType.Method,
|
||||
EndpointType.Function,
|
||||
EndpointType.Constructor,
|
||||
EndpointType.ClassMethod,
|
||||
EndpointType.StaticMethod,
|
||||
],
|
||||
supportedEndpointTypes: [EndpointType.Method, EndpointType.Function],
|
||||
// extensible predicate summaryModel(
|
||||
// string type, string path, string input, string output, string kind
|
||||
// );
|
||||
generateMethodDefinition: (method) => [
|
||||
pythonType(method.packageName, method.typeName, method.endpointType),
|
||||
pythonMethodPath(method.methodName),
|
||||
method.packageName,
|
||||
pythonMethodPath(
|
||||
method.typeName,
|
||||
method.methodName,
|
||||
method.endpointType,
|
||||
),
|
||||
method.input,
|
||||
method.output,
|
||||
method.kind,
|
||||
],
|
||||
readModeledMethod: (row) => {
|
||||
const { packageName, typeName, methodName, endpointType, path } =
|
||||
parsePythonTypeAndPath(row[0] as string, row[1] as string);
|
||||
const packageName = row[0] as string;
|
||||
const { typeName, methodName, endpointType, path } =
|
||||
parsePythonAccessPath(row[1] as string);
|
||||
if (path !== "") {
|
||||
throw new Error("Summary path must be a method");
|
||||
}
|
||||
@@ -150,13 +144,18 @@ export const python: ModelsAsDataLanguage = {
|
||||
// string type, string path, string kind
|
||||
// );
|
||||
generateMethodDefinition: (method) => [
|
||||
pythonType(method.packageName, method.typeName, method.endpointType),
|
||||
pythonMethodPath(method.methodName),
|
||||
method.packageName,
|
||||
pythonMethodPath(
|
||||
method.typeName,
|
||||
method.methodName,
|
||||
method.endpointType,
|
||||
),
|
||||
method.kind,
|
||||
],
|
||||
readModeledMethod: (row) => {
|
||||
const { packageName, typeName, methodName, endpointType, path } =
|
||||
parsePythonTypeAndPath(row[0] as string, row[1] as string);
|
||||
const packageName = row[0] as string;
|
||||
const { typeName, methodName, endpointType, path } =
|
||||
parsePythonAccessPath(row[1] as string);
|
||||
if (path !== "") {
|
||||
throw new Error("Neutral path must be a method");
|
||||
}
|
||||
@@ -173,46 +172,25 @@ export const python: ModelsAsDataLanguage = {
|
||||
};
|
||||
},
|
||||
},
|
||||
type: {
|
||||
extensiblePredicate: "typeModel",
|
||||
// extensible predicate typeModel(string type1, string type2, string path);
|
||||
generateMethodDefinition: (method) => [
|
||||
method.relatedTypeName,
|
||||
pythonType(method.packageName, method.typeName, method.endpointType),
|
||||
pythonPath(method.methodName, method.path),
|
||||
],
|
||||
readModeledMethod: (row) => {
|
||||
const { packageName, typeName, methodName, endpointType, path } =
|
||||
parsePythonTypeAndPath(row[1] as string, row[2] as string);
|
||||
|
||||
return {
|
||||
type: "type",
|
||||
relatedTypeName: row[0] as string,
|
||||
path,
|
||||
signature: pythonMethodSignature(typeName, methodName),
|
||||
endpointType,
|
||||
packageName,
|
||||
typeName,
|
||||
methodName,
|
||||
methodParameters: "",
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
getArgumentOptions: (method) => {
|
||||
// Argument and Parameter are equivalent in Python, but we'll use Argument in the model editor
|
||||
const argumentsList = getArgumentsList(method.methodParameters).map(
|
||||
(argument, index): MethodArgument => {
|
||||
if (hasPythonSelfArgument(method.endpointType) && index === 0) {
|
||||
if (
|
||||
method.endpointType === EndpointType.Method &&
|
||||
argument === "self" &&
|
||||
index === 0
|
||||
) {
|
||||
return {
|
||||
path: "Argument[self]",
|
||||
label: `Argument[self]: ${argument}`,
|
||||
label: "Argument[self]: self",
|
||||
};
|
||||
}
|
||||
|
||||
// If this endpoint has a self argument, self does not count as an argument index so we
|
||||
// If this is a method, self does not count as an argument index, so we
|
||||
// should start at 0 for the second argument
|
||||
if (hasPythonSelfArgument(method.endpointType)) {
|
||||
if (method.endpointType === EndpointType.Method) {
|
||||
index -= 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@ export enum EndpointType {
|
||||
Method = "method",
|
||||
Constructor = "constructor",
|
||||
Function = "function",
|
||||
StaticMethod = "staticMethod",
|
||||
ClassMethod = "classMethod",
|
||||
}
|
||||
|
||||
export interface MethodDefinition {
|
||||
|
||||
@@ -17,7 +17,6 @@ export type Query = {
|
||||
* - libraryVersion: the version of the library that contains the external API. This is a string and can be empty if the version cannot be determined.
|
||||
* - type: the modeled kind of the method, either "sink", "source", "summary", or "neutral"
|
||||
* - classification: the classification of the use of the method, either "source", "test", "generated", or "unknown"
|
||||
* - kind: the kind of the endpoint, language-specific, e.g. "method" or "function"
|
||||
*/
|
||||
applicationModeQuery: string;
|
||||
/**
|
||||
@@ -33,7 +32,6 @@ export type Query = {
|
||||
* - supported: whether this method is modeled. This should be a string representation of a boolean to satify the result pattern for a problem query.
|
||||
* - libraryName: the name of the file or library that contains the method. This is a string and usually the basename of a file.
|
||||
* - type: the modeled kind of the method, either "sink", "source", "summary", or "neutral"
|
||||
* - kind: the kind of the endpoint, language-specific, e.g. "method" or "function"
|
||||
*/
|
||||
frameworkModeQuery: string;
|
||||
dependencies?: {
|
||||
@@ -52,7 +50,6 @@ export type ApplicationModeTuple = [
|
||||
string,
|
||||
ModeledMethodType,
|
||||
CallClassification,
|
||||
string | BqrsEntityValue | undefined,
|
||||
];
|
||||
|
||||
export type FrameworkModeTuple = [
|
||||
@@ -64,5 +61,4 @@ export type FrameworkModeTuple = [
|
||||
boolean,
|
||||
string,
|
||||
ModeledMethodType,
|
||||
string | BqrsEntityValue | undefined,
|
||||
];
|
||||
|
||||
@@ -9,16 +9,20 @@ export const SUPPORTED_LANGUAGES: QueryLanguage[] = [
|
||||
QueryLanguage.Java,
|
||||
QueryLanguage.CSharp,
|
||||
QueryLanguage.Ruby,
|
||||
QueryLanguage.Python,
|
||||
];
|
||||
|
||||
export function isSupportedLanguage(
|
||||
language: QueryLanguage,
|
||||
_modelConfig: ModelConfig,
|
||||
modelConfig: ModelConfig,
|
||||
) {
|
||||
if (SUPPORTED_LANGUAGES.includes(language)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (language === QueryLanguage.Python) {
|
||||
// Python is only enabled when the config setting is set
|
||||
return modelConfig.enablePython;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,6 @@ function mapVariantAnalysisDtoToDto(
|
||||
): VariantAnalysisDto {
|
||||
return {
|
||||
id: variantAnalysis.id,
|
||||
controllerRepo: {
|
||||
id: variantAnalysis.controllerRepo.id,
|
||||
fullName: variantAnalysis.controllerRepo.fullName,
|
||||
private: variantAnalysis.controllerRepo.private,
|
||||
},
|
||||
query: {
|
||||
name: variantAnalysis.query.name,
|
||||
filePath: variantAnalysis.query.filePath,
|
||||
|
||||
@@ -48,12 +48,12 @@ function mapVariantAnalysisToDomainModel(
|
||||
): VariantAnalysis {
|
||||
return {
|
||||
id: variantAnalysis.id,
|
||||
controllerRepo: {
|
||||
id: variantAnalysis.controllerRepo.id,
|
||||
fullName: variantAnalysis.controllerRepo.fullName,
|
||||
private: variantAnalysis.controllerRepo.private,
|
||||
},
|
||||
language: mapQueryLanguageToDomainModel(variantAnalysis.query.language),
|
||||
controllerRepo: {
|
||||
id: 0,
|
||||
fullName: "",
|
||||
private: false,
|
||||
},
|
||||
query: {
|
||||
name: variantAnalysis.query.name,
|
||||
filePath: variantAnalysis.query.filePath,
|
||||
|
||||
@@ -15,11 +15,6 @@ export interface QueryHistoryVariantAnalysisDto {
|
||||
|
||||
export interface VariantAnalysisDto {
|
||||
id: number;
|
||||
controllerRepo: {
|
||||
id: number;
|
||||
fullName: string;
|
||||
private: boolean;
|
||||
};
|
||||
query: {
|
||||
name: string;
|
||||
filePath: string;
|
||||
|
||||
@@ -544,16 +544,9 @@ export async function generateEvalLogSummaries(
|
||||
await cliServer.generateJsonLogSummary(log, jsonSummary);
|
||||
|
||||
if (humanReadableSummary !== undefined) {
|
||||
progress(progressUpdate(3, 3, "Generating summary symbols file"));
|
||||
summarySymbols = outputDir.evalLogSummarySymbolsPath;
|
||||
if (
|
||||
!(await cliServer.cliConstraints.supportsGenerateSummarySymbolMap())
|
||||
) {
|
||||
// We're using an old CLI that cannot generate the summary symbols file while generating the
|
||||
// human-readable log summary. As a fallback, create it by parsing the human-readable
|
||||
// summary.
|
||||
progress(progressUpdate(3, 3, "Generating summary symbols file"));
|
||||
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
|
||||
}
|
||||
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,28 +15,28 @@ export async function extractRawResults(
|
||||
const bqrsInfo = await cliServer.bqrsInfo(filePath);
|
||||
const resultSets = bqrsInfo["result-sets"];
|
||||
|
||||
if (resultSets.length < 1) {
|
||||
if (resultSets.length === 0) {
|
||||
throw new Error("No result sets found in results file.");
|
||||
}
|
||||
if (resultSets.length > 1) {
|
||||
void logger.log(
|
||||
"Multiple result sets found in results file. Only one will be used.",
|
||||
"Multiple result sets found in results file. Using the first one.",
|
||||
);
|
||||
}
|
||||
|
||||
// Always prefer #select over any other result set. #select is usually the result the user
|
||||
// wants to see since it contains the outer #select.
|
||||
// Prefer `#select` result set; otherwise, use the first available set.
|
||||
const schema =
|
||||
resultSets.find((resultSet) => resultSet.name === SELECT_TABLE_NAME) ??
|
||||
resultSets[0];
|
||||
resultSets.find((r) => r.name === SELECT_TABLE_NAME) ?? resultSets[0];
|
||||
|
||||
const chunk = await cliServer.bqrsDecode(filePath, schema.name, {
|
||||
pageSize: MAX_RAW_RESULTS,
|
||||
});
|
||||
|
||||
const resultSet = bqrsToResultSet(schema, chunk);
|
||||
|
||||
const capped = !!chunk.next;
|
||||
|
||||
return { resultSet, fileLinkPrefix, sourceLocationPrefix, capped };
|
||||
return {
|
||||
resultSet,
|
||||
fileLinkPrefix,
|
||||
sourceLocationPrefix,
|
||||
capped: !!chunk.next,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ async function exportVariantAnalysisAnalysisResults(
|
||||
expectedAnalysesResultsCount: number,
|
||||
exportFormat: "gist" | "local",
|
||||
commandManager: AppCommandManager,
|
||||
credentials: Credentials,
|
||||
_credentials: Credentials,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
) {
|
||||
@@ -191,7 +191,6 @@ async function exportVariantAnalysisAnalysisResults(
|
||||
markdownFiles,
|
||||
exportFormat,
|
||||
commandManager,
|
||||
credentials,
|
||||
progress,
|
||||
token,
|
||||
);
|
||||
@@ -236,7 +235,6 @@ async function exportResults(
|
||||
markdownFiles: MarkdownFile[],
|
||||
exportFormat: "gist" | "local",
|
||||
commandManager: AppCommandManager,
|
||||
credentials: Credentials,
|
||||
progress?: ProgressCallback,
|
||||
token?: CancellationToken,
|
||||
) {
|
||||
@@ -249,7 +247,6 @@ async function exportResults(
|
||||
description,
|
||||
markdownFiles,
|
||||
commandManager,
|
||||
credentials,
|
||||
progress,
|
||||
token,
|
||||
);
|
||||
@@ -268,7 +265,6 @@ async function exportToGist(
|
||||
description: string,
|
||||
markdownFiles: MarkdownFile[],
|
||||
commandManager: AppCommandManager,
|
||||
credentials: Credentials,
|
||||
progress?: ProgressCallback,
|
||||
token?: CancellationToken,
|
||||
) {
|
||||
@@ -291,7 +287,7 @@ async function exportToGist(
|
||||
{} as { [key: string]: { content: string } },
|
||||
);
|
||||
|
||||
const gistUrl = await createGist(credentials, description, gistFiles);
|
||||
const gistUrl = await createGist(description, gistFiles);
|
||||
if (gistUrl) {
|
||||
// This needs to use .then to ensure we aren't keeping the progress notification open. We shouldn't await the
|
||||
// "Open gist" button click.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { OctokitResponse } from "@octokit/types/dist-types";
|
||||
import type { Credentials } from "../../common/authentication";
|
||||
import { getGitHubInstanceUrl } from "../../config";
|
||||
import type { VariantAnalysisSubmission } from "../shared/variant-analysis";
|
||||
import type {
|
||||
VariantAnalysis,
|
||||
@@ -7,84 +6,142 @@ import type {
|
||||
VariantAnalysisSubmissionRequest,
|
||||
} from "./variant-analysis";
|
||||
import type { Repository } from "./repository";
|
||||
import { extLogger } from "../../common/logging/vscode";
|
||||
|
||||
export async function submitVariantAnalysis(
|
||||
credentials: Credentials,
|
||||
submissionDetails: VariantAnalysisSubmission,
|
||||
): Promise<VariantAnalysis> {
|
||||
const octokit = await credentials.getOctokit();
|
||||
|
||||
const { actionRepoRef, language, pack, databases, controllerRepoId } =
|
||||
submissionDetails;
|
||||
|
||||
const data: VariantAnalysisSubmissionRequest = {
|
||||
action_repo_ref: actionRepoRef,
|
||||
language,
|
||||
query_pack: pack,
|
||||
repositories: databases.repositories,
|
||||
repository_lists: databases.repositoryLists,
|
||||
repository_owners: databases.repositoryOwners,
|
||||
};
|
||||
|
||||
const response: OctokitResponse<VariantAnalysis> = await octokit.request(
|
||||
"POST /repositories/:controllerRepoId/code-scanning/codeql/variant-analyses",
|
||||
{
|
||||
controllerRepoId,
|
||||
data,
|
||||
},
|
||||
);
|
||||
|
||||
return response.data;
|
||||
function getOctokitBaseUrl(): string {
|
||||
let apiUrl = getGitHubInstanceUrl().toString();
|
||||
if (apiUrl.endsWith("/")) {
|
||||
apiUrl = apiUrl.slice(0, -1);
|
||||
}
|
||||
if (apiUrl.startsWith("https://")) {
|
||||
apiUrl = apiUrl.replace("https://", "http://");
|
||||
}
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
export async function submitVariantAnalysis(
|
||||
submissionDetails: VariantAnalysisSubmission,
|
||||
): Promise<VariantAnalysis> {
|
||||
try {
|
||||
console.log("Getting base URL...");
|
||||
const baseUrl = getOctokitBaseUrl();
|
||||
void extLogger.log(`Base URL: ${baseUrl}`);
|
||||
|
||||
const { actionRepoRef, language, pack, databases, controllerRepoId } =
|
||||
submissionDetails;
|
||||
|
||||
const data: VariantAnalysisSubmissionRequest = {
|
||||
action_repo_ref: actionRepoRef,
|
||||
language,
|
||||
query_pack: pack,
|
||||
repositories: databases.repositories,
|
||||
repository_lists: databases.repositoryLists,
|
||||
repository_owners: databases.repositoryOwners,
|
||||
};
|
||||
|
||||
void extLogger.log(
|
||||
`Sending fetch request with data: ${JSON.stringify(data)}`,
|
||||
);
|
||||
|
||||
void extLogger.log(
|
||||
`Fetch request URL: ${baseUrl}/repositories/${controllerRepoId}/code-scanning/codeql/variant-analyses`,
|
||||
);
|
||||
|
||||
const response = await fetch(
|
||||
`${baseUrl}/repositories/${controllerRepoId}/code-scanning/codeql/variant-analyses`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
},
|
||||
);
|
||||
|
||||
void extLogger.log(`Response status: ${response.status}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Error submitting variant analysis: ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
const responseData = await response.json();
|
||||
void extLogger.log(`Response data: ${responseData}`);
|
||||
|
||||
return responseData;
|
||||
} catch (error) {
|
||||
void extLogger.log(`Error: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
export async function getVariantAnalysis(
|
||||
credentials: Credentials,
|
||||
controllerRepoId: number,
|
||||
variantAnalysisId: number,
|
||||
): Promise<VariantAnalysis> {
|
||||
const octokit = await credentials.getOctokit();
|
||||
const baseUrl = getOctokitBaseUrl();
|
||||
|
||||
const response: OctokitResponse<VariantAnalysis> = await octokit.request(
|
||||
"GET /repositories/:controllerRepoId/code-scanning/codeql/variant-analyses/:variantAnalysisId",
|
||||
const response = await fetch(
|
||||
`${baseUrl}/repositories/${controllerRepoId}/code-scanning/codeql/variant-analyses/${variantAnalysisId}`,
|
||||
{
|
||||
controllerRepoId,
|
||||
variantAnalysisId,
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return response.data;
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error getting variant analysis: ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function getVariantAnalysisRepo(
|
||||
credentials: Credentials,
|
||||
controllerRepoId: number,
|
||||
variantAnalysisId: number,
|
||||
repoId: number,
|
||||
): Promise<VariantAnalysisRepoTask> {
|
||||
const octokit = await credentials.getOctokit();
|
||||
const baseUrl = getOctokitBaseUrl();
|
||||
|
||||
const response: OctokitResponse<VariantAnalysisRepoTask> =
|
||||
await octokit.request(
|
||||
"GET /repositories/:controllerRepoId/code-scanning/codeql/variant-analyses/:variantAnalysisId/repositories/:repoId",
|
||||
{
|
||||
controllerRepoId,
|
||||
variantAnalysisId,
|
||||
repoId,
|
||||
const response = await fetch(
|
||||
`${baseUrl}/repositories/${controllerRepoId}/code-scanning/codeql/variant-analyses/${variantAnalysisId}/repositories/${repoId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return response.data;
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Error getting variant analysis repo: ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function getRepositoryFromNwo(
|
||||
credentials: Credentials,
|
||||
owner: string,
|
||||
repo: string,
|
||||
): Promise<Repository> {
|
||||
const octokit = await credentials.getOctokit();
|
||||
const baseUrl = getOctokitBaseUrl();
|
||||
|
||||
const response = await octokit.rest.repos.get({ owner, repo });
|
||||
return response.data as Repository;
|
||||
const response = await fetch(`${baseUrl}/repos/${owner}/${repo}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error getting repository: ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,22 +149,29 @@ export async function getRepositoryFromNwo(
|
||||
* Returns the URL of the created gist.
|
||||
*/
|
||||
export async function createGist(
|
||||
credentials: Credentials,
|
||||
description: string,
|
||||
files: { [key: string]: { content: string } },
|
||||
): Promise<string | undefined> {
|
||||
const octokit = await credentials.getOctokit();
|
||||
const response = await octokit.request("POST /gists", {
|
||||
description,
|
||||
files,
|
||||
public: false,
|
||||
const baseUrl = getOctokitBaseUrl();
|
||||
|
||||
const response = await fetch(`${baseUrl}/gists`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
description,
|
||||
files,
|
||||
public: false,
|
||||
}),
|
||||
});
|
||||
if (response.status >= 300) {
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Error exporting variant analysis results: ${response.status} ${
|
||||
response?.data || ""
|
||||
}`,
|
||||
`Error creating gist: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response.data.html_url;
|
||||
|
||||
const data = await response.json();
|
||||
return data.html_url;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { CancellationToken } from "vscode";
|
||||
import { Uri, window } from "vscode";
|
||||
import { Uri } from "vscode";
|
||||
import { join, sep, basename, relative } from "path";
|
||||
import { dump, load } from "js-yaml";
|
||||
import { copy, writeFile, readFile, mkdirp } from "fs-extra";
|
||||
@@ -7,26 +7,17 @@ import type { DirectoryResult } from "tmp-promise";
|
||||
import { dir, tmpName } from "tmp-promise";
|
||||
import { tmpDir } from "../tmp-dir";
|
||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||
import type { Credentials } from "../common/authentication";
|
||||
import type { CodeQLCliServer } from "../codeql-cli/cli";
|
||||
import { extLogger } from "../common/logging/vscode";
|
||||
import {
|
||||
getActionBranch,
|
||||
getRemoteControllerRepo,
|
||||
setRemoteControllerRepo,
|
||||
} from "../config";
|
||||
import { getActionBranch } from "../config";
|
||||
import type { ProgressCallback } from "../common/vscode/progress";
|
||||
import { UserCancellationException } from "../common/vscode/progress";
|
||||
import type { RequestError } from "@octokit/types/dist-types";
|
||||
import type { QueryMetadata } from "../common/interface-types";
|
||||
import { getErrorMessage, REPO_REGEX } from "../common/helpers-pure";
|
||||
import { getRepositoryFromNwo } from "./gh-api/gh-api-client";
|
||||
import type { RepositorySelection } from "./repository-selection";
|
||||
import {
|
||||
getRepositorySelection,
|
||||
isValidSelection,
|
||||
} from "./repository-selection";
|
||||
import type { Repository } from "./shared/repository";
|
||||
import type { DbManager } from "../databases/db-manager";
|
||||
import {
|
||||
getQlPackFilePath,
|
||||
@@ -285,13 +276,11 @@ interface PreparedRemoteQuery {
|
||||
base64Pack: string;
|
||||
modelPacks: ModelPackDetails[];
|
||||
repoSelection: RepositorySelection;
|
||||
controllerRepo: Repository;
|
||||
queryStartTime: number;
|
||||
}
|
||||
|
||||
export async function prepareRemoteQueryRun(
|
||||
cliServer: CodeQLCliServer,
|
||||
credentials: Credentials,
|
||||
qlPackDetails: QlPackDetails,
|
||||
progress: ProgressCallback,
|
||||
token: CancellationToken,
|
||||
@@ -322,8 +311,6 @@ export async function prepareRemoteQueryRun(
|
||||
message: "Determining controller repo",
|
||||
});
|
||||
|
||||
const controllerRepo = await getControllerRepo(credentials);
|
||||
|
||||
progress({
|
||||
maxStep: 4,
|
||||
step: 3,
|
||||
@@ -367,7 +354,6 @@ export async function prepareRemoteQueryRun(
|
||||
base64Pack: generatedPack.base64Pack,
|
||||
modelPacks: generatedPack.modelPacks,
|
||||
repoSelection,
|
||||
controllerRepo,
|
||||
queryStartTime,
|
||||
};
|
||||
}
|
||||
@@ -494,84 +480,6 @@ export function getQueryName(
|
||||
return queryMetadata?.name ?? basename(queryFilePath);
|
||||
}
|
||||
|
||||
export async function getControllerRepo(
|
||||
credentials: Credentials,
|
||||
): Promise<Repository> {
|
||||
// Get the controller repo from the config, if it exists.
|
||||
// If it doesn't exist, prompt the user to enter it, check
|
||||
// whether the repo exists, and save the nwo to the config.
|
||||
|
||||
let shouldSetControllerRepo = false;
|
||||
let controllerRepoNwo: string | undefined;
|
||||
controllerRepoNwo = getRemoteControllerRepo();
|
||||
if (!controllerRepoNwo || !REPO_REGEX.test(controllerRepoNwo)) {
|
||||
void extLogger.log(
|
||||
controllerRepoNwo
|
||||
? "Invalid controller repository name."
|
||||
: "No controller repository defined.",
|
||||
);
|
||||
controllerRepoNwo = await window.showInputBox({
|
||||
title:
|
||||
"Controller repository in which to run GitHub Actions workflows for variant analyses",
|
||||
placeHolder: "<owner>/<repo>",
|
||||
prompt:
|
||||
"Enter the name of a GitHub repository in the format <owner>/<repo>. You can change this in the extension settings.",
|
||||
ignoreFocusOut: true,
|
||||
});
|
||||
if (!controllerRepoNwo) {
|
||||
throw new UserCancellationException("No controller repository entered.");
|
||||
} else if (!REPO_REGEX.test(controllerRepoNwo)) {
|
||||
// Check if user entered invalid input
|
||||
throw new UserCancellationException(
|
||||
"Invalid repository format. Must be a valid GitHub repository in the format <owner>/<repo>.",
|
||||
);
|
||||
}
|
||||
|
||||
shouldSetControllerRepo = true;
|
||||
}
|
||||
|
||||
void extLogger.log(`Using controller repository: ${controllerRepoNwo}`);
|
||||
const controllerRepo = await getControllerRepoFromApi(
|
||||
credentials,
|
||||
controllerRepoNwo,
|
||||
);
|
||||
|
||||
if (shouldSetControllerRepo) {
|
||||
void extLogger.log(
|
||||
`Setting the controller repository as: ${controllerRepoNwo}`,
|
||||
);
|
||||
await setRemoteControllerRepo(controllerRepoNwo);
|
||||
}
|
||||
|
||||
return controllerRepo;
|
||||
}
|
||||
|
||||
async function getControllerRepoFromApi(
|
||||
credentials: Credentials,
|
||||
nwo: string,
|
||||
): Promise<Repository> {
|
||||
const [owner, repo] = nwo.split("/");
|
||||
try {
|
||||
const controllerRepo = await getRepositoryFromNwo(credentials, owner, repo);
|
||||
void extLogger.log(`Controller repository ID: ${controllerRepo.id}`);
|
||||
return {
|
||||
id: controllerRepo.id,
|
||||
fullName: controllerRepo.full_name,
|
||||
private: controllerRepo.private,
|
||||
};
|
||||
} catch (e) {
|
||||
if ((e as RequestError).status === 404) {
|
||||
throw new Error(`Controller repository "${owner}/${repo}" not found`);
|
||||
} else {
|
||||
throw new Error(
|
||||
`Error getting controller repository "${owner}/${repo}": ${getErrorMessage(
|
||||
e,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeWorkspaceRefs(qlpack: QlPackFile) {
|
||||
if (!qlpack.dependencies) {
|
||||
return;
|
||||
|
||||
@@ -373,16 +373,19 @@ export class VariantAnalysisManager
|
||||
);
|
||||
}
|
||||
|
||||
// log to extLogger
|
||||
void this.app.logger.log(
|
||||
`Running variant analysis with query: ${queryName}, language: ${variantAnalysisLanguage}`,
|
||||
);
|
||||
|
||||
const {
|
||||
actionBranch,
|
||||
base64Pack,
|
||||
modelPacks,
|
||||
repoSelection,
|
||||
controllerRepo,
|
||||
queryStartTime,
|
||||
} = await prepareRemoteQueryRun(
|
||||
this.cliServer,
|
||||
this.app.credentials,
|
||||
qlPackDetails,
|
||||
progress,
|
||||
token,
|
||||
@@ -399,12 +402,15 @@ export class VariantAnalysisManager
|
||||
count: qlPackDetails.queryFiles.length,
|
||||
};
|
||||
|
||||
// log that submitting
|
||||
void this.app.logger.log("Submitting variant analysis");
|
||||
|
||||
const variantAnalysisSubmission: VariantAnalysisSubmission = {
|
||||
startTime: queryStartTime,
|
||||
actionRepoRef: actionBranch,
|
||||
controllerRepoId: controllerRepo.id,
|
||||
language: variantAnalysisLanguage,
|
||||
pack: base64Pack,
|
||||
controllerRepoId: 0,
|
||||
query: {
|
||||
name: queryName,
|
||||
filePath: firstQueryFile,
|
||||
@@ -422,7 +428,6 @@ export class VariantAnalysisManager
|
||||
let variantAnalysisResponse: ApiVariantAnalysis;
|
||||
try {
|
||||
variantAnalysisResponse = await submitVariantAnalysis(
|
||||
this.app.credentials,
|
||||
variantAnalysisSubmission,
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
@@ -431,9 +436,17 @@ export class VariantAnalysisManager
|
||||
e instanceof RequestError &&
|
||||
handleRequestError(e, this.config.githubUrl, this.app.logger)
|
||||
) {
|
||||
// log
|
||||
void this.app.logger.log(
|
||||
`Error submitting variant analysis: ${getErrorMessage(e)}`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// throwing
|
||||
void this.app.logger.log(
|
||||
`Error submitting variant analysis: ${getErrorMessage(e)}`,
|
||||
);
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -806,8 +819,7 @@ export class VariantAnalysisManager
|
||||
let repoTask: VariantAnalysisRepositoryTask;
|
||||
try {
|
||||
const repoTaskResponse = await getVariantAnalysisRepo(
|
||||
this.app.credentials,
|
||||
variantAnalysis.controllerRepo.id,
|
||||
0,
|
||||
variantAnalysis.id,
|
||||
scannedRepo.repository.id,
|
||||
);
|
||||
|
||||
@@ -62,7 +62,6 @@ export class VariantAnalysisMonitor extends DisposableObject {
|
||||
try {
|
||||
await this._monitorVariantAnalysis(
|
||||
variantAnalysis.id,
|
||||
variantAnalysis.controllerRepo.id,
|
||||
variantAnalysis.executionStartTime,
|
||||
variantAnalysis.query.name,
|
||||
variantAnalysis.language,
|
||||
@@ -74,7 +73,6 @@ export class VariantAnalysisMonitor extends DisposableObject {
|
||||
|
||||
private async _monitorVariantAnalysis(
|
||||
variantAnalysisId: number,
|
||||
controllerRepoId: number,
|
||||
executionStartTime: number,
|
||||
queryName: string,
|
||||
language: QueryLanguage,
|
||||
@@ -97,11 +95,7 @@ export class VariantAnalysisMonitor extends DisposableObject {
|
||||
|
||||
let variantAnalysisSummary: ApiVariantAnalysis;
|
||||
try {
|
||||
variantAnalysisSummary = await getVariantAnalysis(
|
||||
this.app.credentials,
|
||||
controllerRepoId,
|
||||
variantAnalysisId,
|
||||
);
|
||||
variantAnalysisSummary = await getVariantAnalysis(0, variantAnalysisId);
|
||||
} catch (e) {
|
||||
const errorMessage = getErrorMessage(e);
|
||||
|
||||
|
||||
@@ -12,18 +12,6 @@ const ShowPathsLink = styled(VSCodeLink)`
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
const Label = styled.span`
|
||||
color: var(--vscode-descriptionForeground);
|
||||
margin-left: 10px;
|
||||
`;
|
||||
|
||||
function getShortestPathLength(codeFlows: CodeFlow[]): number {
|
||||
const allPathLengths = codeFlows
|
||||
.map((codeFlow) => codeFlow.threadFlows.length)
|
||||
.flat();
|
||||
return Math.min(...allPathLengths);
|
||||
}
|
||||
|
||||
export type CodePathsProps = {
|
||||
codeFlows: CodeFlow[];
|
||||
ruleDescription: string;
|
||||
@@ -52,7 +40,6 @@ export const CodePaths = ({
|
||||
return (
|
||||
<>
|
||||
<ShowPathsLink onClick={onShowPathsClick}>Show paths</ShowPathsLink>
|
||||
<Label>(Shortest: {getShortestPathLength(codeFlows)})</Label>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -24,12 +24,6 @@ describe(CodePaths.name, () => {
|
||||
expect(screen.getByText("Show paths")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders shortest path for code flows", () => {
|
||||
render();
|
||||
|
||||
expect(screen.getByText("(Shortest: 1)")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("posts extension message when 'show paths' link clicked", async () => {
|
||||
render();
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@ import type {
|
||||
ToCompareViewMessage,
|
||||
SetComparisonsMessage,
|
||||
SetComparisonQueryInfoMessage,
|
||||
UserSettings,
|
||||
} from "../../common/interface-types";
|
||||
import { DEFAULT_USER_SETTINGS } from "../../common/interface-types";
|
||||
import CompareSelector from "./CompareSelector";
|
||||
import { vscode } from "../vscode-api";
|
||||
import CompareTable from "./CompareTable";
|
||||
@@ -33,9 +31,6 @@ export function Compare(_: Record<string, never>): React.JSX.Element {
|
||||
const [comparison, setComparison] = useState<SetComparisonsMessage | null>(
|
||||
null,
|
||||
);
|
||||
const [userSettings, setUserSettings] = useState<UserSettings>(
|
||||
DEFAULT_USER_SETTINGS,
|
||||
);
|
||||
|
||||
const message = comparison?.message || "Empty comparison";
|
||||
const hasRows =
|
||||
@@ -53,9 +48,6 @@ export function Compare(_: Record<string, never>): React.JSX.Element {
|
||||
case "setComparisons":
|
||||
setComparison(msg);
|
||||
break;
|
||||
case "setUserSettings":
|
||||
setUserSettings(msg.userSettings);
|
||||
break;
|
||||
default:
|
||||
assertNever(msg);
|
||||
}
|
||||
@@ -93,7 +85,6 @@ export function Compare(_: Record<string, never>): React.JSX.Element {
|
||||
<CompareTable
|
||||
queryInfo={queryInfo}
|
||||
comparison={comparison}
|
||||
userSettings={userSettings}
|
||||
></CompareTable>
|
||||
) : (
|
||||
<Message>{message}</Message>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type {
|
||||
SetComparisonQueryInfoMessage,
|
||||
SetComparisonsMessage,
|
||||
UserSettings,
|
||||
} from "../../common/interface-types";
|
||||
import { className } from "../results/result-table-utils";
|
||||
import { vscode } from "../vscode-api";
|
||||
@@ -13,7 +12,6 @@ import { InterpretedCompareResultTable } from "./InterpretedCompareResultTable";
|
||||
interface Props {
|
||||
queryInfo: SetComparisonQueryInfoMessage;
|
||||
comparison: SetComparisonsMessage;
|
||||
userSettings: UserSettings;
|
||||
}
|
||||
|
||||
const OpenButton = styled(TextButton)`
|
||||
@@ -31,11 +29,7 @@ const Table = styled.table`
|
||||
}
|
||||
`;
|
||||
|
||||
export default function CompareTable({
|
||||
queryInfo,
|
||||
comparison,
|
||||
userSettings,
|
||||
}: Props) {
|
||||
export default function CompareTable({ queryInfo, comparison }: Props) {
|
||||
const result = comparison.result!;
|
||||
|
||||
async function openQuery(kind: "from" | "to") {
|
||||
@@ -84,7 +78,6 @@ export default function CompareTable({
|
||||
{result.kind === "interpreted" && (
|
||||
<InterpretedCompareResultTable
|
||||
results={result.from}
|
||||
userSettings={userSettings}
|
||||
databaseUri={queryInfo.databaseUri}
|
||||
sourceLocationPrefix={result.sourceLocationPrefix}
|
||||
/>
|
||||
@@ -103,7 +96,6 @@ export default function CompareTable({
|
||||
{result.kind === "interpreted" && (
|
||||
<InterpretedCompareResultTable
|
||||
results={result.to}
|
||||
userSettings={userSettings}
|
||||
databaseUri={queryInfo.databaseUri}
|
||||
sourceLocationPrefix={result.sourceLocationPrefix}
|
||||
/>
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
import type { Result, Run } from "sarif";
|
||||
import type { Result } from "sarif";
|
||||
import { AlertTable } from "../results/AlertTable";
|
||||
import type { UserSettings } from "../../common/interface-types";
|
||||
|
||||
type Props = {
|
||||
results: Result[];
|
||||
databaseUri: string;
|
||||
sourceLocationPrefix: string;
|
||||
run?: Run;
|
||||
userSettings: UserSettings;
|
||||
};
|
||||
|
||||
export const InterpretedCompareResultTable = ({
|
||||
results,
|
||||
databaseUri,
|
||||
sourceLocationPrefix,
|
||||
userSettings,
|
||||
}: Props) => {
|
||||
return (
|
||||
<AlertTable
|
||||
results={results}
|
||||
userSettings={userSettings}
|
||||
databaseUri={databaseUri}
|
||||
sourceLocationPrefix={sourceLocationPrefix}
|
||||
header={
|
||||
<thead>
|
||||
<tr>
|
||||
<th colSpan={2}></th>
|
||||
<th className={`vscode-codeql__alert-message-cell`} colSpan={4}>
|
||||
<th className={`vscode-codeql__alert-message-cell`} colSpan={3}>
|
||||
Message
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Location, Result, Run } from "sarif";
|
||||
import type { Location, Result } from "sarif";
|
||||
import type {
|
||||
PathNode,
|
||||
Result as ResultKeysResult,
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
import { getPath, getPathNode, getResult, keyToString } from "./result-keys";
|
||||
import { className, jumpToLocation } from "./result-table-utils";
|
||||
import { onNavigation } from "./navigation";
|
||||
import type { NavigateMsg, UserSettings } from "../../common/interface-types";
|
||||
import type { NavigateMsg } from "../../common/interface-types";
|
||||
import { NavigationDirection } from "../../common/interface-types";
|
||||
import { isNoLocation, parseSarifLocation } from "../../common/sarif-utils";
|
||||
import { sendTelemetry } from "../common/telemetry";
|
||||
@@ -21,8 +21,6 @@ type Props = {
|
||||
results: Result[];
|
||||
databaseUri: string;
|
||||
sourceLocationPrefix: string;
|
||||
run?: Run;
|
||||
userSettings: UserSettings;
|
||||
numTruncatedResults?: number;
|
||||
|
||||
header: ReactNode;
|
||||
@@ -33,8 +31,6 @@ export function AlertTable({
|
||||
results,
|
||||
databaseUri,
|
||||
sourceLocationPrefix,
|
||||
run,
|
||||
userSettings,
|
||||
numTruncatedResults,
|
||||
header,
|
||||
noResults,
|
||||
@@ -206,8 +202,6 @@ export function AlertTable({
|
||||
selectedItem={selectedItem}
|
||||
selectedItemRef={selectedItemRef}
|
||||
databaseUri={databaseUri}
|
||||
run={run}
|
||||
userSettings={userSettings}
|
||||
sourceLocationPrefix={sourceLocationPrefix}
|
||||
updateSelectionCallback={updateSelectionCallback}
|
||||
toggleExpanded={toggle}
|
||||
|
||||
@@ -45,7 +45,7 @@ export function AlertTableHeader({
|
||||
<th colSpan={2}></th>
|
||||
<th
|
||||
className={`${sortClass()} vscode-codeql__alert-message-cell`}
|
||||
colSpan={4}
|
||||
colSpan={3}
|
||||
onClick={toggleSortStateForColumn}
|
||||
>
|
||||
Message
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ThreadFlowLocation, Run } from "sarif";
|
||||
import type { ThreadFlowLocation } from "sarif";
|
||||
import type {
|
||||
PathNode,
|
||||
Result as ResultKeysResult,
|
||||
@@ -9,8 +9,6 @@ import { SarifLocation } from "./locations/SarifLocation";
|
||||
import { selectableZebraStripe } from "./result-table-utils";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { VerticalRule } from "../common/VerticalRule";
|
||||
import type { UserSettings } from "../../common/interface-types";
|
||||
import { TaxaLocations } from "./locations/TaxaLocations";
|
||||
|
||||
interface Props {
|
||||
step: ThreadFlowLocation;
|
||||
@@ -21,8 +19,6 @@ interface Props {
|
||||
selectedItemRef: React.RefObject<HTMLTableRowElement>;
|
||||
databaseUri: string;
|
||||
sourceLocationPrefix: string;
|
||||
run?: Run;
|
||||
userSettings: UserSettings;
|
||||
updateSelectionCallback: (
|
||||
resultKey: PathNode | ResultKeysResult | undefined,
|
||||
) => void;
|
||||
@@ -38,8 +34,6 @@ export function AlertTablePathNodeRow(props: Props) {
|
||||
selectedItemRef,
|
||||
databaseUri,
|
||||
sourceLocationPrefix,
|
||||
run,
|
||||
userSettings,
|
||||
updateSelectionCallback,
|
||||
} = props;
|
||||
|
||||
@@ -92,23 +86,6 @@ export function AlertTablePathNodeRow(props: Props) {
|
||||
"[no location]"
|
||||
)}
|
||||
</td>
|
||||
<td
|
||||
{...selectableZebraStripe(
|
||||
isSelected,
|
||||
zebraIndex,
|
||||
"vscode-codeql__taxa-cell",
|
||||
)}
|
||||
>
|
||||
{userSettings.shouldShowProvenance ? (
|
||||
<div className="vscode-codeql__taxa-cell-contents">
|
||||
<TaxaLocations
|
||||
taxa={step.taxa}
|
||||
run={run}
|
||||
onClick={handleSarifLocationClicked}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</td>
|
||||
<td
|
||||
{...selectableZebraStripe(
|
||||
isSelected,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Run, ThreadFlow } from "sarif";
|
||||
import type { ThreadFlow } from "sarif";
|
||||
import type {
|
||||
PathNode,
|
||||
Result as ResultKeysResult,
|
||||
@@ -10,7 +10,6 @@ import { AlertTablePathNodeRow } from "./AlertTablePathNodeRow";
|
||||
import { AlertTableDropdownIndicatorCell } from "./AlertTableDropdownIndicatorCell";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { VerticalRule } from "../common/VerticalRule";
|
||||
import type { UserSettings } from "../../common/interface-types";
|
||||
|
||||
interface Props {
|
||||
path: ThreadFlow;
|
||||
@@ -21,8 +20,6 @@ interface Props {
|
||||
selectedItemRef: React.RefObject<HTMLTableRowElement>;
|
||||
databaseUri: string;
|
||||
sourceLocationPrefix: string;
|
||||
run?: Run;
|
||||
userSettings: UserSettings;
|
||||
updateSelectionCallback: (
|
||||
resultKey: PathNode | ResultKeysResult | undefined,
|
||||
) => void;
|
||||
@@ -64,7 +61,7 @@ export function AlertTablePathRow(props: Props) {
|
||||
expanded={currentPathExpanded}
|
||||
onClick={handleDropdownClick}
|
||||
/>
|
||||
<td className="vscode-codeql__text-center" colSpan={4}>
|
||||
<td className="vscode-codeql__text-center" colSpan={3}>
|
||||
Path
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Result, Run } from "sarif";
|
||||
import type { Result } from "sarif";
|
||||
import type {
|
||||
PathNode,
|
||||
Result as ResultKeysResult,
|
||||
@@ -12,7 +12,6 @@ import { useCallback, useMemo } from "react";
|
||||
import { SarifLocation } from "./locations/SarifLocation";
|
||||
import { SarifMessageWithLocations } from "./locations/SarifMessageWithLocations";
|
||||
import { AlertTablePathRow } from "./AlertTablePathRow";
|
||||
import type { UserSettings } from "../../common/interface-types";
|
||||
|
||||
interface Props {
|
||||
result: Result;
|
||||
@@ -22,8 +21,6 @@ interface Props {
|
||||
selectedItemRef: React.RefObject<HTMLTableRowElement>;
|
||||
databaseUri: string;
|
||||
sourceLocationPrefix: string;
|
||||
run?: Run;
|
||||
userSettings: UserSettings;
|
||||
updateSelectionCallback: (
|
||||
resultKey: PathNode | ResultKeysResult | undefined,
|
||||
) => void;
|
||||
@@ -93,7 +90,7 @@ export function AlertTableResultRow(props: Props) {
|
||||
{result.codeFlows === undefined ? (
|
||||
<>
|
||||
<td className="vscode-codeql__icon-cell">{info}</td>
|
||||
<td colSpan={4}>{msg}</td>
|
||||
<td colSpan={3}>{msg}</td>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
@@ -102,7 +99,7 @@ export function AlertTableResultRow(props: Props) {
|
||||
onClick={handleDropdownClick}
|
||||
/>
|
||||
<td className="vscode-codeql__icon-cell">{listUnordered}</td>
|
||||
<td colSpan={3}>{msg}</td>
|
||||
<td colSpan={2}>{msg}</td>
|
||||
</>
|
||||
)}
|
||||
<td className="vscode-codeql__location-cell">
|
||||
|
||||
@@ -6,7 +6,7 @@ import { AlertTableNoResults } from "./AlertTableNoResults";
|
||||
import { AlertTableHeader } from "./AlertTableHeader";
|
||||
|
||||
export function ResultTable(props: ResultTableProps) {
|
||||
const { resultSet, userSettings } = props;
|
||||
const { resultSet } = props;
|
||||
switch (resultSet.t) {
|
||||
case "RawResultSet":
|
||||
return <RawTable {...props} resultSet={resultSet.resultSet} />;
|
||||
@@ -21,8 +21,6 @@ export function ResultTable(props: ResultTableProps) {
|
||||
sourceLocationPrefix={
|
||||
resultSet.interpretation.sourceLocationPrefix
|
||||
}
|
||||
run={data.runs[0]}
|
||||
userSettings={userSettings}
|
||||
numTruncatedResults={resultSet.interpretation.numTruncatedResults}
|
||||
header={<AlertTableHeader sortState={data.sortState} />}
|
||||
noResults={
|
||||
|
||||
@@ -8,7 +8,6 @@ import type {
|
||||
ResultSet,
|
||||
ParsedResultSets,
|
||||
IntoResultsViewMsg,
|
||||
UserSettings,
|
||||
} from "../../common/interface-types";
|
||||
import {
|
||||
ALERTS_TABLE_NAME,
|
||||
@@ -34,7 +33,6 @@ interface ResultTablesProps {
|
||||
rawResultSets: readonly ResultSet[];
|
||||
interpretation: Interpretation | undefined;
|
||||
database: DatabaseInfo;
|
||||
userSettings: UserSettings;
|
||||
metadata?: QueryMetadata;
|
||||
resultsPath: string;
|
||||
origResultsPaths: ResultsPaths;
|
||||
@@ -96,7 +94,6 @@ export function ResultTables(props: ResultTablesProps) {
|
||||
interpretation,
|
||||
database,
|
||||
resultsPath,
|
||||
userSettings,
|
||||
metadata,
|
||||
origResultsPaths,
|
||||
isLoadingNewResults,
|
||||
@@ -245,7 +242,6 @@ export function ResultTables(props: ResultTablesProps) {
|
||||
<ResultTable
|
||||
key={resultSetName}
|
||||
resultSet={resultSet}
|
||||
userSettings={userSettings}
|
||||
databaseUri={database.databaseUri}
|
||||
resultsPath={resultsPath}
|
||||
sortState={sortStates.get(resultSetName)}
|
||||
|
||||
@@ -9,11 +9,9 @@ import type {
|
||||
ResultsPaths,
|
||||
ParsedResultSets,
|
||||
ResultSet,
|
||||
UserSettings,
|
||||
} from "../../common/interface-types";
|
||||
import {
|
||||
ALERTS_TABLE_NAME,
|
||||
DEFAULT_USER_SETTINGS,
|
||||
GRAPH_TABLE_NAME,
|
||||
} from "../../common/interface-types";
|
||||
import { ResultTables } from "./ResultTables";
|
||||
@@ -79,10 +77,6 @@ export function ResultsApp() {
|
||||
isExpectingResultsUpdate: true,
|
||||
});
|
||||
|
||||
const [userSettings, setUserSettings] = useState<UserSettings>(
|
||||
DEFAULT_USER_SETTINGS,
|
||||
);
|
||||
|
||||
const updateStateWithNewResultsInfo = useCallback(
|
||||
(resultsInfo: ResultsInfo): void => {
|
||||
let results: Results | null = null;
|
||||
@@ -116,10 +110,6 @@ export function ResultsApp() {
|
||||
const handleMessage = useCallback(
|
||||
(msg: IntoResultsViewMsg): void => {
|
||||
switch (msg.t) {
|
||||
case "setUserSettings":
|
||||
setUserSettings(msg.userSettings);
|
||||
break;
|
||||
|
||||
case "setState":
|
||||
updateStateWithNewResultsInfo({
|
||||
resultsPath: msg.resultsPath,
|
||||
@@ -227,7 +217,6 @@ export function ResultsApp() {
|
||||
? displayedResults.resultsInfo.interpretation
|
||||
: undefined
|
||||
}
|
||||
userSettings={userSettings}
|
||||
database={displayedResults.results.database}
|
||||
origResultsPaths={displayedResults.resultsInfo.origResultsPaths}
|
||||
resultsPath={displayedResults.resultsInfo.resultsPath}
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { UrlValueResolvable } from "../../../common/raw-result-types";
|
||||
interface Props {
|
||||
loc: UrlValueResolvable;
|
||||
label: string;
|
||||
databaseUri: string | undefined;
|
||||
databaseUri: string;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,17 @@ export function Location({
|
||||
const displayLabel = useMemo(() => convertNonPrintableChars(label), [label]);
|
||||
|
||||
if (loc === undefined) {
|
||||
return <NonClickableLocation msg={displayLabel} locationHint={title} />;
|
||||
return <NonClickableLocation msg={displayLabel} />;
|
||||
}
|
||||
|
||||
if (loc.type === "string") {
|
||||
return <a href={loc.value}>{loc.value}</a>;
|
||||
}
|
||||
|
||||
if (databaseUri === undefined) {
|
||||
return <NonClickableLocation msg={displayLabel} locationHint={title} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ClickableLocation
|
||||
loc={loc}
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Props {
|
||||
text?: string;
|
||||
loc?: SarifLogLocation;
|
||||
sourceLocationPrefix: string;
|
||||
databaseUri: string | undefined;
|
||||
databaseUri: string;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
import type {
|
||||
Location as SarifLogLocation,
|
||||
ArtifactLocation,
|
||||
PhysicalLocation,
|
||||
ReportingDescriptorReference,
|
||||
Run,
|
||||
ToolComponent,
|
||||
} from "sarif";
|
||||
import { SarifLocation } from "./SarifLocation";
|
||||
|
||||
/** The definition of a taxon for a data extension model row. */
|
||||
interface ModelTaxon {
|
||||
kind: "model";
|
||||
location: SarifLogLocation;
|
||||
}
|
||||
|
||||
/** A taxon for a built-in model, such as `AdditionalFlowStep`. */
|
||||
interface BuiltInTaxon {
|
||||
kind: "string";
|
||||
text: string;
|
||||
}
|
||||
|
||||
type TaxonDefinition = ModelTaxon | BuiltInTaxon;
|
||||
|
||||
/** Resolve an `ArtifactLocation` that might contain a relative reference instead of an absolute
|
||||
* URI.
|
||||
*/
|
||||
function resolveArtifactLocation(
|
||||
location: ArtifactLocation,
|
||||
baseUri: URL,
|
||||
): ArtifactLocation {
|
||||
if (location.uri === undefined) {
|
||||
// No URI at all. Just return the original location.
|
||||
return location;
|
||||
}
|
||||
return {
|
||||
...location,
|
||||
uri: new URL(location.uri, baseUri).toString(),
|
||||
};
|
||||
}
|
||||
|
||||
/** Get the URI of the pack's local root directory, if available. */
|
||||
function getLocalPackUri(extension: ToolComponent): URL | undefined {
|
||||
if (extension.locations === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const localPackLocation = extension.locations.find(
|
||||
(loc) =>
|
||||
loc.properties !== undefined &&
|
||||
loc.properties.tags !== undefined &&
|
||||
loc.properties.tags.includes("CodeQL/LocalPackRoot"),
|
||||
);
|
||||
if (localPackLocation === undefined || localPackLocation.uri === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new URL(localPackLocation.uri);
|
||||
}
|
||||
|
||||
/** Resolve a `ReportingDescriptorReference` to the built-in taxon it refers to, or `undefined` if
|
||||
* it is not a built-in taxon.
|
||||
*/
|
||||
function resolveBuiltInTaxon(
|
||||
taxonRef: ReportingDescriptorReference,
|
||||
): BuiltInTaxon | undefined {
|
||||
if (
|
||||
taxonRef.id !== undefined &&
|
||||
taxonRef.index === undefined &&
|
||||
taxonRef.toolComponent === undefined
|
||||
) {
|
||||
return {
|
||||
kind: "string",
|
||||
text: taxonRef.id,
|
||||
};
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a `ReportingDescriptorReference` to the MaD taxon definition it refers to, or
|
||||
* `undefined` if it does not refer to a MaD model.
|
||||
*/
|
||||
function resolveModelTaxon(
|
||||
taxonRef: ReportingDescriptorReference,
|
||||
run: Run,
|
||||
): ModelTaxon | undefined {
|
||||
const extensions = run.tool.extensions;
|
||||
if (extensions === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const extensionIndex = taxonRef.toolComponent?.index;
|
||||
if (
|
||||
extensionIndex === undefined ||
|
||||
extensionIndex < 0 ||
|
||||
extensionIndex >= extensions.length
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const extension = extensions[extensionIndex];
|
||||
if (extension.taxa === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const localPackUri = getLocalPackUri(extension);
|
||||
if (localPackUri === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const taxonIndex = taxonRef.index;
|
||||
if (
|
||||
taxonIndex === undefined ||
|
||||
taxonIndex < 0 ||
|
||||
taxonIndex >= extension.taxa.length
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const taxonDef = extension.taxa[taxonIndex];
|
||||
if (taxonDef.properties === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const location: PhysicalLocation =
|
||||
taxonDef.properties["CodeQL/DataExtensionLocation"];
|
||||
if (location === undefined || location.artifactLocation === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
kind: "model",
|
||||
location: {
|
||||
physicalLocation: {
|
||||
...location,
|
||||
artifactLocation: resolveArtifactLocation(
|
||||
location.artifactLocation,
|
||||
localPackUri,
|
||||
),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Resolve a `ReportingDescriptorReference` to the taxon definition it refers to. */
|
||||
function resolveTaxonDefinition(
|
||||
run: Run,
|
||||
taxonRef: ReportingDescriptorReference,
|
||||
): TaxonDefinition | undefined {
|
||||
return resolveModelTaxon(taxonRef, run) ?? resolveBuiltInTaxon(taxonRef);
|
||||
}
|
||||
|
||||
interface Props {
|
||||
taxa: ReportingDescriptorReference[] | undefined;
|
||||
run: Run | undefined;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
/** Generate the React elements for each taxon. */
|
||||
export function TaxaLocations({
|
||||
taxa,
|
||||
run,
|
||||
onClick,
|
||||
}: Props): React.JSX.Element[] {
|
||||
if (taxa === undefined || taxa.length === 0 || run === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return taxa.flatMap((taxonRef, index) => {
|
||||
if (taxonRef.properties === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const role = taxonRef.properties["CodeQL/DataflowRole"];
|
||||
if (typeof role !== "string") {
|
||||
return [];
|
||||
}
|
||||
|
||||
const taxonDef = resolveTaxonDefinition(run, taxonRef);
|
||||
if (taxonDef === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={index}>
|
||||
{`(${role}) `}
|
||||
<SarifLocation
|
||||
loc={taxonDef.kind === "model" ? taxonDef.location : undefined}
|
||||
databaseUri={undefined}
|
||||
text={taxonDef.kind === "string" ? taxonDef.text : undefined}
|
||||
sourceLocationPrefix=""
|
||||
onClick={onClick}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import type {
|
||||
QueryMetadata,
|
||||
RawResultsSortState,
|
||||
ResultSet,
|
||||
UserSettings,
|
||||
} from "../../common/interface-types";
|
||||
import { SortDirection } from "../../common/interface-types";
|
||||
import { assertNever } from "../../common/helpers-pure";
|
||||
@@ -12,7 +11,6 @@ import type { UrlValueResolvable } from "../../common/raw-result-types";
|
||||
export interface ResultTableProps {
|
||||
resultSet: ResultSet;
|
||||
databaseUri: string;
|
||||
userSettings: UserSettings;
|
||||
metadata?: QueryMetadata;
|
||||
resultsPath: string | undefined;
|
||||
sortState?: RawResultsSortState;
|
||||
@@ -43,7 +41,7 @@ export const selectedRowClassName = "vscode-codeql__result-table-row--selected";
|
||||
|
||||
export function jumpToLocation(
|
||||
loc: UrlValueResolvable,
|
||||
databaseUri: string | undefined,
|
||||
databaseUri: string,
|
||||
): void {
|
||||
vscode.postMessage({
|
||||
t: "viewSourceFile",
|
||||
|
||||
@@ -144,12 +144,3 @@ td.vscode-codeql__path-index-cell {
|
||||
.vscode-codeql__location-cell {
|
||||
text-align: right !important;
|
||||
}
|
||||
|
||||
.vscode-codeql__taxa-cell {
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.vscode-codeql__taxa-cell-contents {
|
||||
background-color: transparent;
|
||||
display: grid;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
"v2.18.1",
|
||||
"v2.17.6",
|
||||
"v2.17.5",
|
||||
"v2.16.6",
|
||||
"v2.15.5",
|
||||
"v2.14.6",
|
||||
"nightly"
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ export default defineConfig({
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: "http://localhost:8080",
|
||||
baseURL: "http://server:8080",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
|
||||
@@ -1,59 +1,16 @@
|
||||
import {
|
||||
parsePythonAccessPath,
|
||||
parsePythonType,
|
||||
pythonEndpointType,
|
||||
pythonPath,
|
||||
} from "../../../../../src/model-editor/languages/python/access-paths";
|
||||
import { EndpointType } from "../../../../../src/model-editor/method";
|
||||
|
||||
describe("parsePythonType", () => {
|
||||
it("parses a type with a package", () => {
|
||||
expect(parsePythonType("requests.utils")).toEqual({
|
||||
packageName: "requests",
|
||||
typeName: "utils",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses a nested type with a package", () => {
|
||||
expect(parsePythonType("requests.adapters.HTTPAdapter")).toEqual({
|
||||
packageName: "requests",
|
||||
typeName: "adapters.HTTPAdapter",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses a package without a type", () => {
|
||||
expect(parsePythonType("requests")).toEqual({
|
||||
packageName: "requests",
|
||||
typeName: "",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses an empty string", () => {
|
||||
expect(parsePythonType("")).toEqual({
|
||||
packageName: "",
|
||||
typeName: "",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const testCases: Array<{
|
||||
path: string;
|
||||
shortTypeName: string;
|
||||
method: ReturnType<typeof parsePythonAccessPath>;
|
||||
}> = [
|
||||
{
|
||||
path: "Member[CommonTokens].Member[Class].Instance.Member[foo]",
|
||||
shortTypeName: "",
|
||||
method: {
|
||||
typeName: "CommonTokens.Class",
|
||||
methodName: "foo",
|
||||
endpointType: EndpointType.Method,
|
||||
path: "",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "Member[foo]",
|
||||
shortTypeName: "CommonTokens.Class",
|
||||
method: {
|
||||
typeName: "CommonTokens.Class",
|
||||
methodName: "foo",
|
||||
@@ -63,17 +20,6 @@ const testCases: Array<{
|
||||
},
|
||||
{
|
||||
path: "Member[CommonTokens].Member[Class].Instance.Member[foo].Parameter[self]",
|
||||
shortTypeName: "",
|
||||
method: {
|
||||
typeName: "CommonTokens.Class",
|
||||
methodName: "foo",
|
||||
endpointType: EndpointType.Method,
|
||||
path: "Parameter[self]",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "Member[foo].Parameter[self]",
|
||||
shortTypeName: "CommonTokens.Class",
|
||||
method: {
|
||||
typeName: "CommonTokens.Class",
|
||||
methodName: "foo",
|
||||
@@ -83,7 +29,6 @@ const testCases: Array<{
|
||||
},
|
||||
{
|
||||
path: "Member[getSource].ReturnValue",
|
||||
shortTypeName: "",
|
||||
method: {
|
||||
typeName: "",
|
||||
methodName: "getSource",
|
||||
@@ -93,17 +38,6 @@ const testCases: Array<{
|
||||
},
|
||||
{
|
||||
path: "Member[CommonTokens].Member[makePromise].ReturnValue.Awaited",
|
||||
shortTypeName: "",
|
||||
method: {
|
||||
typeName: "CommonTokens",
|
||||
methodName: "makePromise",
|
||||
endpointType: EndpointType.Function,
|
||||
path: "ReturnValue.Awaited",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "Member[makePromise].ReturnValue.Awaited",
|
||||
shortTypeName: "CommonTokens!",
|
||||
method: {
|
||||
typeName: "CommonTokens",
|
||||
methodName: "makePromise",
|
||||
@@ -113,17 +47,6 @@ const testCases: Array<{
|
||||
},
|
||||
{
|
||||
path: "Member[ArgPos].Member[anyParam].Argument[any]",
|
||||
shortTypeName: "",
|
||||
method: {
|
||||
typeName: "ArgPos",
|
||||
methodName: "anyParam",
|
||||
endpointType: EndpointType.Function,
|
||||
path: "Argument[any]",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "Member[anyParam].Argument[any]",
|
||||
shortTypeName: "ArgPos!",
|
||||
method: {
|
||||
typeName: "ArgPos",
|
||||
methodName: "anyParam",
|
||||
@@ -133,17 +56,6 @@ const testCases: Array<{
|
||||
},
|
||||
{
|
||||
path: "Member[ArgPos].Instance.Member[self_thing].Argument[self]",
|
||||
shortTypeName: "",
|
||||
method: {
|
||||
typeName: "ArgPos",
|
||||
methodName: "self_thing",
|
||||
endpointType: EndpointType.Method,
|
||||
path: "Argument[self]",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "Member[self_thing].Argument[self]",
|
||||
shortTypeName: "ArgPos",
|
||||
method: {
|
||||
typeName: "ArgPos",
|
||||
methodName: "self_thing",
|
||||
@@ -154,138 +66,44 @@ const testCases: Array<{
|
||||
];
|
||||
|
||||
describe("parsePythonAccessPath", () => {
|
||||
it.each(testCases)(
|
||||
"parses $path with $shortTypeName",
|
||||
({ path, shortTypeName, method }) => {
|
||||
expect(parsePythonAccessPath(path, shortTypeName)).toEqual(method);
|
||||
},
|
||||
);
|
||||
it.each(testCases)("parses $path", ({ path, method }) => {
|
||||
expect(parsePythonAccessPath(path)).toEqual(method);
|
||||
});
|
||||
});
|
||||
|
||||
describe("pythonPath", () => {
|
||||
it("returns empty for an empty method name", () => {
|
||||
expect(pythonPath("", "ReturnValue")).toEqual("ReturnValue");
|
||||
});
|
||||
|
||||
it("returns empty for an empty path", () => {
|
||||
expect(pythonPath("foo", "")).toEqual("Member[foo]");
|
||||
});
|
||||
|
||||
it("returns correctly for a full method name and path", () => {
|
||||
expect(pythonPath("foo", "ReturnValue")).toEqual("Member[foo].ReturnValue");
|
||||
it.each(testCases)("constructs $path", ({ path, method }) => {
|
||||
expect(
|
||||
pythonPath(
|
||||
method.typeName,
|
||||
method.methodName,
|
||||
method.endpointType,
|
||||
method.path,
|
||||
),
|
||||
).toEqual(path);
|
||||
});
|
||||
});
|
||||
|
||||
describe("pythonEndpointType", () => {
|
||||
it("returns method for a method", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(self,a)",
|
||||
},
|
||||
"InstanceMethod",
|
||||
),
|
||||
pythonEndpointType({
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(self,a)",
|
||||
}),
|
||||
).toEqual(EndpointType.Method);
|
||||
});
|
||||
|
||||
it("returns class method for a class method", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(cls,a)",
|
||||
},
|
||||
"ClassMethod",
|
||||
),
|
||||
).toEqual(EndpointType.ClassMethod);
|
||||
});
|
||||
|
||||
it("returns static method for a static method", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(a)",
|
||||
},
|
||||
"StaticMethod",
|
||||
),
|
||||
).toEqual(EndpointType.StaticMethod);
|
||||
});
|
||||
|
||||
it("returns function for a function", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "",
|
||||
methodName: "foo",
|
||||
methodParameters: "(a)",
|
||||
},
|
||||
"Function",
|
||||
),
|
||||
).toEqual(EndpointType.Function);
|
||||
});
|
||||
|
||||
it("returns constructor for an init method", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(a)",
|
||||
},
|
||||
"InitMethod",
|
||||
),
|
||||
).toEqual(EndpointType.Constructor);
|
||||
});
|
||||
|
||||
it("returns class for a class", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "",
|
||||
methodParameters: "",
|
||||
},
|
||||
"Class",
|
||||
),
|
||||
).toEqual(EndpointType.Class);
|
||||
});
|
||||
|
||||
it("returns method for a method without endpoint kind", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(self,a)",
|
||||
},
|
||||
undefined,
|
||||
),
|
||||
).toEqual(EndpointType.Method);
|
||||
});
|
||||
|
||||
it("returns function for a function without endpoint kind", () => {
|
||||
expect(
|
||||
pythonEndpointType(
|
||||
{
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(a)",
|
||||
},
|
||||
undefined,
|
||||
),
|
||||
pythonEndpointType({
|
||||
packageName: "testlib",
|
||||
typeName: "CommonTokens",
|
||||
methodName: "foo",
|
||||
methodParameters: "(a)",
|
||||
}),
|
||||
).toEqual(EndpointType.Function);
|
||||
});
|
||||
});
|
||||
|
||||
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "vscode-codeql",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
26
vscode-codeql.code-workspace
Normal file
26
vscode-codeql.code-workspace
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"typescript.tsdk": "./extensions/ql-vscode/node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"terminal.integrated.env.linux": {
|
||||
"LANG": "en-US",
|
||||
"TZ": "UTC"
|
||||
},
|
||||
"terminal.integrated.env.osx": {
|
||||
"LANG": "en-US",
|
||||
"TZ": "UTC"
|
||||
},
|
||||
"terminal.integrated.env.windows": {
|
||||
"LANG": "en-US",
|
||||
"TZ": "UTC"
|
||||
},
|
||||
"github.copilot.advanced": {},
|
||||
"github-enterprise.uri": "http://server:8080"
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user