コード例 #1
0
        private void CreateOutcomePage([NotNull] ExcelReportEngine engine,
                                       [NotNull] IQualityAnalyzer analyzer, [NotNull] QualityAnalyzerResult outcome)
        {
            var p = engine.AddPage(analyzer.Label);

            engine.AddHeader(p, "Finding Type", "Finding Name", "Description");

            var findings = outcome.Findings?.ToArray();

            if (findings?.Any() ?? false)
            {
                string text;
                foreach (var finding in findings)
                {
                    if (finding is IIdentity identity)
                    {
                        if (identity is IDataFlow flow)
                        {
                            text = $"Flow from {_model.GetIdentityTypeName(flow.Source)} '{flow.Source.Name}' to {_model.GetIdentityTypeName(flow.Target)} '{flow.Target.Name}'.";
                        }
                        else if (identity is IThreatEvent threatEvent)
                        {
                            text = $"Threat Event applied to {_model.GetIdentityTypeName(threatEvent.Parent)} '{threatEvent.Parent.Name}'.";
                        }
                        else
                        {
                            text = null;
                        }

                        engine.AddRow(p,
                                      _model.GetIdentityTypeName(identity),
                                      identity.Name, text);
                    }
                    else
                    {
                        engine.AddRow(p, finding.GetType().Name, finding.ToString());
                    }
                }
            }
        }
コード例 #2
0
        private void CreateSummary([NotNull] ExcelReportEngine engine,
                                   double healthIndex,
                                   IEnumerable <QualityAnalyzerResult> outcomes)
        {
            var p = engine.AddPage("Summary");

            engine.AddHeader(p, "Assessment", "Evaluation");

            engine.AddRow(p, "Threat Model Health Index", QualityAnalyzersManager.GetHealthIndexDescription(healthIndex));

            var analyzers = QualityAnalyzersManager.QualityAnalyzers?.ToArray();

            if (analyzers?.Any() ?? false)
            {
                foreach (var analyzer in analyzers)
                {
                    var outcome = outcomes?.FirstOrDefault(x => x.Id == analyzer.GetExtensionId());
                    if (outcome != null)
                    {
                        engine.AddRow(p, analyzer.Label, outcome.Assessment.GetEnumLabel());
                    }
                }
            }
        }