Files
Playa/hosts/Volcanic.AgenticCore.Telegram/TelegramProcessEnvironment.cs
EugeneTes 76bda6cf55 fix(processes): address review findings
- Fill TimeZoneId only for a configured session/host zone with a resolvable IANA id
  (IExtensionHost.TimeZoneId); otherwise children inherit the host's TZ instead of TZ=Local/UTC.
- Host hardening logs a warning instead of throwing when libc/prctl can't be resolved.
- A hook or process_spawn handler returning a null or incomplete context fails the spawn with
  InvalidOperationException, so bash reports "process environment hook failed".
- Move tool-result redaction into the Agent slice with a behavioural no-change check.
- ProcessSpawnContext.ApplyTo(psi) sets cwd and replaces the environment; used by bash and ExecAsync.
- Split the Telegram process environment types into their own files; move the Extensions.Tests
  NoHostHardening under Support/; check the Claude Code assembly never references the spawn policy.
- Spec and docs: TZ inheritance, incomplete contexts, ApplyTo, async spawn handlers, root skip.
2026-09-26 19:32:47 +02:00

32 lines
1.6 KiB
C#

using Volcanic.AgenticCore.Features.Processes;
namespace Volcanic.AgenticCore.Telegram;
/// <summary>The Telegram host's process environment: section, <c>PROCESS_ENV_ALLOW</c> and the host's secret values.</summary>
public static class TelegramProcessEnvironment
{
public const string AllowVariable = "PROCESS_ENV_ALLOW";
/// <summary>Adds the section's lists, <c>PROCESS_ENV_ALLOW</c> and the bot token to <paramref name="target"/>.</summary>
public static void Configure(ProcessEnvironmentOptions target, TelegramOptions telegram, ProcessEnvironmentSection section, Func<string, string?> getEnv)
{
ArgumentNullException.ThrowIfNull(target);
ArgumentNullException.ThrowIfNull(telegram);
ArgumentNullException.ThrowIfNull(section);
ArgumentNullException.ThrowIfNull(getEnv);
target.Deny.AddRange(section.Deny);
target.Allow.AddRange(section.Allow);
if (getEnv(AllowVariable) is { Length: > 0 } allow)
target.Allow.AddRange(allow.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries));
target.HardenHostProcess = section.HardenHostProcess;
if (!string.IsNullOrWhiteSpace(telegram.BotToken)) target.SecretValues.Add(telegram.BotToken);
}
/// <summary>The startup log line: names only, never values.</summary>
public static string Describe(ProcessEnvironmentOptions options)
{
ArgumentNullException.ThrowIfNull(options);
return $"Process environment: {options.Deny.Count} deny rules, allow: {(options.Allow.Count == 0 ? "none" : string.Join(", ", options.Allow))}";
}
}