Skip to content

Сделать Sidecar UV2 replay локальным (EditorPrefs, по умолчанию выключено) - #121

Closed
SashaRX wants to merge 1 commit into
mainfrom
codex/propose-fix-for-sidecar-replay-vulnerability
Closed

Сделать Sidecar UV2 replay локальным (EditorPrefs, по умолчанию выключено)#121
SashaRX wants to merge 1 commit into
mainfrom
codex/propose-fix-for-sidecar-replay-vulnerability

Conversation

@SashaRX

@SashaRX SashaRX commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Закрыть уязвимость, при которой проектный файл MeshLabSettings.asset мог навязать автоматическую воспроизводимость sidecar-файлов при импорте моделей и тем самым позволял злоумышленнику управлять поведением импортера.
  • Вернуть поведение, при котором persistent sidecar replay является явным локальным выбором разработчика, а не коммитируемой опцией проекта.

Description

  • Заменён механизм хранения флага реплея: Editor/PostprocessorDefineManager.cs теперь читает и пишет локальную EditorPrefs с ключом LightmapUvTool.SidecarUv2Mode через EditorPrefs.GetBool/SetBool, по умолчанию false, вместо обращения к MeshLabProjectSettings.Instance.sidecarMode.
  • Удалено сериализуемое поле sidecarMode из Editor/Settings/MeshLabProjectSettings.cs, и UI-переключатель в настройках проекта теперь отображает и меняет локальную настройку через PostprocessorDefineManager, с явной подсказкой, что значение хранится локально в EditorPrefs.
  • При ResetToDefaults() проектных настроек локальный флаг реплея явно сбрасывается в false через PostprocessorDefineManager.SetEnabled(false).
  • Изменены файлы: Editor/PostprocessorDefineManager.cs и Editor/Settings/MeshLabProjectSettings.cs.

Testing

  • Запущён статический сценарий проверки (python3-snippet) который подтвердил, что PostprocessorDefineManager использует EditorPrefs, значение по умолчанию — false, и что поле public bool sidecarMode удалено из проектных настроек, и проверка прошла успешно.
  • Выполнены rg/поиск по коду и git diff --check для валидации правок и обнаружения остаточных вхождений, и они не выявили проблем; проверки завершились успешно.
  • Unity Editor отсутствует в окружении, поэтому EditMode/ интеграционные тесты Unity не запускались в контейнере (тесты не выполнялись).

Codex Task

Summary by CodeRabbit

  • Изменения
    • Режим Sidecar UV2 теперь сохраняется как локальная настройка редактора, а не в настройках проекта.
    • Настройка по умолчанию отключена.
    • Сброс настроек редактора автоматически отключает режим Sidecar UV2.
    • Переключатель режима сохраняет выбранное состояние только для текущего пользователя и среды редактора.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Режим Sidecar UV2 больше не хранится в MeshLabProjectSettings. PostprocessorDefineManager использует пользовательские EditorPrefs. Переключатель и сброс настроек работают через этот менеджер.

Changes

Настройки Sidecar UV2

Layer / File(s) Summary
Хранение и применение режима
Editor/PostprocessorDefineManager.cs, Editor/Settings/MeshLabProjectSettings.cs
PostprocessorDefineManager читает и записывает состояние через EditorPrefs с ключом LightmapUvTool.SidecarUv2Mode. Переключатель и сброс настроек используют этот менеджер. Значение по умолчанию отключено.

Estimated code review effort: 2 (Простой) | ~10 минут

Suggested reviewers: claude

Poem

Я кролик, и режим включать не стал,
В EditorPrefs настройку спрятал.
Переключатель путь теперь нашёл,
А сброс режим надёжно отвёл.
Прыг-скок — проектный флаг исчез!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок точно описывает основной результат: перенос режима Sidecar UV2 replay в локальные EditorPrefs с отключением по умолчанию.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/propose-fix-for-sidecar-replay-vulnerability

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Editor/Settings/MeshLabProjectSettings.cs`:
- Line 192: Update the reset flow around
PostprocessorDefineManager.SetEnabled(false) so its prompt and confirmation
dialog explicitly state that the setting is stored in user-level EditorPrefs and
disabling Sidecar Mode affects other projects for the same user on the machine.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45804767-87e6-42ed-a793-83b77a44222e

📥 Commits

Reviewing files that changed from the base of the PR and between 21d382e and 43f3758.

📒 Files selected for processing (2)
  • Editor/PostprocessorDefineManager.cs
  • Editor/Settings/MeshLabProjectSettings.cs

inst.repackPerMesh = fresh.repackPerMesh;
inst.savePath = fresh.savePath;
inst.sidecarMode = fresh.sidecarMode;
PostprocessorDefineManager.SetEnabled(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target context ---'
sed -n '150,215p' Editor/Settings/MeshLabProjectSettings.cs
printf '%s\n' '--- definitions and usages ---'
rg -n -C 3 'class PostprocessorDefineManager|SetEnabled\(|Sidecar Mode|Sidecar mode|Reset every Mesh Lab project setting|ResetToDefaults' .

Repository: SashaRX/UnityMeshLab

Length of output: 10399


🌐 Web query:

Unity EditorPrefs stores preferences per user machine project scope documentation

💡 Result:

In Unity, the EditorPrefs class is used to store and access user-specific Editor preferences that are scoped to the local machine, not to a specific project [1][2][3]. Key characteristics of EditorPrefs include: Scope and Persistence: - Machine Scope: EditorPrefs store settings that persist across all projects on a specific local machine [2][4]. They are not saved within the project folder or shared via version control [2][4]. - Storage Location: On Windows, these are stored in the registry under HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x [1][3]. On macOS, they are stored in a.plist file in ~/Library/Preferences/ [1][3]. On Linux, they are stored in ~/.local/share/unity3d/prefs [1][3]. Distinction from Project Settings: - While EditorPrefs are personal, machine-level settings, Project Settings are intended for settings that are shared across a team [2][4]. Project Settings are stored within the project's folder structure (typically in the ProjectSettings directory) and are intended to be tracked by version control systems [2][5][4]. Implementing Project-Specific Preferences: - Because EditorPrefs are machine-wide by default, they do not inherently support project-scoped storage [6][7]. To associate EditorPrefs with a specific project, developers often manually prepend a project-specific identifier (such as a hash of the project's path or a unique project ID) to the preference key [6][7]. Alternatively, for project-scoped settings, developers typically use files stored within the project’s Assets or ProjectSettings folders (such as ScriptableObjects or JSON files), or utilize the Settings Manager package to handle project-specific repositories [5][7][8].

Citations:


🏁 Script executed:

#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
settings = Path("Editor/Settings/MeshLabProjectSettings.cs").read_text()
manager = Path("Editor/PostprocessorDefineManager.cs").read_text()
checks = {
    "reset calls SetEnabled(false)": "PostprocessorDefineManager.SetEnabled(false);" in settings,
    "SetEnabled writes EditorPrefs": "EditorPrefs.SetBool(PrefKey, enabled);" in manager,
    "shared preference key": 'const string PrefKey = "LightmapUvTool.SidecarUv2Mode";' in manager,
    "tooltip calls it a project setting": "Reset every Mesh Lab project setting" in settings,
    "dialog calls it a project setting": "Reset every project setting" in settings,
}
for name, result in checks.items():
    print(f"{name}: {result}")
PY

Repository: SashaRX/UnityMeshLab

Length of output: 339


Уточните область действия сброса.

PostprocessorDefineManager.SetEnabled(false) записывает пользовательский EditorPrefs. Поэтому сброс в одном проекте отключает Sidecar Mode в других проектах того же пользователя на этой машине. Обновите подсказку и диалог, чтобы явно указать эту область действия.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Editor/Settings/MeshLabProjectSettings.cs` at line 192, Update the reset flow
around PostprocessorDefineManager.SetEnabled(false) so its prompt and
confirmation dialog explicitly state that the setting is stored in user-level
EditorPrefs and disabling Sidecar Mode affects other projects for the same user
on the machine.

SashaRX commented Aug 6, 2026

Copy link
Copy Markdown
Owner Author

Закрыт без применения: PR отключает sidecar replay по умолчанию (per-user EditorPrefs) вместо валидации данных; вместо этого приняты валидационные фиксы #126/#139/#151/#189.


Generated by Claude Code

@SashaRX SashaRX closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant