-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
obfuscate ip addresses in alert error message (#511)
* obfuscate ip addresses in alert error message Signed-off-by: Surya Sashank Nistala <[email protected]> * make ip obfuscation lower case Signed-off-by: Surya Sashank Nistala <[email protected]> * update test with lowercase ip obfuscation Signed-off-by: Surya Sashank Nistala <[email protected]> --------- Signed-off-by: Surya Sashank Nistala <[email protected]> (cherry picked from commit b8e6e75) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f435dbc
commit 446c4ad
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
src/test/kotlin/org/opensearch/commons/alerting/alerts/AlertErrorTests.kt
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.opensearch.commons.alerting.alerts | ||
|
||
import org.junit.Assert | ||
import org.junit.jupiter.api.Test | ||
import java.time.Instant | ||
|
||
class AlertErrorTests { | ||
|
||
@Test | ||
fun `test alertError obfuscates IP addresses in message`() { | ||
val message = | ||
"AlertingException[[5f32db4e2a4fa94f6778cb895dae7a24][10.212.77.91:9300][indices:admin/create]]; " + | ||
"nested: Exception[org.opensearch.transport.RemoteTransportException: [5f32db4e2a4fa94f6778cb895dae7a24][10.212.77.91:9300]" + | ||
"[indices:admin/create]];; java.lang.Exception: org.opensearch.transport.RemoteTransportException: [5f32db4e2a4fa94f6778cb895" + | ||
"dae7a24][10.212.77.91:9300][indices:admin/create]" | ||
val alertError = AlertError(Instant.now(), message = message) | ||
Assert.assertEquals( | ||
alertError.message, | ||
"AlertingException[[5f32db4e2a4fa94f6778cb895dae7a24][x.x.x.x:9300][indices:admin/create]]; " + | ||
"nested: Exception[org.opensearch.transport.RemoteTransportException: [5f32db4e2a4fa94f6778cb895dae7a24][x.x.x.x:9300]" + | ||
"[indices:admin/create]];; java.lang.Exception: org.opensearch.transport.RemoteTransportException: " + | ||
"[5f32db4e2a4fa94f6778cb895dae7a24][x.x.x.x:9300][indices:admin/create]" | ||
) | ||
} | ||
} |