跳转到正文
报告库
用途分类 / 数据分析

Flutter Apply Architecture Best Practices Skill 安全审计

作者说它能做什么(原文)

Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.

第三方安全检查结论

发现安全风险

已检查文件
1
发现的风险
1
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 1 项风险
中风险

示例缓存未按用户 ID 区分,可能向请求者返回另一用户的资料

原文依据:2 处
发现了什么

示例 Repository 只保存一个 `_cachedUser`。`getUser(id)` 只要缓存非空就立即返回它,并不会确认缓存用户的 ID 是否等于本次请求的 ID。

为什么需要注意

如果作者或代理把该示例用于可查询多个账户的应用,同一个 Repository 实例先后处理不同用户时,后一次请求可能看到前一个用户的姓名或其他被扩展进模型的资料,同时也会造成错误的账户决策。

该风险由示例代码直接支持,但只会在同一个 `UserRepository` 实例先后查询不同用户 ID 时出现:缓存一旦非空,方法便直接返回旧用户,没有比较本次 `id`。如果用户照搬此示例并在多个账户或资料请求间共享 Repository,界面可能显示另一位先前查询用户的资料。证据只是教学示例,不能证明任何应用已经采用或泄露数据;用户可要求作者将缓存按 ID 建键,或在返回前核对缓存用户 ID。

SKILL.md:88来自说明文档打开原文件
  final ApiClient _apiClient;  User? _cachedUser;  Future<User> getUser(String id) async {    if (_cachedUser != null) return _cachedUser!;        final apiModel = await _apiClient.fetchUser(id);    _cachedUser = User(id: apiModel.id, name: apiModel.fullName); // Transform to Domain Model    return _cachedUser!;  }
查看另外 1 个位置
SKILL.md:83来自说明文档打开原文件
// 2. Repository (Single source of truth, returns Domain Model)class UserRepository {  UserRepository({required ApiClient apiClient}) : _apiClient = apiClient;    final ApiClient _apiClient;  User? _cachedUser;  Future<User> getUser(String id) async {    if (_cachedUser != null) return _cachedUser!;        final apiModel = await _apiClient.fetchUser(id);    _cachedUser = User(id: apiModel.id, name: apiModel.fullName); // Transform to Domain Model    return _cachedUser!;  }
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。未发现风险
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

5 个说明模块

该 Skill 是一份 Flutter 架构指南,要求把应用划分为 UI、数据和可选领域逻辑层,并通过 ViewModel、Repository 与 Service 分离界面状态、业务逻辑及外部数据访问。

查看原文
SKILL.md:18来自说明文档打开原文件
Enforce strict Separation of Concerns by dividing the application into distinct layers. Never mix UI rendering with business logic or data fetching.
SKILL.md:23来自说明文档打开原文件
*   **Views:** Write reusable, lean widgets. Restrict logic in Views to UI-specific operations (e.g., animations, layout constraints, simple routing). Pass all required data from the ViewModel.*   **ViewModels:** Manage UI state and handle user interactions. Extend `ChangeNotifier` (or use `Listenable`) to expose state. Expose immutable state snapshots to the View. Inject Repositories into ViewModels via the constructor.
SKILL.md:26来自说明文档打开原文件
### Data LayerImplement the Repository pattern to isolate data access logic and create a single source of truth.*   **Services:** Create stateless classes to wrap external APIs (HTTP clients, local databases, platform plugins). Return raw API models or `Result` wrappers.*   **Repositories:** Consume one or more Services. Transform raw API models into clean Domain Models. Handle caching, offline synchronization, and retry logic. Expose Domain Models to ViewModels.

新增功能工作流会让代理创建或修改模型、服务、Repository、ViewModel、界面和依赖注入注册,随后运行单元测试并根据失败继续修改逻辑。

查看原文
SKILL.md:59来自说明文档打开原文件
### Task Progress- [ ] **Step 1: Define Domain Models.** Create immutable data classes for the feature using `freezed` or `built_value`.- [ ] **Step 2: Implement Services.** Create or update Service classes to handle external API communication.- [ ] **Step 3: Implement Repositories.** Create the Repository to consume Services and return Domain Models.- [ ] **Step 4: Apply Conditional Logic (Domain Layer).**  - *If the feature requires complex data transformation or cross-repository logic:* Create a Use Case class.  - *If the feature is a simple CRUD operation:* Skip to Step 5.- [ ] **Step 5: Implement the ViewModel.** Create the ViewModel extending `ChangeNotifier`. Inject required Repositories/Use Cases. Expose immutable state and command methods.- [ ] **Step 6: Implement the View.** Create the UI widget. Use `ListenableBuilder` or `AnimatedBuilder` to listen to ViewModel changes.- [ ] **Step 7: Inject Dependencies.** Register the new Service, Repository, and ViewModel in the dependency injection container (e.g., `provider` or `get_it`).- [ ] **Step 8: Run Validator.** Execute unit tests for the ViewModel and Repository.
SKILL.md:68来自说明文档打开原文件
- [ ] **Step 7: Inject Dependencies.** Register the new Service, Repository, and ViewModel in the dependency injection container (e.g., `provider` or `get_it`).- [ ] **Step 8: Run Validator.** Execute unit tests for the ViewModel and Repository.  - *Feedback Loop:* Run tests -> Review failures -> Fix logic -> Re-run until passing.
从这里开始 · 工作说明SKILL.md
flutter-apply-architecture-best-practices
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。
文件与检查记录1 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
读取了多少行
163
文件校验值(用于核对版本)
0f11f0c6eca2dc20042be4ef17e974bd113eb8be6b5ef1136b0c6e80dee881b8