Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abarz722 committed Mar 14, 2024
1 parent c9b6e9e commit 8ff813f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
11 changes: 4 additions & 7 deletions roles/lib/files/FWO.Report.Filter/Ast/AstNodeFilterNetwork.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using NetTools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using FWO.Logging;

namespace FWO.Report.Filter.Ast
Expand Down Expand Up @@ -42,7 +37,8 @@ private DynGraphqlQuery ExtractDestinationFilter(DynGraphqlQuery query)
{
string QueryVarName = AddVariable<string>(query, "dst", Operator.Kind, Value.Text);
query.ruleWhereStatement += $"rule_tos: {{ object: {{ objgrp_flats: {{ objectByObjgrpFlatMemberId: {{ obj_name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }} }} }}";
query.connectionWhereStatement += $"nwobject_connections: {{connection_field: {{ _eq: 2 }}, owner_network: {{name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }}";
query.connectionWhereStatement += $"_or: [ {{ nwobject_connections: {{connection_field: {{ _eq: 2 }}, owner_network: {{name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }} }}, " +
$"{{ nwgroup_connections: {{connection_field: {{ _eq: 2 }}, nwgroup: {{ name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }} }} ]";
}
return query;
}
Expand All @@ -56,7 +52,8 @@ private DynGraphqlQuery ExtractSourceFilter(DynGraphqlQuery query)
{
string QueryVarName = AddVariable<string>(query, "src", Operator.Kind, Value.Text);
query.ruleWhereStatement += $"rule_froms: {{ object: {{ objgrp_flats: {{ objectByObjgrpFlatMemberId: {{ obj_name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }} }} }}";
query.connectionWhereStatement += $"nwobject_connections: {{connection_field: {{ _eq: 1 }}, owner_network: {{name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }}";
query.connectionWhereStatement += $"_or: [ {{ nwobject_connections: {{connection_field: {{ _eq: 1 }}, owner_network: {{name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }} }}, " +
$"{{ nwgroup_connections: {{connection_field: {{ _eq: 1 }}, nwgroup: {{ name: {{ {ExtractOperator()}: ${QueryVarName} }} }} }} }} ]";
}
return query;
}
Expand Down
41 changes: 33 additions & 8 deletions roles/lib/files/FWO.Report.Filter/Ast/AstNodeFilterString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,41 @@ private DynGraphqlQuery ExtractFullTextFilter(DynGraphqlQuery query)
string queryVarName = AddVariable<string>(query, "fullTextFiler", Operator.Kind, semanticValue!);
string queryOperator = ExtractOperator();

List<string> ruleFieldNames = new () { "rule_src", "rule_dst", "rule_svc", "rule_action", "rule_name", "rule_comment", "rule_uid" }; // TODO: add comment later
List<string> ruleFieldNames = new () { "rule_src", "rule_dst", "rule_svc", "rule_action", "rule_name", "rule_comment", "rule_uid" };
List<string> ruleSearchParts = new ();
foreach (string field in ruleFieldNames)
{
ruleSearchParts.Add($"{{{field}: {{{queryOperator}: ${queryVarName} }} }} ");
}
query.ruleWhereStatement += $"_or: [ {string.Join(", ", ruleSearchParts)} ]";
// List<string> connFieldNames = new () { "name" };
// List<string> connSearchParts = new ();
// foreach (string field in connFieldNames)
// connSearchParts.Add($"{{{field}: {{{queryOperator}: ${queryVarName} }} }} ");
// query.connectionWhereStatement += $"_or: [ {string.Join(", ", connSearchParts)} ]";

List<string> connFieldNames = new () { "name", "reason" /*, "creator" */ };
List<string> nwobjFieldNames = new () { "name" /*, "creator" */ };
List<string> nwGroupFieldNames = new () { "id_string", "name", "comment" /*, "creator" */ };
List<string> svcFieldNames = new () { "name" };
List<string> svcGroupFieldNames = new () { "name", "comment" /*, "creator" */ };
List<string> connSearchParts = new ();
foreach (string field in connFieldNames)
{
connSearchParts.Add($"{{{field}: {{{queryOperator}: ${queryVarName} }} }} ");
}
foreach (string field in nwobjFieldNames)
{
connSearchParts.Add($"{{ nwobject_connections: {{owner_network: {{{field}: {{{queryOperator}: ${queryVarName} }} }} }} }} ");
}
foreach (string field in nwGroupFieldNames)
{
connSearchParts.Add($"{{ nwgroup_connections: {{nwgroup: {{{field}: {{{queryOperator}: ${queryVarName} }} }} }} }} ");
}
foreach (string field in svcFieldNames)
{
connSearchParts.Add($"{{ service_connections: {{service: {{{field}: {{{queryOperator}: ${queryVarName} }} }} }} }} ");
}
foreach (string field in svcGroupFieldNames)
{
connSearchParts.Add($"{{ service_group_connections: {{service_group: {{{field}: {{{queryOperator}: ${queryVarName} }} }} }} }} ");
}
query.connectionWhereStatement += $"_or: [ {string.Join(", ", connSearchParts)} ]";
return query;
}

Expand Down Expand Up @@ -112,8 +137,8 @@ private DynGraphqlQuery ExtractActionFilter(DynGraphqlQuery query)
private DynGraphqlQuery ExtractServiceFilter(DynGraphqlQuery query)
{
string queryVarName = AddVariable<string>(query, "svc", Operator.Kind, semanticValue!);
query.ruleWhereStatement += $"rule_services: {{service: {{svcgrp_flats: {{serviceBySvcgrpFlatMemberId: {{svc_name: {{ {ExtractOperator()}: ${queryVarName} }} }} }} }} }}";
query.connectionWhereStatement += $"service_connections: {{service: {{name: {{ {ExtractOperator()}: ${queryVarName} }} }} }}";
query.ruleWhereStatement += $"rule_services: {{ service: {{svcgrp_flats: {{serviceBySvcgrpFlatMemberId: {{svc_name: {{ {ExtractOperator()}: ${queryVarName} }} }} }} }} }} ";
query.connectionWhereStatement += $"_or: [ {{ service_connections: {{service: {{name: {{ {ExtractOperator()}: ${queryVarName} }} }} }} }}, {{ service_group_connections: {{service_group: {{name: {{ {ExtractOperator()}: ${queryVarName} }} }} }} }} ]";
return query;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@

<ConfirmDelete @bind-Display="ShowDeleteTemplateDialog" PerformAction="DeleteTemplate" Title="@(userConfig.GetText("report_template"))"
DeleteMessage="@(userConfig.GetText("U1002") + " " + reportTemplateInEdit.Name + " ?")"
AllowedRoles="@($"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}")"/>
AllowedRoles="@($"{Roles.Admin}, {Roles.FwAdmin}, {Roles.Reporter}, {Roles.ReporterViewAll}, {Roles.Modeller}")"/>


@code
Expand Down
2 changes: 1 addition & 1 deletion roles/ui/files/FWO.UI/Shared/RightSidebar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</div>
<div class="mt-2">
<CascadingValue Value="collapseSidebarReport">
<ObjectGroupCollection FetchObjects="FetchContent" Recert="false" Tab="RsbTab.usedObj" InputDataType="OwnerReport"
<ObjectGroupCollection FetchObjects="FetchContent" Recert="false" Tab="RsbTab.usedObj" StartCollapsed="false" InputDataType="OwnerReport"
Data="CurrentReport.ReportData.OwnerData"
NameExtractor="own => own.Name"
NetworkObjectExtractor="own => own.GetAllNetworkObjects()"
Expand Down

0 comments on commit 8ff813f

Please sign in to comment.