Skip to content

Commit

Permalink
Merge branch 'FEATURE/LEARN-MORE-AST-28255' of https://github.com/Che…
Browse files Browse the repository at this point in the history
…ckmarx/ast-visual-studio-extension into FEATURE/LEARN-MORE-AST-28255
  • Loading branch information
hmmachadocx committed Aug 24, 2023
2 parents 3ea7e17 + 59ae11a commit 54bb551
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class CxWindowControl : UserControl
private readonly CxToolbar cxToolbar;
private readonly ResultInfoPanel resultInfoPanel;
private readonly AsyncPackage package;
private ResultVulnerabilitiesPanel resultsVulnPanel;
private readonly ResultVulnerabilitiesPanel resultsVulnPanel;
public CxWindowControl(AsyncPackage package)
{
InitializeComponent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public ResultVulnerabilitiesPanel(AsyncPackage package, CxWindowControl cxWindow
/// <param name="result"></param>
public void Draw(Result result)
{
learnMore = null;
this.result = result;
nodes = result.Data.Nodes ?? new List<Node>();
packageDataList = result.Data.PackageData ?? new List<PackageData>();
Expand All @@ -45,9 +44,12 @@ public void Draw(Result result)
switch (result.Type)
{
case "sast":
cxWindowUI.LearnMorePanelTitle.Children.Clear();
cxWindowUI.RemediationPanelTitle.Children.Clear();
BuildAttackVectorPanel();
cxWindowUI.SastVulnerabilitiesPanel.Visibility = Visibility.Visible;
cxWindowUI.VulnerabilitiesPanel.Visibility = Visibility.Hidden;
learnMore = null;
break;
case "sca":
BuildPackageDataPanel();
Expand Down Expand Up @@ -182,7 +184,6 @@ public async Task LearnMoreAndRemediationAsync(CxToolbar cxToolbar)
return;
};


cxWindowUI.LearnMorePanelTitle.Children.Clear();
cxWindowUI.RemediationPanelTitle.Children.Clear();

Expand All @@ -204,55 +205,47 @@ await Task.Run(() =>
cxWindowUI.LearnMorePanelTitle.Children.Clear();
cxWindowUI.RemediationPanelTitle.Children.Clear();

if (learnMore != null) {
if (learnMore != null)
{
foreach (var learnInfo in learnMore)
{
if (learnInfo.risk != null)
{
AddSectionTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.RISK);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, learnInfo.risk);
AddSectionTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.RISK);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, learnInfo.risk);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, string.Empty);

AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, string.Empty);
AddSectionTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.CAUSE);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, learnInfo.cause);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, string.Empty);

AddSectionTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.GENERAL_RECOMENDATIONS);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, learnInfo.generalRecommendations);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, string.Empty);

AddSectionTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.CAUSE);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, learnInfo.cause);

AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, string.Empty);

if (learnInfo.samples == null || learnInfo.samples.Count == 0)
{
AddTextWithTitle(cxWindowUI.RemediationPanelTitle, CxConstants.NO_INFORMATION);

AddSectionTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.GENERAL_RECOMENDATIONS);
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, learnInfo.generalRecommendations);
}

if (learnInfo.samples[0].code != null)
foreach (var sample in learnInfo.samples)
{
foreach (var sample in learnInfo.samples)
AddSectionTitle(cxWindowUI.RemediationPanelTitle, string.Format(CxConstants.CODE_SAMPLE_TITLE, sample.title, sample.progLanguage));
TextBox codeTextBox = new TextBox
{
if (cxWindowUI.RemediationPanelTitle.Children.Count > 0)
{
AddTextWithTitle(cxWindowUI.RemediationPanelTitle, string.Empty);
}

AddSectionTitle(cxWindowUI.RemediationPanelTitle, sample.title);

TextBox codeTextBox = new TextBox
{
Text = sample.code.Trim(),
IsReadOnly = true,
TextWrapping = TextWrapping.WrapWithOverflow,
Margin = new Thickness(10, 5, 0, 0)
};
cxWindowUI.RemediationPanelTitle.Children.Add(codeTextBox);
}
Text = sample.code.Trim(),
IsReadOnly = true,
TextWrapping = TextWrapping.WrapWithOverflow,
Margin = new Thickness(10, 5, 0, 0)
};
cxWindowUI.RemediationPanelTitle.Children.Add(codeTextBox);
AddTextWithTitle(cxWindowUI.RemediationPanelTitle, string.Empty);
}
}
}
else
{
AddTextWithTitle(cxWindowUI.LearnMorePanelTitle, CxConstants.NO_INFORMATION);
AddTextWithTitle(cxWindowUI.RemediationPanelTitle, CxConstants.NO_INFORMATION);
learnMore = new List<LearnMore>();
}
}
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ internal class CxConstants
public static string RUN_SCAN_ACTION => "RUN_SCAN_ACTION";

/** LEARN MORE AND REMEDIATION **/
public static string CODE_SAMPLE_TITLE => "{0} using {1}";
public static string NO_INFORMATION => "No information";
public static string LOADING_INFORMATION => "Loading Information...";

Expand Down

0 comments on commit 54bb551

Please sign in to comment.