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 { QlPackDetails } from "./ql-pack-details";
|
||||
import { getQlPackFilePath } from "../common/ql";
|
||||
import { isSarifResultsQueryKind } from "../common/query-metadata";
|
||||
|
||||
export async function resolveCodeScanningQueryPack(
|
||||
logger: BaseLogger,
|
||||
@@ -64,10 +65,7 @@ async function filterToOnlyProblemQueries(
|
||||
const problemQueries: string[] = [];
|
||||
for (const query of queries) {
|
||||
const queryMetadata = await cliServer.resolveMetadata(query);
|
||||
if (
|
||||
queryMetadata.kind === "problem" ||
|
||||
queryMetadata.kind === "path-problem"
|
||||
) {
|
||||
if (isSarifResultsQueryKind(queryMetadata.kind)) {
|
||||
problemQueries.push(query);
|
||||
} else {
|
||||
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 { findVariantAnalysisQlPackRoot } from "./ql";
|
||||
import { resolveCodeScanningQueryPack } from "./code-scanning-pack";
|
||||
import { isSarifResultsQueryKind } from "../common/query-metadata";
|
||||
|
||||
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.
|
||||
if (
|
||||
queryMetadata?.kind &&
|
||||
["problem", "path-problem"].includes(queryMetadata.kind) &&
|
||||
isSarifResultsQueryKind(queryMetadata.kind) &&
|
||||
!queryMetadata.id
|
||||
) {
|
||||
throw new UserCancellationException(
|
||||
|
||||
@@ -11,6 +11,7 @@ import { RepositoriesSort } from "./RepositoriesSort";
|
||||
import { RepositoriesFilter } from "./RepositoriesFilter";
|
||||
import { RepositoriesResultFormat } from "./RepositoriesResultFormat";
|
||||
import type { ResultFormat } from "../../variant-analysis/shared/variant-analysis-result-format";
|
||||
import { isSarifResultsQueryKind } from "../../common/query-metadata";
|
||||
|
||||
type Props = {
|
||||
filterSortValue: RepositoriesFilterSortState;
|
||||
@@ -47,10 +48,7 @@ const RepositoriesResultFormatColumn = styled(RepositoriesResultFormat)`
|
||||
function showResultFormatColumn(
|
||||
variantAnalysisQueryKind: string | undefined,
|
||||
): boolean {
|
||||
return (
|
||||
variantAnalysisQueryKind === "problem" ||
|
||||
variantAnalysisQueryKind === "path-problem"
|
||||
);
|
||||
return isSarifResultsQueryKind(variantAnalysisQueryKind);
|
||||
}
|
||||
|
||||
export const RepositoriesSearchSortRow = ({
|
||||
|
||||
Reference in New Issue
Block a user