From 8f0b77d54f2d03aa1ce7389b91e6d19d73014b58 Mon Sep 17 00:00:00 2001 From: Asger F Date: Fri, 3 Mar 2023 11:44:42 +0100 Subject: [PATCH] Revert "C#: Tool status page support" --- .../BuildScripts.cs | 11 - .../Semmle.Autobuild.Cpp/CppAutobuilder.cs | 3 +- .../BuildScripts.cs | 11 - .../Semmle.Autobuild.CSharp/AutoBuildRule.cs | 69 ------ .../CSharpAutobuilder.cs | 188 +++++---------- .../CSharpDiagnosticClassifier.cs | 133 ----------- .../Semmle.Autobuild.CSharp/DotNetRule.cs | 20 +- .../AutobuildOptions.cs | 1 - .../Semmle.Autobuild.Shared/Autobuilder.cs | 121 +--------- .../Semmle.Autobuild.Shared/BuildActions.cs | 35 --- .../BuildCommandAutoRule.cs | 37 +-- .../Semmle.Autobuild.Shared/BuildScript.cs | 96 -------- .../DiagnosticClassifier.cs | 96 -------- .../Semmle.Autobuild.Shared/EnvVars.cs | 13 - .../Semmle.Autobuild.Shared}/Language.cs | 2 +- .../Semmle.Autobuild.Shared/MarkdownUtil.cs | 65 ----- .../Semmle.Autobuild.Shared/MsBuildRule.cs | 16 +- .../ProjectOrSolution.cs | 1 - .../extractor/Semmle.Util/Semmle.Util.csproj | 1 - .../extractor/Semmle.Util/ToolStatusPage.cs | 224 ------------------ .../diagnostics.expected | 32 --- .../diag_dotnet_incompatible/test.csproj | 66 ------ .../diag_dotnet_incompatible/test.py | 5 - .../diagnostics.expected | 32 --- .../diag_missing_project_files/test.py | 5 - .../diag_missing_project_files/test.sln | 26 -- .../diagnostics.expected | 48 ---- .../diag_missing_xamarin_sdk/test.csproj | 11 - .../diag_missing_xamarin_sdk/test.py | 5 - .../posix-only/diag_autobuild_script/build.sh | 3 - .../diagnostics.expected | 32 --- .../posix-only/diag_autobuild_script/test.py | 5 - .../posix-only/diag_multiple_scripts/build.sh | 3 - .../diagnostics.expected | 32 --- .../diag_multiple_scripts/scripts/build.sh | 3 - .../posix-only/diag_multiple_scripts/test.py | 5 - .../diag_autobuild_script/build.bat | 1 - .../diagnostics.expected | 32 --- .../diag_autobuild_script/test.py | 5 - .../diag_multiple_scripts/build.bat | 1 - .../diagnostics.expected | 32 --- .../diag_multiple_scripts/scripts/build.bat | 1 - .../diag_multiple_scripts/test.py | 5 - 43 files changed, 81 insertions(+), 1452 deletions(-) delete mode 100644 csharp/autobuilder/Semmle.Autobuild.CSharp/AutoBuildRule.cs delete mode 100644 csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpDiagnosticClassifier.cs delete mode 100644 csharp/autobuilder/Semmle.Autobuild.Shared/DiagnosticClassifier.cs delete mode 100644 csharp/autobuilder/Semmle.Autobuild.Shared/EnvVars.cs rename csharp/{extractor/Semmle.Util => autobuilder/Semmle.Autobuild.Shared}/Language.cs (95%) delete mode 100644 csharp/autobuilder/Semmle.Autobuild.Shared/MarkdownUtil.cs delete mode 100644 csharp/extractor/Semmle.Util/ToolStatusPage.cs delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/diagnostics.expected delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.csproj delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.py delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_missing_project_files/diagnostics.expected delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.py delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.sln delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/diagnostics.expected delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.csproj delete mode 100644 csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.py delete mode 100755 csharp/ql/integration-tests/posix-only/diag_autobuild_script/build.sh delete mode 100644 csharp/ql/integration-tests/posix-only/diag_autobuild_script/diagnostics.expected delete mode 100644 csharp/ql/integration-tests/posix-only/diag_autobuild_script/test.py delete mode 100755 csharp/ql/integration-tests/posix-only/diag_multiple_scripts/build.sh delete mode 100644 csharp/ql/integration-tests/posix-only/diag_multiple_scripts/diagnostics.expected delete mode 100755 csharp/ql/integration-tests/posix-only/diag_multiple_scripts/scripts/build.sh delete mode 100644 csharp/ql/integration-tests/posix-only/diag_multiple_scripts/test.py delete mode 100644 csharp/ql/integration-tests/windows-only/diag_autobuild_script/build.bat delete mode 100644 csharp/ql/integration-tests/windows-only/diag_autobuild_script/diagnostics.expected delete mode 100644 csharp/ql/integration-tests/windows-only/diag_autobuild_script/test.py delete mode 100644 csharp/ql/integration-tests/windows-only/diag_multiple_scripts/build.bat delete mode 100644 csharp/ql/integration-tests/windows-only/diag_multiple_scripts/diagnostics.expected delete mode 100644 csharp/ql/integration-tests/windows-only/diag_multiple_scripts/scripts/build.bat delete mode 100644 csharp/ql/integration-tests/windows-only/diag_multiple_scripts/test.py diff --git a/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs b/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs index ecb2e58174d..846d8333030 100644 --- a/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs +++ b/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs @@ -1,6 +1,5 @@ using Xunit; using Semmle.Autobuild.Shared; -using Semmle.Util; using System.Collections.Generic; using System; using System.Linq; @@ -76,15 +75,6 @@ namespace Semmle.Autobuild.Cpp.Tests throw new ArgumentException("Missing RunProcess " + pattern); } - int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary? env, BuildOutputHandler onOutput, BuildOutputHandler onError) - { - var ret = (this as IBuildActions).RunProcess(cmd, args, workingDirectory, env, out var stdout); - - stdout.ForEach(line => onOutput(line)); - - return ret; - } - public IList DirectoryDeleteIn = new List(); void IBuildActions.DirectoryDelete(string dir, bool recursive) @@ -253,7 +243,6 @@ namespace Semmle.Autobuild.Cpp.Tests Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_TRAP_DIR"] = ""; Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_SOURCE_ARCHIVE_DIR"] = ""; Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_ROOT"] = $@"C:\codeql\{codeqlUpperLanguage.ToLowerInvariant()}"; - Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_DIAGNOSTIC_DIR"] = Path.GetTempPath(); Actions.GetEnvironmentVariable["CODEQL_JAVA_HOME"] = @"C:\codeql\tools\java"; Actions.GetEnvironmentVariable["CODEQL_PLATFORM"] = "win64"; Actions.GetEnvironmentVariable["SEMMLE_DIST"] = @"C:\odasa"; diff --git a/cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs b/cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs index e3853b44a0c..1503dedb376 100644 --- a/cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs +++ b/cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs @@ -1,5 +1,4 @@ using Semmle.Autobuild.Shared; -using Semmle.Util; namespace Semmle.Autobuild.Cpp { @@ -22,7 +21,7 @@ namespace Semmle.Autobuild.Cpp public class CppAutobuilder : Autobuilder { - public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options, new DiagnosticClassifier()) { } + public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options) { } public override BuildScript GetBuildScript() { diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs index 0243dc927d1..ec7c63a022d 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests/BuildScripts.cs @@ -1,6 +1,5 @@ using Xunit; using Semmle.Autobuild.Shared; -using Semmle.Util; using System.Collections.Generic; using System; using System.Linq; @@ -86,15 +85,6 @@ namespace Semmle.Autobuild.CSharp.Tests return ret; } - int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary? env, BuildOutputHandler onOutput, BuildOutputHandler onError) - { - var ret = (this as IBuildActions).RunProcess(cmd, args, workingDirectory, env, out var stdout); - - stdout.ForEach(line => onOutput(line)); - - return ret; - } - public IList DirectoryDeleteIn { get; } = new List(); void IBuildActions.DirectoryDelete(string dir, bool recursive) @@ -401,7 +391,6 @@ namespace Semmle.Autobuild.CSharp.Tests actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_TRAP_DIR"] = ""; actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_SOURCE_ARCHIVE_DIR"] = ""; actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_ROOT"] = $@"C:\codeql\{codeqlUpperLanguage.ToLowerInvariant()}"; - actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_DIAGNOSTIC_DIR"] = Path.GetTempPath(); actions.GetEnvironmentVariable["CODEQL_JAVA_HOME"] = @"C:\codeql\tools\java"; actions.GetEnvironmentVariable["CODEQL_PLATFORM"] = isWindows ? "win64" : "linux64"; actions.GetEnvironmentVariable["LGTM_INDEX_VSTOOLS_VERSION"] = vsToolsVersion; diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/AutoBuildRule.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp/AutoBuildRule.cs deleted file mode 100644 index cd138d62af5..00000000000 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/AutoBuildRule.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Semmle.Autobuild.Shared; -using Semmle.Extraction.CSharp; - -namespace Semmle.Autobuild.CSharp -{ - internal class AutoBuildRule : IBuildRule - { - private readonly CSharpAutobuilder autobuilder; - - public DotNetRule DotNetRule { get; } - - public MsBuildRule MsBuildRule { get; } - - public BuildCommandAutoRule BuildCommandAutoRule { get; } - - public AutoBuildRule(CSharpAutobuilder autobuilder) - { - this.autobuilder = autobuilder; - this.DotNetRule = new DotNetRule(); - this.MsBuildRule = new MsBuildRule(); - this.BuildCommandAutoRule = new BuildCommandAutoRule(DotNetRule.WithDotNet); - } - - public BuildScript Analyse(IAutobuilder builder, bool auto) - { - var cleanTrapFolder = - BuildScript.DeleteDirectory(this.autobuilder.TrapDir); - var cleanSourceArchive = - BuildScript.DeleteDirectory(this.autobuilder.SourceArchiveDir); - var tryCleanExtractorArgsLogs = - BuildScript.Create(actions => - { - foreach (var file in Extractor.GetCSharpArgsLogs()) - { - try - { - actions.FileDelete(file); - } - catch // lgtm[cs/catch-of-all-exceptions] lgtm[cs/empty-catch-block] - { } - } - - return 0; - }); - var attemptExtractorCleanup = - BuildScript.Try(cleanTrapFolder) & - BuildScript.Try(cleanSourceArchive) & - tryCleanExtractorArgsLogs & - BuildScript.DeleteFile(Extractor.GetCSharpLogPath()); - - /// - /// Execute script `s` and check that the C# extractor has been executed. - /// If either fails, attempt to cleanup any artifacts produced by the extractor, - /// and exit with code 1, in order to proceed to the next attempt. - /// - BuildScript IntermediateAttempt(BuildScript s) => - (s & this.autobuilder.CheckExtractorRun(false)) | - (attemptExtractorCleanup & BuildScript.Failure); - - return - // First try .NET Core - IntermediateAttempt(this.DotNetRule.Analyse(this.autobuilder, true)) | - // Then MSBuild - (() => IntermediateAttempt(this.MsBuildRule.Analyse(this.autobuilder, true))) | - // And finally look for a script that might be a build script - (() => this.BuildCommandAutoRule.Analyse(this.autobuilder, true) & this.autobuilder.CheckExtractorRun(true)); - } - } -} diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs index ed2ed4013ef..71891fa4e8b 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpAutobuilder.cs @@ -1,8 +1,6 @@ using Semmle.Extraction.CSharp; using Semmle.Util.Logging; using Semmle.Autobuild.Shared; -using Semmle.Util; -using System.Linq; namespace Semmle.Autobuild.CSharp { @@ -31,16 +29,25 @@ namespace Semmle.Autobuild.CSharp public class CSharpAutobuilder : Autobuilder { - private const string buildCommandDocsUrl = - "https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages"; - - private readonly AutoBuildRule autoBuildRule; - - public CSharpAutobuilder(IBuildActions actions, CSharpAutobuildOptions options) : base(actions, options, new CSharpDiagnosticClassifier()) => - this.autoBuildRule = new AutoBuildRule(this); + public CSharpAutobuilder(IBuildActions actions, CSharpAutobuildOptions options) : base(actions, options) { } public override BuildScript GetBuildScript() { + /// + /// A script that checks that the C# extractor has been executed. + /// + BuildScript CheckExtractorRun(bool warnOnFailure) => + BuildScript.Create(actions => + { + if (actions.FileExists(Extractor.GetCSharpLogPath())) + return 0; + + if (warnOnFailure) + Log(Severity.Error, "No C# code detected during build."); + + return 1; + }); + var attempt = BuildScript.Failure; switch (GetCSharpBuildStrategy()) { @@ -58,9 +65,47 @@ namespace Semmle.Autobuild.CSharp attempt = new DotNetRule().Analyse(this, false) & CheckExtractorRun(true); break; case CSharpBuildStrategy.Auto: + var cleanTrapFolder = + BuildScript.DeleteDirectory(TrapDir); + var cleanSourceArchive = + BuildScript.DeleteDirectory(SourceArchiveDir); + var tryCleanExtractorArgsLogs = + BuildScript.Create(actions => + { + foreach (var file in Extractor.GetCSharpArgsLogs()) + { + try + { + actions.FileDelete(file); + } + catch // lgtm[cs/catch-of-all-exceptions] lgtm[cs/empty-catch-block] + { } + } + + return 0; + }); + var attemptExtractorCleanup = + BuildScript.Try(cleanTrapFolder) & + BuildScript.Try(cleanSourceArchive) & + tryCleanExtractorArgsLogs & + BuildScript.DeleteFile(Extractor.GetCSharpLogPath()); + + /// + /// Execute script `s` and check that the C# extractor has been executed. + /// If either fails, attempt to cleanup any artifacts produced by the extractor, + /// and exit with code 1, in order to proceed to the next attempt. + /// + BuildScript IntermediateAttempt(BuildScript s) => + (s & CheckExtractorRun(false)) | + (attemptExtractorCleanup & BuildScript.Failure); + attempt = - // Attempt a few different build strategies to see if one works - this.autoBuildRule.Analyse(this, true) | + // First try .NET Core + IntermediateAttempt(new DotNetRule().Analyse(this, true)) | + // Then MSBuild + (() => IntermediateAttempt(new MsBuildRule().Analyse(this, true))) | + // And finally look for a script that might be a build script + (() => new BuildCommandAutoRule(DotNetRule.WithDotNet).Analyse(this, true) & CheckExtractorRun(true)) | // All attempts failed: print message AutobuildFailure(); break; @@ -69,127 +114,6 @@ namespace Semmle.Autobuild.CSharp return attempt; } - /// - /// A script that checks that the C# extractor has been executed. - /// - public BuildScript CheckExtractorRun(bool warnOnFailure) => - BuildScript.Create(actions => - { - if (actions.FileExists(Extractor.GetCSharpLogPath())) - return 0; - - if (warnOnFailure) - Log(Severity.Error, "No C# code detected during build."); - - return 1; - }); - - protected override void AutobuildFailureDiagnostic() - { - // if `ScriptPath` is not null here, the `BuildCommandAuto` rule was - // run and found at least one script to execute - if (this.autoBuildRule.BuildCommandAutoRule.ScriptPath is not null) - { - var relScriptPath = this.MakeRelative(autoBuildRule.BuildCommandAutoRule.ScriptPath); - - // if we found multiple build scripts in the project directory, then we can say - // as much to indicate that we may have picked the wrong one; - // otherwise, we just report that the one script we found didn't work - DiagnosticMessage message = - this.autoBuildRule.BuildCommandAutoRule.CandidatePaths.Count() > 1 ? - new( - this.Options.Language, - "multiple-build-scripts", - "There are multiple potential build scripts", - markdownMessage: - "CodeQL found multiple potential build scripts for your project and " + - $"attempted to run `{relScriptPath}`, which failed. " + - "This may not be the right build script for your project. " + - $"Set up a [manual build command]({buildCommandDocsUrl})." - ) : - new( - this.Options.Language, - "script-failure", - "Unable to build project using build script", - markdownMessage: - "CodeQL attempted to build your project using a script located at " + - $"`{relScriptPath}`, which failed. " + - $"Set up a [manual build command]({buildCommandDocsUrl})." - ); - - AddDiagnostic(message); - } - - // project files which don't exist get marked as not .NET core projects, but we don't want - // to show an error for this if the files don't exist - var foundNotDotNetProjects = autoBuildRule.DotNetRule.NotDotNetProjects.Where( - proj => this.Actions.FileExists(proj.FullPath) - ); - - // both dotnet and msbuild builds require project or solution files; if we haven't found any - // then neither of those rules would've worked - if (this.ProjectsOrSolutionsToBuild.Count == 0) - { - this.AddDiagnostic(new( - this.Options.Language, - "no-projects-or-solutions", - "No project or solutions files found", - markdownMessage: - "CodeQL could not find any project or solution files in your repository. " + - $"Set up a [manual build command]({buildCommandDocsUrl})." - )); - } - // show a warning if there are projects which are not compatible with .NET Core, in case that is unintentional - else if (foundNotDotNetProjects.Any()) - { - this.AddDiagnostic(new( - this.Options.Language, - "dotnet-incompatible-projects", - "Some projects are incompatible with .NET Core", - severity: DiagnosticMessage.TspSeverity.Warning, - markdownMessage: $""" - CodeQL found some projects which cannot be built with .NET Core: - - {autoBuildRule.DotNetRule.NotDotNetProjects.Select(p => this.MakeRelative(p.FullPath)).ToMarkdownList(MarkdownUtil.CodeFormatter, 5)} - """ - )); - } - - // report any projects that failed to build with .NET Core - if (autoBuildRule.DotNetRule.FailedProjectsOrSolutions.Any()) - { - this.AddDiagnostic(new( - this.Options.Language, - "dotnet-build-failure", - "Some projects or solutions failed to build using .NET Core", - markdownMessage: $""" - CodeQL was unable to build the following projects using .NET Core: - - {autoBuildRule.DotNetRule.FailedProjectsOrSolutions.Select(p => this.MakeRelative(p.FullPath)).ToMarkdownList(MarkdownUtil.CodeFormatter, 10)} - - Set up a [manual build command]({buildCommandDocsUrl}). - """ - )); - } - - // report any projects that failed to build with MSBuild - if (autoBuildRule.MsBuildRule.FailedProjectsOrSolutions.Any()) - { - this.AddDiagnostic(new( - this.Options.Language, - "msbuild-build-failure", - "Some projects or solutions failed to build using MSBuild", - markdownMessage: $""" - CodeQL was unable to build the following projects using MSBuild: - - {autoBuildRule.MsBuildRule.FailedProjectsOrSolutions.Select(p => this.MakeRelative(p.FullPath)).ToMarkdownList(MarkdownUtil.CodeFormatter, 10)} - - Set up a [manual build command]({buildCommandDocsUrl}). - """ - )); - } - } - /// /// Gets the build strategy that the autobuilder should apply, based on the /// options in the `lgtm.yml` file. diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpDiagnosticClassifier.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpDiagnosticClassifier.cs deleted file mode 100644 index e72c46ff361..00000000000 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/CSharpDiagnosticClassifier.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.RegularExpressions; -using Semmle.Autobuild.Shared; -using Semmle.Util; - -namespace Semmle.Autobuild.CSharp -{ - /// - /// A diagnostic rule which tries to identify missing Xamarin SDKs. - /// - public class MissingXamarinSdkRule : DiagnosticRule - { - private const string docsUrl = "https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-xamarin-applications"; - - public class Result : IDiagnosticsResult - { - /// - /// The name of the SDK that is missing. - /// - public string SDKName { get; } - - public Result(string sdkName) - { - this.SDKName = sdkName; - } - - public DiagnosticMessage ToDiagnosticMessage(Autobuilder builder, DiagnosticMessage.TspSeverity? severity = null) where T : AutobuildOptionsShared => new( - builder.Options.Language, - $"missing-xamarin-{this.SDKName.ToLower()}-sdk", - $"Missing Xamarin SDK for {this.SDKName}", - severity: severity ?? DiagnosticMessage.TspSeverity.Error, - markdownMessage: $"[Configure your workflow]({docsUrl}) for this SDK before running CodeQL." - ); - } - - public MissingXamarinSdkRule() : - base("MSB4019:[^\"]*\"[^\"]*Xamarin\\.(?[^\\.]*)\\.CSharp\\.targets\"") - { - } - - public override void Fire(DiagnosticClassifier classifier, Match match) - { - if (!match.Groups.TryGetValue("sdkName", out var sdkName)) - throw new ArgumentException("Expected regular expression match to contain sdkName"); - - var xamarinResults = classifier.Results.OfType().Where(result => - result.SDKName.Equals(sdkName.Value) - ); - - if (!xamarinResults.Any()) - classifier.Results.Add(new Result(sdkName.Value)); - } - } - - public class MissingProjectFileRule : DiagnosticRule - { - private const string runsOnDocsUrl = "https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on"; - private const string checkoutDocsUrl = "https://github.com/actions/checkout#usage"; - - public class Result : IDiagnosticsResult - { - /// - /// A set of missing project files. - /// - public HashSet MissingProjectFiles { get; } - - public Result() - { - this.MissingProjectFiles = new HashSet(); - } - - public DiagnosticMessage ToDiagnosticMessage(Autobuilder builder, DiagnosticMessage.TspSeverity? severity = null) where T : AutobuildOptionsShared => new( - builder.Options.Language, - "missing-project-files", - "Missing project files", - severity: severity ?? DiagnosticMessage.TspSeverity.Warning, - markdownMessage: $""" - Some project files were not found when CodeQL built your project: - - {this.MissingProjectFiles.AsEnumerable().Select(p => builder.MakeRelative(p)).ToMarkdownList(MarkdownUtil.CodeFormatter, 5)} - - This may lead to subsequent failures. You can check for common causes for missing project files: - - - Ensure that the project is built using the {runsOnDocsUrl.ToMarkdownLink("intended operating system")} and that filenames on case-sensitive platforms are correctly specified. - - If your repository uses Git submodules, ensure that those are {checkoutDocsUrl.ToMarkdownLink("checked out")} before the CodeQL action is run. - - If you auto-generate some project files as part of your build process, ensure that these are generated before the CodeQL action is run. - """ - ); - } - - public MissingProjectFileRule() : - base("MSB3202: The project file \"(?[^\"]+)\" was not found. \\[(?[^\\]]+)\\]") - { - } - - public override void Fire(DiagnosticClassifier classifier, Match match) - { - if (!match.Groups.TryGetValue("projectFile", out var projectFile)) - throw new ArgumentException("Expected regular expression match to contain projectFile"); - if (!match.Groups.TryGetValue("location", out var location)) - throw new ArgumentException("Expected regular expression match to contain location"); - - var result = classifier.Results.OfType().FirstOrDefault(); - - // if we do not yet have a result for this rule, create one and add it to the list - // of results the classifier knows about - if (result is null) - { - result = new Result(); - classifier.Results.Add(result); - } - - // then add the missing project file - result.MissingProjectFiles.Add(projectFile.Value); - } - } - - /// - /// Implements a which applies C#-specific rules to - /// the build output. - /// - public class CSharpDiagnosticClassifier : DiagnosticClassifier - { - public CSharpDiagnosticClassifier() - { - // add C#-specific rules to this classifier - this.AddRule(new MissingXamarinSdkRule()); - this.AddRule(new MissingProjectFileRule()); - } - } -} diff --git a/csharp/autobuilder/Semmle.Autobuild.CSharp/DotNetRule.cs b/csharp/autobuilder/Semmle.Autobuild.CSharp/DotNetRule.cs index e18058339f5..394349e2a40 100644 --- a/csharp/autobuilder/Semmle.Autobuild.CSharp/DotNetRule.cs +++ b/csharp/autobuilder/Semmle.Autobuild.CSharp/DotNetRule.cs @@ -15,15 +15,6 @@ namespace Semmle.Autobuild.CSharp /// internal class DotNetRule : IBuildRule { - public readonly List FailedProjectsOrSolutions = new(); - - /// - /// A list of projects which are incompatible with DotNet. - /// - public IEnumerable> NotDotNetProjects { get; private set; } - - public DotNetRule() => NotDotNetProjects = new List>(); - public BuildScript Analyse(IAutobuilder builder, bool auto) { if (!builder.ProjectsOrSolutionsToBuild.Any()) @@ -31,12 +22,10 @@ namespace Semmle.Autobuild.CSharp if (auto) { - NotDotNetProjects = builder.ProjectsOrSolutionsToBuild + var notDotNetProject = builder.ProjectsOrSolutionsToBuild .SelectMany(p => Enumerators.Singleton(p).Concat(p.IncludedProjects)) .OfType>() - .Where(p => !p.DotNetProject); - var notDotNetProject = NotDotNetProjects.FirstOrDefault(); - + .FirstOrDefault(p => !p.DotNetProject); if (notDotNetProject is not null) { builder.Log(Severity.Info, "Not using .NET Core because of incompatible project {0}", notDotNetProject); @@ -61,10 +50,7 @@ namespace Semmle.Autobuild.CSharp var build = GetBuildScript(builder, dotNetPath, environment, projectOrSolution.FullPath); - ret &= BuildScript.Try(clean) & BuildScript.Try(restore) & BuildScript.OnFailure(build, ret => - { - FailedProjectsOrSolutions.Add(projectOrSolution); - }); + ret &= BuildScript.Try(clean) & BuildScript.Try(restore) & build; } return ret; }); diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/AutobuildOptions.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/AutobuildOptions.cs index 8a02370bcf6..d51612272d0 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/AutobuildOptions.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/AutobuildOptions.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using Semmle.Util; namespace Semmle.Autobuild.Shared { diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/Autobuilder.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/Autobuilder.cs index 2335e15015e..1ef5ebd815d 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/Autobuilder.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/Autobuilder.cs @@ -1,4 +1,3 @@ -using Semmle.Util; using Semmle.Util.Logging; using System; using System.Collections.Generic; @@ -190,11 +189,10 @@ namespace Semmle.Autobuild.Shared /// solution file and tools. /// /// The command line options. - protected Autobuilder(IBuildActions actions, TAutobuildOptions options, DiagnosticClassifier diagnosticClassifier) + protected Autobuilder(IBuildActions actions, TAutobuildOptions options) { Actions = actions; Options = options; - DiagnosticClassifier = diagnosticClassifier; pathsLazy = new Lazy>(() => { @@ -234,53 +232,24 @@ namespace Semmle.Autobuild.Shared return ret ?? new List(); }); - CodeQLExtractorLangRoot = Actions.GetEnvironmentVariable(EnvVars.Root(this.Options.Language)); - CodeQlPlatform = Actions.GetEnvironmentVariable(EnvVars.Platform); + CodeQLExtractorLangRoot = Actions.GetEnvironmentVariable($"CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_ROOT"); + CodeQlPlatform = Actions.GetEnvironmentVariable("CODEQL_PLATFORM"); - TrapDir = RequireEnvironmentVariable(EnvVars.TrapDir(this.Options.Language)); - SourceArchiveDir = RequireEnvironmentVariable(EnvVars.SourceArchiveDir(this.Options.Language)); - DiagnosticsDir = RequireEnvironmentVariable(EnvVars.DiagnosticDir(this.Options.Language)); + TrapDir = + Actions.GetEnvironmentVariable($"CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_TRAP_DIR") ?? + throw new InvalidEnvironmentException($"The environment variable CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_TRAP_DIR has not been set."); - this.diagnostics = new DiagnosticsStream(Path.Combine(DiagnosticsDir, $"autobuilder-{DateTime.UtcNow:yyyyMMddHHmm}.jsonc")); + SourceArchiveDir = + Actions.GetEnvironmentVariable($"CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_SOURCE_ARCHIVE_DIR") ?? + throw new InvalidEnvironmentException($"The environment variable CODEQL_EXTRACTOR_{this.Options.Language.UpperCaseName}_SOURCE_ARCHIVE_DIR has not been set."); } - /// - /// Retrieves the value of an environment variable named or throws - /// an exception if no such environment variable has been set. - /// - /// The name of the environment variable. - /// The value of the environment variable. - /// - /// Thrown if the environment variable is not set. - /// - protected string RequireEnvironmentVariable(string name) - { - return Actions.GetEnvironmentVariable(name) ?? - throw new InvalidEnvironmentException($"The environment variable {name} has not been set."); - } + protected string TrapDir { get; } - public string TrapDir { get; } - - public string SourceArchiveDir { get; } - - public string DiagnosticsDir { get; } - - protected DiagnosticClassifier DiagnosticClassifier { get; } + protected string SourceArchiveDir { get; } private readonly ILogger logger = new ConsoleLogger(Verbosity.Info); - private readonly DiagnosticsStream diagnostics; - - /// - /// Makes relative to the root source directory. - /// - /// The path which to make relative. - /// The relative path. - public string MakeRelative(string path) - { - return Path.GetRelativePath(this.RootDirectory, path); - } - /// /// Log a given build event to the console. /// @@ -291,15 +260,6 @@ namespace Semmle.Autobuild.Shared logger.Log(severity, format, args); } - /// - /// Write to the diagnostics file. - /// - /// The diagnostics entry to write. - public void AddDiagnostic(DiagnosticMessage diagnostic) - { - diagnostics.AddEntry(diagnostic); - } - /// /// Attempt to build this project. /// @@ -323,19 +283,7 @@ namespace Semmle.Autobuild.Shared Log(silent ? Severity.Debug : Severity.Info, $"Exit code {ret}{(string.IsNullOrEmpty(msg) ? "" : $": {msg}")}"); } - var onOutput = BuildOutputHandler(Console.Out); - var onError = BuildOutputHandler(Console.Error); - - var buildResult = script.Run(Actions, startCallback, exitCallback, onOutput, onError); - - // if the build succeeded, all diagnostics we captured from the build output should be warnings; - // otherwise they should all be errors - var diagSeverity = buildResult == 0 ? DiagnosticMessage.TspSeverity.Warning : DiagnosticMessage.TspSeverity.Error; - this.DiagnosticClassifier.Results - .Select(result => result.ToDiagnosticMessage(this, diagSeverity)) - .ForEach(AddDiagnostic); - - return buildResult; + return script.Run(Actions, startCallback, exitCallback); } /// @@ -343,58 +291,13 @@ namespace Semmle.Autobuild.Shared /// public abstract BuildScript GetBuildScript(); - - /// - /// Produces a diagnostic for the tool status page that we were unable to automatically - /// build the user's project and that they can manually specify a build command. This - /// can be overriden to implement more specific messages depending on the origin of - /// the failure. - /// - protected virtual void AutobuildFailureDiagnostic() => AddDiagnostic(new DiagnosticMessage( - this.Options.Language, - "autobuild-failure", - "Unable to build project", - visibility: new DiagnosticMessage.TspVisibility(statusPage: true), - plaintextMessage: """ - We were unable to automatically build your project. - Set up a manual build command. - """ - )); - - /// - /// Returns a build script that can be run upon autobuild failure. - /// - /// - /// A build script that reports that we could not automatically detect a suitable build method. - /// protected BuildScript AutobuildFailure() => BuildScript.Create(actions => { Log(Severity.Error, "Could not auto-detect a suitable build method"); - - AutobuildFailureDiagnostic(); - return 1; }); - /// - /// Constructs a which uses the - /// to classify build output. All data also gets written to . - /// - /// - /// The to which the build output would have normally been written to. - /// This is normally or . - /// - /// The constructed . - protected BuildOutputHandler BuildOutputHandler(TextWriter writer) => new(data => - { - if (data is not null) - { - writer.WriteLine(data); - DiagnosticClassifier.ClassifyLine(data); - } - }); - /// /// Value of CODEQL_EXTRACTOR__ROOT environment variable. /// diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/BuildActions.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/BuildActions.cs index d4ca15cd246..f3f9ae15da6 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/BuildActions.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/BuildActions.cs @@ -11,26 +11,11 @@ using System.Runtime.InteropServices; namespace Semmle.Autobuild.Shared { - public delegate void BuildOutputHandler(string? data); - /// /// Wrapper around system calls so that the build scripts can be unit-tested. /// public interface IBuildActions { - - /// - /// Runs a process, captures its output, and provides it asynchronously. - /// - /// The exe to run. - /// The other command line arguments. - /// The working directory (null for current directory). - /// Additional environment variables. - /// A handler for stdout output. - /// A handler for stderr output. - /// The process exit code. - int RunProcess(string exe, string args, string? workingDirectory, IDictionary? env, BuildOutputHandler onOutput, BuildOutputHandler onError); - /// /// Runs a process and captures its output. /// @@ -197,26 +182,6 @@ namespace Semmle.Autobuild.Shared return pi; } - int IBuildActions.RunProcess(string exe, string args, string? workingDirectory, System.Collections.Generic.IDictionary? env, BuildOutputHandler onOutput, BuildOutputHandler onError) - { - var pi = GetProcessStartInfo(exe, args, workingDirectory, env, true); - using var p = new Process - { - StartInfo = pi - }; - p.StartInfo.RedirectStandardError = true; - p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => onOutput(e.Data)); - p.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => onError(e.Data)); - - p.Start(); - - p.BeginErrorReadLine(); - p.BeginOutputReadLine(); - - p.WaitForExit(); - return p.ExitCode; - } - int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary? environment) { var pi = GetProcessStartInfo(cmd, args, workingDirectory, environment, false); diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/BuildCommandAutoRule.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/BuildCommandAutoRule.cs index c0990a75ae1..0d44f0dad4d 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/BuildCommandAutoRule.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/BuildCommandAutoRule.cs @@ -11,42 +11,22 @@ namespace Semmle.Autobuild.Shared { private readonly WithDotNet withDotNet; - /// - /// A list of paths to files in the project directory which we classified as scripts. - /// - public IEnumerable CandidatePaths { get; private set; } - - /// - /// The path of the script we decided to run, if any. - /// - public string? ScriptPath { get; private set; } - public BuildCommandAutoRule(WithDotNet withDotNet) { this.withDotNet = withDotNet; - this.CandidatePaths = new List(); } - /// - /// A list of extensions that we consider to be for scripts on Windows. - /// private readonly IEnumerable winExtensions = new List { ".bat", ".cmd", ".exe" }; - /// - /// A list of extensions that we consider to be for scripts on Linux. - /// private readonly IEnumerable linuxExtensions = new List { "", ".sh" }; - /// - /// A list of filenames without extensions that we think might be build scripts. - /// private readonly IEnumerable buildScripts = new List { "build" }; @@ -55,25 +35,18 @@ namespace Semmle.Autobuild.Shared { builder.Log(Severity.Info, "Attempting to locate build script"); - // a list of extensions for files that we consider to be scripts on the current platform var extensions = builder.Actions.IsWindows() ? winExtensions : linuxExtensions; - // a list of combined base script names with the current platform's script extensions - // e.g. for Linux: build, build.sh var scripts = buildScripts.SelectMany(s => extensions.Select(e => s + e)); - // search through the files in the project directory for paths which end in one of - // the names given by `scripts`, then order them by their distance from the root - this.CandidatePaths = builder.Paths.Where(p => scripts.Any(p.Item1.ToLower().EndsWith)).OrderBy(p => p.Item2).Select(p => p.Item1); - // pick the first matching path, if there is one - this.ScriptPath = this.CandidatePaths.FirstOrDefault(); + var scriptPath = builder.Paths.Where(p => scripts.Any(p.Item1.ToLower().EndsWith)).OrderBy(p => p.Item2).Select(p => p.Item1).FirstOrDefault(); - if (this.ScriptPath is null) + if (scriptPath is null) return BuildScript.Failure; var chmod = new CommandBuilder(builder.Actions); - chmod.RunCommand("/bin/chmod", $"u+x {this.ScriptPath}"); + chmod.RunCommand("/bin/chmod", $"u+x {scriptPath}"); var chmodScript = builder.Actions.IsWindows() ? BuildScript.Success : BuildScript.Try(chmod.Script); - var dir = builder.Actions.GetDirectoryName(this.ScriptPath); + var dir = builder.Actions.GetDirectoryName(scriptPath); // A specific .NET Core version may be required return chmodScript & withDotNet(builder, environment => @@ -85,7 +58,7 @@ namespace Semmle.Autobuild.Shared if (vsTools is not null) command.CallBatFile(vsTools.Path); - command.RunCommand(this.ScriptPath); + command.RunCommand(scriptPath); return command.Script; }); } diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/BuildScript.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/BuildScript.cs index 573c6f3043b..9840d63c5e4 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/BuildScript.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/BuildScript.cs @@ -46,33 +46,6 @@ namespace Semmle.Autobuild.Shared /// The exit code from this build script. public abstract int Run(IBuildActions actions, Action startCallback, Action exitCallBack, out IList stdout); - /// - /// Runs this build command. - /// - /// - /// The interface used to implement the build actions. - /// - /// - /// A call back that is called every time a new process is started. The - /// argument to the call back is a textual representation of the process. - /// - /// - /// A call back that is called every time a new process exits. The first - /// argument to the call back is the exit code, and the second argument is - /// an exit message. - /// - /// - /// A handler for data read from stdout. - /// - /// - /// A handler for data read from stderr. - /// - /// The exit code from this build script. - public abstract int Run(IBuildActions actions, Action startCallback, Action exitCallBack, BuildOutputHandler onOutput, BuildOutputHandler onError); - - /// - /// A build script which executes an external program or script. - /// private class BuildCommand : BuildScript { private readonly string exe, arguments; @@ -137,29 +110,8 @@ namespace Semmle.Autobuild.Shared return ret; } - public override int Run(IBuildActions actions, Action startCallback, Action exitCallBack, BuildOutputHandler onOutput, BuildOutputHandler onError) - { - startCallback(this.ToString(), silent); - var ret = 1; - var retMessage = ""; - try - { - ret = actions.RunProcess(exe, arguments, workingDirectory, environment, onOutput, onError); - } - catch (Exception ex) - when (ex is System.ComponentModel.Win32Exception || ex is FileNotFoundException) - { - retMessage = ex.Message; - } - exitCallBack(ret, retMessage, silent); - return ret; - } - } - /// - /// A build script which runs a C# function. - /// private class ReturnBuildCommand : BuildScript { private readonly Func func; @@ -175,13 +127,8 @@ namespace Semmle.Autobuild.Shared stdout = Array.Empty(); return func(actions); } - - public override int Run(IBuildActions actions, Action startCallback, Action exitCallBack, BuildOutputHandler onOutput, BuildOutputHandler onError) => func(actions); } - /// - /// Allows two build scripts to be composed sequentially. - /// private class BindBuildScript : BuildScript { private readonly BuildScript s1; @@ -228,32 +175,6 @@ namespace Semmle.Autobuild.Shared stdout = @out; return ret2; } - - public override int Run(IBuildActions actions, Action startCallback, Action exitCallBack, BuildOutputHandler onOutput, BuildOutputHandler onError) - { - int ret1; - if (s2a is not null) - { - var stdout1 = new List(); - var onOutputWrapper = new BuildOutputHandler(data => - { - if (data is not null) - stdout1.Add(data); - - onOutput(data); - }); - ret1 = s1.Run(actions, startCallback, exitCallBack, onOutputWrapper, onError); - return s2a(stdout1, ret1).Run(actions, startCallback, exitCallBack, onOutput, onError); - } - - if (s2b is not null) - { - ret1 = s1.Run(actions, startCallback, exitCallBack, onOutput, onError); - return s2b(ret1).Run(actions, startCallback, exitCallBack, onOutput, onError); - } - - throw new InvalidOperationException("Unexpected error"); - } } /// @@ -339,23 +260,6 @@ namespace Semmle.Autobuild.Shared /// public static BuildScript Try(BuildScript s) => s | Success; - /// - /// Creates a build script that runs the build script . If - /// running fails, is invoked with - /// the exit code. - /// - /// The build script to run. - /// - /// The callback that is invoked if failed. - /// - /// The build script which implements this. - public static BuildScript OnFailure(BuildScript s, Action k) => - new BindBuildScript(s, ret => Create(actions => - { - if (!Succeeded(ret)) k(ret); - return ret; - })); - /// /// Creates a build script that deletes the given directory. /// diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/DiagnosticClassifier.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/DiagnosticClassifier.cs deleted file mode 100644 index 94af39ca959..00000000000 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/DiagnosticClassifier.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Collections.Generic; -using System.Text.RegularExpressions; -using Semmle.Util; - -namespace Semmle.Autobuild.Shared -{ - /// - /// Direct results result from the successful application of a , - /// which can later be converted to a corresponding . - /// - public interface IDiagnosticsResult - { - /// - /// Produces a corresponding to this result. - /// - /// - /// The autobuilder to use for constructing the base . - /// - /// - /// An optional severity value which overrides the default severity of the diagnostic. - /// - /// The corresponding to this result. - DiagnosticMessage ToDiagnosticMessage(Autobuilder builder, DiagnosticMessage.TspSeverity? severity = null) where T : AutobuildOptionsShared; - } - - public class DiagnosticRule - { - /// - /// The pattern against which this rule matches build output. - /// - public Regex Pattern { get; } - - /// - /// Constructs a diagnostic rule for the given . - /// - /// - public DiagnosticRule(Regex pattern) - { - this.Pattern = pattern; - } - - /// - /// Constructs a diagnostic rule for the given regular expression . - /// - /// - public DiagnosticRule(string pattern) - { - this.Pattern = new Regex(pattern, RegexOptions.Compiled); - } - - /// - /// Used by a to - /// signal that the rule has matched some build output with . - /// - /// The classifier which is firing the rule. - /// The that resulted from applying the rule. - public virtual void Fire(DiagnosticClassifier classifier, Match match) { } - } - - public class DiagnosticClassifier - { - private readonly List rules; - public readonly List Results; - - public DiagnosticClassifier() - { - this.rules = new List(); - this.Results = new List(); - } - - /// - /// Adds to this classifier. - /// - /// The rule to add. - protected void AddRule(DiagnosticRule rule) - { - this.rules.Add(rule); - } - - /// - /// Applies all of this classifier's rules to to see which match. - /// - /// The line to which the rules should be applied to. - public void ClassifyLine(string line) - { - this.rules.ForEach(rule => - { - var match = rule.Pattern.Match(line); - if (match.Success) - { - rule.Fire(this, match); - } - }); - } - } -} diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/EnvVars.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/EnvVars.cs deleted file mode 100644 index 5d1197f0a9e..00000000000 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/EnvVars.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Semmle.Util; - -namespace Semmle.Autobuild.Shared -{ - public static class EnvVars - { - public const string Platform = "CODEQL_PLATFORM"; - public static string Root(Language language) => $"CODEQL_EXTRACTOR_{language.UpperCaseName}_ROOT"; - public static string TrapDir(Language language) => $"CODEQL_EXTRACTOR_{language.UpperCaseName}_TRAP_DIR"; - public static string SourceArchiveDir(Language language) => $"CODEQL_EXTRACTOR_{language.UpperCaseName}_SOURCE_ARCHIVE_DIR"; - public static string DiagnosticDir(Language language) => $"CODEQL_EXTRACTOR_{language.UpperCaseName}_DIAGNOSTIC_DIR"; - } -} diff --git a/csharp/extractor/Semmle.Util/Language.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/Language.cs similarity index 95% rename from csharp/extractor/Semmle.Util/Language.cs rename to csharp/autobuilder/Semmle.Autobuild.Shared/Language.cs index fa3d71b6154..c53eb7e592d 100644 --- a/csharp/extractor/Semmle.Util/Language.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/Language.cs @@ -1,4 +1,4 @@ -namespace Semmle.Util +namespace Semmle.Autobuild.Shared { public sealed class Language { diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/MarkdownUtil.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/MarkdownUtil.cs deleted file mode 100644 index 13a3533eb31..00000000000 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/MarkdownUtil.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Semmle.Autobuild.Shared -{ - public static class MarkdownUtil - { - /// - /// Formats items as markdown inline code. - /// - /// A function which formats items as markdown inline code. - public static readonly Func CodeFormatter = item => $"`{item}`"; - - /// - /// Formats the string as a markdown link. - /// - /// The URL for the link. - /// The text that is displayed. - /// A string containing a markdown-formatted link. - public static string ToMarkdownLink(this string link, string title) => $"[{title}]({link})"; - - /// - /// Renders as a markdown list of the project paths. - /// - /// - /// The list of projects whose paths should be rendered as a markdown list. - /// - /// The maximum number of items to include in the list. - /// Returns the markdown list as a string. - public static string ToMarkdownList(this IEnumerable projects, int? limit = null) - { - return projects.ToMarkdownList(p => $"`{p.FullPath}`", limit); - } - - /// - /// Renders as a markdown list. - /// - /// The item type. - /// The list that should be formatted as a markdown list. - /// A function which converts individual items into a string representation. - /// The maximum number of items to include in the list. - /// Returns the markdown list as a string. - public static string ToMarkdownList(this IEnumerable items, Func formatter, int? limit = null) - { - var sb = new StringBuilder(); - - // if there is a limit, take at most that many items from the start of the list - var list = limit is not null ? items.Take(limit.Value) : items; - sb.Append(string.Join('\n', list.Select(item => $"- {formatter(item)}"))); - - // if there were more items than allowed in the list, add an extra item indicating - // how many more items there were - var length = items.Count(); - - if (limit is not null && length > limit) - { - sb.Append($"\n- and {length - limit} more. View the CodeQL logs for a full list."); - } - - return sb.ToString(); - } - } -} diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/MsBuildRule.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/MsBuildRule.cs index e0e4404f312..56858cc87a2 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/MsBuildRule.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/MsBuildRule.cs @@ -1,6 +1,7 @@ using Semmle.Util.Logging; -using System.Collections.Generic; +using System; using System.Linq; +using System.Runtime.InteropServices; namespace Semmle.Autobuild.Shared { @@ -30,11 +31,6 @@ namespace Semmle.Autobuild.Shared /// public class MsBuildRule : IBuildRule { - /// - /// A list of solutions or projects which failed to build. - /// - public readonly List FailedProjectsOrSolutions = new(); - public BuildScript Analyse(IAutobuilder builder, bool auto) { if (!builder.ProjectsOrSolutionsToBuild.Any()) @@ -132,13 +128,7 @@ namespace Semmle.Autobuild.Shared command.Argument(builder.Options.MsBuildArguments); - // append the build script which invokes msbuild to the overall build script `ret`; - // we insert a check that building the current project or solution was successful: - // if it was not successful, we add it to `FailedProjectsOrSolutions` - ret &= BuildScript.OnFailure(command.Script, ret => - { - FailedProjectsOrSolutions.Add(projectOrSolution); - }); + ret &= command.Script; } return ret; diff --git a/csharp/autobuilder/Semmle.Autobuild.Shared/ProjectOrSolution.cs b/csharp/autobuilder/Semmle.Autobuild.Shared/ProjectOrSolution.cs index c0504dbcba4..d0c9eeb9669 100644 --- a/csharp/autobuilder/Semmle.Autobuild.Shared/ProjectOrSolution.cs +++ b/csharp/autobuilder/Semmle.Autobuild.Shared/ProjectOrSolution.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using Semmle.Util; namespace Semmle.Autobuild.Shared { diff --git a/csharp/extractor/Semmle.Util/Semmle.Util.csproj b/csharp/extractor/Semmle.Util/Semmle.Util.csproj index 894488f9f84..b2fa737f7c4 100644 --- a/csharp/extractor/Semmle.Util/Semmle.Util.csproj +++ b/csharp/extractor/Semmle.Util/Semmle.Util.csproj @@ -15,7 +15,6 @@ - diff --git a/csharp/extractor/Semmle.Util/ToolStatusPage.cs b/csharp/extractor/Semmle.Util/ToolStatusPage.cs deleted file mode 100644 index 85eca785e88..00000000000 --- a/csharp/extractor/Semmle.Util/ToolStatusPage.cs +++ /dev/null @@ -1,224 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Serialization; - -namespace Semmle.Util -{ - /// - /// Represents diagnostic messages for the tool status page. - /// - public class DiagnosticMessage - { - /// - /// Represents sources of diagnostic messages. - /// - public class TspSource - { - /// - /// An identifier under which it makes sense to group this diagnostic message. - /// This is used to build the SARIF reporting descriptor object. - /// - public string Id { get; } - /// - /// Display name for the ID. This is used to build the SARIF reporting descriptor object. - /// - public string Name { get; } - /// - /// Name of the CodeQL extractor. This is used to identify which tool component the reporting descriptor object should be nested under in SARIF. - /// - public string? ExtractorName { get; } - - public TspSource(string id, string name, string? extractorName = null) - { - Id = id; - Name = name; - ExtractorName = extractorName; - } - } - - /// - /// Enumerates severity levels for diagnostics. - /// - [JsonConverter(typeof(StringEnumConverter), typeof(CamelCaseNamingStrategy))] - public enum TspSeverity - { - Note, - Warning, - Error - } - - /// - /// Stores flags indicating where the diagnostic should be displayed. - /// - public class TspVisibility - { - /// - /// True if the message should be displayed on the status page (defaults to false). - /// - public bool? StatusPage { get; } - /// - /// True if the message should be counted in the diagnostics summary table printed by - /// codeql database analyze (defaults to false). - /// - public bool? CLISummaryTable { get; } - /// - /// True if the message should be sent to telemetry (defaults to false). - /// - public bool? Telemetry { get; } - - public TspVisibility(bool? statusPage = null, bool? cliSummaryTable = null, bool? telemetry = null) - { - this.StatusPage = statusPage; - this.CLISummaryTable = cliSummaryTable; - this.Telemetry = telemetry; - } - } - - /// - /// Represents source code locations for diagnostic messages. - /// - public class TspLocation - { - /// - /// Path to the affected file if appropriate, relative to the source root. - /// - public string? File { get; } - /// - /// The line where the range to which the diagnostic relates to starts. - /// - public int? StartLine { get; } - /// - /// The column where the range to which the diagnostic relates to starts. - /// - public int? StartColumn { get; } - /// - /// The line where the range to which the diagnostic relates to ends. - /// - public int? EndLine { get; } - /// - /// The column where the range to which the diagnostic relates to ends. - /// - public int? EndColumn { get; } - - public TspLocation(string? file = null, int? startLine = null, int? startColumn = null, int? endLine = null, int? endColumn = null) - { - this.File = file; - this.StartLine = startLine; - this.StartColumn = startColumn; - this.EndLine = endLine; - this.EndColumn = endColumn; - } - } - - /// - /// ISO 8601 timestamp. - /// - public string Timestamp { get; } - /// - /// The source of the diagnostic message. - /// - public TspSource Source { get; } - /// - /// GitHub flavored Markdown formatted message. Should include inline links to any help pages. - /// - public string? MarkdownMessage { get; } - /// - /// Plain text message. Used by components where the string processing needed to support - /// Markdown is cumbersome. - /// - public string? PlaintextMessage { get; } - /// - /// List of help links intended to supplement . - /// - public List HelpLinks { get; } - /// - /// SARIF severity. - /// - public TspSeverity? Severity { get; } - /// - /// If true, then this message won't be presented to users. - /// - public bool Internal { get; } - public TspVisibility Visibility { get; } - public TspLocation Location { get; } - /// - /// Structured metadata about the diagnostic message. - /// - public Dictionary Attributes { get; } - - public DiagnosticMessage( - Language language, string id, string name, string? markdownMessage = null, string? plaintextMessage = null, - TspVisibility? visibility = null, TspLocation? location = null, TspSeverity? severity = TspSeverity.Error, - DateTime? timestamp = null, bool? intrnl = null - ) - { - this.Source = new TspSource( - id: $"{language.UpperCaseName.ToLower()}/autobuilder/{id}", - name: name, - extractorName: language.UpperCaseName.ToLower() - ); - this.Timestamp = (timestamp ?? DateTime.UtcNow).ToString("o", CultureInfo.InvariantCulture); - this.HelpLinks = new List(); - this.Attributes = new Dictionary(); - this.Severity = severity; - this.Visibility = visibility ?? new TspVisibility(statusPage: true); - this.Location = location ?? new TspLocation(); - this.Internal = intrnl ?? false; - this.MarkdownMessage = markdownMessage; - this.PlaintextMessage = plaintextMessage; - } - } - - /// - /// A wrapper around an underlying which allows - /// objects to be serialized to it. - /// - public sealed class DiagnosticsStream : IDisposable - { - private readonly JsonSerializer serializer; - private readonly StreamWriter writer; - - /// - /// Initialises a new for a file at . - /// - /// The path to the file that should be created. - public DiagnosticsStream(string path) - { - this.writer = File.CreateText(path); - - var contractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy() - }; - - serializer = new JsonSerializer - { - ContractResolver = contractResolver, - NullValueHandling = NullValueHandling.Ignore - }; - } - - /// - /// Adds as a new diagnostics entry. - /// - /// The diagnostics entry to add. - public void AddEntry(DiagnosticMessage message) - { - serializer.Serialize(writer, message); - writer.Flush(); - } - - /// - /// Releases all resources used by the object. - /// - public void Dispose() - { - writer.Dispose(); - } - } -} diff --git a/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/diagnostics.expected b/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/diagnostics.expected deleted file mode 100644 index 6c799240806..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/diagnostics.expected +++ /dev/null @@ -1,32 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL found some projects which cannot be built with .NET Core:\n\n- `test.csproj`", - "severity": "warning", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/dotnet-incompatible-projects", - "name": "Some projects are incompatible with .NET Core" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL was unable to build the following projects using MSBuild:\n\n- `test.csproj`\n\nSet up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/msbuild-build-failure", - "name": "Some projects or solutions failed to build using MSBuild" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.csproj b/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.csproj deleted file mode 100644 index a07aa955494..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - - Debug - AnyCPU - {F70CE6B6-1735-4AD2-B1EB-B91FCD1012D1} - Library - Properties - Example - Example - v4.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - diff --git a/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.py b/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_dotnet_incompatible/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics() diff --git a/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/diagnostics.expected b/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/diagnostics.expected deleted file mode 100644 index cf061615e24..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/diagnostics.expected +++ /dev/null @@ -1,32 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL was unable to build the following projects using MSBuild:\n\n- `test.sln`\n\nSet up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/msbuild-build-failure", - "name": "Some projects or solutions failed to build using MSBuild" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "Some project files were not found when CodeQL built your project:\n\n- `Example.csproj`\n- `Example.Test.csproj`\n\nThis may lead to subsequent failures. You can check for common causes for missing project files:\n\n- Ensure that the project is built using the [intended operating system](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on) and that filenames on case-sensitive platforms are correctly specified.\n- If your repository uses Git submodules, ensure that those are [checked out](https://github.com/actions/checkout#usage) before the CodeQL action is run.\n- If you auto-generate some project files as part of your build process, ensure that these are generated before the CodeQL action is run.", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/missing-project-files", - "name": "Missing project files" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.py b/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics() diff --git a/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.sln b/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.sln deleted file mode 100644 index 60a70f32fe2..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_missing_project_files/test.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example.csproj", "{F70CE6B6-1735-4AD2-B1EB-B91FCD1012D1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Test", "Example.Test.csproj", "{F4587B5F-9918-4079-9291-5A08CD9761FB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F70CE6B6-1735-4AD2-B1EB-B91FCD1012D1}.Debug|x86.ActiveCfg = Debug|x86 - {F70CE6B6-1735-4AD2-B1EB-B91FCD1012D1}.Debug|x86.Build.0 = Debug|x86 - {F70CE6B6-1735-4AD2-B1EB-B91FCD1012D1}.Release|x86.ActiveCfg = Release|x86 - {F70CE6B6-1735-4AD2-B1EB-B91FCD1012D1}.Release|x86.Build.0 = Release|x86 - {F4587B5F-9918-4079-9291-5A08CD9761FB}.Debug|x86.ActiveCfg = Debug|x86 - {F4587B5F-9918-4079-9291-5A08CD9761FB}.Debug|x86.Build.0 = Debug|x86 - {F4587B5F-9918-4079-9291-5A08CD9761FB}.Release|x86.ActiveCfg = Release|x86 - {F4587B5F-9918-4079-9291-5A08CD9761FB}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/diagnostics.expected b/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/diagnostics.expected deleted file mode 100644 index 0fbd8b42474..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/diagnostics.expected +++ /dev/null @@ -1,48 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL was unable to build the following projects using .NET Core:\n\n- `test.csproj`\n\nSet up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/dotnet-build-failure", - "name": "Some projects or solutions failed to build using .NET Core" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL was unable to build the following projects using MSBuild:\n\n- `test.csproj`\n\nSet up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/msbuild-build-failure", - "name": "Some projects or solutions failed to build using MSBuild" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "[Configure your workflow](https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-xamarin-applications) for this SDK before running CodeQL.", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/missing-xamarin-ios-sdk", - "name": "Missing Xamarin SDK for iOS" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.csproj b/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.csproj deleted file mode 100644 index 5776266cc03..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net7.0 - enable - enable - $(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets - - - diff --git a/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.py b/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/all-platforms/diag_missing_xamarin_sdk/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics() diff --git a/csharp/ql/integration-tests/posix-only/diag_autobuild_script/build.sh b/csharp/ql/integration-tests/posix-only/diag_autobuild_script/build.sh deleted file mode 100755 index 2bb8d868bd0..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_autobuild_script/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exit 1 diff --git a/csharp/ql/integration-tests/posix-only/diag_autobuild_script/diagnostics.expected b/csharp/ql/integration-tests/posix-only/diag_autobuild_script/diagnostics.expected deleted file mode 100644 index f39695d5ecf..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_autobuild_script/diagnostics.expected +++ /dev/null @@ -1,32 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL attempted to build your project using a script located at `build.sh`, which failed. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/script-failure", - "name": "Unable to build project using build script" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL could not find any project or solution files in your repository. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/no-projects-or-solutions", - "name": "No project or solutions files found" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/posix-only/diag_autobuild_script/test.py b/csharp/ql/integration-tests/posix-only/diag_autobuild_script/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_autobuild_script/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics() diff --git a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/build.sh b/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/build.sh deleted file mode 100755 index 2bb8d868bd0..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exit 1 diff --git a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/diagnostics.expected b/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/diagnostics.expected deleted file mode 100644 index e4e137ffef0..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/diagnostics.expected +++ /dev/null @@ -1,32 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL could not find any project or solution files in your repository. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/no-projects-or-solutions", - "name": "No project or solutions files found" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL found multiple potential build scripts for your project and attempted to run `build.sh`, which failed. This may not be the right build script for your project. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/multiple-build-scripts", - "name": "There are multiple potential build scripts" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/scripts/build.sh b/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/scripts/build.sh deleted file mode 100755 index 2bb8d868bd0..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/scripts/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exit 1 diff --git a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/test.py b/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/posix-only/diag_multiple_scripts/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics() diff --git a/csharp/ql/integration-tests/windows-only/diag_autobuild_script/build.bat b/csharp/ql/integration-tests/windows-only/diag_autobuild_script/build.bat deleted file mode 100644 index 8f7ce95c0eb..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_autobuild_script/build.bat +++ /dev/null @@ -1 +0,0 @@ -exit /b 1 diff --git a/csharp/ql/integration-tests/windows-only/diag_autobuild_script/diagnostics.expected b/csharp/ql/integration-tests/windows-only/diag_autobuild_script/diagnostics.expected deleted file mode 100644 index 6a55b710360..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_autobuild_script/diagnostics.expected +++ /dev/null @@ -1,32 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL attempted to build your project using a script located at `build.bat`, which failed. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/script-failure", - "name": "Unable to build project using build script" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL could not find any project or solution files in your repository. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/no-projects-or-solutions", - "name": "No project or solutions files found" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/windows-only/diag_autobuild_script/test.py b/csharp/ql/integration-tests/windows-only/diag_autobuild_script/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_autobuild_script/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics() diff --git a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/build.bat b/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/build.bat deleted file mode 100644 index 8f7ce95c0eb..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/build.bat +++ /dev/null @@ -1 +0,0 @@ -exit /b 1 diff --git a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/diagnostics.expected b/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/diagnostics.expected deleted file mode 100644 index 898d285b352..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/diagnostics.expected +++ /dev/null @@ -1,32 +0,0 @@ -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL could not find any project or solution files in your repository. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/no-projects-or-solutions", - "name": "No project or solutions files found" - }, - "visibility": { - "statusPage": true - } -} -{ - "attributes": {}, - "helpLinks": [], - "internal": false, - "location": {}, - "markdownMessage": "CodeQL found multiple potential build scripts for your project and attempted to run `build.bat`, which failed. This may not be the right build script for your project. Set up a [manual build command](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages).", - "severity": "error", - "source": { - "extractorName": "csharp", - "id": "csharp/autobuilder/multiple-build-scripts", - "name": "There are multiple potential build scripts" - }, - "visibility": { - "statusPage": true - } -} diff --git a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/scripts/build.bat b/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/scripts/build.bat deleted file mode 100644 index 8f7ce95c0eb..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/scripts/build.bat +++ /dev/null @@ -1 +0,0 @@ -exit /b 1 diff --git a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/test.py b/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/test.py deleted file mode 100644 index 62c4d3934a4..00000000000 --- a/csharp/ql/integration-tests/windows-only/diag_multiple_scripts/test.py +++ /dev/null @@ -1,5 +0,0 @@ -from create_database_utils import * -from diagnostics_test_utils import * - -run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully) -check_diagnostics()