Remove remote queries types

This commit is contained in:
Koen Vlaswinkel
2023-02-15 13:42:58 +01:00
parent 6856d1b6a5
commit 8f9e420402
10 changed files with 2 additions and 398 deletions

View File

@@ -1,9 +1,4 @@
import * as sarif from "sarif";
import { AnalysisResults } from "../remote-queries/shared/analysis-result";
import {
AnalysisSummary,
RemoteQueryResult,
} from "../remote-queries/shared/remote-query-result";
import {
RawResultSet,
ResultRow,
@@ -58,13 +53,6 @@ export interface QueryMetadata {
scored?: string;
}
export interface PreviousExecution {
queryName: string;
time: string;
databaseName: string;
durationSeconds: number;
}
export type SarifInterpretationData = {
t: "SarifInterpretationData";
/**
@@ -222,11 +210,6 @@ export interface OpenFileMsg {
filePath: string;
}
export interface OpenVirtualFileMsg {
t: "openVirtualFile";
queryText: string;
}
/**
* Message from the results view to toggle the display of
* query diagnostics.
@@ -353,12 +336,6 @@ export interface SetComparisonsMessage {
readonly databaseUri: string;
}
export enum DiffKind {
Add = "Add",
Remove = "Remove",
Change = "Change",
}
/**
* from is the set of rows that have changes in the "from" query.
* to is the set of rows that have changes in the "to" query.
@@ -407,56 +384,6 @@ export interface ParsedResultSets {
resultSet: ResultSet;
}
export type FromRemoteQueriesMessage =
| ViewLoadedMsg
| RemoteQueryErrorMessage
| OpenFileMsg
| OpenVirtualFileMsg
| RemoteQueryDownloadAnalysisResultsMessage
| RemoteQueryDownloadAllAnalysesResultsMessage
| RemoteQueryExportResultsMessage
| CopyRepoListMessage
| TelemetryMessage;
export type ToRemoteQueriesMessage =
| SetRemoteQueryResultMessage
| SetAnalysesResultsMessage;
export interface SetRemoteQueryResultMessage {
t: "setRemoteQueryResult";
queryResult: RemoteQueryResult;
}
export interface SetAnalysesResultsMessage {
t: "setAnalysesResults";
analysesResults: AnalysisResults[];
}
export interface RemoteQueryErrorMessage {
t: "remoteQueryError";
error: string;
}
export interface RemoteQueryDownloadAnalysisResultsMessage {
t: "remoteQueryDownloadAnalysisResults";
analysisSummary: AnalysisSummary;
}
export interface RemoteQueryDownloadAllAnalysesResultsMessage {
t: "remoteQueryDownloadAllAnalysesResults";
analysisSummaries: AnalysisSummary[];
}
export interface RemoteQueryExportResultsMessage {
t: "remoteQueryExportResults";
queryId: string;
}
export interface CopyRepoListMessage {
t: "copyRepoList";
queryId: string;
}
export interface SetVariantAnalysisMessage {
t: "setVariantAnalysis";
variantAnalysis: VariantAnalysis;

View File

@@ -1,48 +0,0 @@
import { join } from "path";
/**
* Represents a link to an artifact to be downloaded.
*/
export interface DownloadLink {
/**
* A unique id of the artifact being downloaded.
*/
id: string;
/**
* The URL path to use against the GitHub API to download the
* linked artifact.
*/
urlPath: string;
/**
* An optional path to follow inside the downloaded archive containing the artifact.
*/
innerFilePath?: string;
/**
* A unique id of the remote query run. This is used to determine where to store artifacts and data from the run.
*/
queryId: string;
}
/**
* Converts a downloadLink to the path where the artifact should be stored.
*
* @param storagePath The base directory to store artifacts in.
* @param downloadLink The DownloadLink
* @param extension An optional file extension to append to the artifact (no `.`).
*
* @returns A full path to the download location of the artifact
*/
export function createDownloadPath(
storagePath: string,
downloadLink: DownloadLink,
extension = "",
) {
return join(
storagePath,
downloadLink.queryId,
downloadLink.id + (extension ? `.${extension}` : ""),
);
}

View File

@@ -34,7 +34,7 @@ import {
import { Credentials } from "../common/authentication";
/**
* Exports the results of the currently-selected remote query or variant analysis.
* Exports the results of the currently-selected variant analysis.
*/
export async function exportSelectedVariantAnalysisResults(
queryHistoryManager: QueryHistoryManager,
@@ -55,7 +55,7 @@ export async function exportSelectedVariantAnalysisResults(
const MAX_VARIANT_ANALYSIS_EXPORT_PROGRESS_STEPS = 2;
/**
* Exports the results of the given or currently-selected remote query.
* Exports the results of the given or currently-selected variant analysis.
* The user is prompted to select the export format.
*/
export async function exportVariantAnalysisResults(

View File

@@ -1,4 +0,0 @@
export interface Repository {
owner: string;
name: string;
}

View File

@@ -1,4 +0,0 @@
export interface AnalysisFailure {
nwo: string;
error: string;
}

View File

@@ -1,17 +1,5 @@
import { RawResultSet, ResultSetSchema } from "../../pure/bqrs-cli-types";
export type AnalysisResultStatus = "InProgress" | "Completed" | "Failed";
export interface AnalysisResults {
nwo: string;
status: AnalysisResultStatus;
interpretedResults: AnalysisAlert[];
rawResults?: AnalysisRawResults;
resultCount: number;
starCount?: number;
lastUpdated?: number;
}
export interface AnalysisRawResults {
schema: ResultSetSchema;
resultSet: RawResultSet;
@@ -82,19 +70,3 @@ export interface AnalysisMessageLocationToken {
}
export type ResultSeverity = "Recommendation" | "Warning" | "Error";
/**
* Returns the number of (raw + interpreted) results for an analysis.
*/
export const getAnalysisResultCount = (
analysisResults: AnalysisResults,
): number => {
const rawResultCount = analysisResults.rawResults?.resultSet.rows.length || 0;
return analysisResults.interpretedResults.length + rawResultCount;
};
/**
* Returns the total number of results for an analysis by adding all individual repo results.
*/
export const sumAnalysesResults = (analysesResults: AnalysisResults[]) =>
analysesResults.reduce((acc, curr) => acc + getAnalysisResultCount(curr), 0);

View File

@@ -1,30 +0,0 @@
import { DownloadLink } from "../download-link";
import { AnalysisFailure } from "./analysis-failure";
export interface RemoteQueryResult {
queryId: string;
queryTitle: string;
queryFileName: string;
queryFilePath: string;
queryText: string;
language: string;
workflowRunUrl: string;
totalRepositoryCount: number;
affectedRepositoryCount: number;
totalResultCount: number;
executionTimestamp: string;
executionDuration: string;
analysisSummaries: AnalysisSummary[];
analysisFailures: AnalysisFailure[];
}
export interface AnalysisSummary {
nwo: string;
databaseSha: string;
resultCount: number;
sourceLocationPrefix: string;
downloadLink: DownloadLink;
fileSize: string;
starCount?: number;
lastUpdated?: number;
}

View File

@@ -1,170 +0,0 @@
{
"t": "setRemoteQueryResult",
"queryResult": {
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j",
"queryTitle": "Empty block",
"queryFileName": "example.ql",
"queryFilePath": "/home/octocat/vscode-codeql-starter/codeql-custom-queries-javascript/example.ql",
"queryText": "/**\n * @name Empty block\n * @kind problem\n * @problem.severity warning\n * @id javascript/example/empty-block\n */\n\nimport javascript\n\nfrom BlockStmt b\nwhere b.getNumStmt() = 0\nselect b, \"This is an empty block.\"\n",
"language": "javascript",
"workflowRunUrl": "https://github.com/octocat/octo-repo/actions/runs/2955404400",
"totalRepositoryCount": 10,
"affectedRepositoryCount": 10,
"totalResultCount": 16338,
"executionTimestamp": "30 Aug at 0:14 pm",
"executionDuration": "1 minute",
"analysisSummaries": [
{
"nwo": "angular/angular",
"databaseSha": "a360309f31afa97c4268a94fbd6a5108362a7182",
"resultCount": 8436,
"downloadLink": {
"id": "346232925",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232925",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "5.67 MB",
"starCount": 83537,
"lastUpdated": -1066284
},
{
"nwo": "babel/babel",
"databaseSha": "0f62c58c79830cfe0afb26161e96e0e1b0482c01",
"resultCount": 5502,
"downloadLink": {
"id": "346232926",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232926",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "3.80 MB",
"starCount": 41292,
"lastUpdated": -1600284
},
{
"nwo": "facebook/react",
"databaseSha": "e25648b0a89eab6f82bea2c2a1ef90866ac82b33",
"resultCount": 1205,
"downloadLink": {
"id": "346232919",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232919",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "905.24 KB",
"starCount": 194007,
"lastUpdated": -379284
},
{
"nwo": "facebook/jest",
"databaseSha": "187566a70aa4b6aa5f74952b504bbeddb5854aef",
"resultCount": 643,
"downloadLink": {
"id": "346232921",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232921",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "441.60 KB",
"starCount": 39987,
"lastUpdated": -113284
},
{
"nwo": "facebook/create-react-app",
"databaseSha": "f34d88e30c7d8be7181f728d1abc4fd8d5cd07d3",
"resultCount": 198,
"downloadLink": {
"id": "346232928",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232928",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "132.28 KB",
"starCount": 96698,
"lastUpdated": -126284
},
{
"nwo": "vuejs/vue",
"databaseSha": "810f6d12edea47cde7f39eaf7ec3ae1b7300d40c",
"resultCount": 140,
"downloadLink": {
"id": "346232920",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232920",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "89.99 KB",
"starCount": 198970,
"lastUpdated": -167284
},
{
"nwo": "lodash/lodash",
"databaseSha": "2da024c3b4f9947a48517639de7560457cd4ec6c",
"resultCount": 108,
"downloadLink": {
"id": "346232927",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232927",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "70.43 KB",
"starCount": 54215,
"lastUpdated": -9080284
},
{
"nwo": "jquery/jquery",
"databaseSha": "d2436df36a4b2ef556907e734a90771f0dbdbcaf",
"resultCount": 67,
"downloadLink": {
"id": "346232922",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232922",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/jquery/jquery",
"fileSize": "45.07 KB",
"starCount": 56629,
"lastUpdated": -23284
},
{
"nwo": "expressjs/express",
"databaseSha": "33e8dc303af9277f8a7e4f46abfdcb5e72f6797b",
"resultCount": 26,
"downloadLink": {
"id": "346232924",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232924",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bulk-builder/bulk-builder",
"fileSize": "16.96 KB",
"starCount": 58125,
"lastUpdated": -236284
},
{
"nwo": "twbs/bootstrap",
"databaseSha": "af1bd974bba7f6e7f90c5ed3f42738bd101926cb",
"resultCount": 13,
"downloadLink": {
"id": "346232923",
"urlPath": "/repos/octocat/octo-repo/actions/artifacts/346232923",
"innerFilePath": "results.sarif",
"queryId": "Empty block-LUzMYbSaBM4Lv6YP8GQ8j"
},
"sourceLocationPrefix": "/home/runner/work/bootstrap/bootstrap",
"fileSize": "8.50 KB",
"starCount": 159230,
"lastUpdated": -1754284
}
],
"analysisFailures": []
}
}

View File

@@ -1,6 +1,5 @@
import {
FromCompareViewMessage,
FromRemoteQueriesMessage,
FromResultsViewMsg,
FromVariantAnalysisMessage,
VariantAnalysisState,
@@ -14,7 +13,6 @@ export interface VsCodeApi {
msg:
| FromResultsViewMsg
| FromCompareViewMessage
| FromRemoteQueriesMessage
| FromVariantAnalysisMessage,
): void;

View File

@@ -1,37 +0,0 @@
import { join } from "path";
import {
DownloadLink,
createDownloadPath,
} from "../../../src/remote-queries/download-link";
describe("createDownloadPath", () => {
it("should return the correct path", () => {
const downloadLink: DownloadLink = {
id: "abc",
urlPath: "",
innerFilePath: "",
queryId: "def",
};
const expectedPath = join("storage", "def", "abc");
const actualPath = createDownloadPath("storage", downloadLink);
expect(actualPath).toBe(expectedPath);
});
it("should return the correct path with extension", () => {
const downloadLink: DownloadLink = {
id: "abc",
urlPath: "",
innerFilePath: "",
queryId: "def",
};
const expectedPath = join("storage", "def", "abc.zip");
const actualPath = createDownloadPath("storage", downloadLink, "zip");
expect(actualPath).toBe(expectedPath);
});
});