Repository navigation
IRoadmapFilterProvider
| Name | Roadmap Filter Provider |
|---|---|
| Purpose | Returns an enumeration of filters to be used to show only some Mitigations in the Roadmap Panel. |
| Source | |
| Related Interfaces | Returns enumeration of IRoadmapFilter |
| Related Extensions |
The Roadmap Filter Provider is used to retrieve additional filters, to hide the Mitigations which are not interesting from the Roadmap Panel.
The Roadmap Panel is a IPanel implemented in Threats Manager Studio standard Extensions, which allows to define a Roadmap for Mitigations. For more information, please refer to Roadmap - Threats Manager Studio. IPanels are created by IPanelFactory.
Reference implementation for IRoadmapFilrerProvider is available in IterationsFilterProvider.cs from project ThreatsManager.DevOps.
[Extension("D4BB488D-0622-470F-9D9E-6E7E65273E6F", "Iterations Roadmap Filter Provider", 50, ExecutionMode.Business)]
public class IterationsFilterProvider : IRoadmapFilterProvider
{
public IEnumerable<IRoadmapFilter> GetFilters([NotNull] IThreatModel model)
{
var schemaManager = new DevOpsConfigPropertySchemaManager(model);
return schemaManager.GetIterations()?.Select(x => new IterationFilter(x));
}
}Each filter returned by GetFilters() has a Name and provides a method, Filter(), to decide which of the provided Mitigations should be visible.
public class IterationFilter : IRoadmapFilter
{
private readonly Iteration _iteration;
public IterationFilter([NotNull] Iteration iteration)
{
_iteration = iteration;
}
public string Name => $"Show only Mitigations belonging to {_iteration.Name}";
public IEnumerable<IMitigation> Filter(IEnumerable<IMitigation> mitigations)
{
IEnumerable<IMitigation> result = null;
var items = mitigations?.ToArray();
if (items?.Any() ?? false)
{
var model = items.First().Model;
if (model != null)
{
var schemaManager = new DevOpsPropertySchemaManager(model);
var list = new List<IMitigation>();
foreach (var item in items)
{
if (string.CompareOrdinal(schemaManager.GetFirstSeenOn(item)?.IterationId, _iteration.Id) == 0)
{
list.Add(item);
}
}
if (list.Any())
result = list.AsReadOnly();
}
}
return result;
}
public override string ToString()
{
return Name;
}
}There are no examples of custom extensions of this type.
-
Learning Threats Manager
- Introductory Topics
- Start Here
- Basic Concepts
- Diagramming
- Lists
- Advanced Topics
- Concepts
- Threats and Mitigations
- Reporting
- Lists
- Extensions
- Expert Topics
- Metadata
- Creating Templates
- Extensions
- Introductory Topics
-
The Object Model
-
Creating your own Extensions
-
Rehosting the Engine