fix(management): reject native alarm source names that are not legal actor names (review 2026-10-21 lane F follow-up to 01/SR-C1)
This commit is contained in:
@@ -3309,8 +3309,23 @@ public class ManagementActor : ReceiveActor
|
||||
|
||||
// ── Native alarm source bindings (read-only mirror; repository-direct CRUD) ──
|
||||
|
||||
/// <summary>
|
||||
/// A native alarm source's name becomes part of the site actor name
|
||||
/// <c>native-alarm-{canonical}</c>; an illegal character makes the Instance Actor's
|
||||
/// <c>ActorOf</c> throw at deploy. Scripts, alarms and composition slots are checked by
|
||||
/// <c>TemplateService</c>, but native-source CRUD is repository-direct here, so it applies
|
||||
/// <see cref="ActorNameRules"/> itself (review 2026-10-21, lane F follow-up to 01/SR-C1).
|
||||
/// </summary>
|
||||
private static void ValidateNativeAlarmSourceName(string? name)
|
||||
{
|
||||
var error = ActorNameRules.Describe(name);
|
||||
if (error is not null)
|
||||
throw new ManagementCommandException($"Native alarm source name is invalid: {error}");
|
||||
}
|
||||
|
||||
private static async Task<object?> HandleAddNativeAlarmSource(IServiceProvider sp, AddTemplateNativeAlarmSourceCommand cmd, string user)
|
||||
{
|
||||
ValidateNativeAlarmSourceName(cmd.Name);
|
||||
var repo = sp.GetRequiredService<ITemplateEngineRepository>();
|
||||
var source = new TemplateNativeAlarmSource(cmd.Name)
|
||||
{
|
||||
@@ -3331,6 +3346,7 @@ public class ManagementActor : ReceiveActor
|
||||
|
||||
private static async Task<object?> HandleUpdateNativeAlarmSource(IServiceProvider sp, UpdateTemplateNativeAlarmSourceCommand cmd, string user)
|
||||
{
|
||||
ValidateNativeAlarmSourceName(cmd.Name);
|
||||
var repo = sp.GetRequiredService<ITemplateEngineRepository>();
|
||||
var source = await repo.GetTemplateNativeAlarmSourceByIdAsync(cmd.NativeAlarmSourceId)
|
||||
?? throw new ManagementCommandException($"Native alarm source {cmd.NativeAlarmSourceId} not found.");
|
||||
|
||||
Reference in New Issue
Block a user