You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/10/25 06:14:03 UTC

[GitHub] [iotdb] caozj1011 opened a new pull request, #7717: [To rel/0.13] [IOTDB-3662] add audit log.

caozj1011 opened a new pull request, #7717:
URL: https://github.com/apache/iotdb/pull/7717

   Add audit log for insert/delete/query.
   
   For DDL: default is info level.
   
   For DML: insert is debug level, delete and query are info level.
   
   level: IoTDB/LOGGER/NONE


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] HTHou merged pull request #7717: [To rel/0.13] [IOTDB-3662] add audit log.

Posted by GitBox <gi...@apache.org>.
HTHou merged PR #7717:
URL: https://github.com/apache/iotdb/pull/7717


-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] HTHou commented on a diff in pull request #7717: [To rel/0.13] [IOTDB-3662] add audit log.

Posted by GitBox <gi...@apache.org>.
HTHou commented on code in PR #7717:
URL: https://github.com/apache/iotdb/pull/7717#discussion_r1006500813


##########
server/src/main/java/org/apache/iotdb/db/service/basic/StandaloneServiceProvider.java:
##########
@@ -50,7 +51,8 @@ public boolean executeNonQuery(PhysicalPlan plan)
         && IoTDBDescriptor.getInstance().getConfig().isReadOnly()) {
       throw new StorageEngineReadonlyException();
     }
-
+    AuditLogUtils.writeAuditLog(
+        plan.getOperatorName(), String.format("measurements size:%s", plan.getPaths().size()));

Review Comment:
   ```suggestion
       AuditLogUtils.writeAuditLog(
           plan.getOperatorName(),
           String.format(
               "measurements size:%s", plan.getPaths() == null ? 0 : plan.getPaths().size()));
   ```



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] HTHou commented on a diff in pull request #7717: [To rel/0.13] [IOTDB-3662] add audit log.

Posted by GitBox <gi...@apache.org>.
HTHou commented on code in PR #7717:
URL: https://github.com/apache/iotdb/pull/7717#discussion_r1006500583


##########
cluster/src/main/java/org/apache/iotdb/cluster/server/basic/ClusterServiceProvider.java:
##########
@@ -89,6 +90,8 @@ public QueryContext genQueryContext(
 
   @Override
   public boolean executeNonQuery(PhysicalPlan plan) {
+    AuditLogUtils.writeAuditLog(
+        plan.getOperatorName(), String.format("measurements size:%s", plan.getPaths().size()));

Review Comment:
   ```suggestion
       AuditLogUtils.writeAuditLog(
           plan.getOperatorName(),
           String.format(
               "measurements size:%s", plan.getPaths() == null ? 0 : plan.getPaths().size()));
   ```



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [iotdb] HTHou commented on a diff in pull request #7717: [To rel/0.13] [IOTDB-3662] add audit log.

Posted by GitBox <gi...@apache.org>.
HTHou commented on code in PR #7717:
URL: https://github.com/apache/iotdb/pull/7717#discussion_r1006376200


##########
server/src/main/java/org/apache/iotdb/db/utils/AuditLogUtils.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.db.utils;
+
+import org.apache.iotdb.db.conf.IoTDBConfig;
+import org.apache.iotdb.db.conf.IoTDBConstant;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.metadata.IllegalPathException;
+import org.apache.iotdb.db.exception.query.QueryProcessException;
+import org.apache.iotdb.db.metadata.path.PartialPath;
+import org.apache.iotdb.db.qp.physical.crud.InsertRowPlan;
+import org.apache.iotdb.db.qp.utils.DateTimeUtils;
+import org.apache.iotdb.db.query.control.SessionManager;
+import org.apache.iotdb.db.service.IoTDB;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AuditLogUtils {
+  private static final Logger logger = LoggerFactory.getLogger(AuditLogUtils.class);
+  private static final Logger AUDIT_LOGGER =
+      LoggerFactory.getLogger(IoTDBConstant.AUDIT_LOGGER_NAME);
+
+  public static final String LOG = "log";
+  public static final String TYPE = "type";
+  public static final String AUDIT_LOG_DEVICE = "root.system.audit.'%s'";
+  public static final String TYPE_QUERY = "QUERY";
+  public static final String TYPE_LOGIN = "LOGIN";
+  public static final String TYPE_LOGOUT = "LOGOUT";
+  public static final String TYPE_INSERT = "INSERT";
+  public static final String TYPE_DELETE = "DELETE";
+  public static final String LOG_LEVEL_IOTDB = "IOTDB";
+  public static final String LOG_LEVEL_LOGGER = "LOGGER";
+  public static final String LOG_LEVEL_NONE = "NONE";
+
+  public static void writeAuditLog(String type, String log) {
+    IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
+    String auditLogStorage = config.getAuditLogStorage();
+    SessionManager instance = SessionManager.getInstance();
+    String username = instance.getUsername(instance.getCurrSessionId());

Review Comment:
   ```suggestion
       String username = instance.getCurrSession().getUsername();
   ```



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org