Skip to content

Commit 308d1fd

Browse files
committed
lint
1 parent 358dd45 commit 308d1fd

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ build-musl-aux build-musl-cov-aux:
122122
-DCMAKE_TOOLCHAIN_FILE=/sysroot/$(ARCH)-none-linux-musl/Toolchain.cmake \
123123
-DNGINX_PATCH_AWAY_LIBC=ON \
124124
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
125-
-DNGINX_VERSION="$(NGINX_VERSION)" \
125+
-DNGINX_VERSION="$(NGINX_VERSION)" \
126126
-DNGINX_DATADOG_ASM_ENABLED="$(WAF)" . \
127127
-DNGINX_DATADOG_RUM_ENABLED="$(RUM)" . \
128128
-DNGINX_COVERAGE=$(COVERAGE) \

src/security/blocking.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ void BlockingService::initialize(std::optional<std::string_view> templ_html,
304304
new BlockingService(templ_html, templ_json));
305305
}
306306

307-
ngx_int_t BlockingService::block(BlockSpecification spec, ngx_http_request_t &req) {
307+
ngx_int_t BlockingService::block(BlockSpecification spec,
308+
ngx_http_request_t &req) {
308309
BlockResponse const resp = BlockResponse::resolve_content_type(spec, req);
309310
ngx_str_t *templ{};
310311
if (resp.ct == BlockResponse::ContentType::HTML) {
@@ -346,8 +347,8 @@ ngx_int_t BlockingService::block(BlockSpecification spec, ngx_http_request_t &re
346347
// req.headers_out.content_length_n = 0;
347348
// }
348349
if (req.header_only) {
349-
req.headers_out.content_length_n = 0;
350-
req.chunked = 0;
350+
req.headers_out.content_length_n = 0;
351+
req.chunked = 0;
351352
}
352353
req.keepalive = 0;
353354
req.lingering_close = 0;

src/security/blocking.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#pragma once
22

3-
#include <fstream>
43
#include <memory>
54
#include <optional>
6-
#include <sstream>
7-
#include <stdexcept>
5+
#include <string>
86
#include <string_view>
97

108
extern "C" {
@@ -37,7 +35,8 @@ class BlockingService {
3735

3836
static BlockingService *get_instance() { return instance.get(); }
3937

40-
[[nodiscard]] ngx_int_t block(BlockSpecification spec, ngx_http_request_t &req);
38+
[[nodiscard]] ngx_int_t block(BlockSpecification spec,
39+
ngx_http_request_t &req);
4140

4241
private:
4342
BlockingService(std::optional<std::string_view> templ_html_path,

src/security/context.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ ngx_int_t Context::buffer_chain(FilterCtx &filter_ctx, ngx_pool_t &pool,
10871087
size = buf->last - buf->pos;
10881088
new_buf->temporary = 1;
10891089
if (size > 0) {
1090-
new_buf->pos = static_cast<u_char*>(ngx_palloc(&pool, size));
1090+
new_buf->pos = static_cast<u_char *>(ngx_palloc(&pool, size));
10911091
if (!new_buf->pos) {
10921092
return NGX_ERROR;
10931093
}

test/cases/sec_blocking/test_sec_blocking.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@ def test_html_action(self):
141141

142142
def test_html_action_http2(self):
143143
status, headers, body, _ = self.run_with_ua('block_html',
144-
'application/json', http_version=2)
144+
'application/json',
145+
http_version=2)
145146
self.assertEqual(status, 403)
146147
self.assertEqual(headers['content-type'], 'text/html;charset=utf-8')
147148

148149
def test_html_action_http3(self):
149150
status, headers, body, _ = self.run_with_ua('block_html',
150-
'application/json', http_version=3)
151+
'application/json',
152+
http_version=3)
151153
self.assertEqual(status, 403)
152154
self.assertEqual(headers['content-type'], 'text/html;charset=utf-8')
153155

@@ -167,12 +169,16 @@ def test_redirect_action(self):
167169
self.assertEqual(headers['location'], 'https://www.cloudflare.com')
168170

169171
def test_redirect_action_http2(self):
170-
status, headers, _, _ = self.run_with_ua('redirect', '*/*', http_version=2)
172+
status, headers, _, _ = self.run_with_ua('redirect',
173+
'*/*',
174+
http_version=2)
171175
self.assertEqual(status, 301)
172176
self.assertEqual(headers['location'], 'https://www.cloudflare.com')
173177

174178
def test_redirect_action_http3(self):
175-
status, headers, _, _ = self.run_with_ua('redirect', '*/*', http_version=3)
179+
status, headers, _, _ = self.run_with_ua('redirect',
180+
'*/*',
181+
http_version=3)
176182
self.assertEqual(status, 301)
177183
self.assertEqual(headers['location'], 'https://www.cloudflare.com')
178184

@@ -197,14 +203,16 @@ def test_block_body_json_long(self):
197203
def test_block_body_json_long_http2(self):
198204
status, _, _, log_lines = self.run_with_body(
199205
'application/json',
200-
'{"a": "block_default", "b": "' + ('a' * 1024 * 1024), http_version=2)
206+
'{"a": "block_default", "b": "' + ('a' * 1024 * 1024),
207+
http_version=2)
201208
self.assertEqual(status, 403)
202209
self.assert_has_report(log_lines)
203210

204211
def test_block_body_json_long_http3(self):
205212
status, _, _, log_lines = self.run_with_body(
206213
'application/json',
207-
'{"a": "block_default", "b": "' + ('a' * 1024 * 1024), http_version=3)
214+
'{"a": "block_default", "b": "' + ('a' * 1024 * 1024),
215+
http_version=3)
208216
self.assertEqual(status, 403)
209217
self.assert_has_report(log_lines)
210218

@@ -232,7 +240,6 @@ def test_block_on_status_http2(self):
232240
def test_block_on_status_http3(self):
233241
self.block_on_status(3)
234242

235-
236243
def block_on_status_redirect(self, http_version):
237244
if http_version != 3:
238245
status, headers, body = self.orch.send_nginx_http_request(

0 commit comments

Comments
 (0)