Skip to content

Commit f3e1944

Browse files
fix: update protocol to v0.5.11, fix integration test connect() pattern
Update zentinel-agent-protocol lockfile. Fix integration test to separate new() and connect() calls.
1 parent f74c6b4 commit f3e1944

4 files changed

Lines changed: 37 additions & 29 deletions

File tree

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ use tokio::sync::RwLock;
2929
use tracing::{debug, info, warn};
3030

3131
use zentinel_agent_protocol::{
32-
AgentResponse, AuditMetadata, HeaderOp, RequestBodyChunkEvent,
33-
RequestHeadersEvent, ResponseBodyChunkEvent, ResponseHeadersEvent, EventType,
3432
v2::{
35-
AgentCapabilities, AgentFeatures, AgentHandlerV2, AgentLimits, DrainReason,
36-
HealthStatus, MetricsReport, ShutdownReason,
33+
AgentCapabilities, AgentFeatures, AgentHandlerV2, AgentLimits, DrainReason, HealthStatus,
34+
MetricsReport, ShutdownReason,
3735
},
36+
AgentResponse, AuditMetadata, EventType, HeaderOp, RequestBodyChunkEvent, RequestHeadersEvent,
37+
ResponseBodyChunkEvent, ResponseHeadersEvent,
3838
};
3939

4040
/// ModSecurity configuration

src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ async fn main() -> Result<()> {
123123
// gRPC transport (v2 protocol)
124124
info!(address = %grpc_addr, "Starting gRPC v2 agent server");
125125
let server = GrpcAgentServerV2::new("zentinel-modsec-agent", Box::new(agent));
126-
server.run(grpc_addr).await.map_err(|e| anyhow::anyhow!("{}", e))?;
126+
server
127+
.run(grpc_addr)
128+
.await
129+
.map_err(|e| anyhow::anyhow!("{}", e))?;
127130
} else {
128131
// UDS transport (v2 protocol)
129132
info!(socket = ?args.socket, "Starting UDS agent server");

tests/crs_integration.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
//! The CRS must be present in testdata/crs/ for these tests to run.
55
66
use base64::Engine;
7-
use zentinel_agent_modsec::{ModSecAgent, ModSecConfig};
8-
use zentinel_agent_protocol::{
9-
Decision, RequestBodyChunkEvent, RequestHeadersEvent,
10-
RequestMetadata,
11-
v2::{AgentClientV2Uds, UdsAgentServerV2},
12-
};
137
use std::collections::HashMap;
148
use std::path::Path;
159
use std::time::Duration;
1610
use tempfile::tempdir;
11+
use zentinel_agent_modsec::{ModSecAgent, ModSecConfig};
12+
use zentinel_agent_protocol::{
13+
v2::{AgentClientV2Uds, UdsAgentServerV2},
14+
Decision, RequestBodyChunkEvent, RequestHeadersEvent, RequestMetadata,
15+
};
1716

1817
/// Check if CRS is available
1918
fn crs_available() -> bool {
@@ -59,12 +58,16 @@ async fn start_crs_server(config: ModSecConfig) -> Option<(tempfile::TempDir, st
5958

6059
/// Create a client connected to the test server
6160
async fn create_client(socket_path: &std::path::Path) -> AgentClientV2Uds {
62-
AgentClientV2Uds::new("test-client", socket_path.to_string_lossy().to_string(), Duration::from_secs(5))
63-
.await
64-
.expect("Failed to create agent client")
65-
.connect()
66-
.await
67-
.expect("Failed to connect to agent")
61+
AgentClientV2Uds::new(
62+
"test-client",
63+
socket_path.to_string_lossy().to_string(),
64+
Duration::from_secs(5),
65+
)
66+
.await
67+
.expect("Failed to create agent client")
68+
.connect()
69+
.await
70+
.expect("Failed to connect to agent")
6871
}
6972

7073
/// Create a basic request metadata

tests/integration.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
//! you would typically use the full OWASP CRS ruleset.
88
99
use base64::Engine;
10-
use zentinel_agent_modsec::{ModSecAgent, ModSecConfig};
11-
use zentinel_agent_protocol::{
12-
Decision, RequestBodyChunkEvent, RequestHeadersEvent,
13-
RequestMetadata, ResponseBodyChunkEvent,
14-
v2::{AgentClientV2Uds, UdsAgentServerV2},
15-
};
1610
use std::collections::HashMap;
1711
use std::io::Write;
1812
use std::time::Duration;
1913
use tempfile::tempdir;
14+
use zentinel_agent_modsec::{ModSecAgent, ModSecConfig};
15+
use zentinel_agent_protocol::{
16+
v2::{AgentClientV2Uds, UdsAgentServerV2},
17+
Decision, RequestBodyChunkEvent, RequestHeadersEvent, RequestMetadata, ResponseBodyChunkEvent,
18+
};
2019

2120
/// Basic ModSecurity rules for testing
2221
/// These are simplified rules that mirror common attack patterns
@@ -108,12 +107,15 @@ async fn start_test_server_with_rules() -> (tempfile::TempDir, std::path::PathBu
108107

109108
/// Create a client connected to the test server
110109
async fn create_client(socket_path: &std::path::Path) -> AgentClientV2Uds {
111-
AgentClientV2Uds::new("test-client", socket_path.to_string_lossy().to_string(), Duration::from_secs(5))
112-
.await
113-
.expect("Failed to create agent client")
114-
.connect()
115-
.await
116-
.expect("Failed to connect to agent")
110+
let client = AgentClientV2Uds::new(
111+
"test-client",
112+
socket_path.to_string_lossy().to_string(),
113+
Duration::from_secs(5),
114+
)
115+
.await
116+
.expect("Failed to create agent client");
117+
client.connect().await.expect("Failed to connect to agent");
118+
client
117119
}
118120

119121
/// Create a basic request metadata

0 commit comments

Comments
 (0)