-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove log mask feature falling back to the default ecs encoder (
#603) * chore: remove log mask feature falling back to the default ecs encoder * chore: appender name * chore: refine test clarity to accurately reflect logged information
- Loading branch information
1 parent
0e6c87d
commit 5527bf3
Showing
5 changed files
with
19 additions
and
251 deletions.
There are no files selected for viewing
70 changes: 0 additions & 70 deletions
70
src/main/java/it/pagopa/transactions/utils/EcsEncoderLogMasker.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<springProperty name="ECS_SERVICE_VERSION" source="build.version"/> | ||
<appender name="ECS_JSON_CONSOLE_MASKED" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="it.pagopa.transactions.utils.EcsEncoderLogMasker"> | ||
<appender name="ECS_JSON_CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder class="co.elastic.logging.logback.EcsEncoder"> | ||
<serviceName>${ECS_SERVICE_NAME:-undefined}</serviceName> | ||
<serviceVersion>${ECS_SERVICE_VERSION}</serviceVersion> | ||
<serviceEnvironment>${ECS_SERVICE_ENVIRONMENT:-undefined}</serviceEnvironment> | ||
<maskPattern>([\d+]{3,20})</maskPattern> <!-- each string of digits from 3 to 20 char --> | ||
<maskPattern>([a-z0-9.-]+@[a-z]+\.[a-z]{2,3})</maskPattern> <!-- email --> | ||
</encoder> | ||
</appender> | ||
<root level="INFO"> | ||
<appender-ref ref="ECS_JSON_CONSOLE_MASKED"/> | ||
<appender-ref ref="ECS_JSON_CONSOLE"/> | ||
</root> | ||
</configuration> |
85 changes: 0 additions & 85 deletions
85
src/test/java/it/pagopa/transactions/utils/EcsEncoderExceptionTest.java
This file was deleted.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
src/test/java/it/pagopa/transactions/utils/EcsEncoderLogMaskerTests.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package it.pagopa.transactions.utils; | ||
|
||
import it.pagopa.ecommerce.commons.domain.RptId; | ||
import it.pagopa.ecommerce.commons.domain.TransactionId; | ||
import it.pagopa.ecommerce.commons.v2.TransactionTestUtils; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
|
@@ -19,7 +22,7 @@ | |
@Slf4j | ||
@SpringBootTest | ||
@TestPropertySource(locations = "classpath:application-tests.properties") | ||
class LogMaskTests { | ||
class LogFormatterTests { | ||
|
||
private static final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); | ||
private static final ByteArrayOutputStream errContent = new ByteArrayOutputStream(); | ||
|
@@ -37,32 +40,19 @@ public static void restoreStreams() { | |
} | ||
|
||
@Test | ||
void testSimpleLog() { | ||
String simpleMail = "[email protected]"; | ||
log.info(simpleMail); | ||
String complexmail = "[email protected]"; | ||
log.info(complexmail); | ||
String cvvMsg3 = "cvv: 123"; | ||
log.info(cvvMsg3); | ||
String cvvMsg4 = "cvv: 1234"; | ||
log.info(cvvMsg4); | ||
String pan14 = "pan: 12345678901234"; | ||
log.info(pan14); | ||
String pan16 = "pan: 1234567890123456"; | ||
log.info(pan16); | ||
void testShouldNotMaskValues() { | ||
// pre-conditions | ||
TransactionId transactionId = new TransactionId(TransactionTestUtils.TRANSACTION_ID); | ||
RptId rptId = new RptId(TransactionTestUtils.RPT_ID); | ||
// test | ||
log.info("TransactionId: [{}]", transactionId.value()); | ||
log.info("RPT ID: [{}]", rptId.value()); | ||
// assertions | ||
String outcontentString = outContent.toString(StandardCharsets.UTF_8); | ||
assertFalse(outcontentString.contains(simpleMail)); | ||
assertFalse(outcontentString.contains(complexmail)); | ||
assertFalse(outcontentString.contains(cvvMsg3)); | ||
assertFalse(outcontentString.contains(cvvMsg4)); | ||
assertFalse(outcontentString.contains(pan14)); | ||
assertFalse(outcontentString.contains(pan16)); | ||
assertTrue(outcontentString.contains("cvv: ***")); | ||
assertTrue(outcontentString.contains("cvv: ****")); | ||
assertTrue(outcontentString.contains("pan: ****************")); | ||
assertTrue(outcontentString.contains("pan: **************")); | ||
assertTrue(outcontentString.contains("*****************")); | ||
assertTrue(outcontentString.contains("************")); | ||
assertTrue(outcontentString.contains("TransactionId: [" + transactionId.value() + "]")); | ||
assertTrue(outcontentString.contains("RPT ID: [" + rptId.value() + "]")); | ||
// We expect some additional data in the log string | ||
assertTrue(outcontentString.contains("@timestamp")); | ||
} | ||
|
||
} |