forked from mtusi2026/mtusi2026lab7
Prepare verified laboratory 7 implementation and evidence
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
// Native HAProxy request guards originate in lab6 dd110001, histogram delta04ca06e9.
|
||||
// The response block8aa801e8 is independently reviewed; lab7 retains its own8MiB budget.
|
||||
// TLS CN=grafana replaces lab6 HTTP auth. Operator bootstrap stays a separate client identity.
|
||||
// query.size is an input guard, not a hard result row cap: SQL has independent LIMIT semantics.
|
||||
export const openobserveQueryPolicy = String.raw` timeout client 10s
|
||||
timeout server 10s
|
||||
timeout http-request 3s
|
||||
timeout http-keep-alive 1s
|
||||
timeout queue 1s
|
||||
acl grafana ssl_c_s_dn(CN) -m str grafana
|
||||
acl read_method method GET
|
||||
acl search_method method POST
|
||||
acl search_path path -m str /api/default/_search
|
||||
acl read_path path -m str /api/organizations /api/default/streams
|
||||
acl read_path path_reg ^/api/default/streams/[A-Za-z0-9_]+/schema$
|
||||
acl read_path path -m str /api/default/messenger/_values
|
||||
acl read_path path_reg ^/api/default/prometheus/api/v1/(query|query_range|labels|series|metadata)$
|
||||
acl read_path path_reg ^/api/default/prometheus/api/v1/label/[A-Za-z0-9_]+/values$
|
||||
http-request deny deny_status 403 unless !grafana or read_method read_path or search_method search_path
|
||||
http-request wait-for-body time 2s if grafana search_method search_path
|
||||
http-request deny deny_status 413 if grafana search_method search_path { req.body_len gt 65536 }
|
||||
http-request set-var(txn.rows) req.body,json_query('$.query.size','int') if grafana search_method search_path
|
||||
http-request set-var(txn.begin) req.body,json_query('$.query.start_time','int') if grafana search_method search_path
|
||||
http-request set-var(txn.end) req.body,json_query('$.query.end_time','int') if grafana search_method search_path
|
||||
http-request set-var(txn.window) var(txn.end),sub(txn.begin) if grafana search_method search_path
|
||||
# Native plugin supplementary histogram omits size; preserve native default and explicit zero.
|
||||
acl search_size_present req.body,json_query('$.query.size') -m found
|
||||
http-request deny deny_status 400 if grafana search_method search_path search_size_present !{ var(txn.rows) -m int 0:1000 }
|
||||
http-request deny deny_status 400 if grafana search_method search_path !{ var(txn.begin) -m int gt 0 }
|
||||
http-request deny deny_status 400 if grafana search_method search_path !{ var(txn.window) -m int 1:3600000000 }
|
||||
acl duplicate_query query,url_dec -m reg (^|&)size=[^&]*(&[^&]*)*&size= (^|&)start_time=[^&]*(&[^&]*)*&start_time= (^|&)end_time=[^&]*(&[^&]*)*&end_time= (^|&)start=[^&]*(&[^&]*)*&start= (^|&)end=[^&]*(&[^&]*)*&end= (^|&)query=[^&]*(&[^&]*)*&query=
|
||||
http-request deny deny_status 400 if grafana read_method duplicate_query
|
||||
acl values_path path -m str /api/default/messenger/_values
|
||||
http-request set-var(txn.rows) url_param(size),add(0) if grafana read_method values_path
|
||||
http-request set-var(txn.begin) url_param(start_time),add(0) if grafana read_method values_path
|
||||
http-request set-var(txn.end) url_param(end_time),add(0) if grafana read_method values_path
|
||||
http-request set-var(txn.window) var(txn.end),sub(txn.begin) if grafana read_method values_path
|
||||
http-request deny deny_status 400 if grafana read_method values_path !{ var(txn.rows) -m int 1:1000 }
|
||||
http-request deny deny_status 400 if grafana read_method values_path !{ var(txn.window) -m int 1:3600000000 }
|
||||
acl range_path path -m str /api/default/prometheus/api/v1/query_range
|
||||
http-request set-var(txn.begin_s) url_param(start),field(1,.),add(0) if grafana read_method range_path
|
||||
http-request set-var(txn.end_s) url_param(end),field(1,.),add(0) if grafana read_method range_path
|
||||
http-request set-var(txn.window_s) var(txn.end_s),sub(txn.begin_s) if grafana read_method range_path
|
||||
http-request deny deny_status 400 if grafana read_method range_path !{ var(txn.begin_s) -m int gt 0 }
|
||||
http-request deny deny_status 400 if grafana read_method range_path !{ var(txn.window_s) -m int 1:3599 }
|
||||
# Recognized native OO framing only; not a streaming/decompression or SQL work cap.
|
||||
# Adapted from reviewed lab6 8aa801e8, retaining lab7's mTLS identities and 8MiB budget.
|
||||
http-request set-header Accept-Encoding identity
|
||||
acl response_encoded res.fhdr_cnt(Content-Encoding) gt 0
|
||||
acl response_transfer_encoded res.fhdr_cnt(Transfer-Encoding) gt 0
|
||||
acl response_length_single res.fhdr_cnt(Content-Length) eq 1
|
||||
acl response_length_canonical res.fhdr(Content-Length) -m reg ^(0|[1-9][0-9]{0,6})$
|
||||
acl response_length_excessive res.fhdr(Content-Length) -m int gt 8388608
|
||||
http-response return status 502 content-type application/json string '{"error":"query_response_boundary"}' if response_encoded or response_transfer_encoded or !response_length_single or !response_length_canonical or response_length_excessive
|
||||
`;
|
||||
Reference in New Issue
Block a user