codeql: close java/regex-injection alerts #602-#607 (Task 8) - #42
Merged
Conversation
Close 6 CodeQL High alerts by treating user-supplied path / site-name components as literals wherever they are composed into regex patterns: - PSFolderStringUtils.getFolderPatterns (#603): replaced hex-escape loop with Pattern.quote-based literal segment wrapping. Path split on '%' wildcard, each segment Pattern.quote-wrapped, re-joined with '.*' so wildcard still works. Trailing '/' semantics preserved. - PSSiteDataService.updateListAsset (#604-#606): three replaceFirst calls now wrap pattern with Pattern.quote(original) and replacement with Matcher.quoteReplacement(replacement). - PSSiteDataService.updatePage (#607): replaceFirst now uses Pattern.quote(copySiteName) + Matcher.quoteReplacement(origSiteName). Same latent pattern at updateLinkedPage fixed identically. - PSBlogPostVisitDao.updatePostsAfterSiteRename (#602): replaceAll now uses Pattern.quote(prevSiteName) + Matcher.quoteReplacement. Regression tests (PSFolderStringUtilsTest): - 7 adversarial meta-character inputs assert literal matching + \Q marker + no wildcard bleed - % wildcard preservation with empty-span match - ; multi-path split + null/blank returns empty array All 4 tests pass. All modules compile. Fix pattern derived from 004 branch PR #1295 (ae92a09733). # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # interactive rebase in progress; onto 76f4ae3 # Last command done (1 command done): # pick 8f32194 codeql: close java/regex-injection alerts #602-#607 (Task 8) # No commands remaining. # You are currently rebasing branch 'codeql/regex-injection' on '76f4ae3e0f'. # # Changes to be committed: # modified: CHANGELOG.md # modified: deliverytiersuite/delivery-tier-suite/metadata/src/main/java/com/percussion/delivery/metadata/rdbms/impl/PSBlogPostVisitDao.java # modified: modules/utils/src/main/java/com/percussion/utils/string/PSFolderStringUtils.java # modified: modules/utils/src/test/java/com/percussion/utils/string/PSFolderStringUtilsTest.java # modified: projects/sitemanage/src/main/java/com/percussion/sitemanage/service/impl/PSSiteDataService.java #
natechadwick-intsof
force-pushed
the
codeql/regex-injection
branch
from
August 13, 2026 13:36
8f32194 to
602db2c
Compare
Signed-off-by: Nate Chadwick <natechadwick@users.noreply.github.com>
natechadwick
approved these changes
Aug 13, 2026
4 tasks
Collaborator
Author
|
Superseded by #50 (consolidated onto current |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes 6 CodeQL
java/regex-injectionHigh alerts (#602-#607) by treating user-supplied path / site-name components as literals wherever they are composed into regex patterns.Fixes
PSFolderStringUtils.getFolderPatternsPattern.quote-based literal segment wrapping: split on documented%wildcard, quote each segment, re-join with.*. Compiled regex now carries\\Q...\\Emarkers CodeQL recognizes. Trailing-/semantics preserved (decided from raw input, not quoted output).PSSiteDataService.updateListAssetreplaceFirstcalls now usePattern.quote(original)+Matcher.quoteReplacement(replacement)PSSiteDataService.updatePagereplaceFirst(copySiteName, origSiteName)now quoted; same latent pattern atupdateLinkedPagefixed identicallyPSBlogPostVisitDao.updatePostsAfterSiteRenamereplaceAll(prevSiteName, newSiteName)now quotedWhy quote
Site/folder names like
mysite.comwere previously interpreted as regex patterns —.matched any char,(,[,|,+etc. became pattern syntax.Pattern.quotemakes them literal;Matcher.quoteReplacementprevents\/$in replacement strings from being interpreted.Regression tests
PSFolderStringUtilsTest(JUnit 4):a.b.c,site(name),site$name,site^name,site|name,site[abc]name,site+name) assert literal matching +\\Qmarker + no wildcard bleed%wildcard preservation with empty-span match;multi-path split + null/blank returns empty arrayVerification
./mvn-env.sh compile -pl modules/utils,projects/sitemanage,deliverytiersuite/delivery-tier-suite/metadata -am -DskipTests # => BUILD SUCCESSPattern source
004 branch PR #1295 (
ae92a09733) — same CodeQLjava/regex-injectionrule, samePattern.quote/Matcher.quoteReplacementidiom; also fixes the equivalentupdatePagesink at line 2007 that 004 left untouched.Notes
*.versionproperties untouched.Version.propertieswas not modified.