-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathngwaf_inspect.cpp
More file actions
26 lines (22 loc) · 858 Bytes
/
ngwaf_inspect.cpp
File metadata and controls
26 lines (22 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! @example ngwaf_inspect.cpp
#include "fastly/sdk.h"
int main() {
fastly::log::init_simple("logs");
auto req{fastly::Request::from_client()};
auto ires{fastly::security::inspect(
req,
fastly::security::InspectConfig().with_corp("my_corp").with_workspace(
"my_workspace"))};
auto verdict{ires->verdict()};
fastly::Body body{"NGWAF Verdict: "};
if (verdict == fastly::security::InspectVerdict::Allow) {
body << "Allow";
} else if (verdict == fastly::security::InspectVerdict::Block) {
body << "Block";
} else if (verdict == fastly::security::InspectVerdict::Unauthorized) {
body << "Unauthorized";
} else if (verdict == fastly::security::InspectVerdict::Other) {
body << *ires->unrecognized_verdict_info() << " (Other)";
}
fastly::Response::from_body(std::move(body)).send_to_client();
}