Skip to content

Remove unused code and unnecessary indirections#6284

Merged
nscuro merged 2 commits into
DependencyTrack:mainfrom
nscuro:rm-unused-code
Jun 6, 2026
Merged

Remove unused code and unnecessary indirections#6284
nscuro merged 2 commits into
DependencyTrack:mainfrom
nscuro:rm-unused-code

Conversation

@nscuro
Copy link
Copy Markdown
Member

@nscuro nscuro commented Jun 6, 2026

Description

Removes unused code and unnecessary indirections.

Also replaces permission checks that queried the DB despite having an authenticated principal with populated effective permissions available. The AuthorizationFilter populates these for every request, so querying the DB again is redundant.

Originally unplanned but became an obvious byproduct of the above:

Allows resources that do not require a permission to be accessed to still check the principal's effective permissions without having to query the DB. For example /v1/team/visible is accessible by all authenticated principals, but its response content still depends on which permissions those principals hold.

Replaces the separate AuthenticationFeature and AuthorizationFeature with a single AuthFeature. Since the condition for both is now identical, there is no need for separate features anymore.

This change surfaced a few resources where AlpineRequest was deliberately not passed to new QueryManager (which is necessary for ACL-aware query filtering), in order to perform "lookup project and assert access" patterns. To fix this, we introduce a mechanism to explicitly bypass portfolio ACL when needed, using ProjectAccess.unrestricted(() -> ...). Note that the previous implementation was safe, it was just inconsistent with how the rest of the code base works.

Addressed Issue

N/A

Additional Details

N/A

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have updated the migration changelog accordingly
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly
  • This PR is a substantial change (per the ADR criteria), and I have added an ADR under docs/adr/

Also replaces permission checks that queried the DB despite having an authenticated principal with populated effective permissions available. The AuthorizationFilter populates these for every request, so querying the DB again is redundant.

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro added this to the 5.0 milestone Jun 6, 2026
@owasp-dt-bot
Copy link
Copy Markdown

owasp-dt-bot commented Jun 6, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Jun 6, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -8 complexity · 3 duplication

Metric Results
Complexity -8
Duplication 3

View in Codacy

🟢 Coverage 88.77% diff coverage · +0.21% coverage variation

Metric Results
Coverage variation +0.21% coverage variation (-1.00%)
Diff coverage 88.77% diff coverage (70.00%)

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8217941) 41799 36102 86.37%
Head commit (c8d55d2) 41654 (-145) 36066 (-36) 86.58% (+0.21%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6284) 187 166 88.77%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@nscuro nscuro force-pushed the rm-unused-code branch 2 times, most recently from 22308de to 57dfc2a Compare June 6, 2026 20:08
Allows resources that do not *require* a permission to be accessed to still check the principal's effective permissions without having to query the DB. For example `/v1/team/visible` is accessible by all authenticated principals, but its response content still depends on which permissions those principals hold.

Replaces the separate `AuthenticationFeature` and `AuthorizationFeature` with a single `AuthFeature`. Since the condition for both is now identical, there is no need for separate features anymore.

This change surfaced a few resources where `AlpineRequest` was deliberately not passed to `new QueryManager` (which is necessary for ACL-aware query filtering), in order to perform "lookup project and assert access" patterns. To fix this, we introduce a mechanism to explicitly bypass portfolio ACL when needed, using `ProjectAccess.unrestricted(() -> ...)`.

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro merged commit c1aa754 into DependencyTrack:main Jun 6, 2026
19 checks passed
@nscuro nscuro deleted the rm-unused-code branch June 6, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants