Skip to content

Execution audit log bypasses AppStorageEnvironment, so UI tests write to the developer's own log #2242

Description

@datlechin

Found while running swiftlint --strict over the result-chart work in #2222. It is not from that branch: it reproduces on main with no local changes.

ExecutionAuditLog.defaultFileURL() resolves Application Support directly:

internal static func defaultFileURL() -> URL? {
    guard let support = try? FileManager.default.url(
        for: .applicationSupportDirectory,
        in: .userDomainMask,
        appropriateFor: nil,
        create: true
    ) else { return nil }

The repo's own custom rule rejects this:

TablePro/Core/Services/Execution/ExecutionAuditLog.swift:40:19: error: Storage Environment Directory Violation:
Resolve the directory through AppStorageEnvironment.shared, or a UI test writes to the developer's own store.
(storage_environment_directory)

Two consequences:

  1. swiftlint --strict fails on main, so the gate cannot distinguish a new violation from this one. Anyone running the mandatory lint step gets a red run they did not cause and learns to ignore it.
  2. The rule exists because UI tests launch the real app. TableProUITests runs a sandboxed store through AppStorageEnvironment, and this path sidesteps it, so a UI test run appends to the developer's own execution audit log. That log is hash chained, so foreign entries are not merely noise: they are indistinguishable from real ones and they move the chain forward.

What to do: resolve the directory through AppStorageEnvironment.shared like the other storage classes.

Verified: reproduced on main at edae33c with a clean tree (stashed every local change and re-ran the linter against that one file).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions