github-code-scanning[bot] commented on code in PR #12076:
URL: https://github.com/apache/dolphinscheduler/pull/12076#discussion_r996627893
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java:
##########
@@ -112,14 +120,20 @@
return result;
}
- Resource resource = resourceMapper.selectById(resourceId);
- if (resource == null) {
- logger.error("Resource does not exist, resourceId:{}.",
resourceId);
+ Boolean existResource = false;
+ try {
+ existResource = storageOperate.exists(fullName);
+ } catch (IOException e) {
+ logger.error("AmazonServiceException when checking resource: " +
fullName);
+ }
+
+ if (!existResource) {
+ logger.error("resource full name {} is not exist", fullName);
Review Comment:
## Logging should not be vulnerable to injection attacks
<!--SONAR_ISSUE_KEY:AYPkb5rB3zqccheRFO5r-->Change this code to not log
user-controlled data. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AYPkb5rB3zqccheRFO5r&open=AYPkb5rB3zqccheRFO5r&pullRequest=12076">SonarCloud</a></p>
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1887)
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java:
##########
@@ -243,13 +261,24 @@
}
}
- Resource resource = resourceMapper.selectById(resourceId);
- if (resource == null) {
- logger.error("Resource does not exist, resourceId:{}.",
resourceId);
+ // Resource resource = resourceMapper.selectById(resourceId);
+ Boolean doesResExist = false;
+ try {
+ doesResExist = storageOperate.exists(fullName);
+ } catch (Exception e) {
+ logger.error("udf resource checking error", fullName);
result.setCode(Status.RESOURCE_NOT_EXIST.getCode());
result.setMsg(Status.RESOURCE_NOT_EXIST.getMsg());
return result;
}
+
+ if (!doesResExist) {
+ logger.error("resource full name {} is not exist", fullName);
Review Comment:
## Logging should not be vulnerable to injection attacks
<!--SONAR_ISSUE_KEY:AYPkb5rB3zqccheRFO5q-->Change this code to not log
user-controlled data. <p>See more on <a
href="https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AYPkb5rB3zqccheRFO5q&open=AYPkb5rB3zqccheRFO5q&pullRequest=12076">SonarCloud</a></p>
[Show more
details](https://github.com/apache/dolphinscheduler/security/code-scanning/1888)
--
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]