gpt4 book ai didi

cassandra - Cassandra 中的数据审计

转载 作者:行者123 更新时间:2023-12-04 14:27:44 26 4
gpt4 key购买 nike

如何对 cassandra 数据实现审计?
我正在寻找一个开源选项。

cassandra 是否有任何有助于审计的功能?
我可以使用触发器将记录记录到表中吗?我关注了 Triggers示例并且能够将记录插入到 triggers_log 中当更新发生在另一个表上时。
但不确定如何捕获 user/session触发更新的详细信息。我有来自 CQLSH终端,创建 userstrigger_log table

create table AUDIT_LOG (        transaction_id int,       entries map<text, text>,  --> to capture the modifications done to the tables       user varchar,  //authenticated user       time timestamp,        primary key(transaction_id));
CREATE TABLE users (  user_id int PRIMARY KEY,  fname text,  lname text);

Define the trigger on users table using CREATE TRIGGER syntax from cqlsh

Below code so far.

public class AuditTrigger implements ITrigger {

@Override
public Collection<RowMutation> augment(ByteBuffer key, ColumnFamily update) {

List<RowMutation> mutations = new ArrayList<RowMutation>();
for (Column column : update) {
if (column.value().remaining() > 0) {
RowMutation mutation = new RowMutation("mykeyspace", key);
//What do I need here to capture the updates to users
//table and log the updates into various columns of audit_log
mutations.add(mutation);
}
}
return mutations;
}
}

如果触发器不是正确的方法(任何 Spring AOP 方法?),请提出替代方案。我也试过 Cassandra vs logging activity解决方案,但它不打印已执行的 sql,经过身份验证的用户信息。

最佳答案

不幸的是,此时不能使用 Triggers,因为您需要的是包含用户信息且未传递给 Triggers 的 ClientState。

我能想到两种方法。(您需要查看 Cassandra 代码库以更好地理解这些方法)

一种方法是 AOP,即添加一个代理,该代理将 AOP 并使用代理启动 Cassandra。需要作为切入点的类是 QueryProcessor#processStatement 方法。对此方法的调用将以准备好的语句和 QueryState 作为参数。从 PreparedStatement 中,您可以确定用户的意图。 QueryState.getClientState 将返回用户信息所在的 ClientState。

另一种方法涉及自定义身份验证器和授权器。此处描述了在 Cassandra 中的配置。

http://www.datastax.com/documentation/cassandra/2.0/cassandra/security/secure_about_native_authenticate_c.html

您可以使用自定义授权器扩展 AllowAllAuthorizer(这将禁用权限缓存)。每当您在 Authorizer 上收到授权请求时,您都可以记录它。这种方法的缺点是你不知道用户打算对表做什么,只知道他请求对它进行一些授权。权限是包含他想对表执行的操作的权限,但不会传递给授权者。

如果您决定采用这些方法中的任何一种,如果您需要更多详细信息,您可以自由发布后续信息。

关于cassandra - Cassandra 中的数据审计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24684457/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com