Skip to content

Commit bfcd924

Browse files
joshhanson314claude
andcommitted
#4565 Add input validation to InMemorySessionStore
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e61a034 commit bfcd924

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Source/Csla.AspNetCore/Blazor/State/InMemorySessionStore.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@ public class InMemorySessionStore : ISessionStore
2222
/// <inheritdoc />
2323
public ValueTask<Session?> GetSessionAsync(string key)
2424
{
25+
ArgumentNullException.ThrowIfNull(key);
2526
_sessions.TryGetValue(key, out var session);
2627
return new ValueTask<Session?>(session);
2728
}
2829

2930
/// <inheritdoc />
3031
public ValueTask AddOrUpdateSessionAsync(string key, Session session)
3132
{
33+
ArgumentNullException.ThrowIfNull(key);
34+
ArgumentNullException.ThrowIfNull(session);
3235
_sessions.AddOrUpdate(key, session, (_, _) => session);
3336
return ValueTask.CompletedTask;
3437
}
3538

3639
/// <inheritdoc />
3740
public ValueTask PurgeExpiredSessionsAsync(TimeSpan expiration)
3841
{
42+
ArgumentOutOfRangeException.ThrowIfNegative(expiration.Ticks, nameof(expiration));
3943
var expirationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - expiration.TotalSeconds;
4044
List<string> toRemove = [];
4145
foreach (var kvp in _sessions)

0 commit comments

Comments
 (0)