-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DSIP-26][Audit log] Audit log improvement design #15554
Merged
Merged
Changes from all commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
771e934
init
qingwli 844585a
update
qingwli 27277f8
Merge branch 'dev' into augit-log
qingwli c95faa4
support multi codes
qingwli e79ff87
update
qingwli a68357c
update
qingwli 6fd8671
update
qingwli 1eb5d03
update audit log ui
yeahhhz 1de52c1
fix
yeahhhz f46860a
Merge pull request #3 from yeahhhz/audit-log-2
qingwli bbb785b
update object name
yeahhhz a7017f1
Merge pull request #4 from yeahhhz/audit-log-3
qingwli 91432e5
update
qingwli 51ee4d3
Merge remote-tracking branch 'upstream/dev' into augit-log
qingwli 20b0085
update
qingwli adf4651
update
qingwli 5aff032
update
qingwli 29ed211
update
qingwli 7ff0a50
update
qingwli 4a3558a
update
qingwli 6aeec45
update
qingwli 133a6cc
update
qingwli bc34a49
Merge branch 'dev' into audit-log
qingwli 9a3ef75
update
qingwli 1214761
Merge branch 'audit-log' of https://github.com/qingwli/dolphinschedul…
qingwli b6d08ed
update
qingwli 9c8eab8
update
qingwli c223d28
fix code smell
qingwli 9fdcafe
Merge branch 'dev' into audit-log
qingwli 625e7bc
update
qingwli 3f933c6
Merge branch 'dev' into audit-log
qingwli 5e39e4e
update
qingwli 1fd6e65
Merge branch 'audit-log' of https://github.com/qingwli/dolphinschedul…
qingwli c885883
Merge remote-tracking branch 'origin/dev' into audit-log
qingwli b75f927
update
qingwli 81be755
update
qingwli 0d9dd8d
Merge branch 'dev' into audit-log
rickchengx 53a2079
Merge branch 'dev' into audit-log
qingwli a7ab53f
Merge branch 'dev' into audit-log
qingwli 83bda8e
add 3.3.0 upgrade sql
qingwli ce0e1ba
Merge branch 'dev' into audit-log
qingwli bae273e
Merge branch 'dev' into audit-log
qingwli 10f380d
Merge branch 'dev' into audit-log
qingwli 82222a5
Merge branch 'dev' into audit-log
qingwli 94f9fd3
update
qingwli d499513
Merge branch 'audit-log' of https://github.com/qingwli/dolphinschedul…
qingwli b56e74c
Merge branch 'dev' into audit-log
qingwli 7a4f833
update
qingwli 44874bd
Update dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler…
qingwli 8f1c06e
update
qingwli 4eebc90
update
qingwli beb529f
update
qingwli 1411b3e
update audit ui
yeahhhz ccd0699
Merge pull request #5 from yeahhhz/audit-ui-update
qingwli 0f17a77
update
qingwli 066c0ec
Merge branch 'dev' into audit-log
qingwli 963825b
fix
qingwli 3ee0fcd
Merge branch 'audit-log' of https://github.com/qingwli/dolphinschedul…
qingwli 23680a9
Merge branch 'dev' into audit-log
qingwli 0eee722
Merge branch 'dev' into audit-log
qingwli 7e6650f
Merge branch 'dev' into audit-log
qingwli ec07e92
fix
qingwli 90c36a3
update
qingwli 72b2fae
Merge branch 'dev' into audit-log
qingwli c324855
update
qingwli ad89230
Merge branch 'dev' into audit-log
qingwli ff24270
fix
qingwli f79d6fe
Merge branch 'audit-log' of https://github.com/qingwli/dolphinschedul…
qingwli 3430054
test
qingwli ddad807
update
qingwli 836c978
Merge branch 'dev' into audit-log
qingwli d8c1241
update
qingwli 36332ea
Merge branch 'audit-log' of https://github.com/qingwli/dolphinschedul…
qingwli a584530
Merge branch 'dev' into audit-log
qingwli 3b7f63c
update
qingwli 84df67e
update
qingwli 549b985
update
qingwli 847f193
change object -> model
qingwli ed57b8b
Merge branch 'dev' into audit-log
qingwli 91ae786
Merge branch 'dev' into audit-log
qingwli 61f5f50
Merge branch 'dev' into audit-log
qingwli c7e8ecd
Merge branch 'dev' into audit-log
qingwli a7f137a
Merge branch 'dev' into audit-log
qingwli ce108d8
Merge branch 'dev' into audit-log
qingwli cc5de74
Merge branch 'dev' into audit-log
qingwli 5e881fc
update
qingwli 8e0613b
Merge branch 'dev' into audit-log
ruanwenjun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 0 additions & 96 deletions
96
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/AuditMessage.java
This file was deleted.
Oops, something went wrong.
92 changes: 0 additions & 92 deletions
92
...cheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/AuditPublishService.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/OperatorLog.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,39 @@ | ||
/* | ||
* 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.dolphinscheduler.api.audit; | ||
|
||
import org.apache.dolphinscheduler.api.audit.enums.AuditType; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Custom annotation for logging and auditing operator actions in the system. | ||
* This annotation can be applied to methods to indicate the type of operation, object type, | ||
* and specific parameters to be recorded in the logs. | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface OperatorLog { | ||
|
||
AuditType auditType(); | ||
} |
61 changes: 61 additions & 0 deletions
61
...nscheduler-api/src/main/java/org/apache/dolphinscheduler/api/audit/OperatorLogAspect.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,61 @@ | ||
/* | ||
* 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.dolphinscheduler.api.audit; | ||
|
||
import org.apache.dolphinscheduler.api.audit.operator.AuditOperator; | ||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Pointcut; | ||
import org.aspectj.lang.reflect.MethodSignature; | ||
import org.springframework.stereotype.Component; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
|
||
@Aspect | ||
@Slf4j | ||
@Component | ||
public class OperatorLogAspect { | ||
|
||
@Pointcut("@annotation(org.apache.dolphinscheduler.api.audit.OperatorLog)") | ||
public void logPointCut() { | ||
} | ||
|
||
@Around("logPointCut()") | ||
public Object around(ProceedingJoinPoint point) throws Throwable { | ||
MethodSignature signature = (MethodSignature) point.getSignature(); | ||
Method method = signature.getMethod(); | ||
|
||
OperatorLog operatorLog = method.getAnnotation(OperatorLog.class); | ||
|
||
Operation operation = method.getAnnotation(Operation.class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't find the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (operation == null) { | ||
log.warn("Operation is null of method: {}", method.getName()); | ||
return point.proceed(); | ||
} | ||
|
||
AuditOperator operator = SpringApplicationContext.getBean(operatorLog.auditType().getOperatorClass()); | ||
return operator.recordAudit(point, operation.description(), operatorLog.auditType()); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we choose to do auditing with AOP, one important thing is exception handling. If there are bugs / defects in aspect code, it could cause trouble across all the related methods with the audit annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, so please help point the place needs more logic to avoid issue