forked from Ericsson/ecaudit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add column obfuscator for prepared statement bound values
The HideBlobsObfuscator can be used to avoid logging blob values in prepared statements. The obfuscator will also handle collections containing blobs. Closes Ericsson#126
- Loading branch information
Showing
19 changed files
with
659 additions
and
19 deletions.
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
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
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
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
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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
...t/src/main/java/com/ericsson/bss/cassandra/ecaudit/entry/obfuscator/ColumnObfuscator.java
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,37 @@ | ||
/* | ||
* Copyright 2019 Telefonaktiebolaget LM Ericsson | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
package com.ericsson.bss.cassandra.ecaudit.entry.obfuscator; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.Optional; | ||
|
||
import org.apache.cassandra.cql3.ColumnSpecification; | ||
|
||
/** | ||
* Column obfuscator used to handle prepared statement bound values. | ||
*/ | ||
public interface ColumnObfuscator | ||
{ | ||
/** | ||
* Creates an obfuscated string that represent the column value only IF the column should be obfuscated. | ||
* | ||
* @param column the column to check | ||
* @param value the value that may be obfuscated | ||
* @return the obfuscated string representation of the column value, or {@link Optional#empty()} if the value | ||
* should not be obfuscated. | ||
*/ | ||
Optional<String> obfuscate(ColumnSpecification column, ByteBuffer value); | ||
} |
44 changes: 44 additions & 0 deletions
44
...rc/main/java/com/ericsson/bss/cassandra/ecaudit/entry/obfuscator/HideBlobsObfuscator.java
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,44 @@ | ||
/* | ||
* Copyright 2019 Telefonaktiebolaget LM Ericsson | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
package com.ericsson.bss.cassandra.ecaudit.entry.obfuscator; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.Optional; | ||
|
||
import org.apache.cassandra.cql3.CQL3Type; | ||
import org.apache.cassandra.cql3.ColumnSpecification; | ||
import org.apache.cassandra.db.marshal.AbstractType; | ||
|
||
public class HideBlobsObfuscator implements ColumnObfuscator | ||
{ | ||
@Override | ||
public Optional<String> obfuscate(ColumnSpecification column, ByteBuffer value) | ||
{ | ||
return isBlobType(column.type) || isCollectionContainingBlobType(column.type) | ||
? Optional.of("<" + column.type.asCQL3Type() + ">") | ||
: Optional.empty(); | ||
} | ||
|
||
private static boolean isBlobType(AbstractType<?> type) | ||
{ | ||
return type.asCQL3Type() == CQL3Type.Native.BLOB; | ||
} | ||
|
||
private static boolean isCollectionContainingBlobType(AbstractType<?> type) | ||
{ | ||
return type.isCollection() && type.asCQL3Type().toString().contains("blob"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../src/main/java/com/ericsson/bss/cassandra/ecaudit/entry/obfuscator/ShowAllObfuscator.java
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,30 @@ | ||
/* | ||
* Copyright 2019 Telefonaktiebolaget LM Ericsson | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
*/ | ||
package com.ericsson.bss.cassandra.ecaudit.entry.obfuscator; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.Optional; | ||
|
||
import org.apache.cassandra.cql3.ColumnSpecification; | ||
|
||
public class ShowAllObfuscator implements ColumnObfuscator | ||
{ | ||
@Override | ||
public Optional<String> obfuscate(ColumnSpecification column, ByteBuffer value) | ||
{ | ||
return Optional.empty(); // No values should be obfuscated | ||
} | ||
} |
Oops, something went wrong.