Skip to content
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

chore(s3util): add allowFipsEndpoint option in validateArnRegion #3962

Merged
merged 2 commits into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/next-release/feature-s3util-4a5bd10b.json
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "s3util",
"description": "Add allowFipsEndpoint option in validateArnRegion"
}
19 changes: 14 additions & 5 deletions lib/services/s3util.js
Expand Up @@ -132,11 +132,16 @@ var s3util = {
/**
* Validate region field in ARN supplied in Bucket parameter is a valid region
*/
validateArnRegion: function validateArnRegion(req) {
validateArnRegion: function validateArnRegion(req, options) {
if (options === undefined) {
options = {};
}

var useArnRegion = s3util.loadUseArnRegionConfig(req);
var regionFromArn = req._parsedArn.region;
var clientRegion = req.service.config.region;
var useFipsEndpoint = req.service.config.useFipsEndpoint;
var allowFipsEndpoint = options.allowFipsEndpoint || false;

if (!regionFromArn) {
throw AWS.util.error(new Error(), {
Expand All @@ -145,16 +150,20 @@ var s3util = {
});
}

if (
useFipsEndpoint ||
regionFromArn.indexOf('fips') >= 0
) {
if (useFipsEndpoint && !allowFipsEndpoint) {
throw AWS.util.error(new Error(), {
code: 'InvalidConfiguration',
message: 'ARN endpoint is not compatible with FIPS region'
});
}

if (regionFromArn.indexOf('fips') >= 0) {
throw AWS.util.error(new Error(), {
code: 'InvalidConfiguration',
message: 'FIPS region not allowed in ARN'
});
}

if (!useArnRegion && regionFromArn !== clientRegion) {
throw AWS.util.error(new Error(), {
code: 'InvalidConfiguration',
Expand Down