-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Limit WireFormatInfo platform details to a reasonable length #2088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+60
−6
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ public class WireFormatInfo implements Command, MarshallAware { | |
| // Max number of properties allowed in the map is 64 | ||
| static final int MAX_PROPERTY_SIZE = 64; | ||
| // Used to validate property values that allocate buffers, limit to 512 bytes | ||
| static final int MAX_PROPERTY_BUFFER_SIZE = 512; | ||
| public static final int MAX_PROPERTY_BUFFER_SIZE = 512; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch I forgot that you made the default for WireFormatInfo 512 from the original 256 |
||
| // Do not allow any nested collections in properties | ||
| static final int MAX_PROPERTY_DEPTH = 0; | ||
| private static final byte[] MAGIC = new byte[] {'A', 'c', 't', 'i', 'v', 'e', 'M', 'Q'}; | ||
|
|
||
46 changes: 46 additions & 0 deletions
46
activemq-client/src/test/java/org/apache/activemq/ActiveMQConnectionMetaDataTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.activemq; | ||
|
|
||
| import static org.apache.activemq.ActiveMQConnectionMetaData.PLATFORM_DETAILS_MAX_LENGTH; | ||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class ActiveMQConnectionMetaDataTest { | ||
|
|
||
| @Test | ||
| public void testPlatformDetails() { | ||
| // static final should match generated from the utility method | ||
| assertEquals(ActiveMQConnectionMetaData.PLATFORM_DETAILS, | ||
| ActiveMQConnectionMetaData.getPlatformDetails()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPlatformDetailsTruncation() { | ||
| String javaVendor = System.getProperty("java.vendor"); | ||
| try { | ||
| System.setProperty("java.vendor", "a".repeat(PLATFORM_DETAILS_MAX_LENGTH + 1)); | ||
| // ensure we truncate if too large | ||
| assertEquals(PLATFORM_DETAILS_MAX_LENGTH, | ||
| ActiveMQConnectionMetaData.getPlatformDetails().length()); | ||
| } finally { | ||
| // restore original | ||
| System.setProperty("java.vendor", javaVendor); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cuts off the details without any indication they were cut off, which is probably fine. I have seen some implementation do this by inserting an ellipsis after a given point and then appending a small bit trailing value such that you get a sort of visual indication that it was clipped. Probably not needed here so just making sure you thought about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it's fine here, it's off by default and its now 512 and shouldn't really be hit but we could improve it later if needed. This is more of just a fail safe. I doubt anyone even turns this setting on to be honest.