Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bottlecap/src/appsec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod processor;
/// Determines whether the Serverless App & API Protection features are enabled.
#[must_use]
pub const fn is_enabled(cfg: &Config) -> bool {
cfg.serverless_appsec_enabled
cfg.ext.serverless_appsec_enabled
}

/// Determines whether APM is only used as a transport for App & API Protection,
Expand Down
52 changes: 32 additions & 20 deletions bottlecap/src/appsec/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ impl Processor {
Ok(Self {
handle,
ruleset_version,
waf_timeout: cfg.appsec_waf_timeout,
api_sec_sampler: if cfg.api_security_enabled {
waf_timeout: cfg.ext.appsec_waf_timeout,
api_sec_sampler: if cfg.ext.api_security_enabled {
Some(Arc::new(Mutex::new(apisec::Sampler::with_interval(
cfg.api_security_sample_delay,
cfg.ext.api_security_sample_delay,
))))
} else {
None
Expand Down Expand Up @@ -215,7 +215,7 @@ impl Processor {
/// the default built-in ruleset if the [`Config::appsec_rules`] field is
/// [`None`].
fn get_rules(cfg: &Config) -> Result<WafMap, Error> {
if let Some(ref rules) = cfg.appsec_rules {
if let Some(ref rules) = cfg.ext.appsec_rules {
let file = File::open(rules).map_err(|e| Error::AppsecRulesError(rules.clone(), e))?;
serde_json::from_reader(file)
} else {
Expand Down Expand Up @@ -716,7 +716,10 @@ mod tests {
#[test]
fn test_new_with_default_config() {
let config = Config {
serverless_appsec_enabled: true,
ext: crate::config::LambdaConfig {
serverless_appsec_enabled: true,
..Default::default()
},
..Config::default()
};
let _ = Processor::new(&config).expect("Should not fail");
Expand All @@ -725,7 +728,10 @@ mod tests {
#[test]
fn test_new_disabled() {
let config = Config {
serverless_appsec_enabled: false, // Explicitly testing this condition
ext: crate::config::LambdaConfig {
serverless_appsec_enabled: false, // Explicitly testing this condition
..Default::default()
},
..Config::default()
};
assert!(matches!(
Expand All @@ -739,13 +745,16 @@ mod tests {
let tmp = tempfile::NamedTempFile::new().expect("Failed to create tempfile");

let config = Config {
serverless_appsec_enabled: true,
appsec_rules: Some(
tmp.path()
.to_str()
.expect("Failed to get tempfile path")
.to_string(),
),
ext: crate::config::LambdaConfig {
serverless_appsec_enabled: true,
appsec_rules: Some(
tmp.path()
.to_str()
.expect("Failed to get tempfile path")
.to_string(),
),
..Default::default()
},
..Config::default()
};
assert!(matches!(
Expand Down Expand Up @@ -797,13 +806,16 @@ mod tests {
tmp.flush().expect("Failed to flush temp file");

let config = Config {
serverless_appsec_enabled: true,
appsec_rules: Some(
tmp.path()
.to_str()
.expect("Failed to get tempfile path")
.to_string(),
),
ext: crate::config::LambdaConfig {
serverless_appsec_enabled: true,
appsec_rules: Some(
tmp.path()
.to_str()
.expect("Failed to get tempfile path")
.to_string(),
),
..Default::default()
},
..Config::default()
};
let result = Processor::new(&config);
Expand Down
17 changes: 11 additions & 6 deletions bottlecap/src/bin/bottlecap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ fn create_api_key_factory(
let config = Arc::clone(config);
let aws_config = Arc::clone(aws_config);
let client = client.clone();
let api_key_secret_reload_interval = config.api_key_secret_reload_interval;
let api_key_secret_reload_interval = config.ext.api_key_secret_reload_interval;

Arc::new(ApiKeyFactory::new_from_resolver(
Arc::new(move || {
Expand Down Expand Up @@ -398,7 +398,7 @@ async fn extension_loop_active(
&aws_config.runtime_api,
logs_agent_channel,
event_bus_tx.clone(),
config.serverless_logs_enabled,
config.ext.serverless_logs_enabled,
aws_config.is_managed_instance_mode(),
)
.await?;
Expand All @@ -412,7 +412,8 @@ async fn extension_loop_active(
);

// Validate and get the appropriate flush strategy for the current mode
let flush_strategy = get_flush_strategy_for_mode(&aws_config, config.serverless_flush_strategy);
let flush_strategy =
get_flush_strategy_for_mode(&aws_config, config.ext.serverless_flush_strategy);
debug!("Flush strategy: {:?}", flush_strategy);
let mut flush_control = FlushControl::new(flush_strategy, config.flush_timeout);

Expand Down Expand Up @@ -1222,19 +1223,23 @@ async fn start_dogstatsd(
) {
// Start aggregator service and handle
let start_time = Instant::now();
let enrichment_tags = if config.custom_metrics_exclude_tags.is_empty() {
let enrichment_tags = if config.ext.custom_metrics_exclude_tags.is_empty() {
tags_provider.get_tags_string()
} else {
debug!(
"Excluding tags from custom metrics: {:?}",
config.custom_metrics_exclude_tags
config.ext.custom_metrics_exclude_tags
);
tags_provider
.get_tags_vec()
.into_iter()
.filter(|tag| {
let key = tag.split(':').next().unwrap_or("");
!config.custom_metrics_exclude_tags.iter().any(|e| e == key)
!config
.ext
.custom_metrics_exclude_tags
.iter()
.any(|e| e == key)
})
.collect::<Vec<_>>()
.join(",")
Expand Down
129 changes: 0 additions & 129 deletions bottlecap/src/config/additional_endpoints.rs

This file was deleted.

71 changes: 0 additions & 71 deletions bottlecap/src/config/apm_replace_rule.rs

This file was deleted.

Loading
Loading