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

DEV: Refactored modules, tests, and dependency versions to support Sp… …ring Boot migration. #26

Merged
merged 3 commits into from
Dec 12, 2024
Merged
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
48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# eJMask `{*:*}`

eJMask is a JVM-based masking library that provides an easy-to-use API for masking sensitive data in your Java applications. With eJMask, you can quickly mask sensitive information like personal information, credit card numbers, and more. eJMask library is designed to provide a simple interface to make masking sensitive data sets before logging easier and simpler without impacting performance.
eJMask is a JVM-based masking library that provides an easy-to-use API for masking sensitive data in your Java applications. With eJMask, you can quickly mask sensitive information like personal information, credit card numbers, and more. eJMask library is designed to provide a simple interface to make masking sensitive data sets before
logging easier and simpler without impacting performance.

### Features

- Easy-to-use API for integration into your Java applications
- Support for multiple masking strategies, including character substitution and partial masking
- Custom masking strategies can be added easily to meet your specific needs
- Lightweight and efficient, with no external dependencies

### Dependencies

| JDK Version | Spring Version | Spring Boot Version |
|-------------|----------------|---------------------|
| 8 | 5.3.31 | 2.7.18 |

### Getting Started

To get started with eJMask, you'll need to add the eJMask library to your project using your preferred build system, such as Maven or Gradle.
Expand Down Expand Up @@ -41,7 +49,8 @@ public class EJMaskExample {

`IPatternBuilder` implementations are responsible to generate the regular expression needed to replace data to be masked. Pattern builder also have additional responsibility to optimize the regex by creating one expression to mask all list of field names for better performance.

#### eg:
#### eg:

```java
public class JsonPatternBuilder implements IPatternBuilder {

Expand All @@ -57,7 +66,9 @@ public class JsonPatternBuilder implements IPatternBuilder {
}
}
```

#### Extensions

For many standard use cases you can make use of pattern builders defined in `ejmask-extensions` module.

- HeaderFieldPatternBuilder
Expand All @@ -71,6 +82,7 @@ For many standard use cases you can make use of pattern builders defined in `ejm
`IFilter` defines how a field should be masked. This includes the field name, the pattern builder need to be used, number of characters need to be visible at the end or beginning, etc.

eg:

```java

public class Sample implements IFilter {
Expand All @@ -86,6 +98,7 @@ public class Sample implements IFilter {
}
}
```

> Users can also override default values for `VisibleCharacters`,`Group`, `Order)` etc if needed.

### ContentProcessor
Expand All @@ -94,6 +107,7 @@ public class Sample implements IFilter {
A few use case we can use is to decode and encode the string before masking and/or to reduce the size of a large string before performing the masking operation to improve performance.

#### Extensions

- ContentSlicerPreProcessor

### LogProvider
Expand All @@ -107,6 +121,7 @@ LoggerUtil.register(new MyLogProvider());
## Getting Started

### Supported Languages

eJMask is created as a Maven based Java project and can be used as a dependency in a Java based application or other JVM based languages such as Kotlin, Groovy, Scala etc.

### Manual configuration.
Expand All @@ -116,7 +131,7 @@ eJMask will internally dedupe the given set of filters and generate the most opt

#### Adding Filters

Invoke `EJMaskInitializer.addFilters` with list of all Filter instances. `EJMaskInitializer` Internally removes all duplicate and optimizes the MaskingPatterns by grouping similar patterns.
Invoke `EJMaskInitializer.addFilters` with list of all Filter instances. `EJMaskInitializer` Internally removes all duplicate and optimizes the MaskingPatterns by grouping similar patterns.

#### Adding ContentProcessors

Expand Down Expand Up @@ -145,6 +160,7 @@ If you are using spring application ejamsk configurations can easily be auto wir
- Done !!

```java

@Component("data-filter.add-address")
public class AddAddressFilter extends BaseFilter {
AddAddressFilter() {
Expand All @@ -165,6 +181,7 @@ public class AddAddressFilter extends BaseFilter {
- ✔ Done !!

```java

@Configuration("data-filter.config.add-shareholder")
public class AddShareholderRequestFilterConfiguration {

Expand All @@ -189,26 +206,29 @@ eJMask is a spring native library, spring eases the process of configuring eJMas
Fist add `ejmask-spring-core` to your dependency list.

```xml

<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-spring-autoconfig</artifactId>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-spring-core</artifactId>
</dependency>
```

then simply add `com.ebay.ejmask.spring.core` to your spring context scanning.

```xml

<context:component-scan base-package="com.ebay.ejmask.spring.core"/>
```

#### AutoConfiguration

If your application is built on spring boot you can skip the above step by simply adding `ejmask-spring-boot` into dependency list.
If your application is built on spring boot you can skip the above step by simply adding `ejmask-spring-starter` into dependency list.

```xml

<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-spring-boot</artifactId>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-spring-starter</artifactId>
</dependency>
```

Expand All @@ -228,12 +248,15 @@ You can download source and binaries from our [release page](https://github.com/
Alternatively you can pull it from the central Maven repositories:

### Using in your maven project.

> Please check the release version before adding to your project.

```xml

<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-bom</artifactId>
<version>1.2.1</version>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-bom</artifactId>
<version>1.2.1</version>
</dependency>
```

Expand All @@ -252,12 +275,13 @@ compile group: 'com.ebay.ejmask', name: 'ejmask-bom', version: '1.2.1'
- [ ] Users will should be able to configure data filters through `ejmask.ymal`.
- [ ] Users will be able to mask any given field by annotating with `@Mask` annotation.


## License Information

Copyright 2023 eBay Inc.

Author(s): [Prasanth Kaimattil Venu](https://github.com/prasanthkv), [Manikandan Perumal](https://github.com/tbd)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

7 changes: 1 addition & 6 deletions ejmask-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@
</dependency>
<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-spring-boot</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.ebay.ejmask</groupId>
<artifactId>ejmask-spring-autoconfig</artifactId>
<artifactId>ejmask-spring-starter</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
Expand Down
10 changes: 0 additions & 10 deletions ejmask-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
<version>${project.version}</version>
</dependency>
<!-- Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.ebay.ejmask.core;

/**
* Copyright (c) 2023 eBay Inc.
* <p>
Expand Down Expand Up @@ -41,7 +40,6 @@ public class BaseFilter implements IFilter {
* @param patternBuilder new value of patternBuilder
* @param fieldNames new value of fieldNames
*/
@SafeVarargs
public BaseFilter(Class<? extends IPatternBuilder> patternBuilder, String... fieldNames) {
this(patternBuilder, DEFAULT_VISIBLE_CHAR, DEFAULT_PRIORITY, fieldNames);
}
Expand All @@ -53,7 +51,6 @@ public BaseFilter(Class<? extends IPatternBuilder> patternBuilder, String... fie
* @param visibleCharacters new value of visibleCharacters
* @param fieldNames new value of fieldNames
*/
@SafeVarargs
public BaseFilter(Class<? extends IPatternBuilder> patternBuilder, int visibleCharacters, String... fieldNames) {
this(patternBuilder, visibleCharacters, DEFAULT_PRIORITY, fieldNames);
}
Expand All @@ -67,7 +64,6 @@ public BaseFilter(Class<? extends IPatternBuilder> patternBuilder, int visibleCh
* @param order new value of order
* @param fieldNames new value of fieldNames
*/
@SafeVarargs
public BaseFilter(Class<? extends IPatternBuilder> patternBuilder, int visibleCharacters, int order, String... fieldNames) {
if (patternBuilder == null) {
throw new IllegalArgumentException("patternBuilder cannot be null.");
Expand All @@ -81,7 +77,6 @@ public BaseFilter(Class<? extends IPatternBuilder> patternBuilder, int visibleCh
this.fieldNames = fieldNames;
}


/**
* Get the value of patternBuilder
*
Expand Down Expand Up @@ -121,4 +116,4 @@ public int getOrder() {
public String[] getFieldNames() {
return this.fieldNames;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.ebay.ejmask.core.util;

/**
* Copyright (c) 2023 eBay Inc.
* <p>
Expand All @@ -16,7 +15,6 @@
* limitations under the License.
*/


import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Array;
Expand Down Expand Up @@ -89,7 +87,7 @@ public static boolean isAnEmptyArray(Object array) {
* @param array the array to retrieve the length from, may be null
* @return The length of the array, or {@code 0} if the array is {@code null}
*/
private static int getLength(final Object array) {
private static int getLength(Object array) {
return (array == null) ? 0 : Array.getLength(array);
}

Expand All @@ -102,7 +100,7 @@ private static int getLength(final Object array) {
* @return {@code true} if the CharSequence is
* not empty and not null and not whitespace only
*/
public static boolean isNotBlank(final CharSequence cs) {
public static boolean isNotBlank(CharSequence cs) {
return !isBlank(cs);
}

Expand All @@ -114,8 +112,8 @@ public static boolean isNotBlank(final CharSequence cs) {
* @param cs the CharSequence to check, may be null
* @return {@code true} if the CharSequence is null, empty or whitespace only
*/
public static boolean isBlank(final CharSequence cs) {
final int strLen = cs == null ? 0 : cs.length();
public static boolean isBlank(CharSequence cs) {
int strLen = cs == null ? 0 : cs.length();
if (strLen != 0) {
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(cs.charAt(i))) {
Expand Down
10 changes: 0 additions & 10 deletions ejmask-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
<version>${project.version}</version>
</dependency>
<!-- Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
33 changes: 0 additions & 33 deletions ejmask-spring/ejmask-spring-autoconfig/pom.xml

This file was deleted.

Loading
Loading