Skip to content
Draft
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
1 change: 1 addition & 0 deletions roles/lib/files/FWO.Api.Client/Queries/ModellingQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ static ModellingQueries()
removeAllServiceGroupsFromConnection = GetQueryText("modelling/removeAllServiceGroupsFromConnection.graphql");
getConnectionIdsForService = GetQueryText("modelling/getConnectionIdsForService.graphql");
getConnectionIdsForServiceGroup = GetQueryText("modelling/getConnectionIdsForServiceGroup.graphql");
updateConnectionDecommission = GetQueryText("modelling/updateConnectionDecommission.graphql");

getSelectedConnections = connectionDetailsFragment + GetQueryText("modelling/getSelectedConnections.graphql");
addSelectedConnection = GetQueryText("modelling/addSelectedConnection.graphql");
Expand Down
1 change: 0 additions & 1 deletion roles/lib/files/FWO.Data/Device.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;
using FWO.Basics;
using Newtonsoft.Json;
using FWO.Basics;

namespace FWO.Data
{
Expand Down
2 changes: 1 addition & 1 deletion roles/lib/files/FWO.Data/NetworkLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class NetworkLocation : IComparable

public NetworkLocation(NetworkUser user, NetworkObject? networkObject)
{
Object = networkObject;
Object = networkObject ?? new();
User = user;
}

Expand Down
5 changes: 4 additions & 1 deletion roles/lib/files/FWO.Data/Report/DeviceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ public List<Rule> GetRuleList()
}

public DeviceReport()
{ }
{
RulebaseLinks = [];
}

public DeviceReport(DeviceReport device)
{
RulebaseLinks = [];
// TODO: implement this method to return a list of rules associated with the device
}

Expand Down
4 changes: 3 additions & 1 deletion roles/lib/files/FWO.Data/Report/ManagementReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public class ManagementReport
public bool[] Detailed = [false, false, false]; // nobj, nsrv, user

public ManagementReport()
{ }
{
Uid = string.Empty;
}


public string NameAndDeviceNames(string separator = ", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task BuildAdomDeviceVdomStructure(string sessionId, List<Adom> cust
RestResponse<FmApiTopLevelHelperDev> deviceResponse = await restClientFM.GetDevicesPerAdom(sessionId, adom.Name);
if (deviceResponse != null && deviceResponse.StatusCode == HttpStatusCode.OK && deviceResponse.IsSuccessful)
{
adom.DeviceList = deviceResponse.Data?.Result[0].FortiGates;
adom.DeviceList = deviceResponse.Data?.Result[0].FortiGates ?? [];
}
}
// now get vdoms per device
Expand Down
2 changes: 1 addition & 1 deletion roles/lib/files/FWO.Mail/MailerMailKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ await smtp.ConnectAsync(

return true;
}
catch (Exception e)
catch (Exception)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion roles/lib/files/FWO.Report.Filter/DynGraphqlQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private static string GetDevWhereFilter(ref DynGraphqlQuery query, DeviceFilter?

devWhereStatement += "_or: [{";

foreach (ManagementSelect mgmt in deviceFilter.Managements)
foreach (ManagementSelect mgmt in deviceFilter?.Managements ?? [])
{
foreach (DeviceSelect dev in mgmt.Devices)
{
Expand Down
2 changes: 1 addition & 1 deletion roles/lib/files/FWO.Report/Data/DeviceReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void AssignRuleNumbers(RulebaseLink? rbLinkIn = null, int ruleNumber = 1)
// }
}

public bool ContainsRules()
public new bool ContainsRules()
{
return true;
// if (RbLink?.NextRulebase.Rules.Length>0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static bool Merge(this RulebaseReport[] rulebases, RulebaseReport[] ruleb
{
if (rulebases[i].Rules != null && rulebasesToMerge[i].Rules != null && rulebasesToMerge[i].Rules.Length > 0)
{
rulebases[i].Rules = rulebases[i].Rules?.Concat(rulebasesToMerge[i].Rules!).ToArray();
rulebases[i].Rules = rulebases[i].Rules.Concat(rulebasesToMerge[i].Rules!).ToArray();
newObjects = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion roles/lib/files/FWO.Report/Display/RuleDisplayHtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected static string EnforcingGatewayToHtml(Device gateway, int mgmtId, int c
string gwLink = ReportDevicesBase.GetReportDevicesLinkAddress(location, mgmtId, ObjCatString.NwObj, chapterNumber, gateway.Id, reportType);

return DisplayGateway(gateway, reportType, reportType.IsResolvedReport() ? null :
ReportBase.ConstructLink(ReportBase.GetIconClass(ObjCategory.nsrv, "Gateway"), gateway.Name, style, gwLink)).ToString();
ReportBase.ConstructLink(ReportBase.GetIconClass(ObjCategory.nsrv, "Gateway"), gateway.Name ?? string.Empty, style, gwLink)).ToString();
}

private string DisplaySourceOrDestination(Rule rule, int chapterNumber, OutputLocation location, ReportType reportType, string style, bool isSource, bool overwriteIsResolvedReport = false)
Expand Down
7 changes: 6 additions & 1 deletion roles/lib/files/FWO.Report/ReportCompliance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ReportCompliance : ReportBase
private readonly int _maxDegreeOfParallelism;
private readonly SemaphoreSlim _semaphore;
private readonly NatRuleDisplayHtml _natRuleDisplayHtml;
private List<string> _columnsToExport;
private List<string> _columnsToExport = [];
private bool _includeHeaderInExport;
private char _separator;
private int _maxCellSize;
Expand Down Expand Up @@ -378,6 +378,10 @@ private Task GatherEmptyGroups(NetworkLocation[] networkLocations, List<NetworkL

private Task<List<Rule>> GatherReportData((List<Rule> processed, List<RuleViewData> viewData)[]? results)
{
if (results == null)
{
results = [];
}
RuleViewData.Capacity = results.Sum(r => r.viewData.Count);
List<Rule> processedRulesFlat = new(results.Sum(r => r.processed.Count));

Expand Down Expand Up @@ -422,6 +426,7 @@ protected virtual Dictionary<string, object> CreateQueryVariables(int offset, in
return queryVariables;
}

//TODO: Does this need to be async?
protected virtual async Task SetComplianceDataForRule(Rule rule, ApiConnection apiConnection, Func<ComplianceViolation, string>? formatter = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Robin-Smets Is this purposfully left as async? Directing this question at you as you took the awaited method out of the code block, but maybe there is a different reason this needs to be run asynchronously

{
try
Expand Down
4 changes: 3 additions & 1 deletion roles/lib/files/FWO.Report/ReportDevicesBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,16 @@ public async Task<List<ManagementReport>> GetImportIdsInTimeRange(ApiConnection
return (unsupportedList, reducedDeviceFilter);
}

#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
private static async Task<bool> UsageDataAvailable(ApiConnection apiConnection, int devId)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
try
{
// TODO: the following only deals with first rulebase of a gateway:
// return (await apiConnection.SendQueryAsync<List<AggregateCountLastHit>>(ReportQueries.getUsageDataCount, new { devId })
// )[0].RulebasesOnGateway[0].Rulebase.RulesWithHits.Aggregate.Count > 0;
return false; // TODO: implement
return false; // TODO: implement and remove pragma warning disable once done
}
catch (Exception)
{
Expand Down
2 changes: 1 addition & 1 deletion roles/lib/files/FWO.Report/ReportNatRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override string ExportToHtml()
RulebaseLink? initialRulebaseLink = device.RulebaseLinks.FirstOrDefault(_ => _.IsInitialRulebase());
if (initialRulebaseLink != null)
{
foreach (var rule in managementReport.Rulebases.FirstOrDefault(rb => rb.Id == initialRulebaseLink.NextRulebaseId)?.Rules)
foreach (var rule in managementReport.Rulebases.FirstOrDefault(rb => rb.Id == initialRulebaseLink.NextRulebaseId)?.Rules ?? [])
{
AppendNatRuleHeadlineHtml(ref report, device.Name);

Expand Down
1 change: 0 additions & 1 deletion roles/lib/files/FWO.Report/ReportRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class ReportRules(DynGraphqlQuery query, UserConfig userConfig, ReportTyp
{
private const int ColumnCount = 12;
protected bool UseAdditionalFilter = false;
private bool VarianceMode = false;

private static Dictionary<(int deviceId, int managementId), Rule[]> _rulesCache = new();

Expand Down
4 changes: 0 additions & 4 deletions roles/lib/files/FWO.Services/ModellingAppRoleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
using FWO.Data.Modelling;
using FWO.Basics;
using FWO.Config.Api;
using FWO.Basics;
using FWO.Data;
using FWO.Api.Client;
using FWO.Api.Client.Queries;
using NetTools;
using System.Net;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private async Task<bool> GetModelledRulesProductionState(ModellingFilter modelli
private void IdentifyModelledRules(Management mgt, List<Rule> rulesByMgt)
{
// get all rulebase links for this management
List<RulebaseLink> rulebaseLinks = mgt.Devices.Cast<DeviceReport>().SelectMany(d => d.RulebaseLinks.Where(rl => rl.Removed != null)).ToList();
List<RulebaseLink> rulebaseLinks = mgt.Devices.SelectMany(d => d.RulebaseLinks.Where(rl => rl.Removed != null)).ToList();
allModelledRules.Add(mgt.Id, []);
foreach (var rule in rulesByMgt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private WfReqTask ConstructRuleTask(Management mgt, Rule rule, ModellingConnecti
{
Field = ElemFieldType.rule.ToString(),
RuleUid = rule.Uid,
DeviceId = rule.EnforcingGateways.FirstOrDefault().Content?.Id,
DeviceId = rule.EnforcingGateways.FirstOrDefault()?.Content?.Id,
Name = rule.Name
}
];
Expand Down
Loading
Loading