Skip to content

Commit

Permalink
IKC-409 Data masking policies list
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Belke authored and Piotr Belke committed Sep 28, 2024
1 parent 4043152 commit d291b2e
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public class PolicyDto {
private String name;
private MaskingType type;
private Set<String> fields;
private Set<String> resources;
private Set<PolicyResourceDto> resources;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.consdata.kouncil.datamasking.dto;

import com.consdata.kouncil.clusters.dto.ClusterDto;
import lombok.Data;

@Data
public class PolicyResourceDto {

private Long id;
private ClusterDto cluster;
private String topic;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.consdata.kouncil.model.datamasking;

import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import lombok.Getter;
Expand Down Expand Up @@ -40,9 +43,10 @@ public class Policy {
@Column(name = "FIELD")
private Set<String> fields;

@Column(name = "APPLY_TO_ALL_RESOURCES")
private Boolean applyToAllResources;

@ElementCollection
@CollectionTable(name = "POLICY_RESOURCES", joinColumns = @JoinColumn(name = "POLICY_ID"))
@Column(name = "RESOURCES")
private Set<String> resources;
@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER, orphanRemoval = true)
@JoinColumn(name = "POLICY_ID")
private Set<PolicyResource> resources;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.consdata.kouncil.model.datamasking;

import com.consdata.kouncil.model.cluster.Cluster;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;

@Entity
@Table(name = "POLICY_RESOURCE")
@Getter
@Setter
public class PolicyResource {

@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_POLICY_RESOURCE_GEN")
@SequenceGenerator(name = "SEQ_POLICY_RESOURCE_GEN", sequenceName = "SEQ_POLICY_RESOURCE", initialValue = 1, allocationSize = 1)
private Long id;

@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "CLUSTER_ID", insertable = false, updatable = false)
private Cluster cluster;

@Column(name = "TOPIC")
private String topic;

@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "POLICY_ID", insertable = false, updatable = false)
private Policy policy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ create table policy
(
id bigint not null primary key,
name varchar(255),
masking_type varchar(255)
masking_type varchar(255),
apply_to_all_resources boolean
);
create table policy_fields
(
Expand All @@ -11,14 +12,18 @@ create table policy_fields
field varchar(255)
);

create table policy_resources
create table policy_resource
(
policy_id bigint not null
constraint fkk7ao2gxpd7peapqwu27wj9dng references policy,
resources varchar(255)
id bigint not null primary key,
topic varchar(255),
cluster_id bigint
constraint fk58aualhiqf7wqmxjo5nwgnqn9 references cluster,
policy_id bigint
constraint fkltj5s392jlbr2mshmoyn3vd2a references policy
);

CREATE SEQUENCE SEQ_POLICY MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10;
CREATE SEQUENCE SEQ_POLICY_RESOURCE MINVALUE 1 START WITH 1 INCREMENT BY 1 CACHE 10;

insert into system_function(id, name, label, function_group)
VALUES (nextval('SEQ_SYSTEM_FUNCTION'), 'POLICY_LIST', 'Policies list', 'DATA_MASKING'),
Expand Down
16 changes: 4 additions & 12 deletions kouncil-frontend/libs/feat-data-masking/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
export {FeatDataMaskingModule} from './lib/feat-data-masking.module';
export {
PoliciesComponent
} from './lib/policies/policies.component';
export {
PoliciesService
} from './lib/policies/policies.service';
export {
PoliciesBackendService
} from './lib/policies/policies.backend.service';
export {
PoliciesDemoService
} from './lib/policies/policies.demo.service';
export {PoliciesComponent} from './lib/policies/policies.component';
export {PoliciesService} from './lib/policies/policies.service';
export {PoliciesBackendService} from './lib/policies/policies.backend.service';
export {PoliciesDemoService} from './lib/policies/policies.demo.service';
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,7 @@ export class PoliciesComponent extends AbstractTableComponent implements OnInit,
sortable: true,
draggable: true,
width: 300,
valueFormatter: (value: MaskingType): string => {
switch (value) {
case MaskingType.ALL:
return 'Mask all';
case MaskingType.FIRST_5:
return 'Hide first 5 letters';
case MaskingType.LAST_5:
return 'Hide last 5 letters';
}
}
valueFormatter: (value: MaskingType): string => MaskingType[value]
},
{
name: 'Fields',
Expand Down Expand Up @@ -146,4 +137,5 @@ export class PoliciesComponent extends AbstractTableComponent implements OnInit,
return !phrase || policy.name.indexOf(phrase) > -1;
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class Policy {
}

export enum MaskingType {
ALL = 'ALL',
FIRST_5 = 'FIRST_5',
LAST_5 = 'LAST_5'
ALL = 'Hide all',
FIRST_5 = 'Hide first 5 signs',
LAST_5 = 'Hide last 5 signs'
}

0 comments on commit d291b2e

Please sign in to comment.