From db32a3aaeaeec3d1285a09cd07f4b0c1523600d6 Mon Sep 17 00:00:00 2001 From: "John L. Singleton" Date: Thu, 7 Mar 2024 13:47:34 -0500 Subject: [PATCH] improvements to JSON structure --- example/qlt.conf.json | 7 ++++--- .../CodeQL/Commands/Targets/InstallCommand.cs | 5 +++-- .../Targets/InstallQueryPacksCommandTarget.cs | 4 ++-- .../CodeQL/CodeQLInstallation.cs | 12 ++++++------ src/CodeQLToolkit.Shared/Utils/QLTConfig.cs | 12 +++++++----- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/example/qlt.conf.json b/example/qlt.conf.json index 0071334..9beeefd 100644 --- a/example/qlt.conf.json +++ b/example/qlt.conf.json @@ -4,14 +4,15 @@ "CodeQLCLIBundle": "codeql-bundle-v2.15.5", "EnableCustomCodeQLBundles": true, "CodeQLStandardLibraryIdent": "codeql-cli_v2.15.5", - "CustomizationPacks" : [ + "CodeQLPackConfiguration" : [ { "Name": "qlt/cpp-customizations", - "Export" : true + "Bundle" : true }, { "Name": "qlt2/stuff2-tests", - "Export" : false + "Bundle" : false, + "ReferencesBundle" : true } ] } \ No newline at end of file diff --git a/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs b/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs index 8de989a..d90ddcc 100644 --- a/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs +++ b/src/CodeQLToolkit.Features/CodeQL/Commands/Targets/InstallCommand.cs @@ -27,9 +27,10 @@ public override void Run() if (Packs!=null && Packs.Length > 0) { Log.G().LogInformation($"Overriding Packs on the command line. The following Packs will be packaged:"); - installation.CustomizationPacks = Packs.Select(p => new QLTCustomizationPack() + installation.CodeQLPackConfiguration = Packs.Select(p => new CodeQLPackConfiguration() { - Name = p + Name = p, + Bundle = true }).ToArray(); } else diff --git a/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs b/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs index f9aa111..b38d2bc 100644 --- a/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs +++ b/src/CodeQLToolkit.Features/Query/Commands/Targets/InstallQueryPacksCommandTarget.cs @@ -41,7 +41,7 @@ public override void Run() Log.G().LogInformation("In bundle mode so filtering bundled packs..."); - foreach (var pack in config.CustomizationPacks) + foreach (var pack in config.CodeQLPackConfiguration) { Log.G().LogInformation($"Pack {pack.Name} will NOT installed because it is part of the bundle..."); } @@ -49,7 +49,7 @@ public override void Run() files = files.Where(f => // all things that are part of the customization pack must be excluded. // if it is exported is not relevant here. - !config.CustomizationPacks.Any(p => CodeQLPackReader.read(f).Name == p.Name) + !config.CodeQLPackConfiguration.Any(p => CodeQLPackReader.read(f).Name == p.Name && (p.Bundle==true || p.ReferencesBundle==true)) ).ToArray(); Log.G().LogInformation($"Got {files.Length} packs after filtering..."); diff --git a/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs b/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs index 8cb00c2..01c443c 100644 --- a/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs +++ b/src/CodeQLToolkit.Shared/CodeQL/CodeQLInstallation.cs @@ -22,7 +22,7 @@ public class CodeQLInstallation public string CLIBundle { get; set; } public string StandardLibraryIdent { get; set; } public bool EnableCustomCodeQLBundles { get; set; } - public QLTCustomizationPack[] CustomizationPacks { get; set; } + public CodeQLPackConfiguration[] CodeQLPackConfiguration { get; set; } public bool QuickBundle { get; set; } public string Base { get; set; } @@ -47,7 +47,7 @@ public static CodeQLInstallation LoadFromConfig(QLTConfig c) CLIBundle = config.CodeQLCLIBundle, StandardLibraryIdent = config.CodeQLStandardLibraryIdent, StandardLibraryVersion = config.CodeQLStandardLibrary, - CustomizationPacks = config.CustomizationPacks, + CodeQLPackConfiguration = config.CodeQLPackConfiguration, Base = config.Base, CodeQLConfiguration = config.CodeQLConfiguration }; @@ -57,9 +57,9 @@ public static CodeQLInstallation LoadFromConfig(QLTConfig c) public void LogPacksToBeBuilt() { - if(CustomizationPacks != null) + if(CodeQLPackConfiguration != null) { - foreach(var p in CustomizationPacks) + foreach(var p in CodeQLPackConfiguration) { Log.G().LogInformation($"Pack: {p}"); } @@ -278,14 +278,14 @@ private void CustomBundleInstall() var workingDirectory = Path.GetFullPath(Base); - if(CustomizationPacks == null || CustomizationPacks.Length == 0) + if(CodeQLPackConfiguration == null || CodeQLPackConfiguration.Length == 0) { throw new Exception("No packs are set to be exported. Please add at least one pack to export in your `qlt.conf.json` file under the property `ExportedCustomizationPacks`."); } Log.G().LogInformation($"Building custom bundle. This may take a while..."); - var packsToExport = CustomizationPacks.Where(p => p.Export == true).Select(p => p.Name).ToArray(); + var packsToExport = CodeQLPackConfiguration.Where(p => p.Bundle == true).Select(p => p.Name).ToArray(); var packs = string.Join(" ", packsToExport); // next, we run the bundling tool. diff --git a/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs b/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs index 13f4af5..c9663d4 100644 --- a/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs +++ b/src/CodeQLToolkit.Shared/Utils/QLTConfig.cs @@ -7,21 +7,23 @@ namespace CodeQLToolkit.Shared.Utils { - public class QLTCustomizationPack + public class CodeQLPackConfiguration { public string Name { get; set; } - public bool Export { get; set; } - } + public bool Bundle { get; set; } + public bool Publish { get; set;} + public bool ReferencesBundle { get; set; } + + } public class QLTConfig { public string CodeQLCLI { get; set; } public string CodeQLStandardLibrary { get; set; } public string CodeQLCLIBundle { get; set; } - public string CodeQLConfiguration { get; set; } - public QLTCustomizationPack[] CustomizationPacks { get; set; } + public CodeQLPackConfiguration[] CodeQLPackConfiguration { get; set; } public string CodeQLStandardLibraryIdent { get {