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

feat(be:FSADT1-1277): Strict Input validation on backend #910

Merged
merged 34 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5621c70
feat(be:FSADT1-1277): Part #1
mamartinezmejia Apr 5, 2024
7048e67
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 5, 2024
a4223d0
feat(be:FSADT1-1277): Part #2
mamartinezmejia Apr 5, 2024
fccd543
feat(be:FSADT1-1277): Part #3
mamartinezmejia Apr 7, 2024
42aeacf
feat(be:FSADT1-1277): Part #4
mamartinezmejia Apr 7, 2024
436de20
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 7, 2024
9b2af7a
Merge branch 'main' into feat/be/FSADT1-1277
paulushcgcj Apr 8, 2024
2e734ed
feat(be:FSADT1-1277): Part #5
mamartinezmejia Apr 8, 2024
003c1f9
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 8, 2024
6d14e79
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 9, 2024
0bdc200
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 9, 2024
860a2d4
Merge branch 'main' into feat/be/FSADT1-1277
paulushcgcj Apr 9, 2024
3d87d8c
feat(be:FSADT1-1277):
mamartinezmejia Apr 9, 2024
89bfa93
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 9, 2024
f4ebcd3
feat(be:FSADT1-1277):
mamartinezmejia Apr 9, 2024
2771f98
Merge branch 'main' into feat/be/FSADT1-1277
paulushcgcj Apr 9, 2024
15baa7d
Merge branch 'feat/be/FSADT1-1277' of https://github.com/bcgov/nr-for…
mamartinezmejia Apr 9, 2024
bc0948e
Improved validation
mamartinezmejia Apr 9, 2024
a3debfc
Merge branch 'main' into feat/be/FSADT1-1277
mamartinezmejia Apr 10, 2024
2095bc3
Preventing JSON parse issues for the DOB
mamartinezmejia Apr 10, 2024
501d919
Improved validation to be safe
mamartinezmejia Apr 10, 2024
58b087d
Reverted change
mamartinezmejia Apr 10, 2024
92acb16
- Added extra validations for the DOB
mamartinezmejia Apr 10, 2024
7aed2d1
- Included validations for City and Strret Address
mamartinezmejia Apr 11, 2024
357e821
Cleaned code
mamartinezmejia Apr 11, 2024
5ff81a9
Added missing annotations
mamartinezmejia Apr 11, 2024
bf0cf07
Adjusted company name size to the Oracle DB
mamartinezmejia Apr 11, 2024
3685ba3
Adjusted registration number name size to the Oracle DB
mamartinezmejia Apr 11, 2024
cce9fdc
Adjusted registration number and address name size to the Oracle DB
mamartinezmejia Apr 11, 2024
2a6478a
Adjusted city size to the Oracle DB
mamartinezmejia Apr 11, 2024
4d7bbab
Adjusted location name name size to the Oracle DB
mamartinezmejia Apr 11, 2024
b317bec
Adjusted phone number size
mamartinezmejia Apr 11, 2024
3596144
- Validated size of registration number size
mamartinezmejia Apr 11, 2024
0c945d6
Added more size validations
mamartinezmejia Apr 11, 2024
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package ca.bc.gov.app.converters;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;
import org.springframework.security.core.GrantedAuthority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.data.relational.core.mapping.Column;
import jakarta.validation.constraints.NotNull;

@SuperBuilder
@Data
Expand All @@ -17,8 +18,10 @@ public abstract class BaseEntity {
protected LocalDateTime updatedAt;

@Column("create_user")
@NotNull
protected String createdBy;

@Column("update_user")
protected String updatedBy;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;


@Table(name = "client_type_code", schema = ApplicationConstant.POSTGRES_ATTRIBUTE_SCHEMA)
@Data
@EqualsAndHashCode(callSuper = true)
Expand All @@ -27,11 +26,13 @@ public class ClientTypeCodeEntity extends ExpirableBaseEntity {

@Id
@Column("client_type_code")
@NotNull
@Size(min = 1, max = 5)
private String code;

public ClientTypeCodeEntity(
@NotNull @Size(min = 1, max = 4) String code,
@NotNull String description) {
String code,
String description) {
this.code = code;
this.description = description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,32 @@

import ca.bc.gov.app.ApplicationConstant;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.With;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

@Table(name = "contact_type_code", schema = ApplicationConstant.POSTGRES_ATTRIBUTE_SCHEMA)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@With
public class ContactTypeCodeEntity {
public class ContactTypeCodeEntity extends ExpirableBaseEntity {

@Id
@Column("contact_type_code")
private String contactTypeCode;

@NotNull
@Column("description")
private String description;

@NotNull
@Column("effective_date")
private LocalDate effectiveAt;

@NotNull
@Column("expiry_date")
private LocalDate expiredAt;

@Column("create_timestamp")
private LocalDateTime createdAt;

@Column("update_timestamp")
private LocalDateTime updatedAt;

@Column("create_user")
private String createdBy;
@Size(min = 1, max = 2)
private String contactTypeCode;

@Column("update_user")
private String updatedBy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@AllArgsConstructor
@With
public class CountryCodeEntity extends ExpirableBaseEntity {

@Id
@Column("country_code")
@NotNull
Expand All @@ -35,7 +36,7 @@ public class CountryCodeEntity extends ExpirableBaseEntity {

public CountryCodeEntity(
@NotNull @Size(min = 2, max = 2) String countryCode,
@NotNull String description) {
String description) {
this.countryCode = countryCode;
this.description = description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class DistrictCodeEntity extends ExpirableBaseEntity {

@Column("email_address")
@NotNull
@Size(min = 5, max = 100)
private String emailAddress;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import ca.bc.gov.app.ApplicationConstant;
import io.r2dbc.postgresql.codec.Json;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.AllArgsConstructor;
Expand All @@ -27,27 +29,36 @@ public class EmailLogEntity {
private Integer emailLogId;

@Column("email_id")
@Size(min = 1, max = 40)
private String emailId;

@Column("email_sent_ind")
@Size(min = 1, max = 1)
private String emailSentInd;

@Column("exception_message")
private String exceptionMessage;

@Column("template_name")
@NotNull
@Size(min = 3, max = 40)
private String templateName;

@Column("email_address")
@NotNull
@Size(min = 5, max = 100)
private String emailAddress;

@Column("email_subject")
@NotNull
@Size(min = 5, max = 100)
private String emailSubject;

@Column("email_variables")
private Json emailVariables;

@Column("create_timestamp")
@NotNull
private LocalDateTime createDate;

@Column("update_timestamp")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.bc.gov.app.entity.client;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
Expand All @@ -18,7 +19,9 @@
@NoArgsConstructor
@AllArgsConstructor
public abstract class ExpirableBaseEntity extends BaseEntity {

@NotNull
@Size(min = 5, max = 100)
protected String description;

@Column("create_timestamp")
Expand All @@ -31,4 +34,5 @@ public abstract class ExpirableBaseEntity extends BaseEntity {
@NotNull
@Column("expiry_date")
protected LocalDate expiredAt;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ca.bc.gov.app.entity.client;

import ca.bc.gov.app.ApplicationConstant;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -17,28 +19,40 @@
@AllArgsConstructor
@With
public class SubmissionContactEntity {

@Id
@Column("submission_contact_id")
private Integer submissionContactId;

@Column("submission_id")
@NotNull
private Integer submissionId;

@Column("contact_type_code")
@NotNull
@Size(min = 1, max = 2)
private String contactTypeCode;

@Column("first_name")
@Size(min = 1, max = 100)
private String firstName;

@Column("last_name")
@Size(min = 1, max = 100)
private String lastName;

@Column("business_phone_number")
@NotNull
@Size(min = 5, max = 20)
private String businessPhoneNumber;

@Column("email_address")
@NotNull
@Size(min = 5, max = 100)
private String emailAddress;

@Column("idp_user_id")
@Size(min = 5, max = 50)
private String userId;

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package ca.bc.gov.app.entity.client;

import ca.bc.gov.app.ApplicationConstant;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.With;
import java.time.LocalDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
Expand All @@ -24,27 +26,40 @@ public class SubmissionDetailEntity {
private Integer submissionDetailId;

@Column("submission_id")
@NotNull
private Integer submissionId;

@Column("client_number")
@Size(min = 1, max = 8)
private String clientNumber;

@Column("incorporation_number")
@Size(min = 1, max = 50)
private String registrationNumber;

@Column("organization_name")
@Size(min = 3, max = 100)
private String organizationName;

@Column("business_type_code")
@NotNull
@Size(min = 1, max = 1)
private String businessTypeCode;

@Column("client_type_code")
@NotNull
@Size(min = 1, max = 1)
private String clientTypeCode;

@Column("good_standing_ind")
@Size(min = 1, max = 1)
private String goodStandingInd;

@Column("birthdate")
private LocalDate birthdate;

@Column("district_code")
@Size(min = 2, max = 5)
private String districtCode;

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.models.client.SubmissionStatusEnum;
import ca.bc.gov.app.models.client.SubmissionTypeCodeEnum;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -24,16 +25,20 @@
@AllArgsConstructor
@With
public class SubmissionEntity extends BaseEntity {

@Id
@Column("submission_id")
private Integer submissionId;

@Column("submission_status_code")
@Size(min = 1, max = 5)
private SubmissionStatusEnum submissionStatus;

@Column("submission_type_code")
@Size(min = 3, max = 5)
private SubmissionTypeCodeEnum submissionType;

@Column("submission_date")
private LocalDateTime submissionDate;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.bc.gov.app.entity.client;

import ca.bc.gov.app.ApplicationConstant;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -18,8 +19,11 @@
public class SubmissionLocationContactEntity {

@Column("submission_contact_id")
@NotNull
private Integer submissionContactId;

@Column("submission_location_id")
@NotNull
private Integer submissionLocationId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import lombok.With;
import org.springframework.data.relational.core.mapping.Column;


@Data
@Builder
@NoArgsConstructor
Expand All @@ -20,4 +19,5 @@ public class SubmissionLocationContactIdEntity {

@Column("submission_location_id")
private Integer submissionLocationId;

}
Loading
Loading