Skip to content

fix: match group prefix and suffix literally - #135

Merged
uniqueg merged 4 commits into
devfrom
fix/134-group-names-literal
Nov 9, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/134-group-names-literal

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Summary

ElixirPrincipalExtractor recognises team and team admin groups with regular expressions built from the configured base group prefix, admin subgroup and group suffix. These parts went into the expressions as they were, so characters such as the . in the default prefix and suffix matched any character. They are now quoted (Pattern.quote), so only the exact configured text counts; the team name in between stays a pattern (any text without :).

  • ElixirPrincipalExtractor: quote the configured parts (unset parts keep their previous text null).
  • ElixirPrincipalExtractorTest: exact names with the default prefix and suffix still match; names that differ from the configured prefix or suffix only at a . give no team or team admin group; other regex characters (+ * ( $ \E) are matched as text.
  • Docs: access-control.md (configuration) says that the names are compared as plain text; upgrading.md (To 1.2.0) has a new item.

No other place builds regular expressions from configuration (checked Pattern.compile, matches(, replaceAll(, split( and String.format under src/main/java).

Closes #134

Verification

  • The new tests failed before the fix (2 failures, 1 PatternSyntaxException) and pass after it.
  • ./mvnw -B spotless:check checkstyle:check: BUILD SUCCESS, 0 Checkstyle violations.
  • ./mvnw -B clean verify (Temurin 8): BUILD SUCCESS, all unit and integration tests pass, coverage checks met.
  • mkdocs build --strict: built without warnings.
  • CI on c83c83e: all checks pass (Lint, Test, Docs, Smoke test, Scan image, CodeQL, Codecov; image push and publish skipped on PRs, as intended).

Lane

Full review (authorisation code). Adversarial review: no findings. Quality review: docs now name the affected settings and say that patterns no longer work (fixed in c83c83e).

Declined review findings

  • Squash the test commit into the fix: the branch was already pushed (no rewrites); the PR is squash-merged into one commit anyway.
  • Pin the null text for unset parts with a test, or fail instead: it keeps the previous behaviour (an unset part matches no real group); changing it is out of scope.
  • Refactor the test helpers and split the special-character test: low, test readability only; each case already fails on the old code.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Ensure configured team group-name components are matched literally while preserving pattern matching only for the team name.

Bug Fixes:

  • Match configured group prefixes, admin subgroups, and suffixes as literal text so regex metacharacters cannot produce unintended team or team-admin matches.

Documentation:

  • Document literal matching behavior for group-name settings and note the upgrade impact for configurations that relied on regular expressions.

Tests:

  • Add coverage for exact default group names, near-matching prefixes and suffixes, and configured values containing regex metacharacters.

uniqueg and others added 3 commits November 9, 2026 10:40
Tests that configured group names are matched literally; they fail
until the fix for #134 lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quote the configured group prefix, admin subgroup and suffix in the
team and team admin group patterns, so that characters such as . are
matched as text and only the exact group names count.

Closes #134

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v1.2.0 milestone Nov 9, 2026
@uniqueg uniqueg added type: bug Something isn't working priority: high High priority workload: hours Likely takes hours to resolve labels Nov 9, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Quote configured group-name components in the team and admin patterns so they match literally, while retaining pattern matching for the team name.

  • src/main/java/uk/ac/ebi/tsc/tesk/config/security/ElixirPrincipalExtractor.java L36-49, L72-79

Documentation

Explain that configured group-name components are compared literally and describe the compatibility change in the upgrade guide.

  • docs/access-control.md L115-121
  • docs/upgrading.md L171-180

Tests

Verify exact matching of default and regex-metacharacter-containing group names, and rejection of near-matching prefixes and suffixes.

  • src/test/java/uk/ac/ebi/tsc/tesk/config/security/ElixirPrincipalExtractorTest.java L122-204

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.95%. Comparing base (b331df0) to head (c83c83e).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #135      +/-   ##
==========================================
+ Coverage   65.93%   65.95%   +0.01%     
==========================================
  Files          67       67              
  Lines        2698     2699       +1     
  Branches      288      288              
==========================================
+ Hits         1779     1780       +1     
  Misses        772      772              
  Partials      147      147              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 9, 2026 12:13

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Linked issues

#134 fix: match group prefix and suffix literally · 4 of 4 met

# Requirement Status Notes
1 Match the configured group prefix, base group, admin subgroup and suffix literally; leave only the team name variable text without :. ✅ Met Both group patterns quote the configured base-group prefix and suffix; the managed-group pattern also quotes the admin subgroup, while the team name remains ([^:]+).
2 Quote the configured parts with Pattern.quote. ✅ Met The literal helper uses Pattern.quote(String.valueOf(part)) for each configured part.
3 Add unit tests for exact names, near-identical names, and other regex characters matched as text. ✅ Met The tests cover exact defaults, prefix and suffix variants differing at ., and configured characters including +, *, (, $ and \E.
4 Document that configured group names are matched literally. ✅ Met The access-control configuration docs describe literal comparison and that patterns no longer work; the upgrading guide also explains the behavior change.

Sourcery assessment

Needs a human reviewer. The configured group parts now match literally, so groups that previously matched only because a regex character acted as a wildcard may stop granting membership or admin access; a mistake in the new matching could also grant access to the wrong groups. Reverting restores the old matching, but any access or data exposure during the time the change was live cannot be undone.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@uniqueg
uniqueg merged commit 41ff8be into dev Nov 9, 2026
39 of 43 checks passed
@uniqueg
uniqueg deleted the fix/134-group-names-literal branch November 9, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: high High priority type: bug Something isn't working workload: hours Likely takes hours to resolve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: match group prefix and suffix literally

1 participant