github-advanced-security[bot] commented on code in PR #17402: URL: https://github.com/apache/dolphinscheduler/pull/17402#discussion_r2259863708
########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/JSONDescriptorParser.java: ########## @@ -0,0 +1,195 @@ +/* + * 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.plugin.task.grpc.protobufjs; + +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Enum; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Field; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Method; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Namespace; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.OneOf; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.ReflectionObject; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Root; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Service; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Type; + +import java.util.ArrayList; +import java.util.List; + +import com.google.protobuf.DescriptorProtos; +import com.google.protobuf.Descriptors; + +public class JSONDescriptorParser { + + public Descriptors.FileDescriptor buildDescriptor(Root root) throws Descriptors.DescriptorValidationException { + return parseRoot(root); + } + + private void parse(String name, ReflectionObject pbObject) { Review Comment: ## Useless parameter The parameter 'name' is never used. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5501) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/JSONDescriptorParser.java: ########## @@ -0,0 +1,195 @@ +/* + * 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.plugin.task.grpc.protobufjs; + +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Enum; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Field; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Method; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Namespace; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.OneOf; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.ReflectionObject; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Root; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Service; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Type; + +import java.util.ArrayList; +import java.util.List; + +import com.google.protobuf.DescriptorProtos; +import com.google.protobuf.Descriptors; + +public class JSONDescriptorParser { + + public Descriptors.FileDescriptor buildDescriptor(Root root) throws Descriptors.DescriptorValidationException { + return parseRoot(root); + } + + private void parse(String name, ReflectionObject pbObject) { Review Comment: ## Useless parameter The parameter 'pbObject' is never used. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5502) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Enum.java: ########## @@ -0,0 +1,28 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import java.util.Map; + +import lombok.Data; + +@Data Review Comment: ## Missing Override annotation This method overrides [ReflectionObject.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5505) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/OneOf.java: ########## @@ -0,0 +1,28 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import java.util.ArrayList; + +import lombok.Data; + +@Data Review Comment: ## Missing Override annotation This method overrides [ReflectionObject.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5510) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Method.java: ########## @@ -0,0 +1,30 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import lombok.Data; + +@Data Review Comment: ## Missing Override annotation This method overrides [ReflectionObject.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5508) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/MapField.java: ########## @@ -0,0 +1,26 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import lombok.Data; + +@Data Review Comment: ## Missing Override annotation This method overrides [Field.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5506) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/JSONDescriptorParser.java: ########## @@ -0,0 +1,195 @@ +/* + * 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.plugin.task.grpc.protobufjs; + +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Enum; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Field; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Method; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Namespace; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.OneOf; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.ReflectionObject; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Root; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Service; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.types.Type; + +import java.util.ArrayList; +import java.util.List; + +import com.google.protobuf.DescriptorProtos; +import com.google.protobuf.Descriptors; + +public class JSONDescriptorParser { + + public Descriptors.FileDescriptor buildDescriptor(Root root) throws Descriptors.DescriptorValidationException { + return parseRoot(root); + } + + private void parse(String name, ReflectionObject pbObject) { + + } + + private Namespace parseNamespace(Namespace ns) { + List<String> packageNameNS = new ArrayList<>(); Review Comment: ## Container contents are never accessed The contents of this container are never accessed. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5503) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Namespace.java: ########## @@ -0,0 +1,36 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import java.util.Map; + +import lombok.Data; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@Data Review Comment: ## Missing Override annotation This method overrides [ReflectionObject.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5509) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Root.java: ########## @@ -0,0 +1,27 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import lombok.Data; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@Data Review Comment: ## Missing Override annotation This method overrides [Namespace.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5512) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/GrpcTask.java: ########## @@ -0,0 +1,148 @@ +/* + * 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.plugin.task.grpc; + +import static java.util.Objects.isNull; + +import org.apache.dolphinscheduler.common.utils.JSONUtils; +import org.apache.dolphinscheduler.plugin.task.api.AbstractTask; +import org.apache.dolphinscheduler.plugin.task.api.TaskCallBack; +import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; +import org.apache.dolphinscheduler.plugin.task.api.TaskException; +import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; +import org.apache.dolphinscheduler.plugin.task.api.enums.DataType; +import org.apache.dolphinscheduler.plugin.task.api.enums.Direct; +import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.GrpcDynamicService; +import org.apache.dolphinscheduler.plugin.task.grpc.protobufjs.JSONDescriptorHelper; + +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import com.google.protobuf.Descriptors; +import com.google.protobuf.DynamicMessage; +import com.google.protobuf.util.JsonFormat; +import com.google.protobuf.util.JsonFormat.Printer; + +import io.grpc.ManagedChannel; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; + +@Slf4j +public class GrpcTask extends AbstractTask { + + private GrpcParameters grpcParameters; + private TaskExecutionContext taskExecutionContext; + + /** + * constructor + * + * @param taskExecutionContext taskExecutionContext + */ + protected GrpcTask(TaskExecutionContext taskExecutionContext) { + super(taskExecutionContext); + this.taskExecutionContext = taskExecutionContext; + } + + @Override + public void init() { + this.grpcParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), GrpcParameters.class); + log.info("Initialize gRPC task params: {}", JSONUtils.toPrettyJsonString(grpcParameters)); + + if (grpcParameters == null || !grpcParameters.checkParameters()) { + throw new RuntimeException("gRPC task params is not valid"); + } + } + + @Override + public void handle(TaskCallBack taskCallBack) throws TaskException { + try { + ManagedChannel channel = + isNull(this.channel) ? GrpcDynamicService.ChannelFactory.createChannel(grpcParameters.getUrl()) + : this.channel; Review Comment: ## Possible confusion of local and field Potentially confusing name: method [handle](1) also refers to field [channel](2) (as this.channel). [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5504) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Field.java: ########## @@ -0,0 +1,37 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import java.util.Map; + +import lombok.Data; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +@Data Review Comment: ## Missing Override annotation This method overrides [ReflectionObject.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5507) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Service.java: ########## @@ -0,0 +1,28 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import java.util.Map; + +import lombok.Data; + +@Data Review Comment: ## Missing Override annotation This method overrides [Namespace.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5511) ########## dolphinscheduler-task-plugin/dolphinscheduler-task-grpc/src/main/java/org/apache/dolphinscheduler/plugin/task/grpc/protobufjs/types/Type.java: ########## @@ -0,0 +1,29 @@ +/* + * 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.plugin.task.grpc.protobufjs.types; + +import java.util.Map; + +import lombok.Data; + +@Data Review Comment: ## Missing Override annotation This method overrides [Namespace.canEqual](1); it is advisable to add an Override annotation. [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5513) -- 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]
