Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8391

Regex for addSensitiveElementNames is replace only the last element

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4.2
    • Fix Version/s: 3.4.3
    • Component/s: logging
    • Labels:
    • Estimated Complexity:
      Novice

      Description

      Regex Template (MATCH_PATTERN_XML_TEMPLATE) used in MaskSensitiveHelper class for replace all ocurrs of element in XML is getting always only one ocurrs when you have a list of elements to replace.

      In this sample of xml

      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      	<soap:Body>
      		<ns1:listResponse xmlns:ns1="http://acme.org/">
      			<return xmlns:ns2="http://acme.org/">
      				<description>Winter fruit</description>
      				<name>Apple1</name>
      			</return>
      			<return xmlns:ns2="http://acme.org/">
      				<description>Tropical fruit</description>
      				<name>Pineapple1</name>
      			</return>
      		</ns1:listResponse>
      	</soap:Body>
      </soap:Envelope>
      

       if you need to replace the content of element <description>, the regex used for

      "(<description.*>)(.*?)(</description>)"
      

       will started at '<description>Winter fruit' and end at

      'Tropical fruit</description>' , because of this the replaceAll will replace the last occurs in XML.

      To fix it we have to change the match pattern xml template.

      The correct value for it has to be 

        private static final String MATCH_PATTERN_XML_TEMPLATE = "(<-ELEMENT_NAME-*.?>)(.*?)(</-ELEMENT_NAME->)";
      

      not

        private static final String MATCH_PATTERN_XML_TEMPLATE = "(<-ELEMENT_NAME-.*>)(.*?)(</-ELEMENT_NAME->)";
      

       

        Attachments

          Activity

            People

            • Assignee:
              ashakirin Andrei Shakirin
              Reporter:
              carlospanarello Carlos Eduardo Panarello

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Issue deployment