├── src
├── Key.snk
├── Sarif.Sarifer
│ ├── Resources
│ │ └── Package.ico
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio
│ ├── Triskele.ico
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Sarifer.2022
│ ├── Resources
│ │ └── Package.ico
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.Core
│ ├── icon.png
│ ├── Services
│ │ ├── SDataService.cs
│ │ ├── SLoadSarifLogService.cs
│ │ ├── SCloseSarifLogService.cs
│ │ ├── CloseSarifLogService.cs
│ │ ├── ICloseSarifLogService.cs
│ │ └── IDataService.cs
│ ├── readme.md
│ ├── IToolWindow.cs
│ ├── Models
│ │ ├── ISarifErrorListItem.cs
│ │ ├── VSSuppressionState.cs
│ │ ├── StackCollection.cs
│ │ ├── FeedbackType.cs
│ │ ├── ArtifactChangeModel.cs
│ │ └── FixModel.cs
│ ├── FileMonitor
│ │ └── ISarifFileMonitor.cs
│ ├── ProjectKind.cs
│ ├── ErrorList
│ │ ├── IColumnFilterer.cs
│ │ ├── StubDisposable.cs
│ │ ├── FilteredColumnValue.cs
│ │ ├── BaselineStateTableDataSource.cs
│ │ ├── SarifErrorListEventProcessorProvider.cs
│ │ ├── SuppressionStateTableDataSource.cs
│ │ └── SarifErrorListSelectionChangedEventArgs.cs
│ ├── Options
│ │ ├── ISarifViewerGeneralOptions.cs
│ │ ├── SelectedColorChangedEventArgs.cs
│ │ ├── ISarifViewerColorOptions.cs
│ │ ├── SarifViewerColorOptionsControl.xaml.cs
│ │ ├── SarifViewerGeneralOptionsControl.xaml.cs
│ │ ├── ColorOption.cs
│ │ └── LocationTextDecorationCollection.cs
│ ├── Fixes
│ │ ├── DisposableDifferenceViewerControlStringResources.xaml
│ │ ├── IPreviewProvider.cs
│ │ ├── ApplyFixEventArgs.cs
│ │ ├── DisposableDifferenceViewerControl.xaml
│ │ ├── LineSpan.cs
│ │ ├── ReplacementEdit.cs
│ │ └── FixSuggestedActionsSourceProvider.cs
│ ├── overview.md
│ ├── VersionControlParser
│ │ ├── IVersionControlParser.cs
│ │ └── VersionControlParser.cs
│ ├── FileAndForgetEventName.cs
│ ├── Views
│ │ ├── StacksStringResources.xaml
│ │ ├── SarifViewerControl.xaml.cs
│ │ ├── AnalysisStepsStringResources.xaml
│ │ ├── SarifToolWindowControl.xaml.cs
│ │ ├── LocationsStringResources.xaml
│ │ ├── SarifViewerControlStringResources.xaml
│ │ ├── SarifToolWindowControl.xaml
│ │ └── InformationStringResources.xaml
│ ├── CodeFinding
│ │ └── Internals
│ │ │ └── DefaultMatcher.cs
│ ├── Telemetry
│ │ ├── ITelemetryProvider.cs
│ │ ├── KeyEventTelemetryClient.cs
│ │ └── Telemetry.Extensions.cs
│ ├── Guids.cs
│ ├── Controls
│ │ ├── FeedbackControl.xaml.cs
│ │ ├── FeedbackStringResources.xaml
│ │ ├── FeedbackDialog.cs
│ │ └── BindableTextBlock.cs
│ ├── Sarif
│ │ ├── FailureLevel.Extensions.cs
│ │ ├── Suppression.Extensions.cs
│ │ ├── Tool.Extensions.cs
│ │ ├── ThreadFlowLocation.Extensions.cs
│ │ ├── Stack.Extensions.cs
│ │ ├── Region.Extensions.cs
│ │ ├── Invocation.Extensions.cs
│ │ ├── SarifErrorListItem.Extensions.cs
│ │ ├── Replacement.Extensions.cs
│ │ ├── Rule.Extensions.cs
│ │ └── StackFrame.Extensions.cs
│ ├── LogProcessedEventArgs.cs
│ ├── Converters
│ │ ├── ObjectToVisibilityConverter.cs
│ │ ├── BindingDebugConverter.cs
│ │ ├── CollectionToBooleanConverter.cs
│ │ ├── StringToVisibilityConverter.cs
│ │ ├── CollectionToJoinedStringConverter.cs
│ │ ├── BooleanToVisibilityConverter.cs
│ │ ├── CollectionToCountConverter.cs
│ │ ├── Int32ToVisibilityConverter.cs
│ │ ├── BooleanToCollapsedVisibilityConverter.cs
│ │ ├── FileExistsToBooleanConverter.cs
│ │ └── MultipleStringsToVisibilityConverter.cs
│ ├── SarifFileAndContentDefinitions.cs
│ ├── NotifyPropertyChangedObject.cs
│ ├── Tags
│ │ ├── ISarifLocationTagCaretNotify.cs
│ │ ├── ISarifLocationTagger.cs
│ │ ├── TagInCaretChangedEventArgs.cs
│ │ ├── ITextViewCaretListenerService.cs
│ │ ├── SarifLocationTagHelpers.cs
│ │ ├── SarifLocationTagBase.cs
│ │ ├── ISarifLocationTag.cs
│ │ └── ISarifLocationTaggerService.cs
│ ├── HashHelper.cs
│ ├── License.txt
│ ├── Sarif.Viewer.VisualStudio.Core.shproj
│ ├── App.config
│ ├── RunSummary.cs
│ ├── ExceptionalConditions.cs
│ ├── ContentTypes.cs
│ ├── Themes
│ │ └── FixesStyles.xaml
│ ├── Uri.extensions.cs
│ └── KeyValuePairPropertyDescriptor.cs
├── Sarif.Viewer.VisualStudio.2022
│ ├── Triskele.ico
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.Interop
│ ├── icon.png
│ ├── ISarifViewerInterop.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── Sarif.Viewer.VisualStudio.Interop.nuspec
├── Sarif.Viewer.VisualStudio.UnitTests
│ ├── TestData
│ │ ├── BinaryTestFiles
│ │ │ ├── Binaries
│ │ │ │ ├── macho-binary
│ │ │ │ └── testapp.pdb
│ │ │ └── NonBinaries
│ │ │ │ ├── csharpfile.cs
│ │ │ │ └── test.html
│ │ └── FixModel
│ │ │ ├── index.html
│ │ │ └── index_fixed.html
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── VersionConstants.cs
│ ├── CodeFinding
│ │ ├── README.md
│ │ ├── TestFiles
│ │ │ └── C1.c
│ │ └── UnitTests
│ │ │ └── CSharpTestMultiLine.cs
│ ├── TestTraits.cs
│ ├── SarifViewerPackageUnitTests.cs
│ ├── ResourceExtractor.cs
│ └── StringBuilderFileStreamMock.cs
├── version.json
├── Sarif.Sarifer.UnitTests
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.Shell.Core
│ ├── IFileSystem2.cs
│ ├── FileSystem2.cs
│ ├── IFileWatcher.cs
│ ├── Sarif.Viewer.VisualStudio.Shell.Core.shproj
│ ├── IInfoBarService.cs
│ ├── Sarif.Viewer.VisualStudio.Shell.Core.projitems
│ ├── IGitExe.cs
│ └── BrowserService.cs
├── Sarif.Viewer.VisualStudio.ResultSources.Factory.UnitTests
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.Shell
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.Shell.2022
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.ACL
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.Domain
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.UnitTests
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.ACL.2022
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.Domain.2022
│ └── Properties
│ │ └── AssemblyInfo.cs
├── strongname.props
├── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Resources
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.Domain.Core
│ ├── Models
│ │ ├── NoContent.cs
│ │ ├── Constants.cs
│ │ ├── ErrorListMenuItems.cs
│ │ ├── ServiceEventArgs.cs
│ │ ├── Secret.cs
│ │ ├── ErrorListMenuCommand.cs
│ │ ├── ResultSourceServiceEventType.cs
│ │ ├── ErrorListMenuItem.cs
│ │ ├── ResultSourceServiceAction.cs
│ │ ├── ErrorListMenuFlyout.cs
│ │ ├── RequestAddMenuItemsEventArgs.cs
│ │ ├── ResultsUpdatedEventArgs.cs
│ │ ├── MenuCommandInvokedEventArgs.cs
│ │ └── MenuCommandBeforeQueryStatusEventArgs.cs
│ ├── Entities
│ │ └── Secret.cs
│ ├── Sarif.Viewer.VisualStudio.ResultSources.Domain.Core.shproj
│ └── Errors
│ │ └── Error.cs
├── CommonAssemblyInfo.cs
├── Sarif.Sarifer.Core
│ ├── Options
│ │ ├── ISariferOption.cs
│ │ ├── SariferOptionsControl.xaml.cs
│ │ └── SariferOptionsControlResources.xaml
│ ├── FileAndForgetEventName.cs
│ ├── Guids.cs
│ ├── SariferPackageCommandIds.cs
│ ├── Sarif.Sarifer.Core.shproj
│ ├── License.txt
│ ├── TextEditIdledEventArgs.cs
│ ├── LastViewRemovedEventArgs.cs
│ ├── TextEditIdleAssistant.cs
│ └── Commands
│ │ ├── AnalyzeProjectCommand.cs
│ │ ├── AnalyzeSolutionCommand.cs
│ │ └── AnalyzeFileCommand.cs
├── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core
│ ├── Services
│ │ └── GitRepoEventArgs.cs
│ ├── Models
│ │ ├── VerificationCode.cs
│ │ └── UserVerificationResponse.cs
│ ├── Errors
│ │ └── GitHubServiceError.cs
│ ├── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core.shproj
│ └── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core.projitems
├── Sarif.Viewer.VisualStudio.ResultSources.Factory
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.Factory.2022
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── GitHubInfoBarHelper.cs
├── Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.2022
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── GitHubInfoBarHelper.cs
├── Sarif.Viewer.VisualStudio.ResultSources.ACL.Core
│ ├── Sarif.Viewer.VisualStudio.ResultSources.ACL.Core.projitems
│ └── Sarif.Viewer.VisualStudio.ResultSources.ACL.Core.shproj
├── stylecop.json
├── Sarif.Viewer.VisualStudio.ResultSources.Factory.Core
│ ├── IResultSourceFactory.cs
│ ├── Sarif.Viewer.VisualStudio.ResultSources.Factory.Core.projitems
│ └── Sarif.Viewer.VisualStudio.ResultSources.Factory.Core.shproj
└── .ruleset
├── Vsix.cmd
├── triskelion.png
├── .nuget
└── NuGet.exe
├── GeneratedKey.snk
├── BuildAndTest.cmd
├── assets
├── Contributing-Exp.png
├── Contributing-ErrorList.png
├── Contributing-PackageError.png
├── Contributing-ExtensionsWorkload.png
└── Contributing-SetAsStartupProject.png
├── .github
├── CODEOWNERS
└── workflows
│ ├── dotnet-format.yml
│ └── codeql-analysis.yml
├── .gitmodules
├── vs-manifest.json
├── scripts
├── Unzip.ps1
├── RegistrySettings.ps1
├── Run-Tests.ps1
└── Projects.psm1
└── LICENSE
/src/Key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Key.snk
--------------------------------------------------------------------------------
/Vsix.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy RemoteSigned -File %~dp0\scripts\Vsix.ps1 %*
3 |
--------------------------------------------------------------------------------
/triskelion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/triskelion.png
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/GeneratedKey.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/GeneratedKey.snk
--------------------------------------------------------------------------------
/BuildAndTest.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | powershell -ExecutionPolicy RemoteSigned -File %~dp0\scripts\BuildAndTest.ps1 %*
3 |
--------------------------------------------------------------------------------
/assets/Contributing-Exp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/assets/Contributing-Exp.png
--------------------------------------------------------------------------------
/assets/Contributing-ErrorList.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/assets/Contributing-ErrorList.png
--------------------------------------------------------------------------------
/assets/Contributing-PackageError.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/assets/Contributing-PackageError.png
--------------------------------------------------------------------------------
/src/Sarif.Sarifer/Resources/Package.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Sarifer/Resources/Package.ico
--------------------------------------------------------------------------------
/assets/Contributing-ExtensionsWorkload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/assets/Contributing-ExtensionsWorkload.png
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio/Triskele.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Viewer.VisualStudio/Triskele.ico
--------------------------------------------------------------------------------
/assets/Contributing-SetAsStartupProject.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/assets/Contributing-SetAsStartupProject.png
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.2022/Resources/Package.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Sarifer.2022/Resources/Package.ico
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Viewer.VisualStudio.Core/icon.png
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.2022/Triskele.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Viewer.VisualStudio.2022/Triskele.ico
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Interop/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Viewer.VisualStudio.Interop/icon.png
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Code owners file.
2 | # This file controls who is tagged for review for any given pull request.
3 |
4 | # For anything not explicitly taken by someone else:
5 | * @EasyRhinoMSFT @michaelcfanning @50wliu @chrishuynhc
6 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/BinaryTestFiles/Binaries/macho-binary:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/BinaryTestFiles/Binaries/macho-binary
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/BinaryTestFiles/Binaries/testapp.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/sarif-visualstudio-extension/HEAD/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/BinaryTestFiles/Binaries/testapp.pdb
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "src/Sarif.Viewer.VisualStudio.UnitTests/sarif-visualstudio-extension"]
2 | path = src/Sarif.Viewer.VisualStudio.UnitTests/sarif-visualstudio-extension
3 | url = https://github.com/microsoft/sarif-visualstudio-extension.git
4 | branch = Testing-branch
--------------------------------------------------------------------------------
/src/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3 | "version": "3.0",
4 | "publicReleaseRefSpec": [
5 | "^refs/heads/main$",
6 | "^refs/heads/v\\d+(?:\\.\\d+)?$"
7 | ]
8 | }
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 |
6 | [assembly: AssemblyTitle("Unit Tests for Microsoft SARIF Viewer for Visual Studio")]
7 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Services/SDataService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Services
5 | {
6 | internal interface SDataService
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 |
6 | [assembly: AssemblyTitle("Unit Tests for Microsoft SARIF Viewer for Visual Studio")]
7 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/CodeFinding/README.md:
--------------------------------------------------------------------------------
1 | This is a suite of tests we have for the Codefinder algorithms that we use to match our insights to their respective lines in the IDE, handling code drift as much as possible.
2 |
3 | In TestFiles there are a set of example C, C++, and C# files that we have, and we try to match insights to them.
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/BinaryTestFiles/NonBinaries/csharpfile.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace AnalysisTestProject1
5 | {
6 | internal class Class1
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Services/SLoadSarifLogService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Services
5 | {
6 | internal interface SLoadSarifLogService
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Services/SCloseSarifLogService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Services
5 | {
6 | internal interface SCloseSarifLogService
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/FixModel/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | FixModel test source file
7 |
8 |
9 | The quick brown fox
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/readme.md:
--------------------------------------------------------------------------------
1 | How to Debug
2 | ============
3 |
4 | Set the following values in the Sarif.Viewer.VisualStudio project's Debug property page
5 |
6 | Start external program: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
7 | Command line arguments: /rootsuffix Exp /Command "Tools.OpenSARIFfile E:\Path\To\Sarif\log.sarif"
8 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/IFileSystem2.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Shell
5 | {
6 | public interface IFileSystem2
7 | {
8 | bool IsPathRooted(string path);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/IToolWindow.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer
5 | {
6 | public interface IToolWindow
7 | {
8 | void UpdateSelectionList(params object[] items);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/FixModel/index_fixed.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | FixModel test source file
7 |
8 |
9 | The quick brown fox
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Models/ISarifErrorListItem.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer
5 | {
6 | internal interface ISarifErrorListItem
7 | {
8 | void BuildRelatedLocationsTree();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestData/BinaryTestFiles/NonBinaries/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | FixModel test source file
7 |
8 |
9 | The quick brown fox
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Factory.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 |
6 | [assembly: AssemblyTitle("Unit tests for SA result source platform for Microsoft SARIF Viewer for Visual Studio")]
7 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/TestTraits.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.VisualStudio.UnitTests
5 | {
6 | public static class TestTraits
7 | {
8 | public const string Bug = nameof(Bug);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("c4714e68-1701-45d5-9510-e298bb227cf2")]
8 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("3585559d-e715-41de-ae14-f2e18eb516ca")]
8 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.ACL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("47c77d8f-518c-4329-993a-a86a2564155b")]
8 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("032bc0cb-c3cc-4e2d-b42e-efd3e07dfe0e")]
8 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 |
6 | [assembly: AssemblyTitle("Unit tests for GitHubAdvancedSecurity SA result source for Microsoft SARIF Viewer for Visual Studio")]
7 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.ACL.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("14424761-9691-45e7-9bc9-3920c1618cac")]
8 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("a41f6491-b821-4f3f-b00b-3bbd4d5d0d4e")]
8 |
--------------------------------------------------------------------------------
/src/strongname.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | false
7 | $(MsBuildThisFileDirectory)Key.snk
8 |
9 |
10 |
--------------------------------------------------------------------------------
/vs-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/vsix-publish",
3 | "categories": [ "data", "reporting" ],
4 | "identity": {
5 | "internalName": "MicrosoftSarifViewer"
6 | },
7 | "overview": "Content.md",
8 | "priceCategory": "free",
9 | "publisher": "wdgis",
10 | "private": false,
11 | "qna": true,
12 | "repo": "https://github.com/microsoft/sarif-visualstudio-extension"
13 | }
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/FileMonitor/ISarifFileMonitor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.FileMonitor
5 | {
6 | public interface ISarifFileMonitor
7 | {
8 | void StartWatch(string solutionFolder = null);
9 |
10 | void StopWatch();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Resources/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // The following GUID is for the ID of the typelib if this project is exposed to COM
7 | [assembly: Guid("6c18770e-f2d2-4a9e-b5ec-0a3e77ef5005")]
8 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet-format.yml:
--------------------------------------------------------------------------------
1 | name: dotnet format
2 |
3 | on:
4 | pull_request:
5 | branches: [ main ]
6 |
7 | jobs:
8 | check-format:
9 | runs-on: windows-latest
10 |
11 | steps:
12 | - name: Check out code
13 | uses: actions/checkout@v2
14 |
15 | - name: Install format tool
16 | run: dotnet tool install -g dotnet-format
17 |
18 | - name: Run dotnet format
19 | run: dotnet-format --folder --check
20 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/NoContent.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
5 | {
6 | ///
7 | /// Represents an empty content object.
8 | ///
9 | public class NoContent
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/CommonAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | // Setting ComVisible to false makes the types in this assembly not visible
7 | // to COM components. If you need to access a type in this assembly from
8 | // COM, set the ComVisible attribute to true on that type.
9 | [assembly: ComVisible(false)]
10 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Options/ISariferOption.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
5 | {
6 | internal interface ISariferOption
7 | {
8 | bool IsBackgroundAnalysisEnabled { get; }
9 |
10 | bool ShouldAnalyzeSarifFile { get; }
11 |
12 | bool IncludesPassResults { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/FileSystem2.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.IO;
5 |
6 | namespace Microsoft.Sarif.Viewer.Shell
7 | {
8 | public class FileSystem2 : IFileSystem2
9 | {
10 | public bool IsPathRooted(string path)
11 | {
12 | return Path.IsPathRooted(path);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ProjectKind.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer
5 | {
6 | public static class ProjectKind
7 | {
8 | public static readonly string SetupProject = "{54435603-DBB4-11D2-8724-00A0C9A8B90C}";
9 | public static readonly string SolutionFolder = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/IColumnFilterer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.Sarif.Viewer.ErrorList
7 | {
8 | internal interface IColumnFilterer
9 | {
10 | void FilterOut(string columnName, string filteredValue);
11 |
12 | IEnumerable GetFilteredValues(string columnName);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/ISarifViewerGeneralOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Options
5 | {
6 | internal interface ISarifViewerGeneralOptions
7 | {
8 | bool ShouldMonitorSarifFolder { get; }
9 |
10 | bool IsGitHubAdvancedSecurityEnabled { get; }
11 |
12 | bool IsKeyEventAdornmentEnabled { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/DisposableDifferenceViewerControlStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Fix all occurrences in:
6 | Document
7 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/overview.md:
--------------------------------------------------------------------------------
1 | The Microsoft SARIF Viewer extension for Visual Studio provides a convenient UI for analyzing static analysis log files and taking action on the items they contain. The SARIF Viewer integrates with the Visual Studio environment, displaying a list of analysis results in the Error List and result details in a dockable tool window. Embedded target files can be opened right in the text editor with the error line highlighted. If the target file isn't embedded in the log file, the SARIF Viewer will prompt you to open a local copy.
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core/Services/GitRepoEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.Sarif.Viewer.ResultSources.Domain.Models;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.GitHubAdvancedSecurity.Services
7 | {
8 | internal class GitRepoEventArgs : ResultsUpdatedEventArgs
9 | {
10 | public string BranchName { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/StubDisposable.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.ErrorList
7 | {
8 | // This class exists solely to provide an object for the "stub" table data sources to return
9 | // when the TableDataManager calls Subscribe on them.
10 | internal class StubDisposable : IDisposable
11 | {
12 | public void Dispose() { }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Factory/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | // The following GUID is for the ID of the typelib if this project is exposed to COM
8 | [assembly: Guid("0298e0ab-0f86-433f-9423-5db950809f62")]
9 |
10 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.ResultSources.Factory.UnitTests")]
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Factory.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | // The following GUID is for the ID of the typelib if this project is exposed to COM
8 | [assembly: Guid("e558eadd-6b2a-4a20-80a8-ef49c681250e")]
9 |
10 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.ResultSources.Factory.UnitTests")]
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Models/VSSuppressionState.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer
5 | {
6 | public enum VSSuppressionState
7 | {
8 | ///
9 | /// Represents an active result.
10 | ///
11 | Active = 0,
12 |
13 | ///
14 | /// Represents a suppressed result.
15 | ///
16 | Suppressed,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/Constants.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
5 | {
6 | public static class Constants
7 | {
8 | public const string ResultSourceServiceMenuCommandInvokeCallbackKey = "InvokeCallback";
9 | public const string ResultSourceServiceMenuCommandBeforeQueryStatusCallbackKey = "BeforeQueryStatusCallback";
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/VersionControlParser/IVersionControlParser.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer
7 | {
8 | public interface IVersionControlParser
9 | {
10 | public Uri GetSourceFileUri(string relativeFilePath);
11 |
12 | public string ConvertToRawPath(string url);
13 |
14 | public string GetLocalRelativePath(Uri uri, string relativeFilePath);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/FileAndForgetEventName.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer
5 | {
6 | internal static class FileAndForgetEventName
7 | {
8 | private const string Prefix = "Microsoft/VisualStudioSarifViewer/";
9 |
10 | internal const string InfoBarCloseFailure = Prefix + "InfoBarClose/Failure";
11 | internal const string InfoBarOpenFailure = Prefix + "InfoBarOpen/Failure";
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/StacksStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Message
6 | Name
7 | File
8 |
9 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | // The following GUID is for the ID of the typelib if this project is exposed to COM
8 | [assembly: Guid("52dce73d-148d-47e1-a595-9eada6b3b7c5")]
9 |
10 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.UnitTests")]
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 |
7 | // The following GUID is for the ID of the typelib if this project is exposed to COM
8 | [assembly: Guid("52dce73d-148d-47e1-a595-9eada6b3b7c5")]
9 |
10 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.UnitTests")]
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/CodeFinding/Internals/DefaultMatcher.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.CodeFinding.Internal
5 | {
6 | ///
7 | /// This is really just a wrapper for the base, abstract class.
8 | ///
9 | internal class DefaultFinder : CodeFinderBase
10 | {
11 | public DefaultFinder(string fileContents)
12 | : base(fileContents)
13 | {
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/SarifViewerControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Windows.Controls;
5 |
6 | namespace Microsoft.Sarif.Viewer.Views
7 | {
8 | ///
9 | /// Interaction logic for SarifViewerControl.xaml.
10 | ///
11 | public partial class SarifViewerControl : UserControl
12 | {
13 | public SarifViewerControl()
14 | {
15 | this.InitializeComponent();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core/Models/VerificationCode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.GitHubAdvancedSecurity.Models
5 | {
6 | internal class VerificationCode
7 | {
8 | public string Value { get; set; }
9 |
10 | public static implicit operator string(VerificationCode verificationCode)
11 | {
12 | return verificationCode.Value;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.2022/GitHubInfoBarHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.VisualStudio.Imaging;
5 | using Microsoft.VisualStudio.Imaging.Interop;
6 |
7 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain
8 | {
9 | internal static class GitHubInfoBarHelper
10 | {
11 | internal static ImageMoniker GetInfoBarImageMoniker()
12 | {
13 | return KnownMonikers.GitHub;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity/GitHubInfoBarHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.VisualStudio.Imaging;
5 | using Microsoft.VisualStudio.Imaging.Interop;
6 |
7 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain
8 | {
9 | internal static class GitHubInfoBarHelper
10 | {
11 | internal static ImageMoniker GetInfoBarImageMoniker()
12 | {
13 | return KnownMonikers.StatusWarning;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/Properties/VersionConstants.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.CodeAnalysis.Sarif.Viewer.VisualStudio.UnitTests
5 | {
6 | public static class VersionConstants
7 | {
8 | public const string Prerelease = "";
9 | public const string AssemblyVersion = "2.1.20";
10 | public const string FileVersion = AssemblyVersion + ".0";
11 | public const string Version = AssemblyVersion + Prerelease;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ErrorListMenuItems.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
7 | {
8 | public class ErrorListMenuItems
9 | {
10 | public IList Flyouts { get; set; } = new List();
11 |
12 | public IList Commands { get; set; } = new List();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Telemetry/ITelemetryProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.VisualStudio.Telemetry;
5 |
6 | namespace Microsoft.Sarif.Viewer.Telemetry
7 | {
8 | public interface ITelemetryClient
9 | {
10 | ///
11 | /// Queues a telemetry event to be posted to a server.
12 | ///
13 | /// A telemetry event that is ready to be posted.
14 | public void PostEvent(TelemetryEvent eventName);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Guids.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer
7 | {
8 | ///
9 | /// Defines GUIDs used by this package. The values must match the values used in the VSCT file.
10 | ///
11 | internal sealed partial class Guids
12 | {
13 | public const string GuidVSPackageString = "b97edb99-282e-444c-8f53-7de237f2ec5e";
14 |
15 | public static readonly Guid GuidVSPackage = new Guid(GuidVSPackageString);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Interop/ISarifViewerInterop.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.Sarif.Viewer.Interop
8 | {
9 | public interface ISarifViewerInterop
10 | {
11 | Task OpenSarifLogAsync(IEnumerable paths);
12 |
13 | Task OpenSarifLogAsync(string path, bool cleanErrors = true, bool openInEditor = false);
14 |
15 | Task CloseSarifLogAsync(IEnumerable paths);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/AnalysisStepsStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Expand all
6 | Collapse all
7 | Intelligent expand
8 |
9 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/FileAndForgetEventName.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
5 | {
6 | internal static class FileAndForgetEventName
7 | {
8 | internal const string BackgroundAnalysisFailure = Prefix + "BackgroundAnalysis/Failure";
9 | internal const string CloseSarifLogsFailure = Prefix + "CloseSarifLogs/Failure";
10 | internal const string SendDataToViewerFailure = Prefix + "SendDataToViewer/Failure";
11 |
12 | private const string Prefix = "Microsoft/Sarifer/";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Guids.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
7 | {
8 | ///
9 | /// Defines GUIDs used by this package. The values must match the values used in the VSCT file.
10 | ///
11 | internal static class Guids
12 | {
13 | public static readonly Guid SariferCommandSet = new Guid("{CD8EE607-A630-4652-B2BA-748F534235C1}");
14 | public static readonly Guid SariferFolderViewCommandSet = new Guid("71F099FC-EC9E-47D4-9723-9F3865CD0858");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/scripts/Unzip.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Unzips archives to a specified path.
4 | .DESCRIPTION
5 | Unzips archives to a specified path.
6 | .PARAMETER Archive
7 | The path to the archive
8 | .PARAMETER ExtractTo
9 | The directory to which the archive should be expanded
10 | #>
11 |
12 | [CmdletBinding()]
13 | param(
14 | [string]
15 | $Archive,
16 |
17 | [string]
18 | $ExtractTo
19 | )
20 |
21 | [System.Console]::WriteLine($Archive)
22 | [System.Console]::WriteLine($ExtractTo)
23 |
24 | Remove-Item -LiteralPath $ExtractTo -Force -Recurse
25 |
26 | Add-Type -AssemblyName System.IO.Compression.FileSystem
27 |
28 | [System.IO.Compression.ZipFile]::ExtractToDirectory($archive, $extractTo)
29 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/SelectedColorChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.Options
7 | {
8 | public class SelectedColorChangedEventArgs : EventArgs
9 | {
10 | ///
11 | /// The new index to use in the list of highlight colors.
12 | ///
13 | public int NewIndex;
14 |
15 | ///
16 | /// The error type which is having its' color changed.
17 | ///
18 | public string ErrorType;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Controls/FeedbackControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Windows.Controls;
5 |
6 | using Microsoft.Sarif.Viewer.Models;
7 |
8 | namespace Microsoft.Sarif.Viewer.Controls
9 | {
10 | ///
11 | /// Interaction logic for FeedbackControl.xaml.
12 | ///
13 | public partial class FeedbackControl : UserControl
14 | {
15 | public FeedbackControl(FeedbackModel model)
16 | {
17 | this.InitializeComponent();
18 |
19 | this.DataContext = model;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Telemetry/KeyEventTelemetryClient.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.VisualStudio.Telemetry;
5 |
6 | namespace Microsoft.Sarif.Viewer.Telemetry
7 | {
8 | ///
9 | /// The class utilizes Visual Studio SDK TelemetryService to send telemetry data.
10 | ///
11 | internal class KeyEventTelemetryClient : ITelemetryClient
12 | {
13 | ///
14 | public void PostEvent(TelemetryEvent eventName)
15 | {
16 | TelemetryService.DefaultSession.PostEvent(eventName);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ServiceEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
7 | {
8 | ///
9 | /// Represents the base class for events that are raised by result source services.
10 | ///
11 | public class ServiceEventArgs : EventArgs
12 | {
13 | ///
14 | /// Gets or sets the well-known type of the service event.
15 | ///
16 | public ResultSourceServiceEventType ServiceEventType { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 |
8 | [assembly: AssemblyTitle("Microsoft SARIF Viewer for Visual Studio")]
9 | [assembly: AssemblyDescription("Visual Studio Extension for viewing SARIF log files")]
10 |
11 | [assembly: NeutralResourcesLanguage("en")]
12 |
13 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
14 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.UnitTests")]
15 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.Tests.Apex")]
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 |
8 | [assembly: AssemblyTitle("Microsoft SARIF Viewer for Visual Studio 2022")]
9 | [assembly: AssemblyDescription("Visual Studio Extension for viewing SARIF log files")]
10 |
11 | [assembly: NeutralResourcesLanguage("en")]
12 |
13 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
14 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.UnitTests")]
15 | [assembly: InternalsVisibleTo("Sarif.Viewer.VisualStudio.Tests.Apex")]
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/ISarifViewerColorOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Options
5 | {
6 | internal interface ISarifViewerColorOptions
7 | {
8 | ///
9 | /// Gets the color name associated with a certain decoration type (Ex: "NoteUnderline").
10 | ///
11 | /// The decoration type.
12 | /// The string describing the error type. From the .
13 | string GetSelectedColorName(string decorationName);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/IPreviewProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 |
8 | using Microsoft.VisualStudio.Text;
9 |
10 | namespace Microsoft.Sarif.Viewer.Fixes
11 | {
12 | internal interface IPreviewProvider
13 | {
14 | Task CreateChangePreviewAsync(
15 | SarifErrorListItem errorListItem,
16 | ITextBuffer buffer,
17 | Action applyEdit,
18 | string description = null,
19 | FrameworkElement additionalContent = null);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 |
8 | [assembly: AssemblyTitle("Sarifer test data producer extension for Visual Studio")]
9 | [assembly: AssemblyDescription("Generates test data in SARIF format and provides it to the SARIF viewer extension, upon which it depends.")]
10 |
11 | [assembly: NeutralResourcesLanguage("en")]
12 |
13 | // This reference necessary for the MOQ test engine.
14 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
15 | [assembly: InternalsVisibleTo("Sarif.Sarifer.UnitTests")]
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Telemetry/Telemetry.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Text;
7 |
8 | using Microsoft.VisualStudio.Telemetry;
9 |
10 | namespace Microsoft.Sarif.Viewer.Sarif
11 | {
12 | internal static class TelemetryExtension
13 | {
14 | public static void SetValue(this TelemetryEvent telemetryEvent, string key, string value)
15 | {
16 | if (!telemetryEvent.Properties.ContainsKey(key))
17 | {
18 | telemetryEvent.Properties[key] = value;
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/SarifToolWindowControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Windows.Controls;
5 |
6 | namespace Microsoft.Sarif.Viewer.Views
7 | {
8 | ///
9 | /// Interaction logic for SarifToolWindowControl.
10 | ///
11 | public partial class SarifToolWindowControl : UserControl
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | public SarifToolWindowControl()
17 | {
18 | this.InitializeComponent();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Controls/FeedbackStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Comments:
6 | Include code snippet from file
7 | Optional
8 | Report
9 | Cancel
10 |
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Services/CloseSarifLogService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | using Microsoft.Sarif.Viewer.ErrorList;
7 |
8 | namespace Microsoft.Sarif.Viewer.Services
9 | {
10 | public class CloseSarifLogService : SCloseSarifLogService, ICloseSarifLogService
11 | {
12 | ///
13 | public void CloseAllSarifLogs()
14 | {
15 | ErrorListService.CleanAllErrors();
16 | }
17 |
18 | ///
19 | public void CloseSarifLogs(IEnumerable paths)
20 | {
21 | ErrorListService.CloseSarifLogs(paths);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/FailureLevel.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 |
6 | namespace Microsoft.Sarif.Viewer.Sarif
7 | {
8 | internal static class FailureLevelExtensions
9 | {
10 | public static string FormatForVisualStudio(this FailureLevel level)
11 | {
12 | switch (level)
13 | {
14 | case FailureLevel.Error:
15 | return "error";
16 |
17 | case FailureLevel.Warning:
18 | return "warning";
19 |
20 | default:
21 | return "info";
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/SariferPackageCommandIds.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
5 | {
6 | ///
7 | /// Define the IDs of the commands implemented by this package. The values must match the
8 | /// values defined in the Buttons section of the VSCT file.
9 | ///
10 | internal static class SariferPackageCommandIds
11 | {
12 | public const int GenerateTestData = 0x2010;
13 | public const int AnalyzeSolution = 0x2020;
14 | public const int AnalyzeProject = 0x2030;
15 | public const int AnalyzeFile = 0x2040;
16 | public const int AnalyzeSolutionFolder = 0x2050;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.ACL.Core/Sarif.Viewer.VisualStudio.ResultSources.ACL.Core.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | cde5ac01-c3ad-4925-9ce0-d3b7560a13d0
7 |
8 |
9 | Sarif.Viewer.VisualStudio.ResultSources.ACL.Core
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Controls/FeedbackDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Windows;
6 |
7 | using Microsoft.Sarif.Viewer.Models;
8 | using Microsoft.VisualStudio.PlatformUI;
9 |
10 | namespace Microsoft.Sarif.Viewer.Controls
11 | {
12 | internal class FeedbackDialog : DialogWindow
13 | {
14 | public FeedbackDialog(string title, FeedbackModel feedbackModel)
15 | {
16 | this.Title = title;
17 | this.SizeToContent = SizeToContent.WidthAndHeight;
18 | this.ResizeMode = ResizeMode.NoResize;
19 |
20 | this.Content = new FeedbackControl(feedbackModel);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/stylecop.json:
--------------------------------------------------------------------------------
1 | {
2 | // ACTION REQUIRED: This file was automatically added to your project, but it
3 | // will not take effect until additional steps are taken to enable it. See the
4 | // following page for additional information:
5 | //
6 | // https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md
7 |
8 | "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
9 | "settings": {
10 | "documentationRules": {
11 | "copyrightText": "Copyright (c) Microsoft. All rights reserved.\nLicensed under the MIT license. See LICENSE file in the project root for full license information.",
12 | "xmlHeader": false
13 | },
14 | "readabilityRules": {
15 |
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/LogProcessedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer
5 | {
6 | // Provides data for the event handler invoked when the ErrorListService finishes
7 | // processing a SARIF log.
8 | internal class LogProcessedEventArgs
9 | {
10 | public LogProcessedEventArgs(ExceptionalConditions exceptionalConditions)
11 | {
12 | ExceptionalConditions = exceptionalConditions;
13 | }
14 |
15 | // Gets any exceptional conditions (for example, an error-level tool execution
16 | // failure) that occurred during the processing of the log file.
17 | public ExceptionalConditions ExceptionalConditions { get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/ObjectToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class ObjectToVisibilityConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | return value == null ? Visibility.Collapsed : Visibility.Visible;
15 | }
16 |
17 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
18 | {
19 | return null;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/Secret.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
5 | {
6 | ///
7 | /// Represents a secret string.
8 | ///
9 | public class Secret
10 | {
11 | ///
12 | /// Gets or sets the secret value.
13 | ///
14 | public string Value { get; set; }
15 |
16 | ///
17 | /// Gets the secret value.
18 | ///
19 | /// The .
20 | public static implicit operator string(Secret secret)
21 | {
22 | return secret.Value;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/BindingDebugConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Diagnostics;
6 | using System.Globalization;
7 | using System.Windows.Data;
8 |
9 | namespace Microsoft.Sarif.Viewer.Converters
10 | {
11 | public class DatabindingDebugConverter : IValueConverter
12 | {
13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | Debugger.Break();
16 | return value;
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20 | {
21 | Debugger.Break();
22 | return value;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/LocationsStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Defect Locations
6 | ({0})
7 | {0}
8 | Line {0}
9 | Col {0}
10 |
11 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Entities/Secret.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Entities
5 | {
6 | ///
7 | /// Represents a secret string.
8 | ///
9 | public class Secret
10 | {
11 | ///
12 | /// Gets or sets the secret string.
13 | ///
14 | public string Value { get; set; }
15 |
16 | ///
17 | /// Gets the secret value.
18 | ///
19 | /// The .
20 | public static implicit operator string(Secret secret)
21 | {
22 | return secret.Value;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/SarifFileAndContentDefinitions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.ComponentModel.Composition;
5 |
6 | using Microsoft.VisualStudio.Utilities;
7 |
8 | namespace Microsoft.Sarif.Viewer
9 | {
10 | internal static class SarifFileAndContentDefinitions
11 | {
12 | [Export]
13 | [Name("sarif")]
14 | [BaseDefinition("text")]
15 | internal static ContentTypeDefinition sarifContentTypeDefinition = new ContentTypeDefinition();
16 |
17 | [Export]
18 | [FileExtension(".sarif")]
19 | [BaseDefinition("sarif")]
20 | internal static FileExtensionToContentTypeDefinition sarifFileExtensionToContentTypeDefinition = new FileExtensionToContentTypeDefinition();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core/Errors/GitHubServiceError.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.Sarif.Viewer.ResultSources.Domain.Errors;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.GitHubAdvancedSecurity.Errors
7 | {
8 | ///
9 | /// Represents a GitHub service error.
10 | ///
11 | public class GitHubServiceError : Error
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The error messasge.
17 | public GitHubServiceError(string message)
18 | : base(message)
19 | {
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/NotifyPropertyChangedObject.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.ComponentModel;
6 | using System.Runtime.CompilerServices;
7 |
8 | namespace Microsoft.Sarif.Viewer
9 | {
10 | public abstract class NotifyPropertyChangedObject : INotifyPropertyChanged
11 | {
12 | public event PropertyChangedEventHandler PropertyChanged;
13 |
14 | protected void NotifyPropertyChanged([CallerMemberName] string info = null)
15 | {
16 | if (string.IsNullOrEmpty(info))
17 | {
18 | throw new ArgumentNullException(nameof(info));
19 | }
20 |
21 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info));
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Services/ICloseSarifLogService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.Sarif.Viewer.Services
7 | {
8 | ///
9 | /// Provides services for closing log files.
10 | ///
11 | internal interface ICloseSarifLogService
12 | {
13 | ///
14 | /// Closes the specified SARIF logs in the viewer.
15 | ///
16 | /// The complete path to the SARIF log files.
17 | void CloseSarifLogs(IEnumerable paths);
18 |
19 | ///
20 | /// Closes all SARIF logs opened in the viewer.
21 | ///
22 | void CloseAllSarifLogs();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/IFileWatcher.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.IO;
6 |
7 | namespace Microsoft.Sarif.Viewer.Shell
8 | {
9 | public interface IFileWatcher : IDisposable
10 | {
11 | event EventHandler FileChanged;
12 |
13 | event EventHandler FileRenamed;
14 |
15 | event EventHandler FileCreated;
16 |
17 | event EventHandler FileDeleted;
18 |
19 | string FilePath { get; set; }
20 |
21 | string Filter { get; set; }
22 |
23 | void Start();
24 |
25 | void Stop();
26 |
27 | void EnableRaisingEvents();
28 |
29 | void DisableRaisingEvents();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/CollectionToBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class CollectionToBooleanConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | return !(value is ICollection collection) || collection.Count == 0 ? false : (object)true;
15 | }
16 |
17 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
18 | {
19 | return null;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/StringToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class StringToVisibilityConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | return string.IsNullOrWhiteSpace(value as string) ? Visibility.Collapsed : Visibility.Visible;
15 | }
16 |
17 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
18 | {
19 | return null;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ErrorListMenuCommand.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
8 | {
9 | public class ErrorListMenuCommand : ErrorListMenuItem
10 | {
11 | public ErrorListMenuCommand(string text)
12 | : base(text)
13 | {
14 | }
15 |
16 | ///
17 | /// Gets or sets the that will be called by the menu command's Invoke event handler.
18 | ///
19 | public Func> InvokeMenuCommand { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ResultSourceServiceEventType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
5 | {
6 | ///
7 | /// Defines well-known events that can be raised by result source services.
8 | ///
9 | public enum ResultSourceServiceEventType
10 | {
11 | ///
12 | /// None.
13 | ///
14 | None = 0,
15 |
16 | ///
17 | /// Analysis results have been updated by the service.
18 | ///
19 | ResultsUpdated = 1,
20 |
21 | ///
22 | /// Request to add items to the Error List context menu.
23 | ///
24 | RequestAddMenuItems = 2,
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/scripts/RegistrySettings.ps1:
--------------------------------------------------------------------------------
1 | #Requires -RunAsAdministrator
2 |
3 | $ErrorActionPreference = "stop"
4 | $InformationPreference = "continue"
5 |
6 | try {
7 | $vsExePath = (Get-ChildItem -Path ${env:ProgramFiles(x86)} -Filter "devenv.exe" -Recurse)[0].FullName
8 | $rootPath = ".\SOFTWARE\Classes"
9 | Push-Location
10 | Set-Location HKLM:
11 | Write-Information "Setting up the registery keys to run .sarif files with Visual Studio by default ...."
12 | New-Item -Path (Join-Path $rootPath "\.sarif") -Value "SARIFFILE" -Force | Out-Null
13 | $sarifFilePath = Join-Path $rootPath "SARIFFILE\shell\Open"
14 | New-Item -Path $sarifFilePath -Value "&Open with Visual Studio SARIF Viewer" -Force | Out-Null
15 | New-Item -Path "$sarifFilePath\Command" -Value $vsExePath -Force | Out-Null
16 | Write-Information "Registery Key Setting are done"
17 | } catch {
18 | Write-Information $_
19 | } finally {
20 | Pop-Location
21 | }
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Suppression.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 | using Microsoft.Sarif.Viewer.Models;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class SuppressionExtensions
10 | {
11 | public static SuppressionModel ToSuppressionModel(this Suppression suppression, SarifErrorListItem sarifErrorListItem)
12 | {
13 | if (suppression == null)
14 | {
15 | return null;
16 | }
17 |
18 | var model = new SuppressionModel(sarifErrorListItem)
19 | {
20 | Kind = suppression.Kind,
21 | Status = suppression.Status,
22 | };
23 |
24 | return model;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Options/SariferOptionsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Windows.Controls;
5 |
6 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
7 | {
8 | ///
9 | /// Interaction logic for SariferOptionsControl.xaml.
10 | ///
11 | public partial class SariferOptionsControl : UserControl
12 | {
13 | ///
14 | /// A handle to the options page instance that this control is bound to.
15 | ///
16 | private readonly SariferOptionsPage sariferOptionsPage;
17 |
18 | public SariferOptionsControl(SariferOptionsPage page)
19 | {
20 | InitializeComponent();
21 | sariferOptionsPage = page;
22 | this.DataContext = sariferOptionsPage;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/ISarifLocationTagCaretNotify.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Tags
5 | {
6 | ///
7 | /// Implemented by tags that wish to receive caret notifications from .
8 | ///
9 | internal interface ISarifLocationTagCaretNotify
10 | {
11 | ///
12 | /// Called by the when the caret from the text editor enters this tag.
13 | ///
14 | void OnCaretEntered();
15 |
16 | ///
17 | /// Called by the when the caret from the text editor leaves this tag.
18 | ///
19 | void OnCaretLeft();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core/Models/UserVerificationResponse.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Newtonsoft.Json;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.GitHubAdvancedSecurity.Models
7 | {
8 | public class UserVerificationResponse
9 | {
10 | [JsonProperty("user_code")]
11 | public string UserCode { get; set; }
12 |
13 | [JsonProperty("device_code")]
14 | public string DeviceCode { get; set; }
15 |
16 | [JsonProperty("verification_uri")]
17 | public string VerificationUri { get; set; }
18 |
19 | [JsonProperty("expires_in")]
20 | public int ExpiresInSeconds { get; set; }
21 |
22 | [JsonProperty("interval")]
23 | public int PollingIntervalSeconds { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Tool.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 | using Microsoft.Sarif.Viewer.Models;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class ToolExtensions
10 | {
11 | public static ToolModel ToToolModel(this Tool tool)
12 | {
13 | if (tool == null)
14 | {
15 | return null;
16 | }
17 |
18 | var model = new ToolModel()
19 | {
20 | Name = tool.Driver?.Name,
21 | FullName = tool.Driver?.FullName,
22 | Version = tool.Driver?.Version,
23 | SemanticVersion = tool.Driver?.SemanticVersion,
24 | };
25 |
26 | return model;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/CollectionToJoinedStringConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | internal class CollectionToJoinedStringConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | return value is List list ?
15 | string.Join(parameter.ToString(), list) :
16 | null;
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
20 | {
21 | return null;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ErrorListMenuItem.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Threading.Tasks;
6 |
7 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
8 | {
9 | public class ErrorListMenuItem
10 | {
11 | public ErrorListMenuItem(string text)
12 | {
13 | this.Text = text;
14 | }
15 |
16 | public string Text { get; set; }
17 |
18 | ///
19 | /// Gets or sets the that will be called by the menu command's BeforeQueryStatus event handler.
20 | ///
21 | public Func> BeforeQueryStatusMenuCommand { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/ThreadFlowLocation.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 | using Microsoft.Sarif.Viewer.Models;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class ThreadFlowLocationExtensions
10 | {
11 | public static LocationModel ToLocationModel(this ThreadFlowLocation threadFlowLocation, Run run, int resultId, int runIndex)
12 | {
13 | LocationModel model = threadFlowLocation.Location != null
14 | ? threadFlowLocation.Location.ToLocationModel(run, resultId, runIndex)
15 | : new LocationModel(resultId, runIndex);
16 |
17 | model.IsEssential = threadFlowLocation.Importance == ThreadFlowLocationImportance.Essential;
18 |
19 | return model;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/SarifViewerColorOptionsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Windows.Controls;
5 |
6 | namespace Microsoft.Sarif.Viewer.Options
7 | {
8 | ///
9 | /// Interaction logic for SariferOptionsControl.xaml.
10 | ///
11 | public partial class SarifViewerColorOptionsControl : UserControl
12 | {
13 | ///
14 | /// A handle to the options page instance that this control is bound to.
15 | ///
16 | private readonly SarifViewerColorOptionsPage colorOptionsPage;
17 |
18 | public SarifViewerColorOptionsControl(SarifViewerColorOptionsPage page)
19 | {
20 | InitializeComponent();
21 | colorOptionsPage = page;
22 | this.DataContext = colorOptionsPage;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Interop/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Runtime.InteropServices;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("Sarif.Viewer.VisualStudio.Interop")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Sarif.Viewer.VisualStudio.Interop")]
15 | [assembly: AssemblyCopyright("Copyright © 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // The following GUID is for the ID of the typelib if this project is exposed to COM
20 | [assembly: Guid("9d407555-d268-461e-bfaf-4251b0fbf7c9")]
21 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/SarifViewerGeneralOptionsControl.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows.Controls;
6 |
7 | namespace Microsoft.Sarif.Viewer.Options
8 | {
9 | ///
10 | /// Interaction logic for SarifGeneralOptionsControl.xaml.
11 | ///
12 | public partial class SarifViewerGeneralOptionsControl : UserControl
13 | {
14 | ///
15 | /// A handle to the options page instance that this control is bound to.
16 | ///
17 | private readonly SarifViewerGeneralOptionsPage generalOptionsPage;
18 |
19 | public SarifViewerGeneralOptionsControl(SarifViewerGeneralOptionsPage page)
20 | {
21 | InitializeComponent();
22 | generalOptionsPage = page;
23 | this.DataContext = generalOptionsPage;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Factory.Core/IResultSourceFactory.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Threading.Tasks;
6 |
7 | using CSharpFunctionalExtensions;
8 |
9 | using Microsoft.Sarif.Viewer.ResultSources.Domain.Services;
10 |
11 | namespace Microsoft.Sarif.Viewer.ResultSources.Factory
12 | {
13 | ///
14 | /// Provides a factory for result sources.
15 | ///
16 | public interface IResultSourceFactory
17 | {
18 | ///
19 | /// Gets a list of s.
20 | ///
21 | /// The list of valid s, if there are services active for the current solution; otherwise, null.
22 | Task, ErrorType>> GetResultSourceServicesAsync();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Stack.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 | using Microsoft.Sarif.Viewer.Models;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class StackExtensions
10 | {
11 | public static StackCollection ToStackCollection(this Stack stack, int resultId, int runIndex)
12 | {
13 | if (stack == null)
14 | {
15 | return null;
16 | }
17 |
18 | var model = new StackCollection(stack.Message?.Text);
19 |
20 | if (stack.Frames != null)
21 | {
22 | foreach (StackFrame frame in stack.Frames)
23 | {
24 | model.Add(frame.ToStackFrameModel(resultId, runIndex));
25 | }
26 | }
27 |
28 | return model;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ResultSourceServiceAction.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
5 | {
6 | public enum ResultSourceServiceAction
7 | {
8 | ///
9 | /// Indicates that no action should be taken.
10 | ///
11 | None = 0,
12 |
13 | ///
14 | /// Indicates that the menu command should be disabled.
15 | ///
16 | DisableMenuCommand = 1,
17 |
18 | ///
19 | /// Indicates that the Error List item corresponding to the current request should be dismissed.
20 | ///
21 | DismissSelectedItem = 2,
22 |
23 | ///
24 | /// Indicates that the selected Error List items should be dismissed.
25 | ///
26 | DismissAllSelectedItems = 3,
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/BooleanToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class BooleanToVisibilityConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | if (value is bool boolValue)
15 | {
16 | return boolValue ? Visibility.Visible : Visibility.Collapsed;
17 | }
18 | else
19 | {
20 | return Visibility.Collapsed;
21 | }
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
25 | {
26 | return null;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/CollectionToCountConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class CollectionToCountConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | var collection = value as ICollection;
15 |
16 | if (collection != null)
17 | {
18 | return collection.Count;
19 | }
20 | else
21 | {
22 | return 0;
23 | }
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
27 | {
28 | return null;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/Int32ToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class Int32ToVisibilityConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | if (value is int intValue)
15 | {
16 | return intValue > 0 ? Visibility.Visible : Visibility.Collapsed;
17 | }
18 | else
19 | {
20 | return Visibility.Collapsed;
21 | }
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
25 | {
26 | return null;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/BooleanToCollapsedVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows;
6 | using System.Windows.Data;
7 |
8 | namespace Microsoft.Sarif.Viewer.Converters
9 | {
10 | public class BooleanToCollapsedVisibilityConverter : IValueConverter
11 | {
12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13 | {
14 | if (value is bool boolValue)
15 | {
16 | return boolValue ? Visibility.Collapsed : Visibility.Visible;
17 | }
18 | else
19 | {
20 | return Visibility.Visible;
21 | }
22 | }
23 |
24 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
25 | {
26 | return null;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Models/StackCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.ObjectModel;
5 | using System.ComponentModel;
6 |
7 | namespace Microsoft.Sarif.Viewer.Models
8 | {
9 | internal class StackCollection : ObservableCollection
10 | {
11 | private string _message;
12 |
13 | public StackCollection(string message)
14 | {
15 | this._message = message;
16 | }
17 |
18 | public string Message
19 | {
20 | get
21 | {
22 | return this._message;
23 | }
24 |
25 | set
26 | {
27 | if (value != this._message)
28 | {
29 | this._message = value;
30 |
31 | this.OnPropertyChanged(new PropertyChangedEventArgs(nameof(this.Message)));
32 | }
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Factory.Core/Sarif.Viewer.VisualStudio.ResultSources.Factory.Core.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 8d7b18cf-1038-4492-aaf5-4708ba1d60cc
7 |
8 |
9 | Sarif.Viewer.VisualStudio.ResultSources.Factory.Core
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.2022/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Reflection;
5 | using System.Resources;
6 | using System.Runtime.CompilerServices;
7 |
8 | [assembly: AssemblyTitle("Sarifer test data producer extension for Visual Studio")]
9 | [assembly: AssemblyDescription("Generates test data in SARIF format and provides it to the SARIF viewer extension, upon which it depends.")]
10 |
11 | [assembly: NeutralResourcesLanguage("en")]
12 |
13 | // This reference necessary for the MOQ test engine.
14 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
15 | [assembly: InternalsVisibleTo("Sarif.Sarifer.UnitTests")]
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/HashHelper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.IO;
5 | using System.Linq;
6 | using System.Security.Cryptography;
7 |
8 | namespace Microsoft.Sarif.Viewer
9 | {
10 | internal static class HashHelper
11 | {
12 | internal static string GenerateHash(byte[] data)
13 | {
14 | using (var hashFunction = new SHA256Managed())
15 | {
16 | byte[] hash = hashFunction.ComputeHash(data);
17 | return hash.Aggregate(string.Empty, (current, x) => current + $"{x:x2}");
18 | }
19 | }
20 |
21 | internal static string GenerateHash(Stream stream)
22 | {
23 | using (var hashFunction = new SHA256Managed())
24 | {
25 | byte[] hash = hashFunction.ComputeHash(stream);
26 | return hash.Aggregate(string.Empty, (current, x) => current + $"{x:x2}");
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Sarif.Sarifer.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 710b6e5c-8322-4260-b131-41c18d23358f
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/License.txt:
--------------------------------------------------------------------------------
1 | SARIFER ver. 2.0
2 | Copyright (c) Microsoft Corporation
3 | All rights reserved.
4 | MIT License
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/FileExistsToBooleanConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Windows.Data;
6 |
7 | namespace Microsoft.Sarif.Viewer.Converters
8 | {
9 | public class FileExistsToBooleanConverter : IValueConverter
10 | {
11 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
12 | {
13 | bool retVal = false;
14 | string file = value as string;
15 |
16 | if (!string.IsNullOrWhiteSpace(file))
17 | {
18 | if (System.IO.File.Exists(file))
19 | {
20 | retVal = true;
21 | }
22 | }
23 |
24 | return retVal;
25 | }
26 |
27 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
28 | {
29 | return null;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Converters/MultipleStringsToVisibilityConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Globalization;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace Microsoft.Sarif.Viewer.Converters
10 | {
11 | public class MultipleStringsToVisibilityConverter : IMultiValueConverter
12 | {
13 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
14 | {
15 | for (int i = 0; i < values.Length; i++)
16 | {
17 | if (!string.IsNullOrWhiteSpace(values[i] as string))
18 | {
19 | return Visibility.Collapsed;
20 | }
21 | }
22 |
23 | return Visibility.Visible;
24 | }
25 |
26 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
27 | {
28 | return null;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/ApplyFixEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Fixes
5 | {
6 | internal enum FixScope
7 | {
8 | ///
9 | /// Scope of fixes to be applied is in current document.
10 | ///
11 | Document,
12 |
13 | ///
14 | /// Scope of fixes to be applied is in current project.
15 | ///
16 | Project,
17 |
18 | ///
19 | /// Scope of fixes to be applied is in current solution.
20 | ///
21 | Solution,
22 | }
23 |
24 | internal class ApplyFixEventArgs
25 | {
26 | internal ApplyFixEventArgs(FixScope scope, SarifErrorListItem errorItem)
27 | {
28 | this.Scope = scope;
29 | this.ErrorItem = errorItem;
30 | }
31 |
32 | public FixScope Scope { get; }
33 |
34 | public SarifErrorListItem ErrorItem { get; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/License.txt:
--------------------------------------------------------------------------------
1 | SARIF Viewer ver. 2.0
2 | Copyright (c) Microsoft Corporation
3 | All rights reserved.
4 | MIT License
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Region.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 |
6 | namespace Microsoft.Sarif.Viewer.Sarif
7 | {
8 | internal static class RegionExtensions
9 | {
10 | public static bool Include(this Region region, Region location)
11 | {
12 | int currentEndLine = region.EndLine == -1 ? region.StartLine : region.EndLine;
13 | int locationEndLine = location.EndLine == -1 ? location.StartLine : location.EndLine;
14 |
15 | int currentEndColumn = region.EndColumn == -1 ? region.StartColumn : region.EndColumn;
16 | int locationEndColumn = location.EndColumn == -1 ? location.EndColumn : location.EndColumn;
17 |
18 | return region.StartLine <= location.StartLine
19 | && currentEndLine >= locationEndLine
20 | && region.StartColumn <= location.StartColumn
21 | && currentEndColumn >= locationEndColumn;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif.Viewer.VisualStudio.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 795cf790-d1d5-4493-a078-8d78d098dfba
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/ISarifLocationTagger.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.Sarif.Viewer.ErrorList;
7 | using Microsoft.VisualStudio.Text;
8 |
9 | namespace Microsoft.Sarif.Viewer.Tags
10 | {
11 | internal interface ISarifLocationTagger
12 | {
13 | ///
14 | /// Notifies the tagger that all existing tags should be considered dirty.
15 | ///
16 | ///
17 | /// As an example, this happens when SARIF results are cleared from the error list service .
18 | ///
19 | void RefreshTags();
20 |
21 | ///
22 | /// Gets the for which this tagger provides tags.
23 | ///
24 | ITextBuffer TextBuffer { get; }
25 |
26 | ///
27 | /// Fired when a tagger is disposed.
28 | ///
29 | event EventHandler Disposed;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/Sarif.Viewer.VisualStudio.Shell.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | e4649ecf-3dad-418a-b83b-c35b71d50c70
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.ACL.Core/Sarif.Viewer.VisualStudio.ResultSources.ACL.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | cde5ac01-c3ad-4925-9ce0-d3b7560a13d0
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/SarifViewerPackageUnitTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | using Microsoft.Sarif.Viewer.ErrorList;
7 | using Microsoft.Sarif.Viewer.Options;
8 |
9 | using Moq;
10 |
11 | namespace Microsoft.Sarif.Viewer.VisualStudio.UnitTests
12 | {
13 | public class SarifViewerPackageUnitTests
14 | {
15 | internal ICodeAnalysisResultManager resultManager;
16 |
17 | public SarifViewerPackageUnitTests(bool useMockedManager = true)
18 | {
19 | SarifViewerPackage.IsUnitTesting = true;
20 | SarifViewerGeneralOptions.InitializeForUnitTests();
21 |
22 | if (useMockedManager)
23 | {
24 | resultManager = TestUtilities.SetCodeAnalysisResultManager();
25 | }
26 | else
27 | {
28 | resultManager = CodeAnalysisResultManager.Instance;
29 | ErrorListService.CodeManagerInstance = CodeAnalysisResultManager.Instance;
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/TextEditIdledEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | using Microsoft.VisualStudio.Text.Editor;
11 |
12 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
13 | {
14 | public class TextEditIdledEventArgs : EventArgs
15 | {
16 | ///
17 | /// Initializes a new instance of the class.
18 | ///
19 | ///
20 | /// Instance of class.
21 | ///
22 | public TextEditIdledEventArgs(ITextView textView)
23 | {
24 | this.TextView = textView;
25 | }
26 |
27 | ///
28 | /// Gets the path to the file whose contents are being viewed, or null if
29 | /// is not associated with a file.
30 | ///
31 | public ITextView TextView { get; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ErrorListMenuFlyout.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
7 | {
8 | public class ErrorListMenuFlyout : ErrorListMenuItem
9 | {
10 | public ErrorListMenuFlyout(string text)
11 | : base(text)
12 | {
13 | }
14 |
15 | public IList Flyouts { get; set; } = new List();
16 |
17 | public IList Commands { get; set; } = new List();
18 |
19 | public int DescendantCommandsCount
20 | {
21 | get
22 | {
23 | int count = 0;
24 | foreach (ErrorListMenuFlyout flyout in Flyouts)
25 | {
26 | count += flyout.DescendantCommandsCount;
27 | }
28 |
29 | count += this.Commands.Count;
30 | return count;
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 034c4d27-8d71-4f1d-9476-43cfd0841d1e
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/TagInCaretChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.Tags
7 | {
8 | ///
9 | /// Used as arguments for the and
10 | /// events.
11 | ///
12 | internal class TagInCaretChangedEventArgs : EventArgs
13 | {
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | /// The that the caret has either entered or left.
18 | public TagInCaretChangedEventArgs(ISarifLocationTag tag)
19 | {
20 | this.Tag = tag;
21 | }
22 |
23 | ///
24 | /// Gets that that the caret has either entered or left.
25 | ///
26 | public ISarifLocationTag Tag { get; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Factory.Core/Sarif.Viewer.VisualStudio.ResultSources.Factory.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 8d7b18cf-1038-4492-aaf5-4708ba1d60cc
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
22 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Errors/Error.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Errors
5 | {
6 | ///
7 | /// Represents a service error.
8 | ///
9 | public abstract class Error
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | /// The error message.
15 | public Error(string message)
16 | {
17 | this.Message = message;
18 | }
19 |
20 | ///
21 | /// Gets the error message.
22 | ///
23 | /// The error message.
24 | public string Message { get; }
25 |
26 | ///
27 | /// Gets the error message.
28 | ///
29 | /// The .
30 | public static implicit operator string(Error error)
31 | {
32 | return error.Message;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/SarifViewerControlStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Line {0}
6 | Col {0}
7 | Locations
8 | Code Flows
9 | Stacks
10 | Analysis Steps
11 | Info
12 | ({0})
13 |
14 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 3ebe54f0-c0c3-49bc-8696-c1de814d27cf
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: '**'
6 | pull_request:
7 | # The branches below must be a subset of the branches above
8 | branches: [ main ]
9 | schedule:
10 | - cron: '0 0 * * 0'
11 |
12 | jobs:
13 | analyze:
14 | name: Analyze
15 | runs-on: windows-latest
16 | permissions:
17 | actions: read
18 | contents: read
19 | security-events: write
20 |
21 | strategy:
22 | fail-fast: false
23 | matrix:
24 | language: [ 'csharp' ]
25 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26 | # Learn more about CodeQL language support at https://git.io/codeql-language-support
27 |
28 | steps:
29 | - name: Checkout repository
30 | uses: actions/checkout@v2
31 | with:
32 | fetch-depth: 0
33 |
34 | - name: Add msbuild to PATH
35 | uses: microsoft/setup-msbuild@v1.0.2
36 |
37 | - name: Initialize CodeQL
38 | uses: github/codeql-action/init@v2
39 | with:
40 | languages: csharp
41 |
42 | - run: |
43 | .\BuildAndTest.cmd -NoFormat -NoTest
44 |
45 | - name: Perform CodeQL Analysis
46 | uses: github/codeql-action/analyze@v2
47 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Models/FeedbackType.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Models
5 | {
6 | public enum FeedbackType
7 | {
8 | ///
9 | /// Default result type.
10 | ///
11 | None = 0,
12 |
13 | ///
14 | /// Represents an useful result.
15 | ///
16 | UsefulResult,
17 |
18 | ///
19 | /// Represents a false-positive result.
20 | ///
21 | FalsePositiveResult,
22 |
23 | ///
24 | /// Represents a non-actionable result.
25 | ///
26 | NonActionableResult,
27 |
28 | ///
29 | /// Represents a low value result.
30 | ///
31 | LowValueResult,
32 |
33 | ///
34 | /// Represents a non-shipping code result.
35 | ///
36 | NonShippingCodeResult,
37 |
38 | ///
39 | /// Represents an other result type.
40 | ///
41 | OtherResult,
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Options/SariferOptionsControlResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Sarifer Options
6 |
7 | Enable background analysis automatically.
8 | If enabled, the background analysis would trigger if a file is opened or edited.
9 |
10 | Enable analysis for .sarif files.
11 | If enabled, .sarif files will be analyzed by default.
12 |
13 | Generates pass kind analysis results.
14 | If enabled, pass results will also be captured in analysis results.
15 |
16 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/IInfoBarService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using CSharpFunctionalExtensions;
5 |
6 | using Microsoft.VisualStudio.Shell;
7 | using Microsoft.VisualStudio.Shell.Interop;
8 |
9 | namespace Microsoft.Sarif.Viewer.Shell
10 | {
11 | ///
12 | /// Provides a service to manage Visual Studio info bars.
13 | ///
14 | public interface IInfoBarService
15 | {
16 | ///
17 | /// Displays an info bar.
18 | ///
19 | /// The that specifies the settings.
20 | /// The if successful; otherwise, null.
21 | IVsInfoBarUIElement ShowInfoBar(InfoBarModel infoBarModel);
22 |
23 | ///
24 | /// Closes the specified info bar.
25 | ///
26 | /// The to be closed.
27 | /// The of the operation.
28 | Result CloseInfoBar(IVsInfoBarUIElement element);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/LastViewRemovedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.VisualStudio.Text;
7 | using Microsoft.VisualStudio.Text.Editor;
8 |
9 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
10 | {
11 | ///
12 | /// Provides data for the event handler invoked when the last on an
13 | /// is closed.
14 | ///
15 | public class LastViewRemovedEventArgs : EventArgs
16 | {
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | ///
21 | /// The path to the file whose contents are being viewed.
22 | ///
23 | public LastViewRemovedEventArgs(string path)
24 | {
25 | this.Path = path;
26 | }
27 |
28 | ///
29 | /// Gets the path to the file whose contents are being viewed, or null if
30 | /// is not associated with a file.
31 | ///
32 | public string Path { get; }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/DisposableDifferenceViewerControl.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/LineSpan.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.Fixes
7 | {
8 | // This code was taken from roslyn and is used to create diff views for lightbulb previews.
9 | internal struct LineSpan : IEquatable
10 | {
11 | public int Start { get; }
12 |
13 | public int End { get; }
14 |
15 | public LineSpan(int start, int end)
16 | {
17 | this.Start = start;
18 | this.End = end;
19 | }
20 |
21 | public override bool Equals(object obj)
22 | {
23 | return obj is LineSpan span && this.Equals(span);
24 | }
25 |
26 | public bool Equals(LineSpan other)
27 | {
28 | return this.Start == other.Start &&
29 | this.End == other.End;
30 | }
31 |
32 | public override int GetHashCode()
33 | {
34 | int hashCode = -1676728671;
35 | hashCode = (hashCode * -1521134295) + this.Start.GetHashCode();
36 | hashCode = (hashCode * -1521134295) + this.End.GetHashCode();
37 | return hashCode;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core/Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 3ebe54f0-c0c3-49bc-8696-c1de814d27cf
7 |
8 |
9 | Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Core
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/ColorOption.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.Options
5 | {
6 | public class ColorOption
7 | {
8 | ///
9 | /// Gets or sets a descriptive name to describe the highlight that will be displayed to the user.
10 | ///
11 | public string ColorName { get; set; }
12 |
13 | ///
14 | /// Gets or sets the text that is to be used when created the color swatch to display to the user.
15 | ///
16 | public string Text { get; set; }
17 |
18 | ///
19 | /// Gets or sets the text that is used by the VS API to determine how to highlight a particular span. Must be from the class or will always display a red underline.
20 | ///
21 | public string PredefinedErrorTypeName { get; set; }
22 |
23 | public ColorOption(string colorName, string text, string predefinedErrorTypeName)
24 | {
25 | this.ColorName = colorName;
26 | this.Text = text;
27 | this.PredefinedErrorTypeName = predefinedErrorTypeName;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/ITextViewCaretListenerService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.VisualStudio.Text.Editor;
7 | using Microsoft.VisualStudio.Text.Tagging;
8 |
9 | namespace Microsoft.Sarif.Viewer.Tags
10 | {
11 | internal interface ITextViewCaretListenerService
12 | where T : ITag
13 | {
14 | ///
15 | /// Attaches a listener to Visual Studio's caret position for the specified .
16 | ///
17 | /// The text view for which the caret position will be watched.
18 | /// The tagger that contains the tags that will be matched against the caret position.
19 | void CreateListener(ITextView textView, ITagger tagger);
20 |
21 | ///
22 | /// Fired when the Visual Studio caret enters a tag.
23 | ///
24 | event EventHandler CaretEnteredTag;
25 |
26 | ///
27 | /// Fired when the Visual Studio caret leaves a tag.
28 | ///
29 | event EventHandler CaretLeftTag;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/SarifToolWindowControl.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/RunSummary.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 |
6 | namespace Microsoft.Sarif.Viewer
7 | {
8 | internal class RunSummary
9 | {
10 | public int TotalResults;
11 |
12 | public int ErrorResultsCount;
13 |
14 | public int WarningResultsCount;
15 |
16 | public int MessageResultsCount;
17 |
18 | internal void Count(SarifErrorListItem sarifErrorListItem)
19 | {
20 | if (sarifErrorListItem == null)
21 | {
22 | return;
23 | }
24 |
25 | this.TotalResults++;
26 |
27 | switch (sarifErrorListItem.Level)
28 | {
29 | case FailureLevel.Error:
30 | this.ErrorResultsCount++;
31 | break;
32 |
33 | case FailureLevel.Warning:
34 | this.WarningResultsCount++;
35 | break;
36 |
37 | case FailureLevel.Note:
38 | case FailureLevel.None:
39 | this.MessageResultsCount++;
40 | break;
41 |
42 | default:
43 | break;
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Invocation.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 | using Microsoft.Sarif.Viewer.Models;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class InvocationExtensions
10 | {
11 | public static InvocationModel ToInvocationModel(this Invocation invocation)
12 | {
13 | InvocationModel model;
14 |
15 | if (invocation == null)
16 | {
17 | return new InvocationModel();
18 | }
19 |
20 | model = new InvocationModel()
21 | {
22 | CommandLine = invocation.CommandLine,
23 | StartTime = invocation.StartTimeUtc,
24 | EndTime = invocation.EndTimeUtc,
25 | Machine = invocation.Machine,
26 | Account = invocation.Account,
27 | ProcessId = invocation.ProcessId,
28 | FileName = invocation.ExecutableLocation?.Uri?.ToString(),
29 | WorkingDirectory = invocation.WorkingDirectory?.Uri?.ToString(),
30 | EnvironmentVariables = invocation.EnvironmentVariables,
31 | };
32 |
33 | return model;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Models/ArtifactChangeModel.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.ObjectModel;
5 | using System.IO;
6 |
7 | namespace Microsoft.Sarif.Viewer.Models
8 | {
9 | public class ArtifactChangeModel : NotifyPropertyChangedObject
10 | {
11 | private string _filePath;
12 |
13 | public ArtifactChangeModel()
14 | {
15 | this.Replacements = new ObservableCollection();
16 | }
17 |
18 | public string FilePath
19 | {
20 | get
21 | {
22 | return this._filePath;
23 | }
24 |
25 | set
26 | {
27 | if (value != this._filePath)
28 | {
29 | this._filePath = value;
30 |
31 | this.NotifyPropertyChanged();
32 | this.NotifyPropertyChanged(nameof(this.FileName));
33 | }
34 | }
35 | }
36 |
37 | public string FileName
38 | {
39 | get
40 | {
41 | return Path.GetFileName(this.FilePath);
42 | }
43 | }
44 |
45 | public ObservableCollection Replacements { get; }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/RequestAddMenuItemsEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
5 | {
6 | ///
7 | /// Represents event data for a requested to add new menu items.
8 | ///
9 | public class RequestAddMenuItemsEventArgs : ServiceEventArgs
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | public RequestAddMenuItemsEventArgs()
15 | {
16 | this.ServiceEventType = ResultSourceServiceEventType.RequestAddMenuItems;
17 | }
18 |
19 | ///
20 | /// Gets or sets the first menu ID for the requesting service.
21 | ///
22 | public int FirstMenuId { get; set; }
23 |
24 | ///
25 | /// Gets or sets the first command ID for the requesting service.
26 | ///
27 | public int FirstCommandId { get; set; }
28 |
29 | ///
30 | /// Gets or sets the s to be added.
31 | ///
32 | public ErrorListMenuItems MenuItems { get; set; } = new ErrorListMenuItems();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/SarifLocationTagHelpers.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.VisualStudio.ComponentModelHost;
5 | using Microsoft.VisualStudio.Shell;
6 | using Microsoft.VisualStudio.Text;
7 |
8 | namespace Microsoft.Sarif.Viewer.Tags
9 | {
10 | internal static class SarifLocationTagHelpers
11 | {
12 | ///
13 | /// Calls into the tagger service and asks it to refresh the tags being displayed in Visual Studio.
14 | ///
15 | ///
16 | /// The text buffer whose tags are to be refeshed, or null if the tags for all text buffers
17 | /// are to be refreshed.
18 | ///
19 | public static void RefreshTags(ITextBuffer textBuffer = null)
20 | {
21 | var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
22 | if (componentModel != null)
23 | {
24 | ISarifLocationTaggerService sarifLocationTaggerService = componentModel.GetService();
25 | if (sarifLocationTaggerService != null)
26 | {
27 | sarifLocationTaggerService.RefreshTags(textBuffer);
28 | }
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Models/FixModel.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.ObjectModel;
5 |
6 | namespace Microsoft.Sarif.Viewer.Models
7 | {
8 | public class FixModel : NotifyPropertyChangedObject
9 | {
10 | protected string _description;
11 | protected ObservableCollection _artifactChanges;
12 |
13 | public delegate void FixAppliedHandler();
14 |
15 | public FixModel(string description)
16 | {
17 | this._description = description;
18 | this._artifactChanges = new ObservableCollection();
19 | }
20 |
21 | public string Description
22 | {
23 | get
24 | {
25 | return this._description;
26 | }
27 |
28 | set
29 | {
30 | if (value != this._description)
31 | {
32 | this._description = value;
33 |
34 | this.NotifyPropertyChanged();
35 | }
36 | }
37 | }
38 |
39 | public ObservableCollection ArtifactChanges
40 | {
41 | get
42 | {
43 | return this._artifactChanges;
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/scripts/Run-Tests.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Runs tests in all test projects.
4 |
5 | .DESCRIPTION
6 | This script runs the tests in each test project. This is done in a separate script,
7 | rather than inline in BuildAndTest.ps1, because AppVeyor cannot run BuildAndTest.
8 | AppVeyor runs the tests by invoking a separate script, and this is it.
9 |
10 | .PARAMETER Configuration
11 | The build configuration: Release or Debug. Default=Release
12 | #>
13 |
14 | [CmdletBinding()]
15 | param(
16 | [string]
17 | [ValidateSet("Debug", "Release")]
18 | $Configuration="Release"
19 | )
20 |
21 | Set-StrictMode -Version Latest
22 | $ErrorActionPreference = "Stop"
23 | $InformationPreference = "Continue"
24 |
25 | Import-Module $PSScriptRoot\ScriptUtilities.psm1 -Force
26 | Import-Module $PSScriptRoot\Projects.psm1 -Force
27 |
28 | $ScriptName = $([io.Path]::GetFileNameWithoutExtension($PSCommandPath))
29 |
30 | $TestRunnerRootPath = "$NuGetPackageRoot\xunit.runner.console\2.4.1\tools\"
31 |
32 | foreach ($project in $Projects.Test) {
33 | Write-Information "Running tests in ${project}..."
34 | Push-Location $BinRoot\${Platform}_$Configuration\$project
35 | $dll = "$project" + ".dll"
36 | & ${TestRunnerRootPath}net472\xunit.console.exe $dll -parallel none
37 | if ($LASTEXITCODE -ne 0) {
38 | Pop-Location
39 | Exit-WithFailureMessage $ScriptName "${project}: tests failed."
40 | }
41 | Pop-Location
42 | }
43 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Controls/BindableTextBlock.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.ObjectModel;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Documents;
8 |
9 | namespace Microsoft.Sarif.Viewer.Controls
10 | {
11 | public class BindableTextBlock : TextBlock
12 | {
13 | public static readonly DependencyProperty InlineListProperty =
14 | DependencyProperty.Register("InlineList", typeof(ObservableCollection), typeof(BindableTextBlock), new UIPropertyMetadata(null, OnPropertyChanged));
15 |
16 | public ObservableCollection InlineList
17 | {
18 | get { return (ObservableCollection)this.GetValue(InlineListProperty); }
19 | set { this.SetValue(InlineListProperty, value); }
20 | }
21 |
22 | private static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
23 | {
24 | if (e != null && e.NewValue != null)
25 | {
26 | var textBlock = sender as BindableTextBlock;
27 | var list = e.NewValue as ObservableCollection;
28 | textBlock.Inlines.Clear();
29 | textBlock.Inlines.AddRange(list);
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Services/IDataService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.IO;
5 |
6 | using Microsoft.CodeAnalysis.Sarif;
7 |
8 | namespace Microsoft.Sarif.Viewer.Services
9 | {
10 | ///
11 | /// Provides methods for sending data to the SARIF Viewer extension.
12 | ///
13 | internal interface IDataService
14 | {
15 | ///
16 | /// Sends enhanced SARIF result data.
17 | ///
18 | /// A containing the enhanced result data.
19 | /// The cookie value of the enhanced result data.
20 | int SendEnhancedResultData(Stream stream);
21 |
22 | ///
23 | /// Sends enhanced SARIF result data.
24 | ///
25 | /// A containing the enhanced result data.
26 | /// The cookie value of the enhanced result data.
27 | int SendEnhancedResultData(SarifLog sarifLog);
28 |
29 | ///
30 | /// Cleans up enhanced SARIF result data.
31 | ///
32 | /// The cookie value of the enhanced result data.
33 | void CloseEnhancedResultData(int cookie);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/CodeFinding/TestFiles/C1.c:
--------------------------------------------------------------------------------
1 | /*
2 | Just a basic c file.
3 | */
4 |
5 | int Add2(int a, int b) {
6 | return a + b;
7 | }
8 |
9 | int Add3(int a, int b, int c) {
10 | return a + b + c;
11 | }
12 |
13 | int AddAll(int[] numbers, int count) {
14 |
15 | int sum = 0;
16 | for (int i = 0; i < count; i++) {
17 | sum += numbers[i];
18 | }
19 |
20 | return sum;
21 | }
22 |
23 | // This pragma section may cause problems when trying to find the Multiply scope.
24 | #pragma some_macro(Multiply)
25 | #pragma some_macro(Divide)
26 |
27 | int Multiply(int a, int b) {
28 | return a * b;
29 | }
30 |
31 | int Divide(int a, int b) {
32 |
33 | // This should cause a test failure right now since the code that tries to find
34 | // matching curly braces to determine scope doesn't know how to deal with #if/#else.
35 | #if DIVIDE_BY_ZERO_OK
36 | if (b >= 0) {
37 | #else
38 | if (b >= 1) {
39 | #endif
40 | return a / b;
41 | }
42 |
43 | return 0;
44 | }
45 |
46 | bool Foo(int a, int b, int c) {
47 |
48 | // This function call within an if statement may impact detection of Add2's function definition.
49 | if (Add2(a, b)) {
50 | return a + b;
51 | }
52 | else {
53 | return Add2(b, c);
54 | }
55 | }
56 |
57 | int __multiplyImpl(int a, int b) {
58 | return a * b;
59 | }
60 |
61 | bool IsThingEnabled() {
62 | return GetSetting("MySettings.ThingEnabled");
63 | }
64 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/ResultsUpdatedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 |
6 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
7 | {
8 | ///
9 | /// Represents event data for the event fired when new analysis results are received.
10 | ///
11 | public class ResultsUpdatedEventArgs : ServiceEventArgs
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | public ResultsUpdatedEventArgs()
17 | {
18 | this.ServiceEventType = ResultSourceServiceEventType.ResultsUpdated;
19 | }
20 |
21 | ///
22 | /// Gets or sets the instance which contains the analysis results.
23 | ///
24 | public SarifLog SarifLog { get; set; }
25 |
26 | ///
27 | /// Gets or sets the name of the log file.
28 | ///
29 | public string LogFileName { get; set; }
30 |
31 | ///
32 | /// Gets or sets a value indicating whether the log should be written to the .sarif directory.
33 | ///
34 | public bool UseDotSarifDirectory { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ExceptionalConditions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer
7 | {
8 | ///
9 | /// Constants specifying various exceptional conditions that can occur in a SARIF log file.
10 | ///
11 | [Flags]
12 | internal enum ExceptionalConditions
13 | {
14 | ///
15 | /// No exceptional conditions were detected in the log file.
16 | ///
17 | None = 0,
18 |
19 | ///
20 | /// The log file contained no results.
21 | ///
22 | NoResults = 0x00000001,
23 |
24 | ///
25 | /// The log file was not valid JSON.
26 | ///
27 | InvalidJson = 0x00000002,
28 |
29 | ///
30 | /// The log file contained at least one error-level tool configuration notification.
31 | ///
32 | ConfigurationError = 0x00000004,
33 |
34 | ///
35 | /// The log file contained at least one error-level tool execution notification.
36 | ///
37 | ExecutionError = 0x00000008,
38 |
39 | ///
40 | /// The log file contains results have been filtered by ErrorList.
41 | ///
42 | ResultsFiltered = 0x00000010,
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/FilteredColumnValue.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.ErrorList
7 | {
8 | // Associates an error list column with a value that has been filtered from it.
9 | internal struct FilteredColumnValue
10 | {
11 | public string ColumnName { get; }
12 |
13 | public string FilteredValue { get; }
14 |
15 | public FilteredColumnValue(string columnName, string filteredValue)
16 | {
17 | this.ColumnName = columnName ?? throw new ArgumentNullException(nameof(columnName));
18 | this.FilteredValue = filteredValue ?? throw new ArgumentNullException(nameof(filteredValue));
19 | }
20 |
21 | public override bool Equals(object obj) =>
22 | obj is FilteredColumnValue other &&
23 | other.ColumnName.Equals(this.ColumnName, StringComparison.Ordinal) &&
24 | other.FilteredValue.Equals(this.FilteredValue, StringComparison.Ordinal);
25 |
26 | public override int GetHashCode()
27 | {
28 | int result = 17;
29 | unchecked
30 | {
31 | result = (result * 31) + this.ColumnName.GetHashCode();
32 | result = (result * 31) + this.FilteredValue.GetHashCode();
33 | }
34 |
35 | return result;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ContentTypes.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.ComponentModel.Composition;
5 |
6 | using Microsoft.VisualStudio.Utilities;
7 |
8 | namespace Microsoft.Sarif.Viewer
9 | {
10 | public static class ContentTypes
11 | {
12 | ///
13 | /// The content type name for SARIF log files.
14 | ///
15 | public const string Sarif = "SARIF";
16 |
17 | ///
18 | /// The content type name that accepts any file.
19 | ///
20 | public const string Any = "any";
21 |
22 | ///
23 | /// The content type name for text files.
24 | ///
25 | public const string Text = "text";
26 |
27 | ///
28 | /// Gets the base content type definition for SARIF log files..
29 | ///
30 | [Export]
31 | [BaseDefinition("json")]
32 | [Name(Sarif)]
33 | internal static ContentTypeDefinition SarifBaseContentType { get; } = null;
34 |
35 | ///
36 | /// Gets the ".sarif" file extension mapping to "SARIF" content type.
37 | ///
38 | [Export]
39 | [FileExtension(".sarif")]
40 | [ContentType(Sarif)]
41 | internal static FileExtensionToContentTypeDefinition SarifFileExtensionContentType { get; } = null;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/CodeFinding/UnitTests/CSharpTestMultiLine.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | using FluentAssertions;
11 |
12 | using Microsoft.Sarif.Viewer.CodeFinding;
13 |
14 | using Xunit;
15 |
16 | namespace Microsoft.Sarif.Viewer.VisualStudio.UnitTests.CodeFinding.UnitTests
17 | {
18 | public class CSharpTestMultiLine
19 | {
20 | ///
21 | /// Tests if we are able to match multi line snippets
22 | ///
23 | [Theory]
24 | [InlineData("\r")]
25 | [InlineData("\r\n")]
26 | [InlineData("\n")]
27 | public void TestMultiLine(string lineEndings)
28 | {
29 | string filePath = @"CodeFinding\TestFiles\CSharp2.cs";
30 | CodeFinder codeFinder = new CodeFinder(filePath);
31 |
32 | string textToFind = $" Console.WriteLine(\"return a + b + c\");{lineEndings} return a + b + c;";
33 |
34 | MatchQuery query = new MatchQuery(textToFind);
35 | List matches = codeFinder.FindMatches(query);
36 | matches.Count().Should().Be(1);
37 | var bestMatch = MatchResult.GetBestMatch(matches);
38 | bestMatch.LineNumber.Should().Be(38);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/SarifLocationTagBase.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.VisualStudio.Text;
5 |
6 | namespace Microsoft.Sarif.Viewer.Tags
7 | {
8 | internal class SarifLocationTagBase : ISarifLocationTag
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The persistent span for the tag within a document.
14 | /// The SARIF run index associated with this tag.
15 | /// the result ID associated with this tag.
16 | /// Gets the data context for this tag.
17 | public SarifLocationTagBase(IPersistentSpan persistentSpan, int runIndex, int resultId, object context)
18 | {
19 | this.PersistentSpan = persistentSpan;
20 | this.RunIndex = runIndex;
21 | this.ResultId = resultId;
22 | this.Context = context;
23 | }
24 |
25 | ///
26 | public IPersistentSpan PersistentSpan { get; }
27 |
28 | ///
29 | public int RunIndex { get; }
30 |
31 | ///
32 | public int ResultId { get; }
33 |
34 | ///
35 | public object Context { get; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/ISarifLocationTag.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.Sarif.Viewer.Models;
5 | using Microsoft.VisualStudio.Text;
6 |
7 | namespace Microsoft.Sarif.Viewer.Tags
8 | {
9 | internal interface ISarifLocationTag
10 | {
11 | ///
12 | /// Gets the persistent span for a document.
13 | ///
14 | ///
15 | /// This span is not necessarily the same as .
16 | /// It may have been modified to fix up column and line numbers from the region
17 | /// present in the SARIF log.
18 | ///
19 | IPersistentSpan PersistentSpan { get; }
20 |
21 | ///
22 | /// Gets the SARIF run index associated with this tag.
23 | ///
24 | int RunIndex { get; }
25 |
26 | ///
27 | /// Gets the result ID associated with this tag.
28 | ///
29 | int ResultId { get; }
30 |
31 | ///
32 | /// Gets the data context for this tag.
33 | ///
34 | ///
35 | /// This will be objects like or and is typically used
36 | /// for the "data context" for the SARIF explorer window.
37 | ///
38 | object Context { get; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/BaselineStateTableDataSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.VisualStudio.Shell;
7 | using Microsoft.VisualStudio.Shell.TableManager;
8 |
9 | namespace Microsoft.Sarif.Viewer.ErrorList
10 | {
11 | // A "stub" data source whose sole purpose is to cause the Category column
12 | // to be displayed. It never actually adds entries to the Error List.
13 | //
14 | // For an explanation of why these this source is necessary, see the comment
15 | // near the top of SarifResultTableEntry.cs
16 | internal class BaselineStateTableDataSource : SarifTableDataSourceBase
17 | {
18 | private static BaselineStateTableDataSource _instance;
19 |
20 | private BaselineStateTableDataSource()
21 | {
22 | ThreadHelper.ThrowIfNotOnUIThread();
23 |
24 | this.Initialize(SarifResultTableEntry.AbsentResultColumns);
25 | }
26 |
27 | public static BaselineStateTableDataSource Instance =>
28 | _instance ?? (_instance = new BaselineStateTableDataSource());
29 |
30 | public override string Identifier => $"{Guids.GuidVSPackageString}-{nameof(BaselineStateTableDataSource)}";
31 |
32 | public override string DisplayName => Resources.ErrorListAbsentResultsDataSourceDisplayName;
33 |
34 | public override IDisposable Subscribe(ITableDataSink sink) => new StubDisposable();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/SarifErrorListEventProcessorProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.ComponentModel.Composition;
5 |
6 | using Microsoft.VisualStudio.Shell.TableControl;
7 | using Microsoft.VisualStudio.Shell.TableManager;
8 | using Microsoft.VisualStudio.Utilities;
9 |
10 | namespace Microsoft.Sarif.Viewer.ErrorList
11 | {
12 | [Export(typeof(ITableControlEventProcessorProvider))]
13 | [ManagerType(StandardTables.ErrorsTable)]
14 | [DataSourceType(StandardTableDataSources.ErrorTableDataSource)]
15 | [DataSource(Guids.GuidVSPackageString)]
16 | [Name("SARIF Location Text Marker Tag")]
17 | [Order(Before = "Default")]
18 | internal class SarifErrorListEventProcessorProvider : ITableControlEventProcessorProvider
19 | {
20 | #pragma warning disable CS0649 // Filled in by MEF
21 | #pragma warning disable IDE0044 // Assigned by MEF
22 | [Import]
23 | private ISarifErrorListEventSelectionService sarifErrorListEventSelectionService;
24 | #pragma warning restore IDE0044
25 | #pragma warning restore CS0649
26 |
27 | public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
28 | {
29 | (this.sarifErrorListEventSelectionService as SarifErrorListEventProcessor)?.SetTableControl(tableControl);
30 |
31 | return this.sarifErrorListEventSelectionService as ITableControlEventProcessor;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/Sarif.Viewer.VisualStudio.Shell.Core.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | e4649ecf-3dad-418a-b83b-c35b71d50c70
7 |
8 |
9 | Sarif.Viewer.VisualStudio.Shell.Core
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Themes/FixesStyles.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
16 |
17 |
20 |
21 |
26 |
27 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/SarifErrorListItem.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Linq;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class SarifErrorListItemExtensions
10 | {
11 | internal static string GetCombinedRuleIds(this IEnumerable sarifErrorListItems)
12 | {
13 | return string.Join(";", sarifErrorListItems.Select(item => item.Rule.Id).Distinct());
14 | }
15 |
16 | internal static string GetCombinedToolNames(this IEnumerable sarifErrorListItems)
17 | {
18 | return string.Join(";", sarifErrorListItems.Select(item => item.Tool?.Name).Distinct());
19 | }
20 |
21 | internal static string GetCombinedToolVersions(this IEnumerable sarifErrorListItems)
22 | {
23 | return string.Join(";", sarifErrorListItems.Select(item => item.Tool?.Version).Distinct());
24 | }
25 |
26 | internal static IEnumerable GetCombinedSnippets(this IEnumerable sarifErrorListItems)
27 | {
28 | List snippets = new List();
29 | foreach (SarifErrorListItem item in sarifErrorListItems)
30 | {
31 | snippets.AddRange(item.GetCodeSnippets());
32 | }
33 |
34 | return snippets;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/SuppressionStateTableDataSource.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.VisualStudio.Shell;
7 | using Microsoft.VisualStudio.Shell.TableManager;
8 |
9 | namespace Microsoft.Sarif.Viewer.ErrorList
10 | {
11 | // A "stub" data source whose sole purpose is to cause the Supression State column
12 | // to be displayed. It never actually adds entries to the Error List.
13 | //
14 | // For an explanation of why these this is necessary, see the comment near the top
15 | // of SarifResultTableEntry.cs
16 | internal class SuppressionStateTableDataSource : SarifTableDataSourceBase
17 | {
18 | private static SuppressionStateTableDataSource _instance;
19 |
20 | private SuppressionStateTableDataSource()
21 | {
22 | ThreadHelper.ThrowIfNotOnUIThread();
23 |
24 | this.Initialize(SarifResultTableEntry.SuppressedResultColumns);
25 | }
26 |
27 | public static SuppressionStateTableDataSource Instance =>
28 | _instance ?? (_instance = new SuppressionStateTableDataSource());
29 |
30 | public override string Identifier => $"{Guids.GuidVSPackageString}-{nameof(SuppressionStateTableDataSource)}";
31 |
32 | public override string DisplayName => Resources.ErrorListSuppressedResultsDataSourceDisplayName;
33 |
34 | public override IDisposable Subscribe(ITableDataSink sink) => new StubDisposable();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Interop/Sarif.Viewer.VisualStudio.Interop.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $project$
5 | $version$
6 | Microsoft SARIF Visual Studio Viewer Extension Interop Assembly
7 | Microsoft
8 | Microsoft
9 | false
10 | Provides an API that allows Visual Studio extensions to consume services exposed by the Microsoft SARIF Visual Studio Viewer extension.
11 | Version $version$ of the Microsoft SARIF Visual Studio Viewer Extension Interop Assembly
12 | © Microsoft Corporation. All rights reserved.
13 | MIT
14 | https://github.com/microsoft/sarif-visualstudio-extension
15 | triskelion.png
16 | SARIF viewer static analysis
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/ResourceExtractor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Reflection;
8 |
9 | namespace Microsoft.Sarif.Viewer.VisualStudio.UnitTests
10 | {
11 | public class ResourceExtractor
12 | {
13 | private static readonly string s_resourceNamespace = GetResourceNamespace();
14 | private static readonly IEnumerable s_resourceNames = GetResourceNames();
15 |
16 | public static Stream GetResourceStream(string resourceName) =>
17 | Assembly.GetExecutingAssembly().GetManifestResourceStream(GetFullResourceName(resourceName));
18 |
19 | public static IEnumerable GetResrouceStreamsByPath(string path)
20 | {
21 | foreach (string resourceName in s_resourceNames.Where(r => r.StartsWith($"{s_resourceNamespace}.{path}")))
22 | {
23 | yield return Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
24 | }
25 | }
26 |
27 | private static string GetResourceNamespace() =>
28 | typeof(ResourceExtractor).Namespace;
29 |
30 | private static IEnumerable GetResourceNames() =>
31 | Assembly.GetExecutingAssembly().GetManifestResourceNames();
32 |
33 | private static string GetFullResourceName(string resourceName) =>
34 | $"{s_resourceNamespace}.{resourceName}";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/ErrorList/SarifErrorListSelectionChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | namespace Microsoft.Sarif.Viewer.ErrorList
7 | {
8 | ///
9 | /// Used as event arguments for the navigate and selection changed events from .
10 | ///
11 | internal class SarifErrorListSelectionChangedEventArgs : EventArgs
12 | {
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | /// The previous item.
17 | /// The new item.
18 | /// Both parameters may be null.
19 | public SarifErrorListSelectionChangedEventArgs(SarifErrorListItem oldItem, SarifErrorListItem newItem)
20 | {
21 | this.OldItem = oldItem;
22 | this.NewItem = newItem;
23 | }
24 |
25 | ///
26 | /// Gets the previous item.
27 | ///
28 | ///
29 | /// May be null.
30 | ///
31 | public SarifErrorListItem OldItem { get; }
32 |
33 | ///
34 | /// Gets the new item.
35 | ///
36 | ///
37 | /// May be null.
38 | ///
39 | public SarifErrorListItem NewItem { get; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/TextEditIdleAssistant.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Threading;
6 |
7 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer
8 | {
9 | internal class TextEditIdleAssistant : IDisposable
10 | {
11 | // the same delay as the squiggle provider
12 | private const int DefaultUpdateDelayInMS = 3000;
13 |
14 | private readonly Timer waitingTimer;
15 |
16 | private TextEditIdledEventArgs args;
17 |
18 | public TextEditIdleAssistant()
19 | {
20 | this.waitingTimer = new Timer(p => Idled(this, this.args));
21 | }
22 |
23 | ///
24 | /// Timer event fires when specified delay time passes
25 | ///
26 | public event EventHandler Idled = (sender, e) => { };
27 |
28 | ///
29 | /// Triggered wheneven text content changed.
30 | /// If another change triggered within delay time, it resets timer.
31 | ///
32 | /// Event data.
33 | public void TextChanged(TextEditIdledEventArgs args)
34 | {
35 | this.args = args;
36 |
37 | // reset timer if its triggered within default delay time
38 | this.waitingTimer.Change(DefaultUpdateDelayInMS, Timeout.Infinite);
39 | }
40 |
41 | public void Dispose()
42 | {
43 | this.waitingTimer.Dispose();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/scripts/Projects.psm1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Provides a list of SARIF Viewer projects and frameworks.
4 | .DESCRIPTION
5 | The Projects module exports variables whose properties specify the
6 | various kinds of projects in the SARIF Viewer, and the frameworks
7 | for which they are built.
8 | #>
9 |
10 | # .NET Framework versions for which we build.
11 | $Frameworks = @("net472")
12 |
13 | $Projects = @{}
14 | $Projects.Vsix = @(
15 | "Sarif.Viewer.VisualStudio.2022",
16 | "Sarif.Viewer.VisualStudio")
17 | $Projects.NuGet = @("Sarif.Viewer.VisualStudio.Interop")
18 | $Projects.Library = @(
19 | "Sarif.Viewer.VisualStudio.ResultSources.ACL.2022",
20 | "Sarif.Viewer.VisualStudio.ResultSources.ACL",
21 | "Sarif.Viewer.VisualStudio.ResultSources.Domain.2022",
22 | "Sarif.Viewer.VisualStudio.ResultSources.Domain",
23 | "Sarif.Viewer.VisualStudio.Shell.2022",
24 | "Sarif.Viewer.VisualStudio.Shell",
25 | "Sarif.Viewer.VisualStudio.ResultSources.Factory.2022",
26 | "Sarif.Viewer.VisualStudio.ResultSources.Factory",
27 | "Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.2022",
28 | "Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity",
29 | "Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.Resources")
30 | $Projects.Product = $Projects.Vsix + $Projects.NuGet
31 | $Projects.Test = @(
32 | "Sarif.Viewer.VisualStudio.UnitTests",
33 | "Sarif.Viewer.VisualStudio.ResultSources.Factory.UnitTests",
34 | "Sarif.Viewer.VisualStudio.ResultSources.GitHubAdvancedSecurity.UnitTests")
35 | $Projects.All = $Projects.Product + $Projects.Test + $Projects.Library
36 |
37 | Export-ModuleMember -Variable Frameworks, Projects
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/VersionControlParser/VersionControlParser.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.CodeAnalysis.Sarif;
7 | using Microsoft.Sarif.Viewer.Sarif;
8 |
9 | namespace Microsoft.Sarif.Viewer
10 | {
11 | public abstract class VersionControlParser : IVersionControlParser
12 | {
13 | protected readonly VersionControlDetails details;
14 |
15 | internal protected VersionControlParser(VersionControlDetails versionControl)
16 | {
17 | this.details = versionControl;
18 | }
19 |
20 | public abstract string ConvertToRawPath(string url);
21 |
22 | public abstract string GetLocalRelativePath(Uri uri, string relativeFilePath);
23 |
24 | public abstract Uri GetSourceFileUri(string relativeFilePath);
25 |
26 | protected Uri CreateUri(string sourceRelativePath)
27 | {
28 | var baseUri = new Uri(this.details.RepositoryUri.ToString());
29 | if (!baseUri.AbsolutePath.EndsWith("/"))
30 | {
31 | UriBuilder builder = new UriBuilder(baseUri);
32 | builder.Path = baseUri.AbsolutePath + "/";
33 | baseUri = builder.Uri;
34 | }
35 |
36 | if (Uri.TryCreate(baseUri, sourceRelativePath, out Uri sourceUri) &&
37 | sourceUri.IsHttpScheme())
38 | {
39 | return new Uri(ConvertToRawPath(sourceUri.ToString()));
40 | }
41 |
42 | return null;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Commands/AnalyzeProjectCommand.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.ComponentModel.Design;
6 | using System.Linq;
7 |
8 | using EnvDTE;
9 |
10 | using Microsoft.VisualStudio.Shell;
11 |
12 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer.Commands
13 | {
14 | internal class AnalyzeProjectCommand : AnalyzeMenuCommandBase
15 | {
16 | public AnalyzeProjectCommand(IMenuCommandService menuCommandService)
17 | : base(menuCommandService, SariferPackageCommandIds.AnalyzeProject)
18 | {
19 | }
20 |
21 | protected override void AnalyzeTargets()
22 | {
23 | ThreadHelper.ThrowIfNotOnUIThread();
24 |
25 | IEnumerable selectedProjects = (this.dte.ActiveSolutionProjects as object[]).OfType();
26 | if (selectedProjects != null)
27 | {
28 | foreach (Project project in selectedProjects)
29 | {
30 | // Disable the menu click when we are analysing.
31 | SariferPackageCommand.DisableAnalyzeCommands(this.menuCommandService);
32 |
33 | List targetFiles = SariferPackageCommand.GetFiles(project);
34 |
35 | this.backgroundAnalysisService.AnalyzeAsync(project.FullName, targetFiles, this.cancellationTokenSource.Token)
36 | .FileAndForget(FileAndForgetEventName.BackgroundAnalysisFailure);
37 | }
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Options/LocationTextDecorationCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 |
7 | namespace Microsoft.Sarif.Viewer.Options
8 | {
9 | public class LocationTextDecorationCollection
10 | {
11 | public List ColorOptions { get; }
12 |
13 | public ObservableCollection Decorations { get; }
14 |
15 | ///
16 | /// This event is triggered whenever the selected color changes.
17 | ///
18 | public event SelectedColorChangedEventHandler SelectedColorChanged;
19 |
20 | public delegate void SelectedColorChangedEventHandler(SelectedColorChangedEventArgs e);
21 |
22 | public LocationTextDecorationCollection(List colorOptions)
23 | {
24 | this.Decorations = new ObservableCollection();
25 | this.ColorOptions = colorOptions;
26 | }
27 |
28 | public void Add(LocationTextDecoration item)
29 | {
30 | if (item != null)
31 | {
32 | item.SetColorOptions(this.ColorOptions);
33 | this.Decorations.Add(item);
34 | item.SelectedColorChanged += this.SelectedDecorationColorChanged;
35 | }
36 | }
37 |
38 | private void SelectedDecorationColorChanged(SelectedColorChangedEventArgs e)
39 | {
40 | SelectedColorChanged?.Invoke(e);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/ReplacementEdit.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.Sarif.Viewer.Models;
5 | using Microsoft.VisualStudio.Text;
6 |
7 | namespace Microsoft.Sarif.Viewer.Fixes
8 | {
9 | ///
10 | /// Represents an edit to a file. When the edit is applied, the contents of the span will be
11 | /// replaced by the text.
12 | ///
13 | public class ReplacementEdit
14 | {
15 | ///
16 | /// Gets the span to be replaced.
17 | ///
18 | public SnapshotSpan Span { get; }
19 |
20 | ///
21 | /// Gets the text to be inserted.
22 | ///
23 | public string Text { get; }
24 |
25 | ///
26 | /// Initializes a new instance of the class.
27 | ///
28 | /// The SARIF replacement from which to construct the edit.
29 | /// The snapshot to which the edit will be applied.
30 | public ReplacementEdit(ReplacementModel replacement, ITextSnapshot snapshot)
31 | {
32 | this.Text = replacement.InsertedString ?? string.Empty;
33 |
34 | ITrackingSpan replacementSpan = replacement.PersistentSpan.Span;
35 | SnapshotPoint start = replacementSpan.GetStartPoint(snapshot);
36 | SnapshotPoint end = replacementSpan.GetEndPoint(snapshot);
37 |
38 | this.Span = new SnapshotSpan(start, end);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/MenuCommandInvokedEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Microsoft.CodeAnalysis.Sarif;
8 | using Microsoft.VisualStudio.Shell;
9 |
10 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
11 | {
12 | ///
13 | /// Represents event data for the event fired when a menu command is invoked.
14 | ///
15 | public class MenuCommandInvokedEventArgs : EventArgs
16 | {
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// The of instances associated with the menu command invocation.
21 | /// The that was invoked.
22 | public MenuCommandInvokedEventArgs(IList sarifResults, OleMenuCommand menuCommand)
23 | {
24 | this.SarifResults = sarifResults;
25 | this.MenuCommand = menuCommand;
26 | }
27 |
28 | ///
29 | /// Gets the s associated with the selected Error List item(s).
30 | ///
31 | public IList SarifResults { get; } = new List();
32 |
33 | ///
34 | /// Gets the that was invoked.
35 | ///
36 | public OleMenuCommand MenuCommand { get; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Replacement.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.CodeAnalysis.Sarif;
7 | using Microsoft.Sarif.Viewer.Models;
8 |
9 | namespace Microsoft.Sarif.Viewer.Sarif
10 | {
11 | internal static class ReplacementExtensions
12 | {
13 | public static ReplacementModel ToReplacementModel(this Replacement replacement, FileRegionsCache fileRegionsCache, Uri uri)
14 | {
15 | if (replacement == null)
16 | {
17 | return null;
18 | }
19 |
20 | var model = new ReplacementModel
21 | {
22 | Region = uri.IsAbsoluteUri
23 | ? fileRegionsCache.PopulateTextRegionProperties(replacement.DeletedRegion, uri, populateSnippet: false)
24 | : replacement.DeletedRegion,
25 | };
26 |
27 | if (model.Region.CharOffset >= 0)
28 | {
29 | // This is a text replacement.
30 | model.InsertedString = replacement.InsertedContent?.Text;
31 | }
32 | else
33 | {
34 | // This is a binary replacement, but don't try to convert the replacement
35 | // content to a string if there isn't any.
36 | if (replacement.InsertedContent?.Binary != null)
37 | {
38 | model.InsertedBytes = Convert.FromBase64String(replacement.InsertedContent.Binary);
39 | }
40 | }
41 |
42 | return model;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.UnitTests/StringBuilderFileStreamMock.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.IO;
5 | using System.Text;
6 |
7 | namespace Microsoft.Sarif.Viewer.VisualStudio.UnitTests
8 | {
9 | ///
10 | /// Represents a MemoryStream whose contents can be retrieved when it is disposed.
11 | ///
12 | ///
13 | /// This class is useful in unit tests which need to mock a method that creates a stream to
14 | /// which product code subsequently writes. The test arranges for the mocked method to return
15 | /// an instance of this class. After the product code executes, the test can find out what the
16 | /// product code wrote to the stream.
17 | ///
18 | internal class StringBuilderFileStreamMock : MemoryStream
19 | {
20 | private StringBuilder OutputTo { get; }
21 |
22 | ///
23 | /// Creates a new instance of the MemoryStreamToStringBuilder class.
24 | ///
25 | ///
26 | /// A to which the contents of the stream will be written when
27 | /// this instance is disposed.
28 | ///
29 | public StringBuilderFileStreamMock(StringBuilder outputTo)
30 | {
31 | OutputTo = outputTo;
32 | }
33 |
34 | protected override void Dispose(bool disposing)
35 | {
36 | OutputTo.Clear();
37 | OutputTo.Append(Encoding.UTF8.GetString(this.ToArray()));
38 | base.Dispose(disposing);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.ResultSources.Domain.Core/Models/MenuCommandBeforeQueryStatusEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Microsoft.CodeAnalysis.Sarif;
8 |
9 | namespace Microsoft.Sarif.Viewer.ResultSources.Domain.Models
10 | {
11 | ///
12 | /// Represents event data for the event fired before a menu command is queried for status.
13 | ///
14 | public class MenuCommandBeforeQueryStatusEventArgs : EventArgs
15 | {
16 | ///
17 | /// Initializes a new instance of the class.
18 | ///
19 | /// The of instances associated with the menu command invocation.
20 | /// The number of items selected in the Error List.
21 | public MenuCommandBeforeQueryStatusEventArgs(IList sarifResults, int selectedItemsCount)
22 | {
23 | this.SarifResults = sarifResults;
24 | this.SelectedItemsCount = selectedItemsCount;
25 | }
26 |
27 | ///
28 | /// Gets or sets the count of items selected in the Error List.
29 | ///
30 | public int SelectedItemsCount { get; set; }
31 |
32 | ///
33 | /// Gets the s associated with the selected Error List item(s).
34 | ///
35 | public IList SarifResults { get; } = new List();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Views/InformationStringResources.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | Level
6 | Category
7 | Help
8 | Command line
9 | Start time
10 | End time
11 | Machine
12 | Account
13 | Process ID
14 | File name
15 | Working directory
16 | Environment variables
17 | Open Log File
18 |
19 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/Rule.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 |
6 | using Microsoft.CodeAnalysis.Sarif;
7 | using Microsoft.Sarif.Viewer.Models;
8 |
9 | namespace Microsoft.Sarif.Viewer.Sarif
10 | {
11 | internal static class RuleExtensions
12 | {
13 | public static RuleModel ToRuleModel(this ReportingDescriptor rule, string defaultRuleId)
14 | {
15 | RuleModel model;
16 | string ruleId = defaultRuleId;
17 |
18 | if (Guid.TryParse(ruleId, out Guid result) && !string.IsNullOrEmpty(rule.Name))
19 | {
20 | ruleId = rule.Name;
21 | }
22 |
23 | if (rule == null)
24 | {
25 | model = new RuleModel()
26 | {
27 | Id = ruleId,
28 | DefaultFailureLevel = FailureLevel.Warning,
29 | };
30 | }
31 | else
32 | {
33 | model = new RuleModel()
34 | {
35 | Id = ruleId ?? rule.Id,
36 | Name = rule.Name,
37 | Description = rule.FullDescription?.Text,
38 | DefaultFailureLevel = rule.DefaultConfiguration != null ?
39 | rule.DefaultConfiguration.Level :
40 | FailureLevel.Warning, // Default level
41 | HelpUri = rule.HelpUri?.IsAbsoluteUri == true ? rule.HelpUri.AbsoluteUri : null,
42 | };
43 | }
44 |
45 | return model;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Uri.extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class UriExtensions
10 | {
11 | // The acceptable URI schemes
12 | private static readonly HashSet s_httpSchemes = new HashSet(new string[] { Uri.UriSchemeHttp, Uri.UriSchemeHttps },
13 | StringComparer.OrdinalIgnoreCase);
14 |
15 | public static string ToPath(this Uri uri)
16 | {
17 | if (uri == null)
18 | {
19 | return null;
20 | }
21 |
22 | if (uri.IsAbsoluteUri)
23 | {
24 | if (IsHttpScheme(uri))
25 | {
26 | return uri.ToString();
27 | }
28 | else
29 | {
30 | return uri.LocalPath + uri.Fragment;
31 | }
32 | }
33 | else
34 | {
35 | return uri.OriginalString;
36 | }
37 | }
38 |
39 | public static bool IsHttpScheme(this Uri uri)
40 | {
41 | return s_httpSchemes.Contains(uri.Scheme);
42 | }
43 |
44 | public static Uri WithTrailingSlash(this Uri uri)
45 | {
46 | const string Slash = "/";
47 |
48 | string uriString = uri.ToString();
49 | return uriString.EndsWith(Slash) ? uri : new Uri(uriString + Slash, UriKind.RelativeOrAbsolute);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Commands/AnalyzeSolutionCommand.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.ComponentModel.Design;
6 |
7 | using EnvDTE;
8 |
9 | using Microsoft.VisualStudio.Shell;
10 |
11 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer.Commands
12 | {
13 | internal class AnalyzeSolutionCommand : AnalyzeMenuCommandBase
14 | {
15 | public AnalyzeSolutionCommand(IMenuCommandService menuCommandService)
16 | : base(menuCommandService, SariferPackageCommandIds.AnalyzeSolution)
17 | {
18 | }
19 |
20 | protected override void AnalyzeTargets()
21 | {
22 | ThreadHelper.ThrowIfNotOnUIThread();
23 |
24 | Solution solution = this.dte.Solution;
25 | if (solution == null)
26 | {
27 | return;
28 | }
29 |
30 | Projects projects = solution.Projects;
31 | if (projects == null)
32 | {
33 | return;
34 | }
35 |
36 | var targetFiles = new List();
37 | foreach (Project project in projects)
38 | {
39 | targetFiles.AddRange(SariferPackageCommand.GetFiles(project));
40 | }
41 |
42 | // Disable the menu click when we are analysing.
43 | SariferPackageCommand.DisableAnalyzeCommands(this.menuCommandService);
44 | this.backgroundAnalysisService.AnalyzeAsync(solution.FullName, targetFiles, this.cancellationTokenSource.Token)
45 | .FileAndForget(FileAndForgetEventName.BackgroundAnalysisFailure);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Sarif/StackFrame.Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using Microsoft.CodeAnalysis.Sarif;
5 | using Microsoft.Sarif.Viewer.Models;
6 |
7 | namespace Microsoft.Sarif.Viewer.Sarif
8 | {
9 | internal static class StackFrameExtensions
10 | {
11 | public static StackFrameModel ToStackFrameModel(this StackFrame stackFrame, int resultId, int runIndex)
12 | {
13 | var model = new StackFrameModel(resultId, runIndex);
14 |
15 | model.FullyQualifiedLogicalName = stackFrame.Location?.LogicalLocation?.FullyQualifiedName;
16 | model.Message = stackFrame.Location?.Message?.Text;
17 | model.Module = stackFrame.Module;
18 |
19 | if (stackFrame.Location?.PhysicalLocation?.Address != null)
20 | {
21 | model.Address = stackFrame.Location.PhysicalLocation.Address.AbsoluteAddress;
22 | model.Offset = stackFrame.Location.PhysicalLocation.Address.OffsetFromParent ?? 0;
23 | }
24 |
25 | PhysicalLocation physicalLocation = stackFrame.Location?.PhysicalLocation;
26 | if (physicalLocation?.ArtifactLocation != null)
27 | {
28 | model.FilePath = physicalLocation.ArtifactLocation.Uri.ToPath();
29 | Region region = physicalLocation.Region;
30 | if (region != null)
31 | {
32 | model.Region = region;
33 | model.Line = region.StartLine;
34 | model.Column = region.StartColumn;
35 | }
36 | }
37 |
38 | return model;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Tags/ISarifLocationTaggerService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.Runtime.InteropServices;
6 |
7 | using Microsoft.VisualStudio.Text;
8 |
9 | namespace Microsoft.Sarif.Viewer.Tags
10 | {
11 | [Guid("774C62D3-203A-493C-8801-BEA59FE46CA1")]
12 | internal interface ISarifLocationTaggerService
13 | {
14 | ///
15 | /// Causes a tags changed notification to be sent out from all known taggers associated
16 | /// with the specified .
17 | ///
18 | ///
19 | /// The text buffer of interest, or null if the notification should be set to all taggers.
20 | ///
21 | ///
22 | /// As an example, this method is called to send a tags changed notification when a "text
23 | /// view" is already open and visible and a tagger is active for that "text view" when a
24 | /// SARIF log is loaded or cleared.
25 | ///
26 | void RefreshTags(ITextBuffer textBuffer = null);
27 |
28 | ///
29 | /// Adds a new tagger to the list of taggers known to this service.
30 | ///
31 | ///
32 | /// The taggers known to this service will be asked to refresh their tags when
33 | /// is called by consumers of the service.
34 | ///
35 | /// A new instance of ..
36 | void AddTagger(ISarifLocationTagger tagger);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/Fixes/FixSuggestedActionsSourceProvider.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.ComponentModel.Composition;
5 |
6 | using Microsoft.VisualStudio.Language.Intellisense;
7 | using Microsoft.VisualStudio.Text;
8 | using Microsoft.VisualStudio.Text.Editor;
9 | using Microsoft.VisualStudio.Utilities;
10 |
11 | namespace Microsoft.Sarif.Viewer.Fixes
12 | {
13 | ///
14 | /// Provides a for a specified
15 | /// and .
16 | ///
17 | [Export(typeof(ISuggestedActionsSourceProvider))]
18 | [Name(FixActionCategoryName)]
19 | [ContentType(ContentTypes.Any)]
20 | internal class FixSuggestedActionsSourceProvider : ISuggestedActionsSourceProvider
21 | {
22 | private const string FixActionCategoryName = "SARIF fix suggestion";
23 |
24 | #pragma warning disable CS0649 // Filled in by MEF
25 | #pragma warning disable IDE0044 // Assigned by MEF
26 | [Import]
27 | private IPersistentSpanFactory persistentSpanFactory;
28 |
29 | [Import]
30 | private IPreviewProvider previewProvider;
31 | #pragma warning restore IDE0044
32 | #pragma warning restore CS0649
33 |
34 | ///
35 | public ISuggestedActionsSource CreateSuggestedActionsSource(ITextView textView, ITextBuffer textBuffer)
36 | {
37 | if (textBuffer == null && textView == null)
38 | {
39 | return null;
40 | }
41 |
42 | return new FixSuggestedActionsSource(textView, textBuffer, this.persistentSpanFactory, this.previewProvider);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/IGitExe.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Threading.Tasks;
5 |
6 | namespace Microsoft.Sarif.Viewer.Shell
7 | {
8 | public interface IGitExe
9 | {
10 | ///
11 | /// Gets or sets the full path of a folder anywhere within the repo.
12 | ///
13 | string RepoPath { get; set; }
14 |
15 | ///
16 | /// Gets the root repo path of current solution.
17 | ///
18 | /// The file path we want the repo root of.
19 | /// The root repo path.
20 | ValueTask GetRepoRootAsync(string filePath = null);
21 |
22 | ///
23 | /// Gets the root repo URI of current solution.
24 | ///
25 | /// The file path we want the repo uri of.
26 | /// The root repo path.
27 | ValueTask GetRepoUriAsync(string filePath = null);
28 |
29 | ///
30 | /// Gets current repo branch name.
31 | ///
32 | /// The file path we want the repo branch name of.
33 | /// The current branch name.
34 | ValueTask GetCurrentBranchAsync(string filePath = null);
35 |
36 | ///
37 | /// Gets the current repo commit hash..
38 | ///
39 | /// The file path we want the commit hash of.
40 | /// The current commit hash.
41 | ValueTask GetCurrentCommitHashAsync(string filePath = null);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Sarif.Sarifer.Core/Commands/AnalyzeFileCommand.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Collections.Generic;
5 | using System.ComponentModel.Design;
6 | using System.Linq;
7 |
8 | using EnvDTE;
9 |
10 | using Microsoft.VisualStudio.Shell;
11 |
12 | namespace Microsoft.CodeAnalysis.Sarif.Sarifer.Commands
13 | {
14 | internal class AnalyzeFileCommand : AnalyzeMenuCommandBase
15 | {
16 | public AnalyzeFileCommand(IMenuCommandService menuCommandService)
17 | : base(menuCommandService, SariferPackageCommandIds.AnalyzeFile)
18 | {
19 | }
20 |
21 | protected override void AnalyzeTargets()
22 | {
23 | ThreadHelper.ThrowIfNotOnUIThread();
24 |
25 | var targetFiles = new List();
26 |
27 | if (this.dte.SelectedItems != null && this.dte.SelectedItems.Count > 0)
28 | {
29 | foreach (SelectedItem selectedItem in this.dte.SelectedItems)
30 | {
31 | targetFiles.AddRange(SariferPackageCommand.GetFiles(selectedItem));
32 | }
33 |
34 | if (targetFiles.Any())
35 | {
36 | // Disable the menu click when we are analysing.
37 | SariferPackageCommand.DisableAnalyzeCommands(this.menuCommandService);
38 | string logId = targetFiles.First() + (targetFiles.Count > 1 ? $"~{targetFiles.Count}" : string.Empty);
39 | this.backgroundAnalysisService.AnalyzeAsync(logId, targetFiles, this.cancellationTokenSource.Token)
40 | .FileAndForget(FileAndForgetEventName.BackgroundAnalysisFailure);
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Core/KeyValuePairPropertyDescriptor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System;
5 | using System.ComponentModel;
6 |
7 | namespace Microsoft.Sarif.Viewer
8 | {
9 | ///
10 | /// A custom property descriptor which represents one key-value-pair.
11 | /// The property is always grouped/displayed in the Properties category
12 | /// in the Properties tool window.
13 | ///
14 | internal class KeyValuePairPropertyDescriptor : PropertyDescriptor
15 | {
16 | private readonly string _key;
17 | private string _value;
18 |
19 | internal KeyValuePairPropertyDescriptor(string key, string value)
20 | : base(key, null)
21 | {
22 | this._key = key;
23 | this._value = value;
24 | }
25 |
26 | public override Type PropertyType => this._key.GetType();
27 |
28 | public override bool IsReadOnly => true;
29 |
30 | public override Type ComponentType => null;
31 |
32 | public override string Category => "Properties";
33 |
34 | public override void SetValue(object component, object value)
35 | {
36 | this._value = value.ToString();
37 | }
38 |
39 | public override object GetValue(object component)
40 | {
41 | return this._value;
42 | }
43 |
44 | public override bool CanResetValue(object component)
45 | {
46 | return false;
47 | }
48 |
49 | public override void ResetValue(object component)
50 | {
51 | }
52 |
53 | public override bool ShouldSerializeValue(object component)
54 | {
55 | return false;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/Sarif.Viewer.VisualStudio.Shell.Core/BrowserService.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved.
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 |
4 | using System.Diagnostics;
5 | using System.Text.RegularExpressions;
6 |
7 | using Microsoft.Win32;
8 |
9 | namespace Microsoft.Sarif.Viewer.Shell
10 | {
11 | public class BrowserService
12 | {
13 | private const string UserChoicePath = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice";
14 | private const string BrowserCommandPath = @"\shell\open\command";
15 |
16 | public Process NavigateUrl(string url)
17 | {
18 | using (RegistryKey userChoiceKey = Registry.CurrentUser.OpenSubKey(UserChoicePath))
19 | {
20 | if (userChoiceKey != null)
21 | {
22 | object progId = userChoiceKey.GetValue("ProgId");
23 |
24 | if (progId != null)
25 | {
26 | using (RegistryKey browserPathKey = Registry.ClassesRoot.OpenSubKey(progId.ToString() + BrowserCommandPath))
27 | {
28 | if (browserPathKey != null)
29 | {
30 | string keyValue = browserPathKey.GetValue(null).ToString();
31 | Match match = Regex.Match(keyValue, "\"([^\"]*)\"");
32 |
33 | if (match.Success)
34 | {
35 | return Process.Start(match.Value, url);
36 | }
37 | }
38 | }
39 | }
40 | }
41 | }
42 |
43 | return null;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------