- NOTICE: copyright, GPL-3.0-only, and three additional terms of the kinds section 7 permits - (b) preserve the notices and the attribution in the program's legal notices, (c) mark a modified version as different and do not call it "FrameLedger" alone, (e) no trademark rights in the name. Shipped as licenses\NOTICE.txt; release.yml refuses a published tree without it. - Section 7 wants additional terms named in the source files: every first-party .cs .cpp .h .inl .ps1 .xaml file (1,053; src/native/third_party excluded) opens with the SPDX line and a pointer to NOTICE. tools/notice-check.ps1 is the gate (six self-test cases, both directions; -Fix writes a missing header) and tools/resx-gen.ps1 generates the string accessors with the header. - The native VERSIONINFO LegalCopyright said GPL-3.0-or-later; it now names the real licence. - CONTRIBUTING.md, FORKING.md, CODE_OF_CONDUCT.md (Contributor Covenant 2.1 by reference), legal/TRADEMARKS.md. - 12_BUILD gate list, CLAUDE.md layout and conventions. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
5.6 KiB
C#
90 lines
5.6 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using FluentAssertions;
|
|
using FrameLedger.Application.AntiCheat;
|
|
using FrameLedger.Domain.AntiCheat;
|
|
using FrameLedger.Domain.Consent;
|
|
|
|
namespace FrameLedger.Application.Tests.AntiCheat;
|
|
|
|
/// <summary>
|
|
/// D33 (owner decision 2026-09-26): the managed half of the user-mode exception can only narrow. A family is named to the
|
|
/// guard only when the option is on, a grant is on the row for these bytes, and the block is a module, file or folder
|
|
/// finding of that family; a game is eligible only when the guard let exactly that family through — D38 (2026-10-03):
|
|
/// with no session needed, and never once an exception of the game failed its trial.
|
|
/// </summary>
|
|
public sealed class UserModeExceptionRulesTests
|
|
{
|
|
private const string _block = "AntiCheatFile|NetEase Yidun|NEP2.dll";
|
|
|
|
private static ExecutableFingerprint OnDisk => new() { ExePath = @"C:\Games\GF2\GF2_Exilium.exe", SizeBytes = 10, MtimeUnixMs = 20 };
|
|
|
|
private static GameConsentRecord Record(string? block = _block, AntiCheatExceptionGrant? grant = null) =>
|
|
GameConsentRecord.Stored(OnDisk, hookEnabled: true, DateTimeOffset.UnixEpoch, ConsentProvenance.ConsentDialog, "consent-dialog/1", block,
|
|
preScanUnverified: false, DateTimeOffset.UnixEpoch, grant);
|
|
|
|
private static AntiCheatExceptionGrant Grant(string family = "NetEase Yidun", long size = 10, long mtime = 20) => new()
|
|
{
|
|
Family = family,
|
|
GrantedAt = DateTimeOffset.UnixEpoch,
|
|
DisclosureVersion = "ac-exception-dialog/2",
|
|
ExeSizeBytes = size,
|
|
ExeMtimeUnixMs = mtime,
|
|
};
|
|
|
|
[Fact]
|
|
public void TheFamilyIsNamedOnlyWhenEveryConditionHolds()
|
|
{
|
|
UserModeExceptionRules.CoveredFamily(Record(grant: Grant()), OnDisk, optionOn: true).Should().Be("NetEase Yidun");
|
|
|
|
UserModeExceptionRules.CoveredFamily(Record(grant: Grant()), OnDisk, optionOn: false).Should().BeNull("off suspends every exception");
|
|
UserModeExceptionRules.CoveredFamily(Record(), OnDisk, optionOn: true).Should().BeNull("no grant, no exception");
|
|
UserModeExceptionRules.CoveredFamily(Record(grant: Grant(size: 11)), OnDisk, optionOn: true).Should().BeNull("a game update ends it");
|
|
UserModeExceptionRules.CoveredFamily(Record(grant: Grant(family: "Anybrain")), OnDisk, optionOn: true).Should().BeNull("the grant is for the block's family");
|
|
UserModeExceptionRules.CoveredFamily(Record(block: "BlockedStoreId|NetEase Yidun|steam:1", grant: Grant()), OnDisk, optionOn: true)
|
|
.Should().BeNull("a title list is never excepted");
|
|
UserModeExceptionRules.CoveredFamily(Record(block: null, grant: Grant()), OnDisk, optionOn: true).Should().BeNull("an exception exists only over a block");
|
|
UserModeExceptionRules.CoveredFamily(default, OnDisk, optionOn: true).Should().BeNull("a record nobody stored excepts nothing");
|
|
}
|
|
|
|
[Fact]
|
|
public void EligibleMeansTheGuardLetThatFamilyThroughAndNoTrialFailed()
|
|
{
|
|
StoredBlock? block = StoredBlock.Parse(_block);
|
|
AntiCheatVerdict through = AntiCheatVerdict.AllowedUnderException("NetEase Yidun", "NEP2.dll");
|
|
|
|
UserModeExceptionRules.IsEligible(block, through, trialFailed: false).Should().BeTrue("D38: no session is needed before a grant");
|
|
UserModeExceptionRules.IsEligible(block, through, trialFailed: true).Should().BeFalse("an exception that failed its trial is never made again");
|
|
UserModeExceptionRules.IsEligible(block, AntiCheatVerdict.Allowed(), trialFailed: false).Should().BeFalse("a plain pass let nothing through, so it confirmed nothing");
|
|
UserModeExceptionRules.IsEligible(block, AntiCheatVerdict.AllowedUnderException("Anybrain", "x.dll"), trialFailed: false).Should().BeFalse();
|
|
UserModeExceptionRules.IsEligible(block, AntiCheatVerdict.Refused(AntiCheatRefusalReason.AntiCheatFile, "Kernel driver in the game folder", "NEPKernel.sys"),
|
|
trialFailed: false).Should().BeFalse("the Aniimo shape");
|
|
UserModeExceptionRules.IsEligible(StoredBlock.Parse("BlockedExecutable|Valve VAC|cs2.exe"), through, trialFailed: false).Should().BeFalse();
|
|
UserModeExceptionRules.IsEligible(null, through, trialFailed: false).Should().BeFalse();
|
|
}
|
|
|
|
/// <summary>D38: the owner's trial is two good sessions under the grant; until then it is a trial.</summary>
|
|
[Fact]
|
|
public void TheTrialIsTheGrantsFirstTwoGoodSessions()
|
|
{
|
|
UserModeExceptionRules.TrialSessions.Should().Be(2);
|
|
UserModeExceptionRules.InTrial(0).Should().BeTrue();
|
|
UserModeExceptionRules.InTrial(1).Should().BeTrue();
|
|
UserModeExceptionRules.InTrial(2).Should().BeFalse();
|
|
UserModeExceptionRules.InTrial(9).Should().BeFalse();
|
|
}
|
|
|
|
[Fact]
|
|
public void AStoredBlockIsReadOnlyInItsThreeSlotShape()
|
|
{
|
|
StoredBlock.Parse(_block).Should().Be(new StoredBlock(AntiCheatRefusalReason.AntiCheatFile, "NetEase Yidun", "NEP2.dll"));
|
|
StoredBlock.Parse("AntiCheatFile: NetEase Yidun NEP2.dll").Should().BeNull("a row from before 2026-09-25 cannot be split back apart");
|
|
StoredBlock.Parse("3|NetEase Yidun|NEP2.dll").Should().BeNull("a number is not a reason's name");
|
|
StoredBlock.Parse("antichEatfile|NetEase Yidun|NEP2.dll").Should().BeNull("names are exact");
|
|
StoredBlock.Parse(null).Should().BeNull();
|
|
StoredBlock.Parse("AntiCheatDirectory|NetEase Yidun|Yidun|x")!.Value.Signal.Should().Be("Yidun|x", "the signal is the last slot");
|
|
new StoredBlock(AntiCheatRefusalReason.BlockedModule, string.Empty, "x.dll").IsExceptionable.Should().BeFalse("a finding that names no family");
|
|
}
|
|
}
|