Skip to content

Commit 005c883

Browse files
authored
CM-43067 - Add the "Ignore this violation" button for the violation card of SCA (#35)
1 parent c315e3d commit 005c883

File tree

13 files changed

+63
-7
lines changed

13 files changed

+63
-7
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
## [Unreleased]
66

7+
## [1.8.0] - 2024-12-20
8+
9+
- Add the "Ignore this violation" button for the violation card of SCA
10+
- Add support of `.gitignore` files for a file excluding from scans
11+
- Fix "Path to executable" setting reset on empty value
12+
713
## [1.7.0] - 2024-12-11
814

915
- Add AI remediations for IaC and SAST
@@ -73,6 +79,8 @@
7379

7480
The first public release of the extension.
7581

82+
[1.8.0]: https://github.com/cycodehq/visual-studio-extension/releases/tag/v1.8.0
83+
7684
[1.7.0]: https://github.com/cycodehq/visual-studio-extension/releases/tag/v1.7.0
7785

7886
[1.6.1]: https://github.com/cycodehq/visual-studio-extension/releases/tag/v1.6.1
@@ -103,4 +111,4 @@ The first public release of the extension.
103111

104112
[1.0.0]: https://github.com/cycodehq/visual-studio-extension/releases/tag/v1.0.0
105113

106-
[Unreleased]: https://github.com/cycodehq/visual-studio-extension/compare/v1.7.0...HEAD
114+
[Unreleased]: https://github.com/cycodehq/visual-studio-extension/compare/v1.8.0...HEAD

src/extension/Cycode.VisualStudio.Extension.14.0-16.0/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="Cycode.7e1a0714-9b3b-4e0e-9c0a-d23fb20ab86e" Version="1.7.0" Language="en-US" Publisher="cycodehq" />
4+
<Identity Id="Cycode.7e1a0714-9b3b-4e0e-9c0a-d23fb20ab86e" Version="1.8.0" Language="en-US" Publisher="cycodehq" />
55
<DisplayName>Cycode</DisplayName>
66
<Description xml:space="preserve">Cycode for Visual Studio IDE</Description>
77
<MoreInfo>https://github.com/cycodehq/visual-studio-extension</MoreInfo>

src/extension/Cycode.VisualStudio.Extension.17.0/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="Cycode.f2c5020e-67a2-46f8-a888-609412fd59db" Version="1.7.0" Language="en-US" Publisher="cycodehq" />
4+
<Identity Id="Cycode.f2c5020e-67a2-46f8-a888-609412fd59db" Version="1.8.0" Language="en-US" Publisher="cycodehq" />
55
<DisplayName>Cycode</DisplayName>
66
<Description xml:space="preserve">Cycode for Visual Studio IDE</Description>
77
<MoreInfo>https://github.com/cycodehq/visual-studio-extension</MoreInfo>

src/extension/Cycode.VisualStudio.Extension.Shared/Cli/DTO/CliIgnoreType.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
public enum CliIgnoreType {
44
Value,
55
Path,
6-
Rule
6+
Rule,
7+
Cve,
78
}

src/extension/Cycode.VisualStudio.Extension.Shared/Cli/DTO/ScanResult/Sca/ScaDetectionDetailsAlert.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ public class ScaDetectionDetailsAlert {
1414

1515
public string VulnerableRequirements { get; set; }
1616
public string FirstPatchedVersion { get; set; }
17+
public string CveIdentifier { get; set; }
1718
}

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/ScaViolationCardControl.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<RowDefinition />
1818
<RowDefinition />
1919
<RowDefinition />
20+
<RowDefinition />
21+
<RowDefinition />
2022
</Grid.RowDefinitions>
2123
<Grid.ColumnDefinitions>
2224
<ColumnDefinition Width="3*" />
@@ -56,6 +58,14 @@
5658
x:Name="CycodeGuidelines"
5759
Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2"
5860
Title="Cycode Guidelines" />
61+
62+
<common:Hr Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="2" />
63+
<Button Grid.Row="12" Grid.Column="1"
64+
Content="Ignore this violation"
65+
HorizontalAlignment="Right"
66+
VerticalAlignment="Bottom"
67+
Margin="0 0 10 10"
68+
Click="IgnoreButton_OnClickAsync" />
5969
</Grid>
6070
</ScrollViewer>
6171
</UserControl>

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/ScaViolationCardControl.xaml.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
using System.Windows;
2+
using Cycode.VisualStudio.Extension.Shared.Cli.DTO;
13
using Cycode.VisualStudio.Extension.Shared.Cli.DTO.ScanResult.Sca;
24
using Cycode.VisualStudio.Extension.Shared.Helpers;
35
using Cycode.VisualStudio.Extension.Shared.Icons;
6+
using Cycode.VisualStudio.Extension.Shared.Services;
47

58
namespace Cycode.VisualStudio.Extension.Shared.Components.ViolationCards;
69

@@ -11,9 +14,16 @@ public partial class ScaViolationCardControl {
1114
private const int _summaryRowIndex = 8;
1215
private const int _customRemediationGuidelinesRowIndex = 9;
1316
private const int _cycodeRemediationGuidelinesRowIndex = 10;
17+
private const int _actionsButtonHrRowIndex = 11;
18+
private const int _ignoreThisViolationButtonRowIndex = 12;
19+
20+
private readonly ICycodeService _cycodeService = ServiceLocator.GetService<ICycodeService>();
21+
22+
private readonly ScaDetection _detection;
1423

1524
public ScaViolationCardControl(ScaDetection detection) {
1625
InitializeComponent();
26+
_detection = detection;
1727

1828
Header.Icon.Source = ExtensionIcons.GetCardSeverityBitmapSource(detection.Severity);
1929
Header.Title.Text = detection.DetectionDetails.Alert?.Summary ?? detection.Message;
@@ -64,5 +74,16 @@ public ScaViolationCardControl(ScaDetection detection) {
6474
CycodeGuidelines.Markdown = detection.DetectionDetails.RemediationGuidelines;
6575
GridHelper.ShowRow(Grid, _cycodeRemediationGuidelinesRowIndex);
6676
}
77+
78+
if (string.IsNullOrEmpty(detection.DetectionDetails.Alert?.CveIdentifier)) {
79+
GridHelper.HideRow(Grid, _actionsButtonHrRowIndex);
80+
GridHelper.HideRow(Grid, _ignoreThisViolationButtonRowIndex);
81+
}
82+
}
83+
84+
private async void IgnoreButton_OnClickAsync(object sender, RoutedEventArgs e) {
85+
await _cycodeService.ApplyDetectionIgnoreAsync(
86+
CliScanType.Sca, CliIgnoreType.Cve, _detection.DetectionDetails.Alert?.CveIdentifier
87+
);
6788
}
6889
}

src/extension/Cycode.VisualStudio.Extension.Shared/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Cycode.VisualStudio.Extension.Shared;
44

55
public static class Constants {
66
public const string AppName = "visual_studio_extension";
7-
public const string RequiredCliVersion = "2.1.0";
7+
public const string RequiredCliVersion = "2.2.0";
88

99
public const string CycodeDomain = "cycode.com";
1010

src/extension/Cycode.VisualStudio.Extension.Shared/Options/General.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ protected override void OnApply(PageApplyEventArgs e) {
2020
return;
2121
}
2222

23+
if (string.IsNullOrEmpty(general.CliPath)) {
24+
general.CliPath = Constants.DefaultCliPath;
25+
base.OnApply(e);
26+
return;
27+
}
28+
2329
if (!File.Exists(general.CliPath)) {
2430
VS.MessageBox.ShowError(
2531
"The specified executable path does not exist. Please provide a valid path to the executable file."

src/extension/Cycode.VisualStudio.Extension.Shared/Services/CliService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private static string MapIgnoreTypeToOptionName(CliIgnoreType type) {
268268
CliIgnoreType.Value => "--by-value",
269269
CliIgnoreType.Rule => "--by-rule",
270270
CliIgnoreType.Path => "--by-path",
271+
CliIgnoreType.Cve => "--by-cve",
271272
_ => throw new ArgumentException("Invalid CliIgnoreType")
272273
};
273274
}

src/extension/Cycode.VisualStudio.Extension.Shared/Services/CycodeService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ private async Task ApplyDetectionIgnoreInUiAsync(CliIgnoreType ignoreType, strin
196196
scanResultsService.ExcludeResultsByValue(value);
197197
break;
198198
case CliIgnoreType.Path:
199-
break;
200199
case CliIgnoreType.Rule:
201200
break;
201+
case CliIgnoreType.Cve:
202+
scanResultsService.ExcludeResultsByCve(value);
203+
break;
202204
default:
203205
throw new ArgumentOutOfRangeException(nameof(ignoreType), ignoreType, null);
204206
}

src/extension/Cycode.VisualStudio.Extension.Shared/Services/ScanResultsService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public interface IScanResultsService {
2121
void SaveDetectedSegment(CliScanType scanType, TextRange textRange, string value);
2222
string GetDetectedSegment(CliScanType scanType, TextRange textRange);
2323
void ExcludeResultsByValue(string value);
24+
void ExcludeResultsByCve(string value);
2425
}
2526

2627
public class ScanResultsService : IScanResultsService {
@@ -106,6 +107,11 @@ public void ExcludeResultsByValue(string value) {
106107
_secretScanDetections.RemoveAll(detection => detection.DetectionDetails.DetectedValue == value);
107108
}
108109

110+
public void ExcludeResultsByCve(string cve) {
111+
// we have cve only in SCA results
112+
_scaScanDetections.RemoveAll(detection => detection.DetectionDetails.Alert?.CveIdentifier == cve);
113+
}
114+
109115
private void ClearDetectedSegments(CliScanType? scanType = null) {
110116
if (scanType == null) {
111117
_detectedSegments.Clear();

src/extension/Cycode.VisualStudio.Extension.Shared/source.extension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ namespace Cycode.VisualStudio.Extension.Shared;
33
internal sealed class Vsix {
44
public const string Name = "Cycode";
55
public const string Description = "Cycode for Visual Studio IDE";
6-
public const string Version = "1.7.0";
6+
public const string Version = "1.8.0";
77
}

0 commit comments

Comments
 (0)