Skip to content

Commit 57a6119

Browse files
chore: refactor mismatch check to be clearer
1 parent 72d2b94 commit 57a6119

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

bottlecap/src/fips/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,21 @@ compile_error!("When building in fips mode, the default feature must be disabled
1515
pub fn runtime_layer_would_enable_fips_mode(region: &str) -> bool {
1616
let is_gov_region = region.starts_with("us-gov-");
1717

18+
// Note that we are defaulting to `is_gov_region` for this rather than a specific default
19+
// value. So if the `DD_LAMBDA_FIPS_MODE` environment is not set, we expect lambdas in govcloud
20+
// to be running the runtime layers in FIPS mode.
1821
env::var("DD_LAMBDA_FIPS_MODE")
1922
.map(|val| val.to_lowercase() == "true")
2023
.unwrap_or(is_gov_region)
2124
}
2225

23-
#[cfg(feature = "fips")]
24-
pub fn check_fips_mode_mismatch(region: &str) {
25-
let runtime_would_enable = runtime_layer_would_enable_fips_mode(region);
26-
if !runtime_would_enable {
27-
debug!("FIPS mode is enabled in this Extension layer but would be disabled in the runtime layer based on region and environment settings. Set DD_LAMBDA_FIPS_MODE=true or deploy the standard (non-FIPS) version of the Extension layer to ensure consistent FIPS behavior.");
28-
}
29-
}
30-
31-
#[cfg(not(feature = "fips"))]
3226
pub fn check_fips_mode_mismatch(region: &str) {
33-
let runtime_would_enable = runtime_layer_would_enable_fips_mode(region);
34-
if runtime_would_enable {
27+
if runtime_layer_would_enable_fips_mode(region) {
28+
#[cfg(not(feature = "fips"))]
3529
debug!("FIPS mode is disabled in this Extension layer but would be enabled in the runtime layer based on region and environment settings. Deploy the FIPS version of the Extension layer or set DD_LAMBDA_FIPS_MODE=false to ensure consistent FIPS behavior.");
30+
} else {
31+
#[cfg(feature = "fips")]
32+
debug!("FIPS mode is enabled in this Extension layer but would be disabled in the runtime layer based on region and environment settings. Set DD_LAMBDA_FIPS_MODE=true or deploy the standard (non-FIPS) version of the Extension layer to ensure consistent FIPS behavior.");
3633
}
3734
}
3835

0 commit comments

Comments
 (0)