-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code for enabling and disabling and checking on status of custom bundles
- Loading branch information
Showing
12 changed files
with
356 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"CodeQLCLI": "2.11.6", | ||
"CodeQLStandardLibrary": "codeql-cli/v2.11.6", | ||
"CodeQLCLIBundle": "codeql-bundle-20221211" | ||
"CodeQLCLIBundle": "codeql-bundle-20221211", | ||
"EnableCustomCodeQLBundles": false, | ||
"CodeQLStandardLibraryIdent": "codeql-cli_v2.11.6" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using CodeQLToolkit.Features.Test.Commands; | ||
using CodeQLToolkit.Features.Validation.Lifecycle; | ||
using CodeQLToolkit.Features.Validation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using CodeQLToolkit.Features.Bundle.Commands; | ||
using CodeQLToolkit.Features.Bundle.Lifecycle; | ||
|
||
namespace CodeQLToolkit.Features.Bundle | ||
{ | ||
public class BundleFeatureMain : IToolkitFeature | ||
|
||
{ | ||
readonly BundleCommandFeature commandFeature; | ||
readonly BundleLifecycleFeature lifecycleFeature; | ||
readonly static BundleFeatureMain instance; | ||
|
||
static BundleFeatureMain() | ||
{ | ||
instance = new BundleFeatureMain(); | ||
} | ||
|
||
private BundleFeatureMain() | ||
{ | ||
commandFeature = new BundleCommandFeature(); | ||
lifecycleFeature = new BundleLifecycleFeature(); | ||
} | ||
public static BundleFeatureMain Instance { get { return instance; } } | ||
|
||
public void Register(Command parentCommand) | ||
{ | ||
var bundleFeatureCommand = new Command("bundle", "Features related creation and usage of custom CodeQL bundles."); | ||
parentCommand.Add(bundleFeatureCommand); | ||
|
||
Log<BundleFeatureMain>.G().LogInformation("Registering command submodule."); | ||
commandFeature.Register(bundleFeatureCommand); | ||
|
||
Log<BundleFeatureMain>.G().LogInformation("Registering lifecycle submodule."); | ||
lifecycleFeature.Register(bundleFeatureCommand); | ||
|
||
} | ||
|
||
public int Run() | ||
{ | ||
return 0; | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/CodeQLToolkit.Features/Bundle/Commands/BundleCommandFeature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using CodeQLToolkit.Shared.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeQLToolkit.Features.Bundle.Commands | ||
{ | ||
public class BundleCommandFeature : FeatureBase, IToolkitLifecycleFeature | ||
{ | ||
public override LanguageType[] SupportedLangauges | ||
{ | ||
get => new LanguageType[] { | ||
LanguageType.C, | ||
LanguageType.CPP, | ||
LanguageType.CSHARP, | ||
LanguageType.JAVA, | ||
LanguageType.JAVASCRIPT, | ||
LanguageType.GO, | ||
LanguageType.RUBY, | ||
LanguageType.PYTHON | ||
}; | ||
} | ||
|
||
public BundleCommandFeature() | ||
{ | ||
FeatureName = "Bundle"; | ||
} | ||
|
||
public void Register(Command parentCommand) | ||
{ | ||
Log<BundleCommandFeature>.G().LogInformation("Registering command submodule."); | ||
|
||
|
||
var runCommand = new Command("run", "Functions pertaining running bundle commands."); | ||
parentCommand.Add(runCommand); | ||
|
||
//var checkQueryQueriesCommand = new Command("check-queries", "Checks the query metadata for the specified language."); | ||
|
||
//var languageOption = new Option<string>("--language", $"The language to run tests for.") { IsRequired = true }.FromAmong(SupportedLangauges.Select(x => x.ToOptionString()).ToArray()); | ||
|
||
//checkQueryQueriesCommand.Add(languageOption); | ||
|
||
//runCommand.Add(checkQueryQueriesCommand); | ||
|
||
|
||
//checkQueryQueriesCommand.SetHandler((language, basePath, prettyPrint) => | ||
//{ | ||
// Log<BundleCommandFeature>.G().LogInformation("Executing check-query-metadata command..."); | ||
|
||
// new CheckQueriesCommandTarget() | ||
// { | ||
// Base = basePath, | ||
// Language = language, | ||
// PrettyPrint = prettyPrint, | ||
// }.Run(); | ||
|
||
//}, languageOption, Globals.BasePathOption, prettyPrintOption); | ||
} | ||
|
||
public int Run() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/CodeQLToolkit.Features/Bundle/Lifecycle/BaseLifecycleTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeQLToolkit.Features.Bundle.Lifecycle | ||
{ | ||
abstract public class BaseLifecycleTarget : ILifecycleTarget | ||
{ | ||
public int NumThreads { get; set; } | ||
public string UseRunner { get; set; } | ||
|
||
public string ExtraArgs { get; set; } | ||
|
||
|
||
|
||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/CodeQLToolkit.Features/Bundle/Lifecycle/BundleLifecycleFeature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using CodeQLToolkit.Features.CodeQL.Lifecycle.Targets; | ||
using CodeQLToolkit.Features.CodeQL.Lifecycle; | ||
using CodeQLToolkit.Features.Test.Lifecycle.Targets; | ||
using CodeQLToolkit.Features.Test.Lifecycle.Targets.Actions; | ||
using CodeQLToolkit.Shared.Utils; | ||
using System.CommandLine; | ||
using System.Reflection; | ||
using CodeQLToolkit.Features.Bundle.Lifecycle.Targets; | ||
|
||
namespace CodeQLToolkit.Features.Bundle.Lifecycle | ||
{ | ||
public class BundleLifecycleFeature : FeatureBase, IToolkitLifecycleFeature | ||
{ | ||
public BundleLifecycleFeature() | ||
{ | ||
FeatureName = "Bundle"; | ||
} | ||
|
||
public override LanguageType[] SupportedLangauges | ||
{ | ||
get => new LanguageType[] { | ||
LanguageType.C, | ||
LanguageType.CPP, | ||
LanguageType.CSHARP, | ||
LanguageType.JAVA, | ||
LanguageType.JAVASCRIPT, | ||
LanguageType.GO, | ||
LanguageType.RUBY, | ||
LanguageType.PYTHON | ||
}; | ||
} | ||
|
||
public void Register(Command parentCommand) | ||
{ | ||
Log<BundleLifecycleFeature>.G().LogInformation("Registering lifecycle submodule."); | ||
|
||
var setCommand = new Command("set", "Functions pertaining to setting variables related to custom CodeQL bundles."); | ||
parentCommand.Add(setCommand); | ||
|
||
var enableCommand = new Command("enable-custom-bundles", "Enables custom CodeQL Bundles."); | ||
setCommand.Add(enableCommand); | ||
|
||
var disableCommand = new Command("disable-custom-bundles", "Disables custom CodeQL Bundles."); | ||
setCommand.Add(disableCommand); | ||
|
||
var getCommand = new Command("get", "Functions pertaining to getting variables related to CodeQL Bundles."); | ||
parentCommand.Add(getCommand); | ||
|
||
var getEnabledCommand = new Command("enabled", "Determines if custom CodeQL Bundles are enabled."); | ||
getCommand.Add(getEnabledCommand); | ||
|
||
{ | ||
enableCommand.SetHandler((basePath) => | ||
{ | ||
Log<CodeQLLifecycleFeature>.G().LogInformation("Executing enable command..."); | ||
|
||
new SetEnableCustomCodeQLBundlesLifecycleTarget() | ||
{ | ||
Base = basePath | ||
}.Run(); | ||
|
||
}, Globals.BasePathOption); | ||
} | ||
|
||
{ | ||
disableCommand.SetHandler((basePath) => | ||
{ | ||
Log<CodeQLLifecycleFeature>.G().LogInformation("Executing get enabled command..."); | ||
|
||
new SetDisableCustomCodeQLBundlesLifecycleTarget() | ||
{ | ||
Base = basePath | ||
}.Run(); | ||
|
||
}, Globals.BasePathOption); | ||
} | ||
|
||
|
||
{ | ||
getEnabledCommand.SetHandler((basePath) => | ||
{ | ||
Log<CodeQLLifecycleFeature>.G().LogInformation("Executing disable command..."); | ||
|
||
new GetEnabledCustomCodeQLBundlesLifecycleTarget() | ||
{ | ||
Base = basePath | ||
}.Run(); | ||
|
||
}, Globals.BasePathOption); | ||
} | ||
|
||
|
||
} | ||
|
||
public int Run() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...Toolkit.Features/Bundle/Lifecycle/Targets/GetEnabledCustomCodeQLBundlesLifecycleTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using CodeQLToolkit.Shared.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeQLToolkit.Features.Bundle.Lifecycle.Targets | ||
{ | ||
public class GetEnabledCustomCodeQLBundlesLifecycleTarget : ILifecycleTarget | ||
{ | ||
override public void Run() | ||
{ | ||
Log<GetEnabledCustomCodeQLBundlesLifecycleTarget>.G().LogInformation("Running get enabled command..."); | ||
|
||
var c = new QLTConfig() | ||
{ | ||
Base = Base | ||
}; | ||
|
||
var config = c.FromFile(); | ||
|
||
Console.WriteLine($"---------current settings---------"); | ||
Console.WriteLine($"CodeQL Custom Bundles Enabled: {config.EnableCustomCodeQLBundles}"); | ||
Console.WriteLine($"----------------------------------"); | ||
Console.WriteLine("(hint: use `qlt bundle set` to modify these values.)"); | ||
|
||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...Toolkit.Features/Bundle/Lifecycle/Targets/SetDisableCustomCodeQLBundlesLifecycleTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using CodeQLToolkit.Shared.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeQLToolkit.Features.Bundle.Lifecycle.Targets | ||
{ | ||
public class SetDisableCustomCodeQLBundlesLifecycleTarget : ILifecycleTarget | ||
{ | ||
override public void Run() | ||
{ | ||
Log<SetDisableCustomCodeQLBundlesLifecycleTarget>.G().LogInformation("Running set command..."); | ||
|
||
var c = new QLTConfig() | ||
{ | ||
Base = Base | ||
}; | ||
|
||
var config = c.FromFile(); | ||
|
||
config.EnableCustomCodeQLBundles = false; | ||
|
||
config.ToFile(); | ||
|
||
Log<SetDisableCustomCodeQLBundlesLifecycleTarget>.G().LogInformation("Wrote to file..."); | ||
|
||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...LToolkit.Features/Bundle/Lifecycle/Targets/SetEnableCustomCodeQLBundlesLifecycleTarget.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using CodeQLToolkit.Shared.Utils; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CodeQLToolkit.Features.Bundle.Lifecycle.Targets | ||
{ | ||
public class SetEnableCustomCodeQLBundlesLifecycleTarget : ILifecycleTarget | ||
{ | ||
override public void Run() | ||
{ | ||
Log<SetEnableCustomCodeQLBundlesLifecycleTarget>.G().LogInformation("Running set command..."); | ||
|
||
var c = new QLTConfig() | ||
{ | ||
Base = Base | ||
}; | ||
|
||
var config = c.FromFile(); | ||
|
||
config.EnableCustomCodeQLBundles = true; | ||
|
||
config.ToFile(); | ||
|
||
Log<SetEnableCustomCodeQLBundlesLifecycleTarget>.G().LogInformation("Wrote to file..."); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.