Check against problem and path-problem aliases
This commit is contained in:
17
extensions/ql-vscode/src/common/query-metadata.ts
Normal file
17
extensions/ql-vscode/src/common/query-metadata.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const SARIF_RESULTS_QUERY_KINDS = [
|
||||||
|
"problem",
|
||||||
|
"alert",
|
||||||
|
"path-problem",
|
||||||
|
"path-alert",
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this query kind supports producing SARIF results.
|
||||||
|
*/
|
||||||
|
export function isSarifResultsQueryKind(kind: string | undefined): boolean {
|
||||||
|
if (!kind) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SARIF_RESULTS_QUERY_KINDS.includes(kind);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import type { QueryLanguage } from "../common/query-language";
|
|||||||
import type { CodeQLCliServer } from "../codeql-cli/cli";
|
import type { CodeQLCliServer } from "../codeql-cli/cli";
|
||||||
import type { QlPackDetails } from "./ql-pack-details";
|
import type { QlPackDetails } from "./ql-pack-details";
|
||||||
import { getQlPackFilePath } from "../common/ql";
|
import { getQlPackFilePath } from "../common/ql";
|
||||||
|
import { isSarifResultsQueryKind } from "../common/query-metadata";
|
||||||
|
|
||||||
export async function resolveCodeScanningQueryPack(
|
export async function resolveCodeScanningQueryPack(
|
||||||
logger: BaseLogger,
|
logger: BaseLogger,
|
||||||
@@ -64,10 +65,7 @@ async function filterToOnlyProblemQueries(
|
|||||||
const problemQueries: string[] = [];
|
const problemQueries: string[] = [];
|
||||||
for (const query of queries) {
|
for (const query of queries) {
|
||||||
const queryMetadata = await cliServer.resolveMetadata(query);
|
const queryMetadata = await cliServer.resolveMetadata(query);
|
||||||
if (
|
if (isSarifResultsQueryKind(queryMetadata.kind)) {
|
||||||
queryMetadata.kind === "problem" ||
|
|
||||||
queryMetadata.kind === "path-problem"
|
|
||||||
) {
|
|
||||||
problemQueries.push(query);
|
problemQueries.push(query);
|
||||||
} else {
|
} else {
|
||||||
void logger.log(`Skipping non-problem query ${query}`);
|
void logger.log(`Skipping non-problem query ${query}`);
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ import { tryGetQueryMetadata } from "../codeql-cli/query-metadata";
|
|||||||
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders";
|
||||||
import { findVariantAnalysisQlPackRoot } from "./ql";
|
import { findVariantAnalysisQlPackRoot } from "./ql";
|
||||||
import { resolveCodeScanningQueryPack } from "./code-scanning-pack";
|
import { resolveCodeScanningQueryPack } from "./code-scanning-pack";
|
||||||
|
import { isSarifResultsQueryKind } from "../common/query-metadata";
|
||||||
|
|
||||||
const maxRetryCount = 3;
|
const maxRetryCount = 3;
|
||||||
|
|
||||||
@@ -330,7 +331,7 @@ export class VariantAnalysisManager
|
|||||||
// It's not possible to interpret a BQRS file to SARIF without an id property.
|
// It's not possible to interpret a BQRS file to SARIF without an id property.
|
||||||
if (
|
if (
|
||||||
queryMetadata?.kind &&
|
queryMetadata?.kind &&
|
||||||
["problem", "path-problem"].includes(queryMetadata.kind) &&
|
isSarifResultsQueryKind(queryMetadata.kind) &&
|
||||||
!queryMetadata.id
|
!queryMetadata.id
|
||||||
) {
|
) {
|
||||||
throw new UserCancellationException(
|
throw new UserCancellationException(
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { RepositoriesSort } from "./RepositoriesSort";
|
|||||||
import { RepositoriesFilter } from "./RepositoriesFilter";
|
import { RepositoriesFilter } from "./RepositoriesFilter";
|
||||||
import { RepositoriesResultFormat } from "./RepositoriesResultFormat";
|
import { RepositoriesResultFormat } from "./RepositoriesResultFormat";
|
||||||
import type { ResultFormat } from "../../variant-analysis/shared/variant-analysis-result-format";
|
import type { ResultFormat } from "../../variant-analysis/shared/variant-analysis-result-format";
|
||||||
|
import { isSarifResultsQueryKind } from "../../common/query-metadata";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
filterSortValue: RepositoriesFilterSortState;
|
filterSortValue: RepositoriesFilterSortState;
|
||||||
@@ -47,10 +48,7 @@ const RepositoriesResultFormatColumn = styled(RepositoriesResultFormat)`
|
|||||||
function showResultFormatColumn(
|
function showResultFormatColumn(
|
||||||
variantAnalysisQueryKind: string | undefined,
|
variantAnalysisQueryKind: string | undefined,
|
||||||
): boolean {
|
): boolean {
|
||||||
return (
|
return isSarifResultsQueryKind(variantAnalysisQueryKind);
|
||||||
variantAnalysisQueryKind === "problem" ||
|
|
||||||
variantAnalysisQueryKind === "path-problem"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RepositoriesSearchSortRow = ({
|
export const RepositoriesSearchSortRow = ({
|
||||||
|
|||||||
Reference in New Issue
Block a user