- 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>
64 lines
3.4 KiB
C#
64 lines
3.4 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using System.Text;
|
|
using FluentAssertions;
|
|
using FrameLedger.App.Services;
|
|
|
|
namespace FrameLedger.App.Tests;
|
|
|
|
/// <summary>
|
|
/// <c>legal/PRIVACY_POLICY.md</c> §3 (P4 follow-up, 2026-09-15): a user name in a path never leaves the machine in a log
|
|
/// copy, in any spelling a log carries, and nothing else in the file changes.
|
|
/// </summary>
|
|
public sealed class LogRedactorTests
|
|
{
|
|
private static readonly LogRedactor _redactor = new(@"C:\Users\kuujo");
|
|
|
|
[Theory]
|
|
[InlineData(@"ledger C:\Users\kuujo\AppData\Local\FrameLedger\ledger.db", @"ledger C:\Users\<user>\AppData\Local\FrameLedger\ledger.db")]
|
|
[InlineData(@"{""Path"":""C:\\Users\\kuujo\\AppData\\Local""}", @"{""Path"":""C:\\Users\\<user>\\AppData\\Local""}")]
|
|
[InlineData("file:///c:/users/KUUJO/Documents/x.txt", "file:///c:/users/<user>/Documents/x.txt")]
|
|
[InlineData(@"C:\Users\John Smith\Documents", @"C:\Users\<user>\Documents")]
|
|
[InlineData(@"'C:\Users\kuujo'", @"'C:\Users\<user>'")]
|
|
[InlineData("profile C:\\Users\\kuujo\r\nnext", "profile C:\\Users\\<user>\r\nnext")]
|
|
[InlineData(@"image C:\Users\Nguy?n\Games\title.exe", @"image C:\Users\<user>\Games\title.exe")]
|
|
[InlineData(@"two C:\Users\a\x and D:\Users\b\y", @"two C:\Users\<user>\x and D:\Users\<user>\y")]
|
|
public void TheNameInAUsersPathBecomesThePlaceholderInEverySpelling(string log, string expected)
|
|
{
|
|
_redactor.Redact(log).Should().Be(expected);
|
|
_redactor.Redact(_redactor.Redact(log)).Should().Be(expected, "redacting a copy twice changes nothing more");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(@"C:\Program Files\FrameLedger\FrameLedger.exe")]
|
|
[InlineData(@"D:\Games\Users\title.exe")]
|
|
[InlineData(@"C:\Userspace\x")]
|
|
[InlineData("Users: 3, sessions: 12")]
|
|
[InlineData(@"C:\Users\")]
|
|
public void TextThatNamesNoUserIsUnchanged(string log) => _redactor.Redact(log).Should().Be(log);
|
|
|
|
[Fact]
|
|
public void AProfileOutsideTheUsersFolderIsRedactedByItsOwnPath()
|
|
{
|
|
var redirected = new LogRedactor(@"D:\Profiles\kuujo");
|
|
|
|
redirected.Redact(@"ledger D:\Profiles\kuujo\AppData\Local\FrameLedger\ledger.db").Should().Be(@"ledger D:\Profiles\<user>\AppData\Local\FrameLedger\ledger.db");
|
|
redirected.Redact(@"{""P"":""d:\\profiles\\KUUJO\\x""}").Should().Be(@"{""P"":""d:\\profiles\\<user>\\x""}");
|
|
redirected.Redact(@"D:\Profiles\kuujo2\x").Should().Be(@"D:\Profiles\kuujo2\x", "another folder that merely starts with the name");
|
|
new LogRedactor(null).Redact(@"D:\Profiles\kuujo\x").Should().Be(@"D:\Profiles\kuujo\x", "without a profile only X:\\Users paths are known");
|
|
}
|
|
|
|
[Fact]
|
|
public void BytesOutsideTheNamesAreKeptExactlyInUtf8AndInAnsi()
|
|
{
|
|
byte[] utf8 = Encoding.UTF8.GetBytes("[12:00:00.000 INF] Thiết lập đã lưu C:\\Users\\Nguyễn\\AppData\r\n");
|
|
byte[] expectedUtf8 = Encoding.UTF8.GetBytes("[12:00:00.000 INF] Thiết lập đã lưu C:\\Users\\<user>\\AppData\r\n");
|
|
byte[] ansi = [.. Encoding.ASCII.GetBytes("# image C:\\Users\\Jos"), 0xE9, .. Encoding.ASCII.GetBytes("\\Games\\t.exe\n")];
|
|
byte[] expectedAnsi = Encoding.ASCII.GetBytes("# image C:\\Users\\<user>\\Games\\t.exe\n");
|
|
|
|
_redactor.Redact(utf8).Should().Equal(expectedUtf8);
|
|
_redactor.Redact(ansi).Should().Equal(expectedAnsi);
|
|
}
|
|
}
|