Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AST-22257 - Adding support to critical vulnerabilities #147

Merged
merged 11 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace ast_visual_studio_extension_tests.cx_unit_tests.cx_wrapper_tests
[Collection("Cx Collection")]
public class ResultTest : BaseTest
{
public static string SCAN_COMPLETED => "completed";

[Fact]
public void TestResultsHTML()
{
Expand All @@ -27,8 +29,9 @@ public void TestResultsJSON()
{
List<Scan> scanList = cxWrapper.GetScans("statuses=Completed");
Assert.True(scanList.Any());
Scan scan = scanList.FirstOrDefault(scan => scan.Status.ToLower() == SCAN_COMPLETED);

string scanId = scanList[0].ID;
string scanId = scan.ID;
string results = cxWrapper.GetResults(scanId, ReportFormat.json);

Assert.True(!string.IsNullOrEmpty(results));
Expand All @@ -51,8 +54,9 @@ public void TestResultsStructure()
{
List<Scan> scanList = cxWrapper.GetScans("statuses=Completed");
Assert.True(scanList.Any());
List<Scan> completedScans = scanList.Where(scan => scan.Status.Equals("completed", StringComparison.OrdinalIgnoreCase)).ToList();

Results results = GetFirstScanWithResults(scanList).First().Value;
Results results = GetFirstScanWithResults(completedScans).First().Value;

Assert.Equal(results.totalCount, results.results.Count);
}
Expand Down
29 changes: 17 additions & 12 deletions ast-visual-studio-extension/CxExtension/CxWindowControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,18 +440,22 @@
<Separator Style="{StaticResource SeparatorStyle}" />
</StackPanel>

<ToggleButton ToolTip="High" Style="{StaticResource SeverityFilterStyle}" x:Name="HighSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="HighSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="Medium" Style="{StaticResource SeverityFilterStyle}" x:Name="MediumSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="MediumSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="Low" Style="{StaticResource SeverityFilterStyle}" x:Name="LowSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="LowSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="Info" Style="{StaticResource SeverityFilterStyle}" x:Name="InfoSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="InfoSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>

<ToggleButton ToolTip="Critical" Style="{StaticResource SeverityFilterStyle}" x:Name="CriticalSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="CriticalSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="High" Style="{StaticResource SeverityFilterStyle}" x:Name="HighSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="HighSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="Medium" Style="{StaticResource SeverityFilterStyle}" x:Name="MediumSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="MediumSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="Low" Style="{StaticResource SeverityFilterStyle}" x:Name="LowSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="LowSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>
<ToggleButton ToolTip="Info" Style="{StaticResource SeverityFilterStyle}" x:Name="InfoSeverityFilter" Click="SeverityFilter_Click">
<Image x:Name="InfoSeverityFilterImage" Stretch="None"></Image>
</ToggleButton>

<Menu Background="Transparent">
<MenuItem ToolTip="Filter by state" Style="{DynamicResource DefaultMenuItemStyle}" Padding="0" Margin="2,5,2,5">
Expand Down Expand Up @@ -548,6 +552,7 @@

<UniformGrid Rows="1" Columns="3">
<ComboBox IsEditable="True" IsReadOnly="True" Name="TriageSeverityCombobox" Margin="5,5,0,0">
<ComboBoxItem>CRITICAL</ComboBoxItem>
<ComboBoxItem>HIGH</ComboBoxItem>
<ComboBoxItem>MEDIUM</ComboBoxItem>
<ComboBoxItem>LOW</ComboBoxItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public CxWindowControl(AsyncPackage package)
.WithResultsTree(TreeViewResults)
.WithSeverityFilters(new Dictionary<ToggleButton, Severity>
{
{ CriticalSeverityFilter, Severity.CRITICAL },
{ HighSeverityFilter, Severity.HIGH },
{ MediumSeverityFilter , Severity.MEDIUM},
{ LowSeverityFilter, Severity.LOW },
{ InfoSeverityFilter, Severity.INFO },
}, new Dictionary<Severity, Image>
{
{ Severity.CRITICAL, CriticalSeverityFilterImage },
{ Severity.HIGH, HighSeverityFilterImage },
{ Severity.MEDIUM, MediumSeverityFilterImage },
{ Severity.LOW, LowSeverityFilterImage },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public enum Severity
{
CRITICAL,
HIGH,
MEDIUM,
LOW,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ast-visual-studio-extension/CxExtension/Resources/high.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ast-visual-studio-extension/CxExtension/Resources/low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ast-visual-studio-extension/CxExtension/Resources/medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions ast-visual-studio-extension/CxExtension/Utils/CxConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ internal class CxConstants
public static string COLLAPSE_CRUMB => "...";

/************ ICONS ************/
public static string ICON_CRITICAL => "critical.png";
public static string ICON_CRITICAL_TITLE => "C-L.png";
public static string ICON_HIGH => "high.png";
public static string ICON_HIGH_TITLE => "high_18x22.png";
public static string ICON_HIGH_TITLE => "H-L.png";
public static string ICON_MEDIUM => "medium.png";
public static string ICON_MEDIUM_TITLE => "medium_18x22.png";
public static string ICON_MEDIUM_TITLE => "M-L.png";
public static string ICON_LOW => "low.png";
public static string ICON_LOW_TITLE => "low_18x22.png";
public static string ICON_LOW_TITLE => "L-L.png";
public static string ICON_INFO => "info.png";
public static string ICON_INFO_TITLE => "info_18x22.png";
public static string ICON_INFO_TITLE => "I-L.png";
public static string ICON_FLAG => "Flag.png";
public static string ICON_COMMENT => "Comment.png";
public static string ICON_CX_LOGO_INITIAL_PANEL => "checkmarx-80.png";
Expand Down
4 changes: 3 additions & 1 deletion ast-visual-studio-extension/CxExtension/Utils/CxUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ internal class CxUtils
public static string GetIconPathFromSeverity(string severity, Boolean iconForTitle)
{
switch (GetSeverityFromString(severity))
{
{
case Severity.CRITICAL:
return Path.Combine(CxConstants.RESOURCES_BASE_DIR, iconForTitle ? CxConstants.ICON_CRITICAL_TITLE : CxConstants.ICON_CRITICAL);
case Severity.HIGH:
return Path.Combine(CxConstants.RESOURCES_BASE_DIR, iconForTitle ? CxConstants.ICON_HIGH_TITLE : CxConstants.ICON_HIGH);
case Severity.MEDIUM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SettingsUtils

public static readonly Dictionary<object, bool> severityDefaultValues = new Dictionary<object, bool>
{
{ Severity.CRITICAL, true},
{ Severity.HIGH, true },
{ Severity.MEDIUM, true },
{ Severity.LOW, false },
Expand Down
2 changes: 1 addition & 1 deletion ast-visual-studio-extension/CxWrapper/CxWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void TriageUpdate(string projectId, string similarityId, string scanType,
triageArguments.Add(CxConstants.FLAG_SEVERITY);
triageArguments.Add(severity);

Execution.ExecuteCommand(WithConfigArguments(triageArguments), line => null);
Execution.ExecuteCommand(WithConfigArguments(triageArguments), line => line);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public class ResultsSummary
[JsonProperty("TotalIssues")]
public int TotalIssues { get; set; }

[JsonProperty("CriticalIssues")]
public int CriticalIssues { get; set; }

[JsonProperty("HighIssues")]
public int HighIssues { get; set; }

Expand Down
15 changes: 14 additions & 1 deletion ast-visual-studio-extension/ast-visual-studio-extension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@
<PackageReference Include="System.Json" Version="4.7.1" />
</ItemGroup>
<ItemGroup>
<Resource Include="CxExtension\Resources\critical.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="CxExtension\Resources\critical_18x22.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="CxExtension\Resources\critical_title.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<Resource Include="CxExtension\Resources\C-L.png" />
<Resource Include="CxExtension\Resources\H-L.png" />
<Resource Include="CxExtension\Resources\I-L.png" />
<Resource Include="CxExtension\Resources\L-L.png" />
<Resource Include="CxExtension\Resources\M-L.png" />
<Content Include="LICENSE.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
Expand All @@ -191,7 +205,6 @@
</Content>
<Resource Include="CxExtension\Resources\checkmarx-80.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Resource>
<Resource Include="CxExtension\Resources\Comment.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Loading