This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.18.x by this push:
new 3947ca996254 CAMEL-24203: camel-aws-security-hub - implement the
declared getFindingAggregator operation (4.18.x backport) (#24973)
3947ca996254 is described below
commit 3947ca9962542423894a139ecbc3c3e1532afe7b
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue Jul 21 11:21:38 2026 +0200
CAMEL-24203: camel-aws-security-hub - implement the declared
getFindingAggregator operation (4.18.x backport) (#24973)
Backport of #24940 to camel-4.18.x.
Co-authored-by: Claude Fable 5 <[email protected]>
---
.../camel/catalog/components/aws-security-hub.json | 3 +-
.../camel-aws/camel-aws-security-hub/pom.xml | 6 ++
.../aws/securityhub/aws-security-hub.json | 3 +-
.../aws/securityhub/SecurityHubConstants.java | 4 ++
.../aws/securityhub/SecurityHubProducer.java | 23 ++++++++
.../SecurityHubGetFindingAggregatorTest.java | 67 ++++++++++++++++++++++
.../dsl/SecurityHubEndpointBuilderFactory.java | 13 +++++
7 files changed, 117 insertions(+), 2 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-security-hub.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-security-hub.json
index 7523361ebd04..256d93b03c25 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-security-hub.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-security-hub.json
@@ -68,7 +68,8 @@
"CamelAwsSecurityHubUnprocessedFindings": { "index": 17, "kind": "header",
"displayName": "", "group": "batchUpdateFindings", "label":
"batchUpdateFindings", "required": false, "javaType":
"List<BatchUpdateFindingsUnprocessedFinding>", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
list of findings that were not updated", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#UNPROCESSED_FINDINGS"
},
"CamelAwsSecurityHubProcessedFindings": { "index": 18, "kind": "header",
"displayName": "", "group": "batchUpdateFindings", "label":
"batchUpdateFindings", "required": false, "javaType":
"List<AwsSecurityFindingIdentifier>", "deprecated": false, "deprecationNote":
"", "autowired": false, "secret": false, "description": "The list of findings
that were updated successfully", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#PROCESSED_FINDINGS"
},
"CamelAwsSecurityHubFindingId": { "index": 19, "kind": "header",
"displayName": "", "group": "getFindingHistory", "label": "getFindingHistory",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
finding ID to get history for", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#FINDING_ID" },
- "CamelAwsSecurityHubProductArn": { "index": 20, "kind": "header",
"displayName": "", "group": "getFindingHistory", "label": "getFindingHistory",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
product ARN for the finding", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#PRODUCT_ARN" }
+ "CamelAwsSecurityHubProductArn": { "index": 20, "kind": "header",
"displayName": "", "group": "getFindingHistory", "label": "getFindingHistory",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
product ARN for the finding", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#PRODUCT_ARN" },
+ "CamelAwsSecurityHubFindingAggregatorArn": { "index": 21, "kind":
"header", "displayName": "", "group": "getFindingAggregator", "label":
"getFindingAggregator", "required": false, "javaType": "String", "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"description": "The ARN of the finding aggregator to retrieve", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#FINDING_AGGREGATOR_ARN"
}
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Logical name" },
diff --git a/components/camel-aws/camel-aws-security-hub/pom.xml
b/components/camel-aws/camel-aws-security-hub/pom.xml
index 9b4ede396348..637b4c08cfab 100644
--- a/components/camel-aws/camel-aws-security-hub/pom.xml
+++ b/components/camel-aws/camel-aws-security-hub/pom.xml
@@ -70,6 +70,12 @@
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito-version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- test infra -->
<dependency>
<groupId>org.apache.camel</groupId>
diff --git
a/components/camel-aws/camel-aws-security-hub/src/generated/resources/META-INF/org/apache/camel/component/aws/securityhub/aws-security-hub.json
b/components/camel-aws/camel-aws-security-hub/src/generated/resources/META-INF/org/apache/camel/component/aws/securityhub/aws-security-hub.json
index 7523361ebd04..256d93b03c25 100644
---
a/components/camel-aws/camel-aws-security-hub/src/generated/resources/META-INF/org/apache/camel/component/aws/securityhub/aws-security-hub.json
+++
b/components/camel-aws/camel-aws-security-hub/src/generated/resources/META-INF/org/apache/camel/component/aws/securityhub/aws-security-hub.json
@@ -68,7 +68,8 @@
"CamelAwsSecurityHubUnprocessedFindings": { "index": 17, "kind": "header",
"displayName": "", "group": "batchUpdateFindings", "label":
"batchUpdateFindings", "required": false, "javaType":
"List<BatchUpdateFindingsUnprocessedFinding>", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
list of findings that were not updated", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#UNPROCESSED_FINDINGS"
},
"CamelAwsSecurityHubProcessedFindings": { "index": 18, "kind": "header",
"displayName": "", "group": "batchUpdateFindings", "label":
"batchUpdateFindings", "required": false, "javaType":
"List<AwsSecurityFindingIdentifier>", "deprecated": false, "deprecationNote":
"", "autowired": false, "secret": false, "description": "The list of findings
that were updated successfully", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#PROCESSED_FINDINGS"
},
"CamelAwsSecurityHubFindingId": { "index": 19, "kind": "header",
"displayName": "", "group": "getFindingHistory", "label": "getFindingHistory",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
finding ID to get history for", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#FINDING_ID" },
- "CamelAwsSecurityHubProductArn": { "index": 20, "kind": "header",
"displayName": "", "group": "getFindingHistory", "label": "getFindingHistory",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
product ARN for the finding", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#PRODUCT_ARN" }
+ "CamelAwsSecurityHubProductArn": { "index": 20, "kind": "header",
"displayName": "", "group": "getFindingHistory", "label": "getFindingHistory",
"required": false, "javaType": "String", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "description": "The
product ARN for the finding", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#PRODUCT_ARN" },
+ "CamelAwsSecurityHubFindingAggregatorArn": { "index": 21, "kind":
"header", "displayName": "", "group": "getFindingAggregator", "label":
"getFindingAggregator", "required": false, "javaType": "String", "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": false,
"description": "The ARN of the finding aggregator to retrieve", "constantName":
"org.apache.camel.component.aws.securityhub.SecurityHubConstants#FINDING_AGGREGATOR_ARN"
}
},
"properties": {
"label": { "index": 0, "kind": "path", "displayName": "Label", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "Logical name" },
diff --git
a/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubConstants.java
b/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubConstants.java
index e4c52e045c24..1cefa249b9e7 100644
---
a/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubConstants.java
+++
b/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubConstants.java
@@ -97,4 +97,8 @@ public interface SecurityHubConstants {
@Metadata(label = "getFindingHistory",
description = "The product ARN for the finding", javaType =
"String")
String PRODUCT_ARN = "CamelAwsSecurityHubProductArn";
+
+ @Metadata(label = "getFindingAggregator",
+ description = "The ARN of the finding aggregator to retrieve",
javaType = "String")
+ String FINDING_AGGREGATOR_ARN = "CamelAwsSecurityHubFindingAggregatorArn";
}
diff --git
a/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubProducer.java
b/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubProducer.java
index 94021b52cca0..b53168d3fc96 100644
---
a/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubProducer.java
+++
b/components/camel-aws/camel-aws-security-hub/src/main/java/org/apache/camel/component/aws/securityhub/SecurityHubProducer.java
@@ -45,6 +45,7 @@ import
software.amazon.awssdk.services.securityhub.model.BatchUpdateFindingsRequ
import
software.amazon.awssdk.services.securityhub.model.BatchUpdateFindingsResponse;
import software.amazon.awssdk.services.securityhub.model.DescribeHubRequest;
import software.amazon.awssdk.services.securityhub.model.DescribeHubResponse;
+import
software.amazon.awssdk.services.securityhub.model.GetFindingAggregatorRequest;
import
software.amazon.awssdk.services.securityhub.model.GetFindingHistoryRequest;
import
software.amazon.awssdk.services.securityhub.model.GetFindingHistoryResponse;
import software.amazon.awssdk.services.securityhub.model.GetFindingsRequest;
@@ -94,6 +95,9 @@ public class SecurityHubProducer extends DefaultProducer {
case listEnabledProductsForImport:
listEnabledProductsForImport(getEndpoint().getSecurityHubClient(), exchange);
break;
+ case getFindingAggregator:
+ getFindingAggregator(getEndpoint().getSecurityHubClient(),
exchange);
+ break;
default:
throw new IllegalArgumentException("Unsupported operation");
}
@@ -292,6 +296,25 @@ public class SecurityHubProducer extends DefaultProducer {
});
}
+ private void getFindingAggregator(SecurityHubClient securityHubClient,
Exchange exchange)
+ throws InvalidPayloadException {
+ executeOperation(
+ exchange,
+ GetFindingAggregatorRequest.class,
+ securityHubClient::getFindingAggregator,
+ () -> {
+ String findingAggregatorArn
+ =
exchange.getIn().getHeader(SecurityHubConstants.FINDING_AGGREGATOR_ARN,
String.class);
+ if (ObjectHelper.isEmpty(findingAggregatorArn)) {
+ throw new IllegalArgumentException("Finding Aggregator
ARN must be specified");
+ }
+ GetFindingAggregatorRequest.Builder builder =
GetFindingAggregatorRequest.builder();
+ builder.findingAggregatorArn(findingAggregatorArn);
+ return
securityHubClient.getFindingAggregator(builder.build());
+ },
+ "Get Finding Aggregator");
+ }
+
private void describeHub(SecurityHubClient securityHubClient, Exchange
exchange) throws InvalidPayloadException {
executeOperation(
exchange,
diff --git
a/components/camel-aws/camel-aws-security-hub/src/test/java/org/apache/camel/component/aws/securityhub/SecurityHubGetFindingAggregatorTest.java
b/components/camel-aws/camel-aws-security-hub/src/test/java/org/apache/camel/component/aws/securityhub/SecurityHubGetFindingAggregatorTest.java
new file mode 100644
index 000000000000..daff1572e2c9
--- /dev/null
+++
b/components/camel-aws/camel-aws-security-hub/src/test/java/org/apache/camel/component/aws/securityhub/SecurityHubGetFindingAggregatorTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.camel.component.aws.securityhub;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+import software.amazon.awssdk.services.securityhub.SecurityHubClient;
+import
software.amazon.awssdk.services.securityhub.model.GetFindingAggregatorRequest;
+import
software.amazon.awssdk.services.securityhub.model.GetFindingAggregatorResponse;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class SecurityHubGetFindingAggregatorTest extends CamelTestSupport {
+
+ private static final String AGGREGATOR_ARN
+ =
"arn:aws:securityhub:eu-west-1:123456789012:finding-aggregator/abcd";
+
+ @BindToRegistry("securityHubClient")
+ private final SecurityHubClient securityHubClient =
mock(SecurityHubClient.class);
+
+ @Test
+ public void getFindingAggregatorIsSupportedAndUsesTheArnHeader() throws
Exception {
+
when(securityHubClient.getFindingAggregator(any(GetFindingAggregatorRequest.class)))
+
.thenReturn(GetFindingAggregatorResponse.builder().findingAggregatorArn(AGGREGATOR_ARN).build());
+
+ // Before the fix this operation fell through to "Unsupported
operation".
+ template.send("direct:start",
+ exchange ->
exchange.getIn().setHeader(SecurityHubConstants.FINDING_AGGREGATOR_ARN,
AGGREGATOR_ARN));
+
+ ArgumentCaptor<GetFindingAggregatorRequest> captor
+ = ArgumentCaptor.forClass(GetFindingAggregatorRequest.class);
+ verify(securityHubClient).getFindingAggregator(captor.capture());
+ assertEquals(AGGREGATOR_ARN, captor.getValue().findingAggregatorArn());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+
.to("aws-security-hub://test?securityHubClient=#securityHubClient&operation=getFindingAggregator");
+ }
+ };
+ }
+}
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecurityHubEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecurityHubEndpointBuilderFactory.java
index 11bb46e37e43..469351d0f84b 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecurityHubEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SecurityHubEndpointBuilderFactory.java
@@ -853,6 +853,19 @@ public interface SecurityHubEndpointBuilderFactory {
public String awsSecurityHubProductArn() {
return "CamelAwsSecurityHubProductArn";
}
+ /**
+ * The ARN of the finding aggregator to retrieve.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: getFindingAggregator
+ *
+ * @return the name of the header {@code
+ * AwsSecurityHubFindingAggregatorArn}.
+ */
+ public String awsSecurityHubFindingAggregatorArn() {
+ return "CamelAwsSecurityHubFindingAggregatorArn";
+ }
}
static SecurityHubEndpointBuilder endpointBuilder(String componentName,
String path) {
class SecurityHubEndpointBuilderImpl extends AbstractEndpointBuilder
implements SecurityHubEndpointBuilder, AdvancedSecurityHubEndpointBuilder {