Skip to content

Commit 2ec14e9

Browse files
committed
add partial appsec processor
1 parent 192339e commit 2ec14e9

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

bottlecap/src/appsec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env;
22

33
use crate::config::Config;
44

5-
// pub mod processor;
5+
pub mod processor;
66

77
#[must_use]
88
pub fn is_enabled(config: &Config) -> bool {

bottlecap/src/appsec/processor.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use std::sync::Arc;
2+
3+
use crate::appsec::{get_rules, is_enabled, is_standalone};
4+
use crate::config::Config;
5+
6+
use libddwaf::WafInstance;
7+
use tracing::{debug, info};
8+
9+
pub struct Processor {
10+
_config: Arc<Config>,
11+
_handle: WafInstance,
12+
}
13+
14+
impl Processor {
15+
pub fn new(config: Arc<Config>) -> Result<Self, Box<dyn std::error::Error>> {
16+
if !is_enabled(&config) {
17+
return Err("AppSec is not enabled".into());
18+
}
19+
debug!("Starting ASM processor");
20+
21+
if is_standalone() {
22+
info!(
23+
"Starting ASM in standalone mode. APM tracing will be disabled for this service."
24+
);
25+
}
26+
27+
// Check if ASM can run properly
28+
// wafHealth
29+
30+
let _rules = get_rules(&config).unwrap_or_default();
31+
32+
Err("Not implemented".into())
33+
}
34+
}

bottlecap/src/bin/bottlecap/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,5 +1019,5 @@ fn start_api_runtime_proxy(
10191019
let config = Arc::clone(config);
10201020
let aws_config = aws_config.clone();
10211021
let invocation_processor = invocation_processor.clone();
1022-
interceptor::start(aws_config, invocation_processor).ok()
1022+
interceptor::start(config, aws_config, invocation_processor).ok()
10231023
}

bottlecap/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![allow(clippy::cast_precision_loss)]
1818
#![allow(clippy::needless_pass_by_value)]
1919

20+
pub mod appsec;
2021
pub mod config;
2122
pub mod event_bus;
2223
pub mod events;

0 commit comments

Comments
 (0)