CRZbulabula commented on code in PR #16428:
URL: https://github.com/apache/iotdb/pull/16428#discussion_r2361539748
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNodeShutdownHook.java:
##########
@@ -90,6 +95,23 @@ private void startWatcher() {
@Override
public void run() {
logger.info("DataNode exiting...");
+ if (CommonDescriptor.getInstance().getConfig().isEnableAuditLog()) {
+ AuditLogFields fields =
+ new AuditLogFields(
+ "root",
+ -1,
+ null,
+ AuditEventType.DESTROY_KEY,
+ AuditLogOperation.CONTROL,
+ PrivilegeType.SECURITY,
+ true,
+ null,
+ null);
+ String logMessage =
+ String.format("Successfully destroy the tsfile encrypt key in
DataNode %s", nodeLocation);
Review Comment:
U sure the tsfile encrypt key is destroyed here? Better record this audit
log just behind the code execution.
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/audit/AbstractAuditLogger.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.iotdb.commons.audit;
+
+import org.apache.iotdb.commons.auth.entity.PrivilegeType;
+import org.apache.iotdb.commons.conf.CommonConfig;
+import org.apache.iotdb.commons.conf.CommonDescriptor;
+
+import java.util.List;
+
+public class AbstractAuditLogger {
+ private static final CommonConfig config =
CommonDescriptor.getInstance().getConfig();
+ private static final List<AuditLogOperation> auditLogOperationList =
+ config.getAuditableOperationType();
+
+ private static final PrivilegeLevel auditablePrivilegeLevel =
config.getAuditableOperationLevel();
+
+ private static final String auditableOperationResult =
config.getAuditableOperationResult();
+
+ void log(AuditLogFields auditLogFields, String log) {
+ // do nothing
+ }
+
+ public boolean checkBeforeLog(AuditLogFields auditLogFields) {
+ String username = auditLogFields.getUsername();
+ String address = auditLogFields.getCliHostname();
+ AuditEventType type = auditLogFields.getAuditType();
+ AuditLogOperation operation = auditLogFields.getOperationType();
+ PrivilegeType privilegeType = auditLogFields.getPrivilegeType();
+ PrivilegeLevel privilegeLevel = judgePrivilegeLevel(privilegeType);
+ boolean result = auditLogFields.isResult();
+
+ // to do: check whether this event should be logged.
+ // if whitelist or blacklist is used, only ip on the whitelist or
blacklist can be logged
Review Comment:
Seems the framework is ready to be merged! But plz don't forget this, this
PR can be merged after implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]