Generate UserConfig from schema ... ish

This commit is contained in:
Michael B. Gale
2025-10-17 16:13:06 +01:00
parent 816fc30181
commit 0cf61911ea
14 changed files with 98 additions and 34 deletions
+3 -1
View File
@@ -26472,7 +26472,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -26538,6 +26539,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -32321,7 +32321,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -32387,6 +32388,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -26472,7 +26472,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -26538,6 +26539,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -32321,7 +32321,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -32387,6 +32388,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+6 -4
View File
@@ -32321,7 +32321,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -32387,6 +32388,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
@@ -35283,12 +35285,12 @@ var require_lib2 = __commonJS({
}
});
// src/db-config-schema.json
// schemas/db-config-schema.json
var require_db_config_schema = __commonJS({
"src/db-config-schema.json"(exports2, module2) {
"schemas/db-config-schema.json"(exports2, module2) {
module2.exports = {
$schema: "https://json-schema.org/draft/2020-12/schema",
title: "CodeQL Database Configuration",
title: "UserConfig",
description: "Format of the config file supplied by the user for CodeQL analysis",
type: "object",
properties: {
+3 -1
View File
@@ -26472,7 +26472,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -26538,6 +26539,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -32321,7 +32321,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -32387,6 +32388,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -26472,7 +26472,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -26538,6 +26539,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -45008,7 +45008,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -45074,6 +45075,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -33618,7 +33618,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -33684,6 +33685,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -26472,7 +26472,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -26538,6 +26539,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+3 -1
View File
@@ -32321,7 +32321,8 @@ var require_package = __commonJS({
ava: "npm run transpile && ava --serial --verbose",
test: "npm run ava -- src/",
"test-debug": "npm run test -- --timeout=20m",
transpile: "tsc --build --verbose"
transpile: "npm run generate:schemas && tsc --build --verbose",
"generate:schemas": "node json-schemas.mjs"
},
ava: {
typescript: {
@@ -32387,6 +32388,7 @@ var require_package = __commonJS({
"eslint-plugin-import": "2.29.1",
"eslint-plugin-no-async-foreach": "^0.1.1",
glob: "^11.0.3",
"json-schema-to-typescript": "^15.0.4",
nock: "^14.0.10",
sinon: "^21.0.0",
typescript: "^5.9.3"
+6 -19
View File
@@ -4,6 +4,7 @@ import * as yaml from "js-yaml";
import * as jsonschema from "jsonschema";
import * as semver from "semver";
import type { UserConfig as DbConfig, QuerySpec } from "../db-config-schema";
import * as errorMessages from "../error-messages";
import {
RepositoryProperties,
@@ -13,6 +14,8 @@ import { Language } from "../languages";
import { Logger } from "../logging";
import { cloneObject, ConfigurationError, prettyPrintPack } from "../util";
export type { QuerySpec } from "../db-config-schema";
export interface ExcludeQueryFilter {
exclude: Record<string, string[] | string>;
}
@@ -23,30 +26,14 @@ export interface IncludeQueryFilter {
export type QueryFilter = ExcludeQueryFilter | IncludeQueryFilter;
export interface QuerySpec {
name?: string;
uses: string;
}
/**
* Format of the config file supplied by the user.
*/
export interface UserConfig {
name?: string;
"disable-default-queries"?: boolean;
queries?: QuerySpec[];
"paths-ignore"?: string[];
paths?: string[];
// If this is a multi-language analysis, then the packages must be split by
// language. If this is a single language analysis, then no split by
// language is necessary.
packs?: Record<string, string[]> | string[];
export type UserConfig = DbConfig & {
// Set of query filters to include and exclude extra queries based on
// codeql query suite `include` and `exclude` properties
"query-filters"?: QueryFilter[];
}
};
/**
* Represents additional configuration data from a source other than
@@ -496,7 +483,7 @@ export function parseUserConfig(
try {
const schema =
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("../../src/db-config-schema.json") as jsonschema.Schema;
require("../../schemas/db-config-schema.json") as jsonschema.Schema;
const doc = yaml.load(contents);
+53
View File
@@ -0,0 +1,53 @@
/* This file was automatically generated by `npm run generate:schemas`. Do not edit by hand. */
/**
* Format of the config file supplied by the user for CodeQL analysis
*/
export interface UserConfig {
/**
* Name of the configuration
*/
name?: string;
/**
* Whether to disable default queries
*/
"disable-default-queries"?: boolean;
/**
* List of additional queries to run
*/
queries?: QuerySpec[];
/**
* Paths to ignore during analysis
*/
"paths-ignore"?: string[];
/**
* Paths to include in analysis
*/
paths?: string[];
/**
* Query packs to include. Can be a simple array for single-language analysis or an object with language-specific arrays for multi-language analysis
*/
packs?:
| string[]
| {
[k: string]: string[];
};
/**
* Set of query filters to include and exclude extra queries based on CodeQL query suite include and exclude properties
*/
"query-filters"?: unknown[];
[k: string]: unknown;
}
/**
* Detailed query specification object
*/
export interface QuerySpec {
/**
* Optional name for the query
*/
name?: string;
/**
* The query or query suite to use
*/
uses: string;
}