-
Notifications
You must be signed in to change notification settings - Fork 4.6k
🐛Destination-dynamodb: enforce ssl connection #18672
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
Merged
etsybaev
merged 12 commits into
master
from
etsybaev/16283-destination-dynamodb-enforce-ssl-connection
Nov 3, 2022
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ea39075
[16283] Destination-dynamodb: enforce ssl connection
etsybaev cc52c13
Minor refactor
etsybaev c2073c4
Merge branch 'master' into etsybaev/16283-destination-dynamodb-enforc…
etsybaev 75f13db
bumped version
etsybaev 24e8d3e
auto-bump connector version
octavia-squidington-iii d687af8
Added strict-encrypt runner
etsybaev 35b6bca
minor refactor
etsybaev 6178874
minor fix
etsybaev 528f3a8
Merge branch 'master' into etsybaev/16283-destination-dynamodb-enforc…
etsybaev 6688844
Merge branch 'master' into etsybaev/16283-destination-dynamodb-enforc…
etsybaev 5baf6be
Bumped versino
etsybaev 127dcd4
auto-bump connector version
octavia-squidington-iii 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
18 changes: 18 additions & 0 deletions
18
...src/main/java/io/airbyte/integrations/destination/dynamodb/DynamodbDestinationRunner.java
This file contains hidden or 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,18 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.dynamodb; | ||
|
||
import io.airbyte.integrations.base.adaptive.AdaptiveDestinationRunner; | ||
|
||
public class DynamodbDestinationRunner { | ||
|
||
public static void main(final String[] args) throws Exception { | ||
AdaptiveDestinationRunner.baseOnEnv() | ||
.withOssDestination(DynamodbDestination::new) | ||
.withCloudDestination(DynamodbDestinationStrictEncrypt::new) | ||
.run(args); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...n/java/io/airbyte/integrations/destination/dynamodb/DynamodbDestinationStrictEncrypt.java
This file contains hidden or 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,45 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.dynamodb; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.protocol.models.AirbyteConnectionStatus; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DynamodbDestinationStrictEncrypt extends DynamodbDestination { | ||
|
||
private static final String NON_SECURE_URL_ERR_MSG = "Server Endpoint requires HTTPS"; | ||
private static final Logger LOGGER = LoggerFactory.getLogger(DynamodbDestinationStrictEncrypt.class); | ||
|
||
public DynamodbDestinationStrictEncrypt() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public AirbyteConnectionStatus check(final JsonNode config) { | ||
try { | ||
final DynamodbDestinationConfig dynamodbDestinationConfig = | ||
DynamodbDestinationConfig.getDynamodbDestinationConfig(config); | ||
|
||
// enforce ssl connection | ||
if (!DynamodbChecker.testCustomEndpointSecured(dynamodbDestinationConfig.getEndpoint())) { | ||
return new AirbyteConnectionStatus() | ||
.withStatus(AirbyteConnectionStatus.Status.FAILED) | ||
.withMessage(NON_SECURE_URL_ERR_MSG); | ||
} | ||
|
||
DynamodbChecker.attemptDynamodbWriteAndDelete(dynamodbDestinationConfig); | ||
return new AirbyteConnectionStatus().withStatus(AirbyteConnectionStatus.Status.SUCCEEDED); | ||
} catch (final Exception e) { | ||
LOGGER.error("Exception attempting to access the DynamoDB table: ", e); | ||
return new AirbyteConnectionStatus() | ||
.withStatus(AirbyteConnectionStatus.Status.FAILED) | ||
.withMessage("Could not connect to the DynamoDB table with the provided configuration. \n" + e | ||
.getMessage()); | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...va/io/airbyte/integrations/destination/dynamodb/DynamodbDestinationStrictEncryptTest.java
This file contains hidden or 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,40 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.dynamodb; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.protocol.models.AirbyteConnectionStatus; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class DynamodbDestinationStrictEncryptTest { | ||
|
||
private static final String NON_SECURE_URL_ERR_MSG = "Server Endpoint requires HTTPS"; | ||
etsybaev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Test that checks if user is using a connection that is HTTPS only | ||
*/ | ||
@Test | ||
public void checksCustomEndpointIsHttpsOnly() { | ||
etsybaev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
final DynamodbDestination destinationWithHttpsOnlyEndpoint = new DynamodbDestinationStrictEncrypt(); | ||
final AirbyteConnectionStatus status = destinationWithHttpsOnlyEndpoint.check(getUnsecureConfig()); | ||
assertEquals(AirbyteConnectionStatus.Status.FAILED, status.getStatus()); | ||
assertEquals(NON_SECURE_URL_ERR_MSG, status.getMessage()); | ||
} | ||
|
||
protected JsonNode getUnsecureConfig() { | ||
return Jsons.jsonNode(ImmutableMap.builder() | ||
.put("dynamodb_endpoint", "http://testurl.com:9000") | ||
.put("dynamodb_table_name_prefix", "integration-test") | ||
.put("dynamodb_region", "us-east-2") | ||
.put("access_key_id", "dummy_access_key_id") | ||
.put("secret_access_key", "dummy_secret_access_key") | ||
.build()); | ||
} | ||
|
||
} |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.