@@ -37,25 +37,31 @@ import {
37
37
import type { QlPackFile } from "../packaging/qlpack-file" ;
38
38
import { expandShortPaths } from "../common/short-paths" ;
39
39
import type { QlPackDetails } from "./ql-pack-details" ;
40
+ import type { ModelPackDetails } from "../common/model-pack-details" ;
40
41
41
42
/**
42
43
* Well-known names for the query pack used by the server.
43
44
*/
44
45
const QUERY_PACK_NAME = "codeql-remote/query" ;
45
46
47
+ interface GeneratedQlPackDetails {
48
+ base64Pack : string ;
49
+ modelPacks : ModelPackDetails [ ] ;
50
+ }
51
+
46
52
/**
47
53
* Two possibilities:
48
54
* 1. There is no qlpack.yml (or codeql-pack.yml) in this directory. Assume this is a lone query and generate a synthetic qlpack for it.
49
55
* 2. There is a qlpack.yml (or codeql-pack.yml) in this directory. Assume this is a query pack and use the yml to pack the query before uploading it.
50
56
*
51
- * @returns the entire qlpack as a base64 string .
57
+ * @returns details about the generated QL pack .
52
58
*/
53
59
async function generateQueryPack (
54
60
cliServer : CodeQLCliServer ,
55
61
qlPackDetails : QlPackDetails ,
56
62
tmpDir : RemoteQueryTempDir ,
57
63
token : CancellationToken ,
58
- ) : Promise < string > {
64
+ ) : Promise < GeneratedQlPackDetails > {
59
65
const workspaceFolders = getOnDiskWorkspaceFolders ( ) ;
60
66
const extensionPacks = await getExtensionPacksToInject (
61
67
cliServer ,
@@ -129,7 +135,7 @@ async function generateQueryPack(
129
135
...queryOpts ,
130
136
// We need to specify the extension packs as dependencies so that they are included in the MRVA pack.
131
137
// The version range doesn't matter, since they'll always be found by source lookup.
132
- ...extensionPacks . map ( ( p ) => `--extension-pack=${ p } @*` ) ,
138
+ ...extensionPacks . map ( ( p ) => `--extension-pack=${ p . name } @*` ) ,
133
139
] ;
134
140
} else {
135
141
precompilationOpts = [ "--qlx" ] ;
@@ -152,7 +158,10 @@ async function generateQueryPack(
152
158
token ,
153
159
) ;
154
160
const base64Pack = ( await readFile ( bundlePath ) ) . toString ( "base64" ) ;
155
- return base64Pack ;
161
+ return {
162
+ base64Pack,
163
+ modelPacks : extensionPacks ,
164
+ } ;
156
165
}
157
166
158
167
async function createNewQueryPack (
@@ -278,6 +287,7 @@ async function getPackedBundlePath(remoteQueryDir: string): Promise<string> {
278
287
interface PreparedRemoteQuery {
279
288
actionBranch : string ;
280
289
base64Pack : string ;
290
+ modelPacks : ModelPackDetails [ ] ;
281
291
repoSelection : RepositorySelection ;
282
292
controllerRepo : Repository ;
283
293
queryStartTime : number ;
@@ -330,10 +340,10 @@ export async function prepareRemoteQueryRun(
330
340
331
341
const tempDir = await createRemoteQueriesTempDirectory ( ) ;
332
342
333
- let base64Pack : string ;
343
+ let generatedPack : GeneratedQlPackDetails ;
334
344
335
345
try {
336
- base64Pack = await generateQueryPack (
346
+ generatedPack = await generateQueryPack (
337
347
cliServer ,
338
348
qlPackDetails ,
339
349
tempDir ,
@@ -358,7 +368,8 @@ export async function prepareRemoteQueryRun(
358
368
359
369
return {
360
370
actionBranch,
361
- base64Pack,
371
+ base64Pack : generatedPack . base64Pack ,
372
+ modelPacks : generatedPack . modelPacks ,
362
373
repoSelection,
363
374
controllerRepo,
364
375
queryStartTime,
@@ -404,8 +415,8 @@ async function fixPackFile(
404
415
async function getExtensionPacksToInject (
405
416
cliServer : CodeQLCliServer ,
406
417
workspaceFolders : string [ ] ,
407
- ) : Promise < string [ ] > {
408
- const result : string [ ] = [ ] ;
418
+ ) : Promise < ModelPackDetails [ ] > {
419
+ const result : ModelPackDetails [ ] = [ ] ;
409
420
if ( cliServer . useExtensionPacks ( ) ) {
410
421
const extensionPacks = await cliServer . resolveQlpacks (
411
422
workspaceFolders ,
@@ -422,7 +433,7 @@ async function getExtensionPacksToInject(
422
433
) } `,
423
434
) ;
424
435
}
425
- result . push ( name ) ;
436
+ result . push ( { name, path : paths [ 0 ] } ) ;
426
437
} ) ;
427
438
}
428
439
@@ -431,7 +442,7 @@ async function getExtensionPacksToInject(
431
442
432
443
async function addExtensionPacksAsDependencies (
433
444
queryPackDir : string ,
434
- extensionPacks : string [ ] ,
445
+ extensionPacks : ModelPackDetails [ ] ,
435
446
) : Promise < void > {
436
447
const qlpackFile = await getQlPackFilePath ( queryPackDir ) ;
437
448
if ( ! qlpackFile ) {
@@ -447,7 +458,7 @@ async function addExtensionPacksAsDependencies(
447
458
) as QlPackFile ;
448
459
449
460
const dependencies = syntheticQueryPack . dependencies ?? { } ;
450
- extensionPacks . forEach ( ( name ) => {
461
+ extensionPacks . forEach ( ( { name } ) => {
451
462
// Add this extension pack as a dependency. It doesn't matter which
452
463
// version we specify, since we are guaranteed that the extension pack
453
464
// is resolved from source at the given path.
0 commit comments