Skip to content

Commit c4159c3

Browse files
committed
Refactor JSON parsing comments and update warning messages for clarity
1 parent 925df62 commit c4159c3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/hooks/app/helpers.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def enforce_request_limits(config)
4040
# Note: Timeout enforcement would typically be handled at the server level (Puma, etc.)
4141
end
4242

43-
# Parse request payload with security limits
43+
# Parse request payload
4444
#
4545
# @param raw_body [String] The raw request body
4646
# @param headers [Hash] The request headers
@@ -59,9 +59,8 @@ def parse_payload(raw_body, headers, symbolize: true)
5959
return parsed_payload
6060
rescue JSON::ParserError, ArgumentError => e
6161
# If JSON parsing fails or security limits exceeded, return raw body
62-
# Log security violations at debug level to avoid log spam
6362
if e.message.include?("nesting") || e.message.include?("depth")
64-
log.warn("JSON parsing security limit exceeded: #{e.message}")
63+
log.warn("JSON parsing limit exceeded: #{e.message}")
6564
end
6665
end
6766
end
@@ -87,7 +86,7 @@ def load_handler(handler_class_name)
8786

8887
private
8988

90-
# Safely parse JSON with security limits to prevent JSON bombs
89+
# Safely parse JSON
9190
#
9291
# @param json_string [String] The JSON string to parse
9392
# @return [Hash, Array] Parsed JSON object

spec/unit/lib/hooks/app/helpers_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def error!(message, code)
236236
# Mock logger to capture debug messages
237237
logger = instance_double("Logger")
238238
allow(helper).to receive(:log).and_return(logger)
239-
expect(logger).to receive(:warn).with(/JSON parsing security limit exceeded/)
239+
expect(logger).to receive(:warn).with(/JSON parsing limit exceeded/)
240240

241241
# Mock the safe_json_parse method to simulate nesting limit exceeded
242242
allow(helper).to receive(:safe_json_parse).and_raise(ArgumentError, "nesting exceeded")

0 commit comments

Comments
 (0)