Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/cli/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
"modavd/internal/report"
)

// scriptPrivacyHead is the first line of collect-info.ps1's privacy note; report.PrivacyNote says it differently.
const scriptPrivacyHead = "隐私提示:问题包只保存在本机,脚本不会上传。"

// golden reads what a package script printed for a test scenario (internal/report/testdata/golden), LF line ends.
func golden(t *testing.T, parts ...string) string {
t.Helper()
Expand Down Expand Up @@ -45,6 +48,12 @@ func TestHumanCollectInfoMatchesScript(t *testing.T) {
}{{"full", true, nil}, {"bare", false, []string{"杀毒软件:无效命名空间 "}}} {
console := golden(t, c.name, "collect-console.txt")
want := console[strings.Index(console, "\n收集完成。\n"):]
// but for the first line of the privacy note (report.PrivacyNote): a script no longer collects
head, _, _ := strings.Cut(report.PrivacyNote, "\r\n")
if strings.Count(want, scriptPrivacyHead+"\n") != 1 {
t.Fatalf("%s: the script's privacy note head not found once", c.name)
}
want = strings.Replace(want, scriptPrivacyHead+"\n", head+"\n", 1)
res := &report.CollectResult{
ZipPath: `{{BASE}}\out\魔改AVD问题信息-20260115-120000.zip`, ZipSize: "{{SIZE}}",
PrivacyNote: report.PrivacyNote, MasFound: c.mas, Problems: c.problems,
Expand Down
25 changes: 21 additions & 4 deletions internal/report/parity_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,27 @@ func compareLines(t *testing.T, what string, got, want []string) {
}
}

// scriptPrivacyHead is the first line of collect-info.ps1's $PrivacyNote, which PrivacyNote says differently.
const scriptPrivacyHead = "隐私提示:问题包只保存在本机,脚本不会上传。"

// modavdPrivacyHead is PrivacyNote's first line.
func modavdPrivacyHead() string {
head, _, _ := strings.Cut(PrivacyNote, "\r\n")
return head
}

// modavdLine is what modavd writes on purpose instead of a line of collect-info.ps1's summary.txt:
// - the PowerShell that ran the script: modavd's version and Go version;
// - the adb.exe the live section runs: modavd speaks the adb host protocol itself (no adb.exe, never a server of
// its own), to the server that listens on the port.
// its own), to the server that listens on the port;
// - the first line of the privacy note: who does not upload is the manager or the CLI, not a script.
func (f *fixture) modavdLine(line string) string {
if line == "PowerShell:{{PSVERSION}}" {
return "modavd:" + buildinfo.Version + "(" + runtime.Version() + ")"
}
if line == scriptPrivacyHead {
return modavdPrivacyHead()
}
if strings.HasPrefix(line, "adb:") && strings.Contains(line, " -P "+strconv.Itoa(f.adbPort)+"(") {
var pid uint32
for _, l := range f.sc.Listeners {
Expand Down Expand Up @@ -353,13 +366,17 @@ func TestCollectMatchesScript(t *testing.T) {
}
}

// the end of the console output: zip path, the privacy note word for word
// the end of the console output: zip path, the privacy note word for word but for its first line
console, _ := f.golden(t, name, "collect-console.txt")
if !containsLine(lines(console), "文件:"+res.ZipPath) {
t.Errorf("zip %s, the script printed:\n%s", res.ZipPath, console)
}
if !strings.Contains(console, PrivacyNote) || res.PrivacyNote != PrivacyNote {
t.Error("the privacy note is not the one collect-info.ps1 prints")
scriptNote := scriptPrivacyHead + strings.TrimPrefix(PrivacyNote, modavdPrivacyHead())
if !strings.Contains(console, scriptNote) || res.PrivacyNote != PrivacyNote {
t.Error("the privacy note is not the one collect-info.ps1 prints, but for its first line")
}
if strings.Contains(PrivacyNote, "脚本") || !strings.HasPrefix(PrivacyNote, "隐私提示:问题包只保存在本机,") {
t.Errorf("privacy note head %q", modavdPrivacyHead())
}
if exists(res.Stage) || res.StageKept {
t.Errorf("stage %s left behind", res.Stage)
Expand Down
6 changes: 4 additions & 2 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import (
"modavd/internal/root"
)

// PrivacyNote is collect-info.ps1's $PrivacyNote, word for word: the head of summary.txt and the last thing printed.
const PrivacyNote = "隐私提示:问题包只保存在本机,脚本不会上传。\r\n" +
// PrivacyNote is the head of summary.txt and the last thing printed: collect-info.ps1's $PrivacyNote word for word,
// but for the first line. The script's said "脚本不会上传"; from ModAVD 0.38.2 the package has no such script any
// more (ModAVD/ModAVD#45), and what collects and what could upload is the manager or the CLI, so it says those.
const PrivacyNote = "隐私提示:问题包只保存在本机,管理器和命令行都不会上传它。\r\n" +
"- 里面有:summary.txt(电脑和模拟器的情况)、模拟器日志、实例配置、AUTO-MAS 日志(mas 文件夹);有实例在运行时还有现场截图和安卓状态(live 文件夹);模拟器近 7 天崩溃过的话还有崩溃转储(crash 文件夹)。不收磁盘镜像,不收 AUTO-MAS 的配置和账号数据,也不会有意收集账号密码。\r\n" +
"- 这些文件里都有本机路径,路径里可能有 Windows 用户名;截图和 AUTO-MAS 日志里可能有游戏账号名。\r\n" +
"- 可以公开:在 GitHub Issue(https://github.com/ModAVD/ModAVD/issues)里贴 summary.txt 和日志,或者上传删掉 crash 文件夹后的问题包。上传前看一眼,不想公开的内容先删掉。\r\n" +
Expand Down
Loading