From b89981431397b3d06f7092e4a02b6d5056df36cb Mon Sep 17 00:00:00 2001 From: selmankoc Date: Mon, 14 Sep 2026 13:42:38 +0300 Subject: [PATCH 1/9] fix(ci): use BOT_SECRET to open auto-merge-forward PRs PRs opened with the default GITHUB_TOKEN can get their pull_request checks stuck in "action_required" and never run, which leaves mergeStateStatus BLOCKED forever even with an approved review and auto-merge enabled (observed with the same workflow in volosoft/volo). The merge step already avoids github.token for the same class of issue; do the same for PR creation here too. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/auto-merge-forward.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-merge-forward.yml b/.github/workflows/auto-merge-forward.yml index 187bf488fb..ea263035cb 100644 --- a/.github/workflows/auto-merge-forward.yml +++ b/.github/workflows/auto-merge-forward.yml @@ -106,11 +106,14 @@ jobs: git push origin "$FORWARD_BRANCH" echo "branch=$FORWARD_BRANCH" >> "$GITHUB_OUTPUT" + # BOT_SECRET, not github.token: a PR opened with the default token gets its + # pull_request checks stuck in "action_required", so they never pass and the + # PR stays permanently blocked from merging. - name: Create pull request if: steps.target.outputs.skip != 'true' id: pr env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.BOT_SECRET }} run: | set -euo pipefail SOURCE="${{ steps.target.outputs.source }}" From 6706107bf337f3c0e5ade0fd04f626af98b87856 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 10:51:26 +0000 Subject: [PATCH 2/9] docs(studio): release 3.1.2 - 3.1.2 (#26202) * docs(studio): update documentation for release 3.1.2 - Updated release notes for 3.1.2 - Updated version mapping with ABP 10.6.1 Release: 3.1.2 * Fix formatting in version mapping table --------- Co-authored-by: github-actions[bot] Co-authored-by: selman koc <64414348+skoc10@users.noreply.github.com> --- docs/en/studio/release-notes.md | 13 ++++++++++++- docs/en/studio/version-mapping.md | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/en/studio/release-notes.md b/docs/en/studio/release-notes.md index 7778860259..7253bddbaa 100644 --- a/docs/en/studio/release-notes.md +++ b/docs/en/studio/release-notes.md @@ -9,7 +9,18 @@ This document contains **brief release notes** for each ABP Studio release. Release notes only include **major features** and **visible enhancements**. Therefore, they don't include all the development done in the related version. -## 3.1.1 (2026-08-28) Latest +## 3.1.2 (2026-09-22) Latest + +* UI/UX Improvements +* Auto-merge forward rel-3.0 → rel-3.1 by: //github.com/volosoft/abp-studio/pull/5335 +* Add grouped sidebar navigation to classic and modern solution wizards +* Fix update toasts and assistant response copy actions +* Add notification for human authors on merge conflicts in auto-merge w… +* Studio browser: persistent profiles, history, pinning, find, and device preview +* Hide provider dashboard links from AI error messages +* Fix macOS .zshrc corruption from interactive shell env capture + +## 3.1.1 (2026-08-28) * Refactor release version resolution logic to ensure proper tag handling * Fix chmod command syntax in set-executable-permissions scripts for Li… diff --git a/docs/en/studio/version-mapping.md b/docs/en/studio/version-mapping.md index 6cdbd43f31..f8a3b4e44b 100644 --- a/docs/en/studio/version-mapping.md +++ b/docs/en/studio/version-mapping.md @@ -11,6 +11,7 @@ This document provides a general overview of the relationship between various ve | **ABP Studio Version** | **ABP Version of Startup Template** | |------------------------|---------------------------| +| 3.1.2 | 10.6.1 | | 3.0.9 - 3.1.1 | 10.6.0 | | 3.0.6 - 3.0.8 | 10.5.0 | | 3.0.4 - 3.0.5 | 10.4.1 | From e487eb23a74fad35832348d713ffbd7704e6b3d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 15:04:05 +0300 Subject: [PATCH 3/9] docs(studio): release 3.1.3 - 3.1.3 (#26203) * docs(studio): update documentation for release 3.1.3 - Updated release notes for 3.1.3 - Updated version mapping with ABP 10.6.1 Release: 3.1.3 * Update version-mapping.md --------- Co-authored-by: github-actions[bot] Co-authored-by: selman koc <64414348+skoc10@users.noreply.github.com> --- docs/en/studio/release-notes.md | 7 ++++++- docs/en/studio/version-mapping.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/en/studio/release-notes.md b/docs/en/studio/release-notes.md index 7253bddbaa..465bbe9452 100644 --- a/docs/en/studio/release-notes.md +++ b/docs/en/studio/release-notes.md @@ -9,7 +9,12 @@ This document contains **brief release notes** for each ABP Studio release. Release notes only include **major features** and **visible enhancements**. Therefore, they don't include all the development done in the related version. -## 3.1.2 (2026-09-22) Latest +## 3.1.3 (2026-09-22) Latest + +* Upgrade Studio to Avalonia 12 +* Bump ABP Studio version to 3.1.3 and update related properties + +## 3.1.2 (2026-09-22) * UI/UX Improvements * Auto-merge forward rel-3.0 → rel-3.1 by: //github.com/volosoft/abp-studio/pull/5335 diff --git a/docs/en/studio/version-mapping.md b/docs/en/studio/version-mapping.md index f8a3b4e44b..e0a63a95a0 100644 --- a/docs/en/studio/version-mapping.md +++ b/docs/en/studio/version-mapping.md @@ -11,7 +11,7 @@ This document provides a general overview of the relationship between various ve | **ABP Studio Version** | **ABP Version of Startup Template** | |------------------------|---------------------------| -| 3.1.2 | 10.6.1 | +| 3.1.2 - 3.1.3 | 10.6.1 | | 3.0.9 - 3.1.1 | 10.6.0 | | 3.0.6 - 3.0.8 | 10.5.0 | | 3.0.4 - 3.0.5 | 10.4.1 | From c3adbaf09c7eb33a3387ec50f2d358035fd2d73b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:52:05 +0800 Subject: [PATCH 4/9] docs(studio): release 3.1.4 - 3.1.4 (#26231) * docs(studio): update documentation for release 3.1.4 - Updated release notes for 3.1.4 - Updated version mapping with ABP 10.6.1 Release: 3.1.4 * Update version-mapping.md --------- Co-authored-by: github-actions[bot] Co-authored-by: selman koc <64414348+skoc10@users.noreply.github.com> --- docs/en/studio/release-notes.md | 13 ++++++++++++- docs/en/studio/version-mapping.md | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/en/studio/release-notes.md b/docs/en/studio/release-notes.md index 465bbe9452..b7ffd2a81d 100644 --- a/docs/en/studio/release-notes.md +++ b/docs/en/studio/release-notes.md @@ -9,7 +9,18 @@ This document contains **brief release notes** for each ABP Studio release. Release notes only include **major features** and **visible enhancements**. Therefore, they don't include all the development done in the related version. -## 3.1.3 (2026-09-22) Latest +## 3.1.4 (2026-10-05) Latest + +* Update built-in AI Assistant default models +* Fix sidebar flyout backdrop so Switch branch dimming works +* Support running several ABP Studio instances side +* Show .abpignore paths to the AI without exposing contents +* Open macOS folders in Finder instead of Terminal +* Fix Containers Start staying disabled after bind +* Fix missing scroll on the browser start page application list +* Use classic console colors for the light-theme terminal palette + +## 3.1.3 (2026-09-22) * Upgrade Studio to Avalonia 12 * Bump ABP Studio version to 3.1.3 and update related properties diff --git a/docs/en/studio/version-mapping.md b/docs/en/studio/version-mapping.md index e0a63a95a0..268beef824 100644 --- a/docs/en/studio/version-mapping.md +++ b/docs/en/studio/version-mapping.md @@ -11,7 +11,7 @@ This document provides a general overview of the relationship between various ve | **ABP Studio Version** | **ABP Version of Startup Template** | |------------------------|---------------------------| -| 3.1.2 - 3.1.3 | 10.6.1 | +| 3.1.2 - 3.1.4 | 10.6.1 | | 3.0.9 - 3.1.1 | 10.6.0 | | 3.0.6 - 3.0.8 | 10.5.0 | | 3.0.4 - 3.0.5 | 10.4.1 | From a25442ec688927a87b74a0403667dce84c88abc5 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 5 Oct 2026 20:59:01 +0800 Subject: [PATCH 5/9] Validate blob names in file system provider and blogging file service - Require post create or update permission for blogging image upload --- .../DefaultBlobFilePathCalculator.cs | 34 ++++- .../BlogFilePathCalculator_Tests.cs | 111 +++++++++++++-- .../FileSystemBlobContainer_Path_Tests.cs | 70 ++++++++++ .../Volo/Blogging/Files/FileAppService.cs | 22 ++- .../Volo/Blogging/FileAppService_Tests.cs | 131 ++++++++++++++++++ 5 files changed, 352 insertions(+), 16 deletions(-) create mode 100644 framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobContainer_Path_Tests.cs create mode 100644 modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs diff --git a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs index 963404b71c..57c80ae0f9 100644 --- a/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs +++ b/framework/src/Volo.Abp.BlobStoring.FileSystem/Volo/Abp/BlobStoring/FileSystem/DefaultBlobFilePathCalculator.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Linq; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; @@ -16,7 +18,7 @@ public class DefaultBlobFilePathCalculator : IBlobFilePathCalculator, ITransient public virtual string Calculate(BlobProviderArgs args) { var fileSystemConfiguration = args.Configuration.GetFileSystemConfiguration(); - var blobPath = fileSystemConfiguration.BasePath; + var blobPath = Path.GetFullPath(fileSystemConfiguration.BasePath); if (CurrentTenant.Id == null) { @@ -29,11 +31,33 @@ public class DefaultBlobFilePathCalculator : IBlobFilePathCalculator, ITransient if (fileSystemConfiguration.AppendContainerNameToBasePath) { - blobPath = Path.Combine(blobPath, args.ContainerName); + blobPath = CombineRelativePath(blobPath, args.ContainerName, nameof(args.ContainerName)); } - blobPath = Path.Combine(blobPath, args.BlobName); + return CombineRelativePath(blobPath, args.BlobName, nameof(args.BlobName)); + } + + protected virtual string CombineRelativePath(string rootPath, string relativePath, string parameterName) + { + if (Path.IsPathRooted(relativePath)) + { + throw new ArgumentException($"The {parameterName} must be a relative path.", parameterName); + } + + var segments = relativePath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); + if (segments.Any(segment => segment == "." || segment == "..")) + { + throw new ArgumentException($"The {parameterName} must not contain '.' or '..' segments.", parameterName); + } + + var fullRootPath = Path.GetFullPath(rootPath).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + var fullPath = Path.GetFullPath(Path.Combine(fullRootPath, relativePath)); + + if (!fullPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).StartsWith(fullRootPath + Path.DirectorySeparatorChar, StringComparison.Ordinal)) + { + throw new ArgumentException($"The {parameterName} must point to a location inside the storage directory.", parameterName); + } - return blobPath; + return fullPath; } } diff --git a/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs b/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs index e318f4617e..a447008133 100644 --- a/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs +++ b/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/BlogFilePathCalculator_Tests.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Runtime.InteropServices; using Shouldly; using Volo.Abp.MultiTenancy; using Xunit; @@ -17,38 +18,128 @@ public class BlogFilePathCalculator_Tests : AbpBlobStoringFileSystemTestBase _currentTenant = GetRequiredService(); } + private static readonly string BasePath = Path.GetFullPath(Path.Combine(Path.GetTempPath(), "my-files")); + [Fact] public void Default_Settings() { - var separator = Path.DirectorySeparatorChar; - _calculator.Calculate( - GetArgs($"C:{separator}my-files", "my-container", "my-blob") - ).ShouldBe($"C:{separator}my-files{separator}host{separator}my-container{separator}my-blob"); + GetArgs(BasePath, "my-container", "my-blob") + ).ShouldBe(Path.Combine(BasePath, "host", "my-container", "my-blob")); } [Fact] public void Default_Settings_With_TenantId() { - var separator = Path.DirectorySeparatorChar; var tenantId = Guid.NewGuid(); using (_currentTenant.Change(tenantId)) { _calculator.Calculate( - GetArgs($"C:{separator}my-files", "my-container", "my-blob") - ).ShouldBe($"C:{separator}my-files{separator}tenants{separator}{tenantId:D}{separator}my-container{separator}my-blob"); + GetArgs(BasePath, "my-container", "my-blob") + ).ShouldBe(Path.Combine(BasePath, "tenants", tenantId.ToString("D"), "my-container", "my-blob")); } } [Fact] public void AppendContainerNameToBasePath_Set_To_False() { - var separator = Path.DirectorySeparatorChar; + _calculator.Calculate( + GetArgs(BasePath, "my-container", "my-blob", appendContainerNameToBasePath: false) + ).ShouldBe(Path.Combine(BasePath, "host", "my-blob")); + } + [Fact] + public void Relative_BasePath() + { + _calculator.Calculate( + GetArgs("my-files", "my-container", "my-blob") + ).ShouldBe(Path.GetFullPath(Path.Combine("my-files", "host", "my-container", "my-blob"))); + } + + [Theory] + [InlineData("my-folder/my-blob")] + [InlineData("my-folder/my-sub-folder/my-blob")] + [InlineData("my..blob")] + [InlineData("..my-blob")] + public void Should_Allow_BlobName_Inside_Container(string blobName) + { + _calculator.Calculate( + GetArgs(BasePath, "my-container", blobName) + ).ShouldBe(Path.GetFullPath(Path.Combine(BasePath, "host", "my-container", blobName))); + } + + [Theory] + [InlineData("../my-blob")] + [InlineData("../../my-blob")] + [InlineData("../../../my-blob")] + [InlineData("my-folder/../../my-blob")] + [InlineData("my-folder/../my-blob")] + [InlineData("./my-blob")] + [InlineData(".")] + [InlineData("./")] + [InlineData("my-folder/..")] + public void Should_Throw_If_BlobName_Contains_Navigation_Segments(string blobName) + { + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, "my-container", blobName))); + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, "my-container", blobName.Replace('/', Path.DirectorySeparatorChar)))); + } + + [Fact] + public void Should_Throw_If_BlobName_Is_Rooted() + { + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, "my-container", Path.Combine(BasePath, "host", "my-container", "my-blob")))); + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, "my-container", Path.Combine(Path.GetTempPath(), "my-blob")))); + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, "my-container", Path.DirectorySeparatorChar + "my-blob"))); + } + + [Theory] + [InlineData("C:my-blob")] + [InlineData("\\my-blob")] + [InlineData("\\\\server\\share\\my-blob")] + [InlineData("\\\\?\\C:\\my-blob")] + public void Should_Throw_If_BlobName_Is_Rooted_On_Windows(string blobName) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, "my-container", blobName))); + } + + [Fact] + public void Should_Throw_If_BlobName_Points_To_Another_Tenant() + { + var tenantId = Guid.NewGuid(); + var otherTenantId = Guid.NewGuid(); + + using (_currentTenant.Change(tenantId)) + { + Should.Throw(() => _calculator.Calculate( + GetArgs(BasePath, "my-container", $"../../{otherTenantId:D}/my-container/my-blob"))); + + Should.Throw(() => _calculator.Calculate( + GetArgs(BasePath, "my-container", $"../{otherTenantId:D}/my-blob", appendContainerNameToBasePath: false))); + } + } + + [Theory] + [InlineData("../my-container")] + [InlineData("../../tenants/my-container")] + [InlineData("my-folder/../my-container")] + [InlineData(".")] + public void Should_Throw_If_ContainerName_Contains_Navigation_Segments(string containerName) + { + Should.Throw(() => _calculator.Calculate(GetArgs(BasePath, containerName, "my-blob"))); + } + + [Fact] + public void Should_Ignore_ContainerName_If_AppendContainerNameToBasePath_Set_To_False() + { _calculator.Calculate( - GetArgs($"C:{separator}my-files", "my-container", "my-blob", appendContainerNameToBasePath: false) - ).ShouldBe($"C:{separator}my-files{separator}host{separator}my-blob"); + GetArgs(BasePath, "../my-container", "my-blob", appendContainerNameToBasePath: false) + ).ShouldBe(Path.Combine(BasePath, "host", "my-blob")); } private static BlobProviderArgs GetArgs( diff --git a/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobContainer_Path_Tests.cs b/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobContainer_Path_Tests.cs new file mode 100644 index 0000000000..f1d3c48c9c --- /dev/null +++ b/framework/test/Volo.Abp.BlobStoring.FileSystem.Tests/Volo/Abp/BlobStoring/FileSystem/FileSystemBlobContainer_Path_Tests.cs @@ -0,0 +1,70 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.BlobStoring.TestObjects; +using Volo.Abp.MultiTenancy; +using Xunit; + +namespace Volo.Abp.BlobStoring.FileSystem; + +public class FileSystemBlobContainer_Path_Tests : AbpBlobStoringFileSystemTestBase +{ + private readonly IBlobContainer _container; + private readonly ICurrentTenant _currentTenant; + private readonly string _basePath; + + public FileSystemBlobContainer_Path_Tests() + { + _container = GetRequiredService>(); + _currentTenant = GetRequiredService(); + _basePath = GetRequiredService() + .Get() + .GetFileSystemConfiguration() + .BasePath; + } + + [Fact] + public async Task Should_Not_Access_Files_Outside_Container() + { + var outsideFilePath = Path.Combine(_basePath, "host", "outside.txt"); + Directory.CreateDirectory(Path.GetDirectoryName(outsideFilePath)!); + File.WriteAllText(outsideFilePath, "outside"); + + const string blobName = "../outside.txt"; + + await Should.ThrowAsync(() => _container.SaveAsync(blobName, "changed".GetBytes(), overrideExisting: true)); + await Should.ThrowAsync(() => _container.GetAllBytesOrNullAsync(blobName)); + await Should.ThrowAsync(() => _container.ExistsAsync(blobName)); + await Should.ThrowAsync(() => _container.DeleteAsync(blobName)); + + File.Exists(outsideFilePath).ShouldBeTrue(); + File.ReadAllText(outsideFilePath).ShouldBe("outside"); + } + + [Fact] + public async Task Should_Not_Access_Blobs_Of_Another_Tenant() + { + var tenantId = Guid.NewGuid(); + var otherTenantId = Guid.NewGuid(); + var containerName = BlobContainerNameAttribute.GetContainerName(); + + using (_currentTenant.Change(otherTenantId)) + { + await _container.SaveAsync("my-blob", "other tenant".GetBytes()); + } + + using (_currentTenant.Change(tenantId)) + { + var blobName = $"../../{otherTenantId:D}/{containerName}/my-blob"; + + await Should.ThrowAsync(() => _container.GetAllBytesOrNullAsync(blobName)); + await Should.ThrowAsync(() => _container.DeleteAsync(blobName)); + } + + using (_currentTenant.Change(otherTenantId)) + { + (await _container.GetAllBytesAsync("my-blob")).ShouldBe("other tenant".GetBytes()); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs index 5bb488106c..87503d3412 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs @@ -4,7 +4,9 @@ using System.ComponentModel.DataAnnotations; using System.IO; using System.Net.Mime; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Volo.Abp; +using Volo.Abp.Authorization; using Volo.Abp.BlobStoring; using Volo.Abp.Content; using Volo.Abp.Validation; @@ -24,7 +26,7 @@ namespace Volo.Blogging.Files public virtual async Task GetAsync(string name) { - Check.NotNullOrWhiteSpace(name, nameof(name)); + ValidateFileName(name); return new RawFileDto { @@ -34,10 +36,23 @@ namespace Volo.Blogging.Files public virtual async Task GetFileAsync(string name) { + ValidateFileName(name); + var fileStream = await BlobContainer.GetAsync(name); return new RemoteStreamContent(fileStream, name, GetByExtension(Path.GetExtension(name)), disposeStream: true); } + protected virtual void ValidateFileName(string name) + { + if (string.IsNullOrWhiteSpace(name) || + name.IndexOfAny(new[] { '/', '\\' }) >= 0 || + name == "." || + name == "..") + { + ThrowValidationException("Invalid file name!", nameof(name)); + } + } + private static string GetByExtension(string extension) { extension = extension.RemovePreFix(".").ToLowerInvariant(); @@ -61,6 +76,11 @@ namespace Volo.Blogging.Files public virtual async Task CreateAsync(FileUploadInputDto input) { + if (!await AuthorizationService.IsGrantedAnyAsync(BloggingPermissions.Posts.Create, BloggingPermissions.Posts.Update)) + { + throw new AbpAuthorizationException(); + } + if (input.File == null) { ThrowValidationException("Bytes of file can not be null or empty!", nameof(input.File)); diff --git a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs new file mode 100644 index 0000000000..a1787f6b49 --- /dev/null +++ b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Security.Claims; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using NSubstitute; +using Shouldly; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.PixelFormats; +using Volo.Abp.Authorization; +using Volo.Abp.BlobStoring; +using Volo.Abp.Content; +using Volo.Abp.Validation; +using Volo.Blogging.Files; +using Xunit; + +namespace Volo.Blogging +{ + public class FileAppService_Tests : BloggingApplicationTestBase + { + private readonly IFileAppService _fileAppService; + private IBlobContainer _blobContainer; + private FakeAuthorizationService _authorizationService; + + public FileAppService_Tests() + { + _fileAppService = GetRequiredService(); + } + + protected override void AfterAddApplication(IServiceCollection services) + { + _blobContainer = Substitute.For>(); + _blobContainer.GetAsync(Arg.Any(), Arg.Any()) + .Returns(_ => new MemoryStream(new byte[] { 1, 2, 3 })); + services.AddSingleton(_blobContainer); + + _authorizationService = new FakeAuthorizationService(); + services.Replace(ServiceDescriptor.Singleton(_authorizationService)); + services.Replace(ServiceDescriptor.Singleton(_authorizationService)); + } + + [Theory] + [InlineData("my-image.png")] + [InlineData("my..image.png")] + public async Task Should_Get_File(string name) + { + (await _fileAppService.GetAsync(name)).Bytes.ShouldBe(new byte[] { 1, 2, 3 }); + (await _fileAppService.GetFileAsync(name)).FileName.ShouldBe(name); + } + + [Theory] + [InlineData(" ")] + [InlineData(".")] + [InlineData("..")] + [InlineData("../my-image.png")] + [InlineData("..\\my-image.png")] + [InlineData("my-folder/my-image.png")] + [InlineData("my-folder\\my-image.png")] + public async Task Should_Not_Get_File_With_Invalid_Name(string name) + { + await Should.ThrowAsync(() => _fileAppService.GetAsync(name)); + await Should.ThrowAsync(() => _fileAppService.GetFileAsync(name)); + + await _blobContainer.DidNotReceiveWithAnyArgs().GetAsync(default, default); + } + + [Theory] + [InlineData(BloggingPermissions.Posts.Create)] + [InlineData(BloggingPermissions.Posts.Update)] + public async Task Should_Upload_Image_With_Create_Or_Update_Permission(string permission) + { + _authorizationService.GrantedPolicies.Add(permission); + + var output = await _fileAppService.CreateAsync(CreateUploadInput()); + + output.Name.ShouldEndWith(".png"); + output.WebUrl.ShouldBe("/api/blogging/files/www/" + output.Name); + await _blobContainer.Received(1).SaveAsync(output.Name, Arg.Any(), Arg.Any(), Arg.Any()); + } + + [Fact] + public async Task Should_Not_Upload_Image_Without_Permission() + { + _authorizationService.GrantedPolicies.Add(BloggingPermissions.Posts.Delete); + + await Should.ThrowAsync(() => _fileAppService.CreateAsync(CreateUploadInput())); + + await _blobContainer.DidNotReceiveWithAnyArgs().SaveAsync(default, default(Stream), default, default); + } + + private static FileUploadInputDto CreateUploadInput() + { + var stream = new MemoryStream(); + using (var image = new Image(1, 1)) + { + image.SaveAsPng(stream); + } + + stream.Position = 0; + + return new FileUploadInputDto + { + Name = "my-image.png", + File = new RemoteStreamContent(stream, "my-image.png", "image/png") + }; + } + + private class FakeAuthorizationService : IAbpAuthorizationService + { + public HashSet GrantedPolicies { get; } = new HashSet(); + + public IServiceProvider ServiceProvider => null; + + public ClaimsPrincipal CurrentPrincipal { get; } = new ClaimsPrincipal(); + + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, IEnumerable requirements) + { + return Task.FromResult(AuthorizationResult.Success()); + } + + public Task AuthorizeAsync(ClaimsPrincipal user, object resource, string policyName) + { + return Task.FromResult(GrantedPolicies.Contains(policyName) ? AuthorizationResult.Success() : AuthorizationResult.Failed()); + } + } + } +} From 44b26b6f29cc58969891e372dcba8a452fd839c4 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 5 Oct 2026 21:29:45 +0800 Subject: [PATCH 6/9] Validate generated file name before saving blog image --- .../Volo/Blogging/Files/FileAppService.cs | 1 + .../Volo/Blogging/FileAppService_Tests.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs index 87503d3412..d2b8e79690 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Files/FileAppService.cs @@ -105,6 +105,7 @@ namespace Volo.Blogging.Files } var uniqueFileName = GenerateUniqueFileName(Path.GetExtension(input.Name)); + ValidateFileName(uniqueFileName); await BlobContainer.SaveAsync(uniqueFileName, input.File.GetStream()); diff --git a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs index a1787f6b49..0ffd90a5f1 100644 --- a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs +++ b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/FileAppService_Tests.cs @@ -92,6 +92,19 @@ namespace Volo.Blogging await _blobContainer.DidNotReceiveWithAnyArgs().SaveAsync(default, default(Stream), default, default); } + [Fact] + public async Task Should_Not_Upload_Image_With_Invalid_Name() + { + _authorizationService.GrantedPolicies.Add(BloggingPermissions.Posts.Create); + + var input = CreateUploadInput(); + input.Name = "my-image.png\\my-folder"; + + await Should.ThrowAsync(() => _fileAppService.CreateAsync(input)); + + await _blobContainer.DidNotReceiveWithAnyArgs().SaveAsync(default, default(Stream), default, default); + } + private static FileUploadInputDto CreateUploadInput() { var stream = new MemoryStream(); From cc37ea79eb3a44ae134c14028c5a5a6d2f074c6c Mon Sep 17 00:00:00 2001 From: Tarik Ozdemir <96834270+tarikozdemir@users.noreply.github.com> Date: Mon, 5 Oct 2026 23:04:54 +0300 Subject: [PATCH 7/9] Fix grammar and clarity in module documentation Corrected minor grammatical errors and improved clarity in the documentation regarding module development and dependency registration. --- docs/en/framework/architecture/modularity/basics.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/framework/architecture/modularity/basics.md b/docs/en/framework/architecture/modularity/basics.md index c6ee6f567c..0de5b9bc26 100644 --- a/docs/en/framework/architecture/modularity/basics.md +++ b/docs/en/framework/architecture/modularity/basics.md @@ -13,7 +13,7 @@ ABP was designed to support to build fully modular applications and systems wher * The [modular monolith application development tutorial](../../../tutorials/modular-crm/index.md) explains and demonstrates how to build **modular monolith applications** with ABP. * [Pre-built application modules](../../../modules/index.md) are **ready to use** in any kind of application. * [Module startup template](../../../solution-templates/application-module/index.md) is a jump start way to **create a new reusable application module**. -* [Module development best practice guide](../best-practices/index.md) explains some **best practices** to develop **re-usable application modules** based on **DDD** principles and layers. A module designed based on this guide will be **database independent** and can be deployed as a **microservice** if needed. +* [Module development best practice guide](../best-practices/index.md) explains some **best practices** to develop **re-usable application modules** based on **DDD** principles and layers. A module designed based on this guide will be **database-independent** and can be deployed as a **microservice** if needed. * [ABP CLI](../../../cli/index.md) has commands to support modular development. * All other framework features are compatible to the modularity system. @@ -46,7 +46,7 @@ public class BlogModule : AbpModule } ```` -You can register dependencies one by one as stated in Microsoft's [documentation](../../fundamentals/dependency-injection.md). But ABP has a **conventional dependency registration system** which automatically register all services in your assembly. See the [dependency Injection](../../fundamentals/dependency-injection.md) documentation for more about the dependency injection system. +You can register dependencies one by one as stated in Microsoft's [documentation](../../fundamentals/dependency-injection.md). But ABP has a **conventional dependency registration system** which automatically registers all services in your assembly. See the [dependency Injection](../../fundamentals/dependency-injection.md) documentation for more about the dependency injection system. You can also configure other services and modules in this way. Example: @@ -186,7 +186,7 @@ Contributor order is the order of the `Contributors` list. The four built-in con Lastly, you can override ``OnApplicationShutdown`` method if you want to execute some code while application is being shutdown. -> This methods has asynchronous version too. If you want to make asynchronous calls inside this method, override the asynchronous version instead of the synchronous one. +> This method has an asynchronous version too. If you want to make asynchronous calls inside this method, override the asynchronous version instead of the synchronous one. ## Module Dependencies @@ -201,7 +201,7 @@ public class BlogModule } ```` -You can use multiple ``DependsOn`` attribute or pass multiple module types to a single ``DependsOn`` attribute depending on your preference. +You can use multiple ``DependsOn`` attributes or pass multiple module types to a single ``DependsOn`` attribute depending on your preference. A depended module may depend on another module, but you only need to define your direct dependencies. ABP investigates the dependency graph for the application at startup and initializes/shutdowns modules in the correct order. @@ -224,13 +224,13 @@ In this example, we assume that the `BlogService` class is inside one assembly ( Notice that `BlogService` is only an arbitrary selected type in the target assembly. It is just used to indicate the related assembly. You could use any type in the assembly. -> WARNING: If you need to use the `AdditionalAssembly`, be sure that you don't design your system in a wrong way. With this example above, the `BlogService` class' assembly should normally have its own module class and the `BlogModule` should depend on it using the `DependsOn` attribute. Do not use the `AdditionalAssembly` attribute when you can already use the `DependsOn` attribute. +> WARNING: If you need to use the `AdditionalAssembly`, be sure that you don't design your system in a wrong way. With the example above, the `BlogService` class' assembly should normally have its own module class and the `BlogModule` should depend on it using the `DependsOn` attribute. Do not use the `AdditionalAssembly` attribute when you can already use the `DependsOn` attribute. ## Framework Modules vs Application Modules There are **two types of modules.** They don't have any structural difference but categorized by functionality and purpose: -- **Framework modules**: These are **core modules of the framework** like caching, emailing, theming, security, serialization, validation, EF Core integration, MongoDB integration... etc. They do not have application/business functionalities but makes your daily development easier by providing common infrastructure, integration and abstractions. +- **Framework modules**: These are **core modules of the framework** like caching, emailing, theming, security, serialization, validation, EF Core integration, MongoDB integration... etc. They do not have application/business functionalities but make your daily development easier by providing common infrastructure, integration and abstractions. - **Application modules**: These modules implement **specific application/business functionalities** like blogging, document management, identity management, tenant management... etc. They generally have their own entities, services, APIs and UI components. See [pre-built application modules](../../../modules). ## See Also From a83978fde2a82feccde4a2327679509f47a929d5 Mon Sep 17 00:00:00 2001 From: Tarik Ozdemir <96834270+tarikozdemir@users.noreply.github.com> Date: Mon, 5 Oct 2026 23:25:40 +0300 Subject: [PATCH 8/9] Fix typos and enhance clarity in entities.md Corrected typos and improved clarity in the entities documentation. --- .../architecture/best-practices/entities.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/en/framework/architecture/best-practices/entities.md b/docs/en/framework/architecture/best-practices/entities.md index b96e9c1a9d..da35893265 100644 --- a/docs/en/framework/architecture/best-practices/entities.md +++ b/docs/en/framework/architecture/best-practices/entities.md @@ -13,7 +13,7 @@ ## Entities -Every aggregate root is also an entity. So, these rules are valid for aggregate roots too unless aggregate root rules override them. +Every aggregate root is also an entity. So, these rules are valid for aggregate roots too, unless aggregate root rules override them. - **Do** define entities in the **domain layer**. @@ -22,7 +22,7 @@ Every aggregate root is also an entity. So, these rules are valid for aggregate * **Do** define a **primary constructor** that ensures the validity of the entity on creation. Primary constructors are used to create a new instance of the entity by the application code. - **Do** define primary constructor as `public`, `internal` or `protected internal` based on the requirements. If it's not public, the entity is expected to be created by a domain service. -- **Do** always initialize sub collections in the primary constructor. +- **Do** always initialize sub-collections in the primary constructor. - **Do not** generate `Guid` keys inside the constructor. Get it as a parameter, so the calling code will use `IGuidGenerator` to generate a new `Guid` value. ### Parameterless Constructor @@ -55,7 +55,7 @@ Every aggregate root is also an entity. So, these rules are valid for aggregate ### Aggregate Boundary -* **Do** keep aggregates **as small as possible**. Most of the aggregates will only have primitive properties and will not have sub collections. Consider these as design decisions: +* **Do** keep aggregates **as small as possible**. Most aggregates will have only primitive properties and no sub-collections. Consider these as design decisions: * **Performance** & **memory** cost of loading & saving aggregates (keep in mind that an aggregate is normally loaded & saved as a single unit). Larger aggregates will consume more CPU & memory. * **Consistency** & **validity** boundary. @@ -75,9 +75,9 @@ public class Issue : FullAuditedAggregateRoot //Using Guid as the key/iden protected Issue() { - /* This constructor is for ORMs to be used while getting the entity from database. + /* This constructor is for ORMs to be used while getting the entity from the database. * - No need to initialize the Labels collection - since it will be overrided from the database. + since it will be overridden from the database. - It's protected since proxying and deserialization tools may not work with private constructors. */ @@ -104,7 +104,7 @@ public class Issue : FullAuditedAggregateRoot //Using Guid as the key/iden return this; } - /* AddLabel & RemoveLabel methods manages the Labels collection + /* AddLabel & RemoveLabel methods manage the Labels collection * in a safe way (prevents adding the same label twice) */ public virtual Issue AddLabel(Guid labelId) @@ -170,4 +170,4 @@ public class IssueLabel : Entity ## See Also -* [Video tutorial](https://abp.io/video-courses/essentials/entities) \ No newline at end of file +* [Video tutorial](https://abp.io/video-courses/essentials/entities) From 4390eebaa8fe6bc8790cec55b816f67aca41ff68 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 5 Oct 2026 23:34:36 +0300 Subject: [PATCH 9/9] Fix formatting and consistency in dependency injection section Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- docs/en/framework/architecture/modularity/basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/framework/architecture/modularity/basics.md b/docs/en/framework/architecture/modularity/basics.md index 0de5b9bc26..ebbf76d558 100644 --- a/docs/en/framework/architecture/modularity/basics.md +++ b/docs/en/framework/architecture/modularity/basics.md @@ -46,7 +46,7 @@ public class BlogModule : AbpModule } ```` -You can register dependencies one by one as stated in Microsoft's [documentation](../../fundamentals/dependency-injection.md). But ABP has a **conventional dependency registration system** which automatically registers all services in your assembly. See the [dependency Injection](../../fundamentals/dependency-injection.md) documentation for more about the dependency injection system. +You can register dependencies one by one as stated in Microsoft's [documentation](../../fundamentals/dependency-injection.md). But ABP has a **conventional dependency registration system** which automatically registers all services in your assembly. See the [dependency injection](../../fundamentals/dependency-injection.md) documentation for more about the dependency injection system. You can also configure other services and modules in this way. Example: