halo-dev / halo

强大易用的开源建站工具。
https://www.halo.run
GNU General Public License v3.0
34.02k stars 9.71k forks source link

Make ApplicationContext inaccessible in ITemplateContext #6680

Closed JohnNiang closed 1 month ago

JohnNiang commented 1 month ago

What type of PR is this?

/kind improvement /area core /area plugin /milestone 2.20.x

What this PR does / why we need it:

This PR disables access to ApplicationContext using ITemplateContext.

Does this PR introduce a user-facing change?

None
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 33.33333% with 28 lines in your changes missing coverage. Please review.

Project coverage is 58.04%. Comparing base (6cd8dc8) to head (849335e). Report is 79 commits behind head on main.

Files with missing lines Patch % Lines
.../halo/app/theme/dialect/SecureTemplateContext.java 24.32% 25 Missing and 3 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6680 +/- ## ============================================ - Coverage 58.18% 58.04% -0.14% - Complexity 3774 3942 +168 ============================================ Files 651 676 +25 Lines 22125 23154 +1029 Branches 1538 1579 +41 ============================================ + Hits 12873 13440 +567 - Misses 8641 9090 +449 - Partials 611 624 +13 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

f2c-ci-robot[bot] commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guqing

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/halo-dev/halo/blob/main/OWNERS)~~ [guqing] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
guqing commented 1 month ago

/kind api-change 此 PR 禁止插件通过 SpringContextUtils 获取 ApplicationContext,如果插件使用到此方法则需要使用依赖注入来代替