Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NVSHAS-9709,NVSHAS-9747 #823

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions admin/src/main/scala/com/neu/api/group/GroupApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class GroupApi(resourceService: GroupService) extends BaseApi {
}
} ~
get {
parameter(Symbol("name").?) { name =>
parameter(Symbol("name").?, Symbol("scope").?) { (name, scope) =>
Utils.respondWithWebServerHeaders() {
resourceService.getDlpSensor(tokenId, name)
resourceService.getDlpSensor(tokenId, name, scope)
}
}
} ~
Expand Down Expand Up @@ -285,9 +285,9 @@ class GroupApi(resourceService: GroupService) extends BaseApi {
}
} ~
get {
parameter(Symbol("name").?) { name =>
parameter(Symbol("name").?, Symbol("scope").?) { (name, scope) =>
Utils.respondWithWebServerHeaders() {
resourceService.getWafSensor(tokenId, name)
resourceService.getWafSensor(tokenId, name, scope)
}
}
} ~
Expand Down
2 changes: 1 addition & 1 deletion admin/src/main/scala/com/neu/model/DlpJsonProtocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object DlpJsonProtocol extends DefaultJsonProtocol {
given dlpSensorFmt: RootJsonFormat[DlpSensor] = jsonFormat4(DlpSensor.apply)
given dlpSensorDataFmt: RootJsonFormat[DlpSensorData] = jsonFormat1(DlpSensorData.apply)
given dlpSensorsDataFmt: RootJsonFormat[DlpSensorsData] = jsonFormat1(DlpSensorsData.apply)
given dlpSensorConfigFmt: RootJsonFormat[DlpSensorConfig] = jsonFormat7(DlpSensorConfig.apply)
given dlpSensorConfigFmt: RootJsonFormat[DlpSensorConfig] = jsonFormat8(DlpSensorConfig.apply)
given dlpSensorConfigDataFmt: RootJsonFormat[DlpSensorConfigData] = jsonFormat1(
DlpSensorConfigData.apply
)
Expand Down
1 change: 1 addition & 0 deletions admin/src/main/scala/com/neu/model/DlpRule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ case class DlpSensorsData(sensors: Seq[DlpSensor])
case class DlpSensorConfig(
name: String,
comment: Option[String],
cfg_type: Option[String],
change: Option[Seq[DlpRule]],
delete: Option[Seq[DlpRule]],
rules: Option[Seq[DlpRule]],
Expand Down
1 change: 1 addition & 0 deletions admin/src/main/scala/com/neu/model/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ case class Groups4Export(
groups: Array[String],
policy_mode: Option[String],
profile_mode: Option[String],
use_name_referral: Boolean,
remote_export_options: Option[RemoteExportOptions] = None
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object GroupJsonProtocol extends DefaultJsonProtocol {
given remoteExportOptionsFormat: RootJsonFormat[RemoteExportOptions] = jsonFormat3(
RemoteExportOptions.apply
)
given groups4ExportFormat: RootJsonFormat[Groups4Export] = jsonFormat4(Groups4Export.apply)
given groups4ExportFormat: RootJsonFormat[Groups4Export] = jsonFormat5(Groups4Export.apply)

given criteriaItemFormat: RootJsonFormat[CriteriaItem] = jsonFormat1(CriteriaItem.apply)
given groupConfigDTOFormat: RootJsonFormat[GroupConfigDTO] = jsonFormat8(GroupConfigDTO.apply)
Expand Down
2 changes: 1 addition & 1 deletion admin/src/main/scala/com/neu/model/WafJsonProtocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object WafJsonProtocol extends DefaultJsonProtocol {
given wafSensorFmt: RootJsonFormat[WafSensor] = jsonFormat4(WafSensor.apply)
given wafSensorDataFmt: RootJsonFormat[WafSensorData] = jsonFormat1(WafSensorData.apply)
given wafSensorsDataFmt: RootJsonFormat[WafSensorsData] = jsonFormat1(WafSensorsData.apply)
given wafSensorConfigFmt: RootJsonFormat[WafSensorConfig] = jsonFormat5(WafSensorConfig.apply)
given wafSensorConfigFmt: RootJsonFormat[WafSensorConfig] = jsonFormat6(WafSensorConfig.apply)
given wafSensorConfigDataFmt: RootJsonFormat[WafSensorConfigData] = jsonFormat1(
WafSensorConfigData.apply
)
Expand Down
1 change: 1 addition & 0 deletions admin/src/main/scala/com/neu/model/WafRule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ case class WafSensorsData(sensors: Seq[WafSensor])
case class WafSensorConfig(
name: String,
comment: Option[String],
cfg_type: Option[String],
change: Option[Seq[WafRule]],
delete: Option[Seq[WafRule]],
rules: Option[Seq[WafRule]]
Expand Down
10 changes: 5 additions & 5 deletions admin/src/main/scala/com/neu/service/group/GroupService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GroupService extends BaseService with DefaultJsonFormats with LazyLogging
logger.info("Exporting groups: {}", payload)
RestClient.httpRequestWithHeaderDecode(
s"${baseClusterUri(tokenId)}/file/group",
GET,
POST,
payload,
tokenId
)
Expand Down Expand Up @@ -551,11 +551,11 @@ class GroupService extends BaseService with DefaultJsonFormats with LazyLogging
}
}

def getDlpSensor(tokenId: String, name: Option[String]): Route = complete {
def getDlpSensor(tokenId: String, name: Option[String], scope: Option[String]): Route = complete {
if (name.isEmpty) {
logger.info("Getting sensors")
RestClient.httpRequestWithHeader(
s"${baseClusterUri(tokenId)}/dlp/sensor",
s"${baseClusterUri(tokenId)}/dlp/sensor${if (scope.nonEmpty) s"?scope=${scope.get}" else ""}",
GET,
"",
tokenId
Expand Down Expand Up @@ -691,11 +691,11 @@ class GroupService extends BaseService with DefaultJsonFormats with LazyLogging
)
}

def getWafSensor(tokenId: String, name: Option[String]): Route = complete {
def getWafSensor(tokenId: String, name: Option[String], scope: Option[String]): Route = complete {
if (name.isEmpty) {
logger.info("Getting sensors")
RestClient.httpRequestWithHeader(
s"${baseClusterUri(tokenId)}/waf/sensor",
s"${baseClusterUri(tokenId)}/waf/sensor${if (scope.nonEmpty) s"?scope=${scope.get}" else ""}",
GET,
"",
tokenId
Expand Down
37 changes: 33 additions & 4 deletions admin/webapp/websrc/app/common/api/policy-http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PathConstant } from '@common/constants/path.constant';
import { Group, NetworkRule, ResponseRule, Service } from '@common/types';
import { GlobalVariable } from '@common/variables/global.variable';
import { Observable } from 'rxjs';
import { GlobalConstant } from '@common/constants/global.constant';
import { pluck } from 'rxjs/operators';

@Injectable()
Expand Down Expand Up @@ -124,9 +125,23 @@ export class PolicyHttpService {
return GlobalVariable.http.patch(PathConstant.DLP_GROUPS_URL, payload);
}

getDLPSensors() {
getDLPSensors(source) {
const options: any = [];
if (source === GlobalConstant.NAV_SOURCE.FED_POLICY) {
options.push({
params: {
scope: 'fed',
},
});
} else {
options.push({
params: {
scope: 'local',
},
});
}
return GlobalVariable.http
.get(PathConstant.DLP_SENSORS_URL)
.get(PathConstant.DLP_SENSORS_URL, ...options)
.pipe(pluck('sensors'));
}

Expand All @@ -140,9 +155,23 @@ export class PolicyHttpService {
return GlobalVariable.http.patch(PathConstant.WAF_GROUPS_URL, payload);
}

getWAFSensors() {
getWAFSensors(source) {
const options: any = [];
if (source === GlobalConstant.NAV_SOURCE.FED_POLICY) {
options.push({
params: {
scope: 'fed',
},
});
} else {
options.push({
params: {
scope: 'local',
},
});
}
return GlobalVariable.http
.get(PathConstant.WAF_SENSORS_URL)
.get(PathConstant.WAF_SENSORS_URL, ...options)
.pipe(pluck('sensors'));
}
}
54 changes: 40 additions & 14 deletions admin/webapp/websrc/app/common/services/dlp-sensors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { TranslateService } from '@ngx-translate/core';
import { DomSanitizer } from '@angular/platform-browser';
import { UtilsService } from '@common/utils/app.utils';
import { pluck } from 'rxjs/operators';
import { SensorActionButtonsComponent } from '@routes/dlp-sensors/partial/sensor-action-buttons/sensor-action-buttons.component';
import { RuleActionButtonsComponent } from '@routes/dlp-sensors/partial/rule-action-buttons/rule-action-buttons.component';
import { PatternActionButtonsComponent } from '@routes/dlp-sensors/partial/pattern-action-buttons/pattern-action-buttons.component';
import { SensorActionButtonsComponent } from '@components/dlp-sensors/partial/sensor-action-buttons/sensor-action-buttons.component';
import { RuleActionButtonsComponent } from '@components/dlp-sensors/partial/rule-action-buttons/rule-action-buttons.component';
import { PatternActionButtonsComponent } from '@components/dlp-sensors/partial/pattern-action-buttons/pattern-action-buttons.component';

@Injectable({
providedIn: 'root',
Expand All @@ -26,21 +26,25 @@ export class DlpSensorsService {
this.$win = $(GlobalVariable.window);
}

configGrids = (isWriteDLPSensorAuthorized: boolean) => {
configGrids = (isWriteDLPSensorAuthorized: boolean, source: string = '') => {
const columnDefs4Sensor = [
{
headerName: this.translate.instant('dlp.gridHeader.SENSOR_NAME'),
field: 'name',
headerCheckboxSelection: true,
headerCheckboxSelectionFilteredOnly: true,
checkboxSelection: params => {
if (params.data) return !params.data.predefine;
return false;
},
headerCheckboxSelection: params =>
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY,
headerCheckboxSelectionFilteredOnly: params =>
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY,
cellRenderer: params => {
if (params.value)
return `<span class="${
params.data.predefine ? 'left-margin-32' : ''
params.data.predefine &&
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY
? 'left-margin-32'
: ''
}">
${params.value}
</span>`;
Expand Down Expand Up @@ -100,6 +104,19 @@ export class DlpSensorsService {
},
];

if (source !== GlobalConstant.NAV_SOURCE.FED_POLICY) {
columnDefs4Sensor[0]['checkboxSelection'] = params => {
if (params.data)
return (
!params.data.predefine &&
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY &&
params.data.cfg_type !== GlobalConstant.CFG_TYPE.FED
);
return false;
};
}

const columnDefs4Rules = [
{
headerName: this.translate.instant('dlp.gridHeader.PATTERN_NAME'),
Expand Down Expand Up @@ -186,7 +203,8 @@ export class DlpSensorsService {
),
};

grids.gridOptions.rowSelection = 'multiple';
grids.gridOptions.rowSelection =
source !== GlobalConstant.NAV_SOURCE.FED_POLICY ? 'multiple' : 'single';

grids.gridOptions.rowClassRules = {
'disabled-row': params => {
Expand All @@ -204,9 +222,17 @@ export class DlpSensorsService {
return grids;
};

getDlpSensorsData = () => {
getDlpSensorsData = source => {
const options: any = [];
if (source === GlobalConstant.NAV_SOURCE.FED_POLICY) {
options.push({
params: {
scope: 'fed',
},
});
}
return GlobalVariable.http
.get(PathConstant.DLP_SENSORS_URL)
.get(PathConstant.DLP_SENSORS_URL, ...options)
.pipe(pluck('sensors'));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Webhook } from '@common/types';

@Injectable()
export class FederatedConfigurationService {
public activeTabIndex4Group: number = 0;
constructor(private configHttpService: ConfigHttpService) {}

getFederatedConfig() {
Expand Down
8 changes: 4 additions & 4 deletions admin/webapp/websrc/app/common/services/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ export class GroupsService {
return this.policyHttpService.getDLPGroups(groupName);
};

getDlpSensorData = () => {
return this.policyHttpService.getDLPSensors();
getDlpSensorData = source => {
return this.policyHttpService.getDLPSensors(source);
};

updateGroupDlpSensorData = payload => {
Expand All @@ -855,8 +855,8 @@ export class GroupsService {
return this.policyHttpService.getWAFGroups(groupName);
};

getWafSensorData = () => {
return this.policyHttpService.getWAFSensors();
getWafSensorData = getWAFSensors => {
return this.policyHttpService.getWAFSensors(getWAFSensors);
};

updateGroupWafSensorData = payload => {
Expand Down
54 changes: 40 additions & 14 deletions admin/webapp/websrc/app/common/services/waf-sensors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { TranslateService } from '@ngx-translate/core';
import { DomSanitizer } from '@angular/platform-browser';
import { UtilsService } from '@common/utils/app.utils';
import { pluck } from 'rxjs/operators';
import { SensorActionButtonsComponent } from '@routes/waf-sensors/partial/sensor-action-buttons/sensor-action-buttons.component';
import { RuleActionButtonsComponent } from '@routes/waf-sensors/partial/rule-action-buttons/rule-action-buttons.component';
import { PatternActionButtonsComponent } from '@routes/waf-sensors/partial/pattern-action-buttons/pattern-action-buttons.component';
import { SensorActionButtonsComponent } from '@components/waf-sensors/partial/sensor-action-buttons/sensor-action-buttons.component';
import { RuleActionButtonsComponent } from '@components/waf-sensors/partial/rule-action-buttons/rule-action-buttons.component';
import { PatternActionButtonsComponent } from '@components/waf-sensors/partial/pattern-action-buttons/pattern-action-buttons.component';

@Injectable({
providedIn: 'root',
Expand All @@ -26,21 +26,25 @@ export class WafSensorsService {
this.$win = $(GlobalVariable.window);
}

configGrids = (isWriteWAFSensorAuthorized: boolean) => {
configGrids = (isWriteWAFSensorAuthorized: boolean, source: string = '') => {
const columnDefs4Sensor = [
{
headerName: this.translate.instant('waf.gridHeader.SENSOR_NAME'),
field: 'name',
headerCheckboxSelection: true,
headerCheckboxSelectionFilteredOnly: true,
checkboxSelection: params => {
if (params.data) return !params.data.predefine;
return false;
},
headerCheckboxSelection: params =>
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY,
headerCheckboxSelectionFilteredOnly: params =>
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY,
cellRenderer: params => {
if (params.value)
return `<span class="${
params.data.predefine ? 'left-margin-32' : ''
params.data.predefine &&
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY
? 'left-margin-32'
: ''
}">
${params.value}
</span>`;
Expand Down Expand Up @@ -100,6 +104,19 @@ export class WafSensorsService {
},
];

if (source !== GlobalConstant.NAV_SOURCE.FED_POLICY) {
columnDefs4Sensor[0]['checkboxSelection'] = params => {
if (params.data)
return (
!params.data.predefine &&
params.context.componentParent.source !==
GlobalConstant.NAV_SOURCE.FED_POLICY &&
params.data.cfg_type !== GlobalConstant.CFG_TYPE.FED
);
return false;
};
}

const columnDefs4Rules = [
{
headerName: this.translate.instant('waf.gridHeader.PATTERN_NAME'),
Expand Down Expand Up @@ -186,7 +203,8 @@ export class WafSensorsService {
),
};

grids.gridOptions.rowSelection = 'multiple';
grids.gridOptions.rowSelection =
source !== GlobalConstant.NAV_SOURCE.FED_POLICY ? 'multiple' : 'single';

grids.gridOptions.rowClassRules = {
'disabled-row': params => {
Expand All @@ -204,9 +222,17 @@ export class WafSensorsService {
return grids;
};

getWafSensorsData = () => {
getWafSensorsData = source => {
const options: any = [];
if (source === GlobalConstant.NAV_SOURCE.FED_POLICY) {
options.push({
params: {
scope: 'fed',
},
});
}
return GlobalVariable.http
.get(PathConstant.WAF_SENSORS_URL)
.get(PathConstant.WAF_SENSORS_URL, ...options)
.pipe(pluck('sensors'));
};

Expand Down
Loading