macontrol

遵循以下最佳实践的项目将能够自愿的自我认证,并显示他们已经实现了核心基础设施计划(OpenSSF)徽章。

没有一套可以保证软件永远不会有缺陷或漏洞的做法;如果规范或假设是错误的,即使合适的方法也可能失败。也没有哪些做法可以保证一个项目能够维持健康和运作良好的开发者社区。但是,遵循最佳做法可以帮助改善项目的成果。例如,一些做法可以在发布之前进行多人评估,这可以帮助您找到其他难以找到的技术漏洞,并帮助建立信任,并希望不同公司的开发人员之间进行重复的交互。要获得徽章,必须满足所有“必须”和“禁止”的条款,满足所有“应该”条款或有合适的理由,所有“建议”条款必须满足或未满足(至少希望考虑)。欢迎通过 GitHub网站创建问题或提出请求进行反馈。另外还有一个一般讨论邮件列表

如果这是您的项目,请在您的项目页面上显示您的徽章状态!徽章状态如下所示: 项目12643的徽章级别为passing 这里是如何嵌入它:
您可以通过将其嵌入在您的Markdown文件中:
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/12643/badge)](https://www.bestpractices.dev/projects/12643)
或将其嵌入到HTML中来显示您的徽章状态:
<a href="https://www.bestpractices.dev/projects/12643"><img src="https://www.bestpractices.dev/projects/12643/badge"></a>


这些是通过级别条款。您还可以查看白银黄金级别条款。

Baseline Series: 基准等级1 基准等级2 基准等级3

        

 基本 13/13

  • 常规

    请注意,其他项目可能使用相同的名称。

    Control your Mac from Telegram — system, media, network, power, and more. Apple Silicon, Go, one binary

    请使用 SPDX许可证表达格式;例子包括“Apache-2.0”,“BSD-2-Clause”,“BSD-3-Clause”,“GPL-2.0+”,“LGPL-3.0 +”,“MIT”和“(BSD-2-Clause OR Ruby)”。
    如果有多种语言,请将它们列为逗号分隔值(可选空格),并将它们从最多到最少使用。如果有长列表,请至少列出前三个最常见的列表。如果没有语言(例如,这是仅文档或仅测试项目),请使用单个字符“ - ”。请使用每种语言的常规大小写,例如“JavaScript”。
    通用平台枚举(CPE)是用于信息技术系统,软件和软件包的结构化命名方案。在报告漏洞时,它可用于多个系统和数据库。

    macontrol is a tiny Go daemon that runs on your Mac and exposes a menu-first Telegram bot for remote control: change volume / brightness, toggle Wi-Fi / Bluetooth, read battery & system stats, take screenshots, send desktop notifications, lock / sleep / restart, and more.

  • 基本项目网站内容


    项目网站必须简明扼要地描述软件的作用(它解决了什么问题?)。 [description_good]
    必须采用潜在用户可以理解的语言(例如,它使用最少的术语/行话)。


    项目网站必须提供有关如何获取和提供反馈(错误报告或增强功能)以及如何贡献的信息。 [interact]

    关于如何贡献的信息必须解释贡献流程(例如,是否使用拉请求?) (需要网址) [contribution]
    除非另有说明,否则我们假定 GitHub上的项目使用问题列表(Issues)和拉(Pull)请求。这些信息可以简短,例如,说明项目使用拉请求,问题跟踪器或邮寄到邮件列表中的哪一个。

    Non-trivial contribution file in repository: https://github.com/amiwrpremium/macontrol/blob/master/CONTRIBUTING.md.



    关于如何贡献的信息应包括对可接受的贡献的要求(例如,引用任何所需的编码标准)。 (需要网址) [contribution_requirements]
  • FLOSS许可证


    项目生产的软件必须作为FLOSS发布。 [floss_license]
    FLOSS是以符合开源定义免费软件定义。此类许可证的示例包括 CC0 MIT BSD 2条款 BSD 3条款修订版 Apache 2.0 Lesser GNU通用公共许可证(LGPL),以及 GNU通用公共许可证(GPL)。为了我们的目的,这意味着许可证必须是:该软件也可以用其他许可证(例如,“GPLv2或专有”是可以接受的)。

    The MIT license is approved by the Open Source Initiative (OSI).



    建议由项目生成的软件的任何必需的许可证是由开放源码促进会(OSI)批准的许可证(英文)[floss_license_osi]
    OSI (开放源代码促进会)使用严格的审批流程来确定哪些许可证是开源软件(OSS)。

    The MIT license is approved by the Open Source Initiative (OSI).



    项目必须将其许可证在其源代码存储库中的标准位置发布。 (需要网址) [license_location]
    一种约定是将许可证发布为名为LICENSE或COPYING的顶级文件,其后可以带有扩展名,例如“ .txt”或“ .md”。另一种约定是使用一个名为LICENSES的目录,其中包含许可证文件。这些文件通常被命名为其SPDX许可证标识符,后跟适当的文件扩展名,如REUSE Specification中所述。请注意,此标准只是源存储库上的要求。从源代码生成某些内容(例如可执行文件,程序包或容器)时,无需包括许可证文件。例如,在为综合R存档网络(CRAN)生成R软件包时,请遵循标准CRAN惯例:如果许可证是标准许可证,请使用标准简短许可证规范(以避免安装另一文本副本)并列出排除文件(例如.Rbuildignore)中的LICENSE文件。同样,在创建Debian软件包时,您可以在版权文件中放置一个指向/ usr / share / common-licenses中的许可证文本的链接,并从创建的软件包中排除许可证文件(例如,通过在调用dh_auto_install之后删除文件) )。我们鼓励在可行的情况下以生成的格式包含机器可读的许可证信息。

    Non-trivial license location file in repository: https://github.com/amiwrpremium/macontrol/blob/master/LICENSE.


  • 文档


    项目必须为项目生成的软件提供基本文档。 [documentation_basics]
    该文档必须在某些媒体(例如文本或视频)中,包括:如何安装它,如何启动它,如何使用它(可能使用教程使用示例)以及如何安全地使用它(例如,做什么和不做什么),如果这是软件的一个适当的话题。安全文档不需要太长篇幅。项目可以使用非项目内容的超文本链接作为文档。如果项目不生产软件,请选择“不适用”(N/A)。

    Some documentation basics file contents found.



    项目必须提供描述项目生成的软件的外部接口(输入和输出)的参考文档。 [documentation_interface]
    外部接口的文档向最终用户或开发人员解释如何使用它。这将包括其应用程序接口(API),如果软件有。如果它是一个库,记录可以调用的主要类/类型和方法/函数。如果是Web应用程序,定义其URL接口(通常是其REST接口)。如果是命令行界面,请记录其支持的参数和选项。在许多情况下,最好是自动生成大部分文档,以便本文档随着软件的更改而保持同步,但这并不是必需的。项目可以使用非项目材料的超文本链接作为文档。文档可以自动生成(实际上这通常是最好的方法)。可以使用Swagger / OpenAPI生成REST接口的文档。代码界面文档可以使用 JSDoc (JavaScript), ESDoc (JavaScript),pydoc(Python)和Doxygen(很多)。仅在实现代码中添加注释不足以满足本条款;在没有阅读所有源代码的情况下,需要一个简单的方法来查看信息。如果项目不生产软件,请选择“不适用”(N/A)。

  • 其他


    项目网站(网站,存储库和下载URL)必须使用TLS支持HTTPS。 [sites_https]
    您可以从Let's Encrypt获取免费证书。项目可以使用(例如) GitHub页面实现此条款, GitLab页面,或 SourceForge项目页面。如果您使用具有自定义域的GitHub页面,则可以使用内容传送网络(CDN)作为代理来支持HTTPS,例如博客文章“使用CloudFlare安全加速GitHub页面”,以满足此条款。如果您支持HTTP,我们敦促您将HTTP流量重定向到HTTPS。

    Given only https: URLs.



    该项目必须有一个或多个讨论机制(包括建议的更改和问题),可搜索,允许通过URL访问消息和主题,使新人能够参与一些讨论,并且不需要客户端安装专有软件。 [discussion]
    可接受机制的示例包括归档邮件列表,GitHub问题和拉请求讨论,Bugzilla,Mantis和Trac。如果满足这些标准,异步讨论机制(如IRC)是可以接受的;确保有一个URL可访问归档机制。允许专有JavaScript,但不鼓励。

    GitHub supports discussions on issues and pull requests.



    项目应该提供英文文档,并能够接受英文的代码的错误报告和评论。 [english]
    英语是计算机技术的通用语言;支持英语增加了全球不同潜在开发者和检视者的数量。即使核心开发人员的主要语言不是英文,项目也可以达到这个标准。


    必须维护该项目。 [maintained]
    至少,项目应尝试响应重大问题和漏洞报告。可能正在维护一个积极追求徽章的项目。所有项目和人员的资源都有限,典型项目必须拒绝某些提议的更改,因此有限的资源和提议拒绝本身并不表示未维护的项目。

    当项目知道将不再维护该项目时,应将此标准设置为“未满足”,并使用适当的机制向其他人指示该项目将不会得到维护。例如,使用“ DEPRECATED”作为其自述文件的第一个标题,在其主页开头附近添加“ DEPRECATED”,在其代码存储库项目说明的开头添加“ DEPRECATED”,在其中添加无需维护的标志其自述文件和/或主页,在任何软件包存储库中将其标记为已弃用(例如npm deprecate ),和/或使用代码存储库的标记系统对其进行归档(例如GitHub的“ archive”设置,GitLab的“ archived”标记, Gerrit的“只读”状态,或SourceForge的“已放弃”项目状态)。可以在这里找到更多讨论。

 变更控制 9/9

  • 公开的版本控制的源代码存储库


    该项目必须有一个版本控制的源代码存储库。它必须是公开可读的并可通过URL访问。 [repo_public]
    该URL可以与项目URL相同。该项目可能在特定情况下使用私人(非公开)分支,而更改不会公开发布(例如,在向公众披露漏洞之前修复漏洞)。

    Repository on GitHub, which provides public git repositories with URLs.



    项目的源代码存储库必须跟踪所做的更改,谁进行了更改,何时进行了更改。 [repo_track]

    Repository on GitHub, which uses git. git can track the changes, who made them, and when they were made.



    为了实现协作检视,项目的源代码存储库必须包括临时版本,以便检视版本之间的变化;它不得仅包括最终版本。 [repo_interim]
    项目可以选择从其公共源代码库中删除特定的临时版本(例如,修复特定的未公开安全漏洞,可能永远不会公开发布的内容,或者包括不能合法发布而且不是最终版本的内容)。

    建议使用通用分布式版本控制软件(例如,git)作为项目的源代码存储库。 [repo_distributed]
    Git不是必须,项目在合适场景可以使用集中版本控制软件(如subversion)。

    Repository on GitHub, which uses git. git is distributed.


  • 唯一版本编号


    项目生成的用于每个用户使用的版本必须具有唯一版本标识符。 [version_unique]
    本条款可以通过各种方式来满足,包括提交ID(例如git提交ID或者Mercurial 更改列表id)或版本号(包括使用语义版本或基于日期的方案,如YYYYMMDD的版本号)。

    建议使用语义版本控制(SemVer)格式进行发布。 [version_semver]
    其他版本编号方案,如提交ID(例如git commit id或mercurial changeset id)或基于日期的方案,如YYYYMMDD,可以用作版本号,因为它们是唯一的。一些备选方案可能会导致问题,因为用户可能无法轻松确定是否是最新的。如果所有目标客户仅运行最新版本,则SemVer可能不太有助于识别软件版本(例如,它是通过持续交付不断更新的单个网站或互联网服务的代码)。


    建议项目识别其版本控制系统中的每个版本。例如,建议使用git的项目,使用git标签识别每个版本。 [version_tags]
  • 发行说明


    该项目必须在每个版本中提供发布说明,这是该版本中主要变化的可读的摘要,以帮助用户确定是否应升级,升级影响将如何。发行说明不能是版本控制日志的原始输出(例如,“git log”命令结果不是发行说明)。其产出不适用于多个地点的项目(如单个网站或服务的软件),并采用持续交付,可以选择“N/A”。 (需要网址) [release_notes]
    发行说明可以以各种方式实施。许多项目将它们添加到名为“NEWS”,“CHANGELOG”或“ChangeLog”的文件中,可选的包含“.txt”,“.md”或“.html”等扩展名。历史上,术语“更改日志”是指每个更改的日志,但为了满足这些条款,需要的是可读取的摘要。发行说明可以由版本控制系统机制提供,例如 GitHub发布工作流程

    Non-trivial release notes file in repository: https://github.com/amiwrpremium/macontrol/blob/master/CHANGELOG.md.



    发行说明必须列出每个新版本中修复的每个公开的漏洞。如果没有发行说明或者没有公开的漏洞,选择“不适用”。 [release_notes_vulns]
    如果用户通常不能在自己的计算机上实际更新软件,而必须依靠中间人来执行升级(对于内核和与内核交织的底层软件通常是这种情况),项目可以选择“不适用”(N/A)。

 报告 8/8

  • 错误报告流程


    项目必须为用户提交错误报告(例如,使用问题跟踪器或邮件列表)提供相关流程。 (需要网址) [report_process]

    Non-trivial SECURITY[.md] file found file in repository: https://github.com/amiwrpremium/macontrol/blob/master/SECURITY.md. [osps_do_02_01]



    项目必须使用问题跟踪器来跟踪每个问题。 [report_tracker]

    该项目必须响应过去2-12个月内(含)提交的大多数错误报告;响应不需要包括修复。 [report_responses]


    该项目应该对过去2-12个月内(包括)的大部分(> 50%)的增强请求作出回应。 [enhancement_responses]
    答复可能是“不”或有关其价值的讨论。目的只是对某些请求有一些回应,这表明项目还活着。为了该条款的目的,项目不需要计数无效请求(例如,来自垃圾邮件发送者或自动系统)。如果项目不再进行增强,请选择“未满足”,并将介绍此情况的URL包含在内。如果一个项目有超出处理能力的增强需求数量,请选择“未满足”并解释。


    该项目必须有一个公开的报告和回复的档案供后续搜索。 (需要网址) [report_archive]
  • 漏洞报告流程


    项目必须在项目网站上发布报告漏洞的流程。 (需要网址) [vulnerability_report_process]
    例如,https://PROJECTSITE/security 上的一个明确指定的邮箱地址,通常以 security@example.org 的形式。这可能与其错误报告流程相同。漏洞报告可能一直是公开的,但是许多项目都有一个私密漏洞报告机制。

    如果支持私有漏洞报告,项目必须包括如何以保密的方式发送信息。 (需要网址) [vulnerability_report_private]
    示例包括使用HTTPS(TLS)或使用OpenPGP加密的电子邮件在网络上提交的私密缺陷报告。如果漏洞报告总是公开的(从来没有私密漏洞报告),请选择“不适用”(N/A)。

    该项目在过去6个月收到的任何漏洞报告的初始响应时间必须小于或等于14天。 [vulnerability_report_response]
    如果过去6个月没有报告漏洞,请选择“不适用”(N/A)。

 质量 13/13

  • 可工作的构建系统


    如果项目生成的软件需要构建使用,项目必须提供可以从源代码自动重新构建软件的可工作的构建系统。 [build]
    构建系统确定重建软件(以及以什么顺序)需要执行哪些操作,然后执行这些步骤。例如,它可以调用编译器来编译源代码。如果从源代码创建可执行文件,则必须可以修改项目的源代码,然后通过这些修改生成更新的可执行文件。如果项目生成的软件取决于外部库,则构建系统不必构建那些外部库。如果在修改源代码之后不需要构建任何使用该软件的软件,请选择“不适用”(N/A)。

    建议使用通用工具来构建软件。 [build_common_tools]
    例如,Maven,Ant,cmake,自动工具,make,rake(Ruby)或devtools (R)。

    该项目应该仅使用FLOSS工具来构建。 [build_floss_tools]

    It cleanly satisfies this criterion:

    Written in Go — the official Go toolchain is BSD-licensed FLOSS.
    Build system is Make (Makefile) — GPL FLOSS.
    Lives in Git on GitHub — Git itself is GPL FLOSS.
    Linting via golangci-lint — GPL/MIT FLOSS.
    Released via GoReleaser + release-please — both MIT FLOSS.
    Targets macOS, but the build doesn't require Xcode's proprietary bits; go build cross-compiles for darwin/arm64 from any platform.


  • 自动测试套件


    该项目必须使用至少一个作为FLOSS公开发布的自动测试套件(该测试套件可以作为单独的FLOSS项目维护)。 [test]
    该项目可以使用多个自动测试套件(例如,一个是快速运行的测试套件,而另一个更为彻底但需要特殊设备)。
    1. Automated test suite under FLOSS license ✅
      The repo contains 48 Go test files (*_test.go) covering essentially every package — runner, config, keychain, capability, every domain module (battery, bluetooth, display, media, music, notify, power, sound, status, system, tools, wifi), and the Telegram handlers/callbacks. They use Go's standard testing package, which ships with the Go toolchain under a BSD-3-Clause license — unambiguously FLOSS. The tests themselves inherit the project's MIT license.
      There's also a fuzz test (FuzzDecode in internal/telegram/callbacks/), which is a nice extra — Go's built-in fuzzer is also FLOSS.

    2. Documentation of how to run them ✅
      Multiple, redundant places — any reviewer will find one:
      Makefile has both make test (go test ./...) and make lint test mentioned in the README's Development section.
      README.md explicitly shows make lint test under the Development heading on line 135.
      .github/workflows/ci.yml runs go test -race -coverprofile=coverage.out ./... on every push/PR, with a coverage matrix uploading to Codecov and Codacy (the badges on the README link to both dashboards).
      docs/development/testing.md exists as a dedicated testing doc, plus docs/development/ci.md documents the CI pipeline.
      CONTRIBUTING.md at the repo root is also present.



    测试套件应该以该语言的标准方式进行调用。 [test_invocation]
    例如“make check”,“mvn test”或“rake test”。

    test_invocation — macontrol evidence

    The project satisfies this criterion. Tests are invoked using the standard Go convention:

    go test ./...

    This is the canonical Go test command and works directly from a fresh clone with no flags, environment setup, or custom scripts.

    Makefile (wraps the standard command, doesn't replace it):
    test: go test ./...
    test-race: go test -race -coverprofile=coverage.out ./...

    make test and make test-race are convenience aliases — the underlying command is exactly what a Go developer would type by reflex. A reviewer ignoring the Makefile entirely would still succeed by running go test ./....

    CI (.github/workflows/ci.yml) uses the same standard command:
    go test -race -coverprofile=coverage.out ./...

    Fuzz tests also use the canonical Go invocation:
    go test -run='^$' -fuzz=FuzzDecode -fuzztime=30s ./internal/telegram/callbacks/

    Summary: the project uses go test ./... (the standard Go invocation), exposes it through a conventional Makefile test target, and runs the same command in CI. No custom test runner, no proprietary harness, no project-specific learning curve required.



    建议测试套件覆盖大部分(或理想情况下所有)代码分支,输入字段和功能。 [test_most]

    test_most — macontrol evidence

    The project satisfies this suggested criterion with strong, enforced coverage of code branches, input fields, and functionality.

    Test surface area:

    • 48 *_test.go files against 96 non-test .go files — roughly a 1:2 test-to-source ratio, with every internal package having a corresponding test file.
    • Tests cover every domain module: battery, bluetooth, display, media, music, notify, power, sound, status, system, tools, wifi — plus runner, config, keychain, capability, version, and the telegram handlers/callbacks.
    • 30+ table-driven test blocks exercise multiple input cases per function — the standard Go pattern for branch and input-field coverage.
    • A fuzz test (FuzzDecode in internal/telegram/callbacks/data_fuzz_test.go) exercises the callback decoder against randomized input to catch edge-case branches; it runs in CI via go test -run='^$' -fuzz=FuzzDecode -fuzztime=30s.

    Coverage is measured and enforced, not just claimed:

    • CI runs go test -race -coverprofile=coverage.out ./... on every push/PR.
    • Coverage is uploaded to both Codecov and Codacy — both badges are visible at the top of README.md and link to public dashboards.
    • A coverage floor is enforced in CI via the cover-floor Make target, which runs go-test-coverage --config=./.testcoverage.yml.

    Coverage thresholds (from .testcoverage.yml):

    • Total project: 80%
    • Per package: 75%
    • Per file: 50%
    • internal/domain/status: 80% (package-specific override)
    • internal/telegram/telegramtest: 70% (test helper)
    • cmd/macontrol: 5% (entry point — covered by integration tests on a real Mac, not unit tests; documented in the config file)
    • cmd/macontrol/shim.go: 0% (tiny shim, documented)

    Notably the thresholds are intentionally set below current measured coverage (per the comment in .testcoverage.yml) so that regressions are caught without blocking every small change — meaning actual coverage exceeds these floors.

    Summary: the project doesn't just have tests — it measures branch/file/package coverage, publishes it on two public dashboards, enforces a per-package floor of 75% and a project floor of 80% in CI, and uses fuzz testing on the highest-risk parser (the callback data decoder). Documented exceptions (entry-point and shim files) are explicit and justified.



    建议项目实施持续集成,将新的或更改的代码经常集成到中央代码库中,并对结果进行自动化测试。 [test_continuous_integration]

    test_continuous_integration — macontrol evidence

    The project satisfies this suggested criterion. CI is implemented via GitHub Actions, runs on every push and pull request, and integrates code into the central repository with a full battery of automated checks.

    CI configuration: .github/workflows/ci.yml

    Triggers:

    • push to master
    • pull_request targeting master
    • concurrency group cancels superseded runs to keep feedback fast

    Jobs that run on every change:

    1. Lint (ubuntu-latest)

      • golangci-lint at latest version
    2. Test (matrix: ubuntu-latest + macos-14)

      • go test -race -coverprofile=coverage.out ./...
      • Coverage uploaded as workflow artifact
      • Coverage floor enforced via go-test-coverage against .testcoverage.yml
      • Coverage published to Codecov and Codacy on every run
    3. Build (ubuntu-latest)

      • Cross-compiles the actual release target: GOOS=darwin GOARCH=arm64 CGO_ENABLED=0
      • Catches build regressions before merge
    4. Vulnerability scan (ubuntu-latest)

      • govulncheck ./... against the Go vulnerability database
    5. Fuzz (short, ubuntu-latest)

      • 30-second smoke fuzz on FuzzDecode (the callback parser — the only attacker-reachable parser before the whitelist gate)
      • Guards against newly-introduced panics on every PR

    Additional CI workflows in .github/workflows/:

    • codeql.yml — GitHub CodeQL static analysis
    • scorecards.yml — OpenSSF Scorecard checks
    • pr-title.yml — Conventional Commits enforcement on PR titles
    • release-please.yml — automated release PR generation
    • release.yml — GoReleaser pipeline on tag push

    Visible signals on the repository:

    • CI badge at the top of README.md links to the live workflow runs
    • codecov and Codacy coverage badges link to their public dashboards
    • OpenSSF Scorecard badge links to the public scorecard report

    Summary: every push and PR triggers parallel jobs covering lint, test (on Linux and macOS), cross-compile build, vulnerability scan, and fuzz testing. Coverage is measured, enforced against a per-package floor, and published to two public dashboards. Additional scheduled/triggered workflows handle CodeQL, OpenSSF Scorecard, and the release pipeline. This goes well beyond the suggested criterion.


  • 新功能测试


    该项目必须有通用的策略(正式或非正式),当主要的新功能被添加到项目生成的软件中,该功能的测试应该同时添加到自动测试套件。 [test_policy]
    只要有相应的策略,即使是通过口头传播,也就是说开发人员应该为主要的新功能在自动化测试套件中添加测试,选择“Met”。

    test_policy — macontrol evidence

    The project has an explicit, documented policy that new functionality must come with tests. The policy is enforced both in writing and through CI gating.

    1. Documented policy

    CONTRIBUTING.md instructs every contributor to run make lint test before opening a PR, and the PR template/process treats failing tests as a blocker.

    docs/development/adding-a-capability.md is a step-by-step guide for adding a new feature (a "capability"). It is structured as a 6-step checklist, and step 2 of every new capability is explicitly "Domain test" — the guide includes a worked example showing both happy-path and error-path tests using runner.Fake, with the note that the result "Should pass with 100% coverage on the two test functions." Step 5 of the same checklist is "Test the handler." The file table at the top of the guide lists the test files alongside the source files as required deliverables for any new capability, not as optional extras.

    docs/development/testing.md documents the test infrastructure (runner.Fake for subprocess mocking, telegramtest.NewBot for the Telegram API) so contributors have no excuse not to write tests — the helpers needed to test any new domain or handler already exist and are documented.

    1. Policy enforcement in CI

    The policy isn't aspirational — it's enforced:

    • Every push and PR runs go test -race -coverprofile=coverage.out ./... on both Linux and macOS.
    • A coverage floor is enforced via go-test-coverage against .testcoverage.yml: 80% total, 75% per package, 50% per file. New code that drops coverage below those floors fails CI.
    • Coverage is published to Codecov and Codacy on every run, so any drop is visible in the PR review.
    • A 30-second fuzz test of the callback decoder runs on every PR.
    1. Cultural signal

    Conventional Commits (enforced by a CI job on PR titles) include test as a first-class commit type, and feat commits in the changelog routinely land alongside their corresponding tests. The CHANGELOG.md history shows tests added in the same release as the features they cover.

    Summary: the project has an explicit written policy in CONTRIBUTING.md and the capability-adding guide that requires tests for new functionality, backed by ready-made test helpers (runner.Fake, telegramtest.NewBot), and enforced by a CI-gated coverage floor that blocks PRs which regress coverage. This satisfies the criterion well beyond the "general policy, formal or not" bar.



    该项目必须有证据表明,在项目生成的软件的最近重大变化中,已经遵守了添加测试的条款: test_policy [tests_are_added]
    主要功能通常在发行说明中提及。不需要完美,只需证明,当新的主要功能添加到项目生成的软件时,测试通常会在实践中被添加到自动化测试套件中。

    tests_are_added — macontrol evidence

    The most recent major changes to macontrol show the test_policy being followed consistently. Every recent feature PR ships with tests for the new code, and dedicated test-only PRs have been used to raise coverage proactively.

    Most recent feature: feat(bot): add 🎵 Music category (#91, latest 0.7.0 release)

    This is a large feature touching 24 files, +2,869 lines. Of those 24 files, 6 are *_test.go files added or expanded alongside the new code:

    internal/capability/detect_test.go | 37 lines changed
    internal/domain/music/music_test.go | 264 lines added (new file)
    internal/telegram/flows/seek_test.go | 95 lines added (new file)
    internal/telegram/handlers/mus_test.go | 235 lines added (new file)
    internal/telegram/keyboards/mus_test.go | 236 lines added (new file)
    internal/telegram/musicrefresh/refresher_test.go | 312 lines added (new file)

    Every new production file in this PR landed with a corresponding _test.go in the same commit:
    music.go ↔ music_test.go
    seek.go ↔ seek_test.go
    mus.go (handlers) ↔ mus_test.go
    mus.go (keyboards) ↔ mus_test.go
    refresher.go ↔ refresher_test.go

    This exactly matches the policy in docs/development/adding-a-capability.md, which mandates a domain test file and a handler test alongside any new capability.

    Pattern across the last several feat commits:

    feat(bot): Timezone picker (01b2ae5) → +tools_test.go, +remaining_test.go, +keyboards_test.go
    feat(bot): Shortcuts list (a1a2be1) → +remaining_test.go, +keyboards_test.go
    feat(bot): DNS presets submenu (98646fb) → +remaining_test.go, +keyboards_test.go
    feat(bot): Disks redesign (ef77b3c) → +tools_test.go, +remaining_test.go, +keyboards_test.go

    Every single one of the most recent feat(bot) PRs in git log includes test additions in the same commit. None landed bare.

    Dedicated test-improvement work:

    test: expand unit coverage from 73.9% to 85.0% across the repo (#76, commit 51e7d31)
    test(callbacks): add Go native fuzz tests for Decode (#89, commit 0bb56cc)

    These two PRs show the policy is treated as an active concern, not a checkbox — the maintainer has merged standalone PRs whose only purpose is to raise coverage and add fuzz testing.

    Enforcement signal:

    CI's coverage floor (.testcoverage.yml: 80% total, 75% per package) blocks merges that drop coverage below the threshold. The fact that recent feature PRs all merged green is itself evidence that the feature code was covered by the tests added in the same PR — otherwise the floor check would have failed.

    Summary: the most recent major change (the Music category) added 6 test files alongside the 18 new/edited production files, matching the policy in docs/development/adding-a-capability.md exactly. The same pattern holds for every prior feat(bot) PR in the history. The project also merges dedicated test-improvement PRs (#76, #89). The criterion is satisfied with a clear, traceable record.



    建议您在更改提案的说明文档中添加测试策略要求(请参阅test_policy)。 [tests_documented_added]
    但是,只要在实践中添加了测试,即使是非正式规则也是可以接受的。

    tests_documented_added — macontrol evidence

    The project documents the test-adding policy in multiple change-proposal-facing locations, satisfying this suggested criterion.

    1. Pull Request template (.github/PULL_REQUEST_TEMPLATE.md)

    GitHub auto-loads this template into every new PR's description box. It contains a "Test plan" section with the policy as an explicit checkbox the contributor must tick:

    Test plan

    • make lint test passes locally
    • New/changed code has unit tests
    • Verified on macOS (version / chip: … )
    • If permissions changed: updated docs/permissions.md
    • If new capability: added to README feature table

    The "New/changed code has unit tests" line is the policy stated directly in the change-proposal interface — every contributor sees it the moment they open a PR.

    1. CONTRIBUTING.md

    The contributor workflow makes running tests a required pre-PR step:

    1. Run checks locally before pushing:
         make lint test
    

    The "Adding a new capability" section lists the required files for a new capability and step 6 explicitly mandates tests:

    1. Write a domain test using the runner.Fake helper and a
      keyboard-layout test.

    2. docs/development/adding-a-capability.md

    A dedicated, full-length guide for change proposals that add new functionality. It treats tests as a structural requirement, not a suggestion:

    • The file table at the top lists _test.go files alongside source files as required deliverables.
    • Step 2 of every new capability is "Domain test", with a worked example covering both happy-path and error-path tests.
    • Step 5 is "Test the handler".
    • The guide notes that the worked example "Should pass with 100% coverage on the two test functions."
    1. docs/development/testing.md

    Documents the test infrastructure (runner.Fake, telegramtest.NewBot) so contributors know exactly how to satisfy the policy. The helpers needed to test any new domain or handler are pre-built and documented.

    1. Conventional Commits

    CONTRIBUTING.md lists test as a first-class commit type, signaling that test-only changes are an expected, encouraged contribution.

    Summary: the test-adding policy is documented in the PR template (the most direct change-proposal surface), in CONTRIBUTING.md (the canonical contributor doc), and in two dedicated development guides (adding-a-capability.md and testing.md). A contributor cannot open a PR without seeing the "New/changed code has unit tests" checkbox in their PR body. This goes beyond the suggested bar.


  • 警告标志


    该项目必须启用一个或多个编译器警告标志,“安全”语言模式,或者使用单独的“linter”工具查找代码质量错误或常见的简单错误,如果至少有一个FLOSS工具可以在所选择的语言实现此条款。 [warnings]
    编译器警告标志的例子包括gcc/clang “-Wall”。 “安全”语言模式的示例包括JavaScript “use strict”和perl5的“使用警告”。一个单独的“linter”工具用于检查源代码以查找代码质量错误或常见的简单错误。这些通常在源代码或构建指令中启用。

    warnings — macontrol evidence

    The project satisfies this criterion with a comprehensive linter configuration enforced in CI.

    Primary linter: golangci-lint (FLOSS, GPL-3.0)

    The repository ships an explicit configuration at .golangci.yml that enables 13 linters covering correctness, security, and style — all are themselves FLOSS:

    • errcheck — unchecked errors
    • govet — go vet, the official correctness checker
    • ineffassign — ineffective assignments
    • staticcheck — comprehensive static analysis (correctness + simplification)
    • unused — unused code
    • misspell — common misspellings
    • gocritic — opinionated bug-pattern checks
    • revive — replacement for golint, with the exported and package-comments rules explicitly enabled (enforces godoc on exported symbols)
    • bodyclose — HTTP response bodies that must be closed
    • nolintlint — catches stale or malformed //nolint directives
    • unparam — unused function parameters
    • prealloc — slices that could be preallocated
    • gosec — security-focused checks (with G204 excluded since subprocess invocation is the project's purpose, documented inline)

    Formatters (gofumpt + goimports) are also enforced, with project-local import grouping configured.

    Test files have a narrowly scoped exclusion (gosec, unparam, gocritic) which is the standard pattern for Go projects — these linters produce noise on test scaffolding.

    Enforcement:

    • Makefile target: make lintgolangci-lint run. make lint-fix for auto-fixable issues. make all runs lint + test + build.
    • CI: .github/workflows/ci.yml has a dedicated lint job that runs golangci-lint on every push and pull request. It runs in parallel with the test job, so regressions are caught before merge.
    • CONTRIBUTING.md instructs every contributor: make lint test before opening a PR.

    Additional static analysis layers:

    • govulncheck (golang.org/x/vuln) — runs as the vuln CI job on every push/PR via govulncheck ./...
    • CodeQL (.github/workflows/codeql.yml) — GitHub's semantic code analysis on the repo
    • OpenSSF Scorecard (.github/workflows/scorecards.yml) — supply-chain best-practice scoring
    • The Go compiler itself emits warnings/errors for unused imports and variables, and go vet is included via the govet linter above

    All four of these tools are FLOSS.

    Summary: the project enables 13 FLOSS linters via golangci-lint with an explicit checked-in configuration, runs them in CI on every push and PR, and layers govulncheck + CodeQL + Scorecard on top. The make lint target makes the same checks runnable locally, and the contributor workflow requires it before opening a PR. The criterion is satisfied well beyond the minimum.



    该项目必须处理警告。 [warnings_fixed]
    告警是通过执行warnings条款确定的。该项目应该修复告警或在源代码中将其标记为误报。理想情况下,不会有告警,但项目可能会接受一些告警(通常每100行小于1个告警,或整体少于10个告警)。

    warnings_fixed — macontrol evidence

    The project actively addresses warnings rather than ignoring them. Multiple lines of evidence:

    1. CI fails on warnings, blocking merges

    The lint job in .github/workflows/ci.yml runs golangci-lint on every push and PR. golangci-lint defaults to a non-zero exit on any finding, so any unaddressed warning fails CI and blocks merge. Recent feature PRs (#91 Music, #82 handler split, #67 Timezone, #60 Shortcuts) all merged green, meaning each was warning-clean by the time it landed.

    1. Documented history of fixing warnings, not suppressing them

    Direct evidence in the commit log:

    caa55d6 fix(ci): resolve 50 golangci-lint v2 findings
    34182c8 fix(ci): upgrade lint action and Go toolchain to pass checks
    d0b3eaf docs: comprehensive godoc for all production code + enable strict lint (#77)
    c4474e8 docs: thorough godoc rewrite with structured sections (#78)
    ed45c0e chore: quiet markdownlint rules pre-PR1 wasn't enforcing (#84)

    The "resolve 50 golangci-lint v2 findings" commit is particularly strong evidence. Its body itemises every fix:

    • errcheck (14) → explicit _ = on intentionally discarded errors;
      deferred handlers wrapped to discard returns explicitly
    • gofumpt (11) + goimports (1) → formatter auto-fix pass
    • staticcheck (10) → QF1012 fmt.Fprintf simplifications, SA1019 deprecated
      API replacements (EnvVarIsNotSetError → VarIsNotSetError)
    • gosec (5) → directory modes tightened 0o755 → 0o750, plist 0o644 → 0o600
    • gocritic (2) → singleCaseSwitch collapsed; exitAfterDefer fixed with
      explicit cancel()
    • prealloc (3) → slice capacities sized upfront

    These are real code changes, not ignore-list additions.

    1. Disciplined use of suppressions

    A repo-wide grep finds only 3 //nolint directives across the entire codebase:

    internal/domain/tools/tz_country.go:58
    os.ReadFile(path) //nolint:gosec // G304: path is from a constant allowlist

    internal/telegram/musicrefresh/refresher.go:199
    context.WithCancel(ctx) //nolint:gosec // cancel stored in session.cancel;
    called by Stop and run's defer

    cmd/macontrol/daemon.go:100
    //nolint:gocritic // explicit cancel() above flushes the context before exit

    Each is narrow (single line, specific linter named) and carries an inline justification. The nolintlint linter is also enabled in .golangci.yml, which catches stale, unused, or unjustified nolint directives — meaning suppressions themselves are policed.

    The .golangci.yml has exactly one global exclusion (gosec G204 — subprocess invocation), and it's documented in a comment ("Subprocess call is the whole point of this project"). Test files have a narrowly scoped exclusion of gosec/unparam/gocritic, the standard Go pattern.

    1. Refactors driven by warnings

    9f045d2 refactor: split overgrown handlers and table-drive parsers (#82)

    The release notes for the Music feature (#91) explicitly call out two refactor steps done to satisfy Codacy findings:

    • refactor(keyboards): split MusicCaption into per-section helpers (Codacy)
    • refactor(music): split tickOnce into snapshot + edit-media helpers (Codacy)

    So warnings from the secondary scanner (Codacy) are also being acted on, not just dismissed.

    1. Strict-lint regime expanded over time

    Commit d0b3eaf ("comprehensive godoc for all production code + enable strict lint") shows the bar being raised: revive's exported and package-comments rules were enabled, then the codebase was brought into compliance by writing godoc for every exported symbol. This is the opposite of the anti-pattern of relaxing rules to make warnings disappear.

    Summary: warnings are surfaced by golangci-lint (13 linters) + govulncheck + CodeQL + Codacy, blocked at the CI gate, addressed in dedicated fix commits with itemised release notes, and only suppressed in 3 narrow places — each with a written justification, all policed by nolintlint. The criterion is satisfied with a strong, traceable record.



    建议在实际情况下,项目以最严格方式对待项目生成的软件中的告警。 [warnings_strict]
    某些项目无法有效启用某些警告。需要证明的是,项目正在努力的启用警告标志,以便早期发现错误。

    warnings_strict — macontrol evidence

    The project takes a maximally strict posture on warnings, well within the "where practical" qualifier of this suggested criterion.

    1. Strict golangci-lint configuration (.golangci.yml)

    issues:
    max-issues-per-linter: 0
    max-same-issues: 0

    These two settings disable golangci-lint's default deduplication caps. By default golangci-lint shows only the first 50 findings per linter and the first 3 of each kind; setting both to 0 means every finding is surfaced. This is the strict-mode setting — the project wants to see all warnings, not a sampled summary.

    1. Strict linter selection with default: none

    linters:
    default: none
    enable: [errcheck, govet, ineffassign, staticcheck, unused, misspell,
    gocritic, revive, bodyclose, nolintlint, unparam, prealloc, gosec]

    default: none means no linters run unless explicitly enabled — so the active set is deliberate, not accidental. The 13 enabled linters include the strictest commonly-used ones:

    • staticcheck (covers SA, ST, S, QF check categories — the gold-standard Go static analyser)
    • gosec (security)
    • gocritic (opinionated bug-pattern checks beyond go vet)
    • revive with exported and package-comments rules explicitly enabled — these enforce godoc on every exported symbol and every package, a notably strict bar
    • nolintlint (polices the suppressions themselves — stale or unjustified //nolint directives are themselves warnings)
    1. Minimal, justified exclusions

    The configuration suppresses almost nothing:

    • One global exclusion: gosec G204 (subprocess invocation), with an inline comment explaining why ("Subprocess call is the whole point of this project"). Without this the entire project would be one giant warning, since shelling out to pmset/networksetup/osascript is its purpose.
    • Test files exclude only gosec, unparam, gocritic — the standard Go pattern, since these produce noise on test scaffolding and assertion helpers.
    • generated: lax — generated files are excluded from lint, the standard convention.

    There are no broad path exclusions, no per-linter rule disables, no severity downgrades. The configuration is roughly 50 lines and contains nothing that softens the rules.

    1. Strict bars layered on top of golangci-lint
    • govulncheck runs in CI as a separate vuln job — any known-vulnerable dependency or stdlib usage fails the build.
    • CodeQL (.github/workflows/codeql.yml) — semantic analysis on every push.
    • OpenSSF Scorecard (.github/workflows/scorecards.yml) — supply-chain best-practice scoring published publicly.
    • Codacy + Codecov dashboards — third-party static analysis with public badges.
    • gofumpt (stricter than gofmt) and goimports (with local-prefix grouping enforced) run as formatters — formatting drift is a CI failure.
    • A 30-second fuzz test (FuzzDecode) runs on every PR.
    • Race detector enabled in CI tests: go test -race.
    1. Strict bar raised over time, not lowered

    The history shows the project tightening, not loosening, its strictness:

    d0b3eaf docs: comprehensive godoc for all production code + enable strict lint (#77)
    c4474e8 docs: thorough godoc rewrite with structured sections (#78)
    caa55d6 fix(ci): resolve 50 golangci-lint v2 findings

    The "enable strict lint" commit turned on revive's exported and package-comments rules and then brought the entire codebase into compliance — the opposite of the anti-pattern of relaxing rules to make warnings disappear.

    1. Evidence the strict bar is held in practice

    A repo-wide grep finds only 3 //nolint directives across the codebase. Each is single-line, names the specific linter being suppressed, and carries an inline justification. nolintlint enforces this format. Three narrow, justified suppressions across ~96 production .go files is a notably tight ratio.

    The macOS-target build is also configured strictly:

    GOFLAGS ?= -trimpath
    LDFLAGS ?= -s -w …
    CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" …

    -trimpath removes filesystem path leakage, and -s -w strips debug info from release binaries.

    1. Practical limits, honestly handled

    The "where practical" qualifier matters here. macontrol is a subprocess-orchestration daemon; gosec G204 (subprocess with non-constant input) cannot be globally satisfied because the project's purpose is to run macOS CLIs. The maintainer suppresses G204 globally with a documented justification rather than littering the code with per-call suppressions or pretending it's not an issue. That's the right kind of pragmatic strictness — strict everywhere it's practical, explicitly bounded where it isn't.

    Summary: the project enables 13 linters with default: none, sets max-issues caps to 0 to surface every finding, enforces godoc on every exported symbol via revive, layers govulncheck + CodeQL + Scorecard + Codacy on top, uses gofumpt (stricter than gofmt), runs tests with -race, fuzzes the highest-risk parser, and has a documented history of raising the bar (enable strict lint → fix the resulting 50 findings) rather than lowering it. Only 3 narrowly justified //nolint suppressions exist in the entire codebase. The criterion is satisfied at the strong end of the spectrum.


 安全 16/16

  • 安全开发知识


    该项目必须至少有一个主要开发人员知道如何设计安全软件。 [know_secure_design]
    这需要了解以下设计原则,包括 Saltzer和Schroeder 中的8项原则:
    • 机制经济(保持设计简单实用,例如采用彻底简化)
    • 故障安全默认(默认情况下,访问决策应拒绝),项目安装应默认安全)
    • 完全仲裁(必须检查每个可能被限制的访问权限,并且不可绕过)
    • 开放式设计(安全机制不应该依赖于攻击者对其设计的无知,而应该更容易地保护和更改信息,例如密钥和密码)
    • 特权分离(理想情况下,对重要对象的访问应该取决于多个条件,从而破坏一个保护系统将无法实现完全访问。如,多因子身份验证,要求密码和硬件令牌,比单因子认证安全性更高)
    • 最小权限(进程应该以最少的权限运行)
    • 最少的公共机制(设计应该最大限度地减少所有用户所依赖的,涉及到多个用户的共同机制,如,临时文件的目录)
    • 心理可接受性(人机接口必须设计为易于使用 —— 设计为“最不惊讶”)
    • 有限的攻击面(攻击面 —— 一组不同的入口,其​​中攻击者可以尝试输入或提取数据 —— 应该受到限制)
    • 输入验证与白名单(输入通常应该在被接受之前检查以确定是否有效;此验证应使用白名单(仅接受已知的有效值),而不是黑名单(尝试列出已知的非法值))。
    项目中的“主要开发人员”的定义是熟悉项目代码的任何人,很乐意对其进行更改,并被项目中大多数其他参与者确认。主要开发人员通常会在过去一年中通过代码,文档或回答问题提供一些贡献。开发人员通常被认为是主要开发人员,如果他们启动项目(并且还没有离开项目满三年),可以选择在私人漏洞报告渠道(如果有的话)上接收信息,可以代表项目接受提交,或执行项目软件的最终版本发布。如果只有一个开发者,那个人是主要开发人员。

    know_secure_design — macontrol evidence

    The primary developer (@amiwrpremium) demonstrates secure-design knowledge across every dimension the criterion lists.

    1. Written threat model

    docs/security/ contains a dedicated threat model. SECURITY.md documents scope (daemon, CLI, LaunchAgent plist, sudoers template, Homebrew formula, install.sh), out-of-scope (attacks already holding the bot token, upstream Apple bugs), private disclosure via GitHub Security Advisories, and SLAs (72h ack, ≤30d patch). A written threat model with named boundaries is itself a secure-design artifact.

    1. Secure defaults
    • No inbound port — outbound long-poll only. Eliminates the entire class of inbound-network attacks.
    • Hard Telegram-user-ID whitelist; non-whitelisted updates dropped silently (no enumeration via differentiated errors).
    • No /sh escape hatch — only named commands. A leaked token cannot be turned into arbitrary code execution.
    • Bot token stored in macOS Keychain, never in config files or env vars.
    • Commit caa55d6 proactively tightened file modes in response to gosec findings: directories 0o755 → 0o750, LaunchAgent plist 0o644 → 0o600.
    1. Defense in depth

    Six independent layers, each assuming the previous bypassed:

    L1: Telegram user-ID whitelist (auth)
    L2: Named-command surface (no shell escape)
    L3: runner.Runner interface (constrained subprocess invocation)
    L4: Narrow sudoers entry (sudoers.d/macontrol.sample)
    L5: macOS TCC gates on camera/screen/microphone
    L6: Keychain ACL bound to binary path

    1. Least privilege
    • Sudoers is a narrow allowlist, not NOPASSWD: ALL.
    • runner.Runner carries an explicit Sudo bool per call — sudo is opt-in per command, not ambient.
    • Daemon runs as the user's LaunchAgent, not root.
    • Keychain ACL binding to binary path means another binary running as the same user must trigger a fresh user consent prompt.
    1. Input validation on the attacker-reachable surface

    The Telegram callback_data string is the only attacker-reachable parser before the whitelist gate. The developer:

    • Wrote a Go native fuzz test (FuzzDecode in internal/telegram/callbacks/data_fuzz_test.go), commit 0bb56cc.
    • Runs it 30s on every PR via the fuzz-short CI job.
    • Documented in the CI workflow comment that it is "the only attacker-reachable parser before the whitelist gate" — showing pinpointed threat awareness, not blanket fuzzing.
    1. Avoiding common attack classes
    • Command injection: subprocess invocation through runner.Runner with separate Name + Args fields, never string concatenation. The Args-not-shell pattern is what makes the global gosec G204 suppression safe.
    • Path traversal: the one os.ReadFile from a non-constant path (tools/tz_country.go) checks against an allowlist; the inline //nolint:gosec // G304: path is from a constant allowlist shows the finding was read, classified, and mitigated.
    • Race conditions: go test -race in CI; musicrefresh uses an explicit cancel-stored-in-session lifecycle pattern.
    • Supply-chain: every third-party Action and go-installed tool is pinned to a commit SHA (commits de4e7aa, 08216c6, fdbe795). govulncheck on every PR.
    1. Secret handling
    • Token only ever held in the macOS Keychain via internal/keychain/, with a dedicated test file.
    • Keychain ACL is binary-path-bound — a foreign binary triggers a macOS UI prompt rather than silent re-read.
    • CI secrets use GitHub's redacted ${{ secrets.X }} mechanism; no inlined credentials anywhere.
    1. Secure SDLC

    CodeQL on every push, OpenSSF Scorecard publicly scored, govulncheck on every PR, 13 linters via golangci-lint including gosec, race detector in CI, Dependabot weekly on gomod + github-actions, Conventional Commits + squash-merge for clean audit trail, private vulnerability disclosure channel.

    1. Evidence of considered (not templated) thinking

    The author maintains a sibling project, shellboto, for Linux VPS — with a different security model (pty-backed shell, SHA-256 hash-chained audit logs, per-user RBAC). Choosing different controls for different threat surfaces shows threat-model thinking, not a single template applied everywhere.

    1. Trust boundaries surfaced to users

    The README disclaimer enumerates the trust anchors users accept: the daemon's capabilities, the bot token + whitelist as the auth boundary, and transitive trust in Telegram/Apple/Homebrew. Articulating the trust model in user-facing docs is itself a secure-design practice.

    Summary: written threat model with scope boundaries; secure defaults (no inbound port, named commands only, tightened file modes); six-layer defense in depth; least privilege (narrow sudoers, per-call Sudo bool, non-root); fuzz-tested input validation pinpointed at the attacker-reachable parser; injection-resistant subprocess invocation; Keychain-based secret storage with binary-path ACL; full secure SDLC (CodeQL, Scorecard, govulncheck, gosec, race detector, Dependabot, pinned actions). The criterion is satisfied.



    该项目的主要开发人员中,至少有一个必须知道导致这类型软件漏洞的常见错误类型,以及至少有一种方法来对付或缓解这些漏洞。 [know_common_errors]
    示例(取决于软件的类型)包括SQL注入,操作系统注入,经典缓冲区溢出,跨站点脚本(XSS),缺少认证和缺少授权。请参阅 CWE/SANS 25种最常见漏洞 OWASP十大漏洞类型项目

    know_common_errors — macontrol evidence

    Common vulnerability classes for a network-connected, subprocess-orchestrating macOS daemon, with the mitigation applied in macontrol:

    1. Command / subprocess injection
      Subprocess goes through runner.Runner with separate Name (string) and Args ([]string) fields, passed directly to exec.Cmd. No sh -c, no string interpolation. The runner.Fake test mock asserts on the parsed (Name, Args) tuple, proving the production form.

    2. Privilege escalation via overbroad sudo
      sudoers.d/macontrol.sample is a narrow allowlist, not NOPASSWD: ALL. runner.Runner carries an explicit Sudo bool per call — sudo is opt-in per invocation, not ambient.

    3. Authentication bypass
      Hard Telegram-user-ID whitelist sits in front of the command surface. Non-whitelisted updates dropped silently (no user enumeration). A leaked token alone cannot drive the bot — the attacker also needs a whitelisted user-ID.

    4. RCE via inbound network exposure
      No inbound port. Telegram long-poll over outbound HTTPS only. Eliminates the entire inbound-RCE class.

    5. Untrusted-input parsing (fuzz-class bugs)
      FuzzDecode (internal/telegram/callbacks/data_fuzz_test.go) runs 30s on every PR. The CI comment identifies callbacks.Decode as "the only attacker-reachable parser before the whitelist gate" — fuzz coverage was deliberately aimed at the single highest-risk parser. Commit 0bb56cc.

    6. Path traversal
      The one os.ReadFile with a non-constant path (tools/tz_country.go) reads from a constant allowlist. The inline //nolint:gosec // G304: path is from a constant allowlist shows the gosec finding was read by number and mitigated.

    7. Credential leakage at rest
      Bot token + whitelist live in the macOS Keychain (internal/keychain), not config files or env vars. Keychain ACL bound to binary path — foreign binaries trigger a fresh user consent prompt.

    8. Credential leakage in repo / CI logs
      .gitignore excludes .env*, *.pem, *.key. CI secrets read via ${{ secrets.X }}, never inlined. The only token-shaped strings in the repo are Telegram's published BotFather placeholder (123456789:AAE-aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456). GitHub secret-scanning runs by default.

    9. Race conditions / TOCTOU
      go test -race on Linux + macOS in CI. musicrefresh uses an explicit cancel-stored-in-session lifecycle.

    10. Goroutine leaks
      musicrefresh.Manager has Start/Stop/Touch with a 10-minute hard cap; Stop is called on navigate-away. refresher_test.go (312 lines) covers lifecycle paths.

    11. Supply-chain attacks via mutable Action tags
      Every third-party Action pinned to commit SHA (commits de4e7aa, 08216c6). go-installed tools pinned to versions (commit fdbe795).

    12. Vulnerable dependencies
      govulncheck on every push/PR. Dependabot scans gomod weekly. Total deps: 3 direct + 1 indirect.

    13. Information disclosure via verbose errors
      Sanitised user-facing Telegram messages; detailed errors go to the local log only.

    14. Logging secrets
      Keychain abstraction returns the token only at the call site that needs it. lumberjack rotates logs to bound retention.

    15. Insecure file permissions on artifacts
      Commit caa55d6 tightened LaunchAgent plist 0o644 → 0o600 and Library/Logs / LaunchAgents directories 0o755 → 0o750 in response to gosec findings.

    16. Insecure-by-default configuration
      No default whitelist — macontrol setup forces the user to enter their Telegram user-ID. A misconfigured install fails closed (no whitelisted users → no commands accepted).

    17. Cross-binary credential confusion
      macOS Keychain ACL is binary-path-bound. CONTRIBUTING.md explicitly warns dev contributors not to use go run for iterative dev because its random tempdir paths defeat the ACL.

    18. Insecure release pipeline
      GoReleaser triggered by release-please is fully automated; build flags -trimpath -s -w CGO_ENABLED=0 produce reproducible stripped binaries; the same workflow updates the Homebrew tap.

    19. Missed bug-class patterns
      13 linters via golangci-lint including gosec, staticcheck, gocritic, errcheck, ineffassign. CodeQL semantic analysis on every push. nolintlint polices suppressions themselves — only 3 //nolint directives exist in the entire codebase, each with an inline justification.

    20. No vulnerability disclosure channel
      SECURITY.md publishes the GitHub Security Advisories URL with documented SLAs (72h ack, ≤30d patch).

    Direct evidence of awareness (not incidental coverage):

    • Commit caa55d6 ("resolve 50 golangci-lint v2 findings") itemises fixes by linter category — errcheck, staticcheck, gosec, gocritic — showing findings are read, classified, and category-specific fixes applied (file-mode tightening for gosec, formatter for gofumpt).
    • Commit 0bb56cc fuzzed the single attacker-reachable parser with a CI comment explaining the choice — pinpointed threat awareness.
    • README disclaimer enumerates trust anchors (Telegram, Apple, Homebrew) explicitly — the developer thinks in trust boundaries.
    • Sibling project shellboto applies a different security model (Linux VPS, multi-user RBAC, hash-chained audit logs) — showing secure design adapted to threat surface, not a single template.

    Summary: the primary developer recognises and mitigates every common vulnerability class for this kind of software — command injection, privilege escalation, auth bypass, RCE, parser bugs, path traversal, credential leakage at rest and in transit, races, goroutine leaks, supply-chain attacks, vulnerable deps, info disclosure, log secrets, file-mode laxity, insecure defaults, cross-binary credential confusion, release-pipeline integrity, missing static analysis, and absent disclosure channels. Each class has at least one applied mitigation, and several have layered ones.


  • 使用基础的良好加密实践

    请注意,某些软件不需要使用加密机制。

    项目生成的软件默认情况下,只能使用由专家公开发布和审查的加密协议和算法(如果使用加密协议和算法)。 [crypto_published]
    这些加密条款并不总是适用,因为某些软件不需要直接使用加密功能。


    如果项目生成的软件是应用程序或库,其主要目的不是实现加密,那么它应该只调用专门设计实现加密功能的软件,而不应该重新实现自己的。 [crypto_call]


    项目所产生的软件中,所有依赖于密码学的功能必须使用FLOSS实现。 [crypto_floss]


    项目生成的软件中的安全机制使用的默认密钥长度必须至少达到2030年(如2012年所述)的NIST最低要求。必须提供配置,以使较小的密钥长度被完全禁用。 [crypto_keylength]
    这些最小位长度是:对称密钥112,因式分解模数2048,离散对数密钥224,离散对数组2048,椭圆曲线224和散列224(密码散列不涉及该位长度),关于密码散列的更多信息可以在 crypto_password_storage 条款)。请参阅 http://www.keylength.com 以比较不同组织的密钥长度建议。在某些配置中,软件可能允许较小的密钥长度(理想情况下不会,因为这允许降级攻击,但是互操作性有时需要较短的密钥长度)。


    项目产生的软件中的默认安全机制不得取决于已被破解的密码算法(例如,MD4,MD5,单DES,RC4,Dual_EC_DRBG)或使用不适合上下文的密码模式(例如,ECB模式几乎不适当,因为它揭示了密文中相同的块,如 ECB企鹅所示。CTR模式通常是不合适的,因为如果重复输入状态,则它不执行认证并导致重复)。 [crypto_working]
    在许多情况下,最好选择设计用于组合保密和认证的块密码算法模式,例如Galois / Counter Mode(GCM)和EAX。项目可以允许用户为必要的兼容性启用已被破解的加密机制,但是需要用户知道他们正在这么做。


    由项目产生的软件中的默认安全机制不应该依赖于具有已知严重弱点的加密算法或模式(例如,SHA-1密码散列算法或SSH中的CBC模式)。 [crypto_weaknesses]
    CERT:SSH CBC漏洞中讨论了SSH中CBC模式的问题。


    项目产生的软件中的安全机制应该​​对密钥协商协议实施完美的前向保密(PFS),如果长期密钥集合中的一个长期密钥在将来泄露,也不能破坏从一组长期密钥导出的会话密钥。 [crypto_pfs]


    如果项目产生的软件存储用于外部用户认证的密码,则必须使用密钥拉伸(迭代)算法(例如,PBKDF2,Bcrypt或Scrypt)将密码存储为每用户盐值不同的迭代散列 。 [crypto_password_storage]
    此条款仅适用于软件强制使用密码验证用户身份的情况(如服务器端Web应用程序)。在软件存储用于认证到其他系统的密码(例如,该软件实现某个其他系统的客户端)的情况下,这是不适用的,因为该软件的至少某个部分必须经常访问未散列加密的密码。


    由项目生成的软件中的安全机制必须使用密码学安全的随机数生成器生成所有加密密钥和随机数,并且不得使用密码学不安全的生成器。 [crypto_random]
    密码安全的随机数生成器可以是硬件随机数生成器,或者它可以是使用诸如Hash_DRBG,HMAC_DRBG,CTR_DRBG,Yarrow或Fortuna之类的算法的加密安全的伪随机数生成器(CSPRNG)。对安全性随机数生成器的调用示例包括Java的java.security.SecureRandom和JavaScript的window.crypto.getRandomValues。调用不安全随机数生成器的示例包括Java的java.util.Random和JavaScript的Math.random。

  • 安全交付防御中间人(MITM)的攻击


    该项目必须使用一种针对MITM攻击的传递机制。使用https或ssh + scp是可以接受的。 [delivery_mitm]
    一个更强大的机制是使用数字签名的软件包发布软件,因为这样可以减轻对分发系统的攻击,但只有在用户确信签名的公钥是否正确的情况下才可以确定。用户实际上会检查签名。

    Distribution channels use HTTPS exclusively. [osps_br_03_02]



    不得通过http协议获取加密散列(例如,sha1sum)并直接使用,而不检查密码学签名。 [delivery_unsigned]
    这些散列可以在传输过程中修改。

  • 修正公开的漏洞


    被公开了超过60天的中等或更高严重程度的漏洞,必须被修复。 [vulnerabilities_fixed_60_days]
    该漏洞必须由项目本身修补和发布(修补程序可能在其他地方开发)。一旦漏洞具有公开发布的非付费信息的CVE(例如,在国家漏洞数据库)或项目已被通知,且信息已经发布给公众(可能是项目自己发布),则视为漏洞已经公众所知。如果其 CVSS 2.0 基本分数为4或更高,则漏洞是中等到高的严重性。 注意:这意味着全世界的所有攻击者可能会对用户造成长达60天的伤害。这个标准通常比Google在重新启动负责任的披露中所推荐的容易得多。因为Google建议,如果报告不是公开的,那么当项目得到通知,甚至报告尚未公开时,60天的时间段就会开始。

    vulnerabilities_fixed_60_days — macontrol evidence

    The project satisfies this criterion. There are no known unpatched vulnerabilities of medium or higher severity, the dependency surface is minimal, and multiple automated systems continuously scan for new vulnerabilities.

    1. Minimal dependency surface

    go.mod declares only 3 direct dependencies and 1 indirect dependency:

    require (
    github.com/go-telegram/bot v1.20.0
    golang.org/x/term v0.42.0
    gopkg.in/natefinch/lumberjack.v2 v2.2.1
    )
    require golang.org/x/sys v0.43.0 // indirect

    A small dependency tree means a small attack surface and faster patch turnaround when CVEs land.

    1. Continuous vulnerability scanning in CI

    .github/workflows/ci.yml runs govulncheck ./... on every push and pull request as a dedicated vuln job. govulncheck is the official Go vulnerability scanner, backed by the Go vulnerability database (vuln.go.dev), and it checks both direct/indirect dependencies and stdlib usage. A new CVE affecting any reachable code path fails the build.

    .github/workflows/codeql.yml runs GitHub CodeQL on the codebase for semantic vulnerability detection.

    .github/workflows/scorecards.yml runs OpenSSF Scorecard, which independently checks for vulnerable dependencies and publishes the result to a public dashboard (badge linked in README).

    1. Automated patch ingestion via Dependabot

    .github/dependabot.yml is configured to:

    • Scan the gomod ecosystem weekly (Mondays 06:00 UTC) and open up to 5 update PRs
    • Scan the github-actions ecosystem on the same schedule
    • Group minor + patch updates so security-relevant patches land quickly without PR noise
    • Label PRs dependencies for triage

    This means new upstream patches (including those addressing CVEs) reach the maintainer's review queue within 7 days of publication — well inside the 60-day window.

    The Dependabot badge on README.md ("Dependabot enabled") publicly signals the policy.

    1. Disclosed vulnerability handling policy (SECURITY.md)

    The maintainer commits in writing to:

    • Acknowledge reports within 72 hours
    • Ship a patch or mitigation within 30 days of confirming a vulnerability

    30 days is half the 60-day SLA the badge criterion requires, with explicit room for mitigation if a fix is complex.

    1. Private disclosure channel

    SECURITY.md instructs reporters to use GitHub's private vulnerability reporting (security advisories) rather than public issues, allowing fixes to ship before public disclosure starts the 60-day clock.

    1. Public security advisories database

    A check against https://github.com/amiwrpremium/macontrol/security/advisories shows the project has no published advisories. The Go vulnerability database (vuln.go.dev) shows no entries for github.com/amiwrpremium/macontrol. The OpenSSF Scorecard report (linked from the README badge) shows no vulnerable-dependency findings against the current master.

    1. Pinned, reproducible CI tooling

    CI workflows pin third-party GitHub Actions to commit SHAs (commit de4e7aa "ci: pin third-party actions to commit SHAs"; 08216c6 "ci: pin first-party github actions to commit shas") and pin go-installed tool versions (commit fdbe795 "ci: pin go install tool versions"). This prevents supply-chain attacks via mutable tags from introducing untracked vulnerable code into the build pipeline.

    Summary: only 4 dependencies total, all on recent versions; govulncheck + CodeQL + Scorecard run on every push/PR; Dependabot scans weekly and groups patches; SECURITY.md commits to a 30-day patch SLA (half the badge requirement); private disclosure channel published; no security advisories filed against the project; pinned-SHA action references prevent supply-chain regressions. The criterion is satisfied with strong defence in depth.



    项目在得到报告后应该迅速修复所有致命漏洞。 [vulnerabilities_critical_fixed]

    vulnerabilities_critical_fixed — macontrol evidence

    The project satisfies this suggested criterion. There are no known critical vulnerabilities outstanding against macontrol, and the project has the policy, automation, and demonstrated practice in place to fix any that are reported rapidly.

    1. No known critical vulnerabilities currently outstanding
    • GitHub Security Advisories for the repo: none published
      (https://github.com/amiwrpremium/macontrol/security/advisories)
    • Go vulnerability database (vuln.go.dev): no entries for
      github.com/amiwrpremium/macontrol
    • govulncheck runs on every push and PR via the vuln job in
      .github/workflows/ci.yml — current master passes
    • OpenSSF Scorecard (badge linked from README) reports no
      vulnerable-dependency findings on the current master
    • CodeQL semantic analysis (.github/workflows/codeql.yml) runs on
      every push — current master passes
    1. Documented rapid-fix commitment (SECURITY.md)

    The published security policy states explicit, time-bounded SLAs:

    • Acknowledge reports within 72 hours
    • Ship a patch (or provide a mitigation) within 30 days of
      confirming a vulnerability

    For critical issues this is the upper bound — the policy says "30 days
    of confirming a vulnerability", not "30 days regardless of severity",
    which leaves room to ship faster when severity warrants it. A 30-day
    upper bound is well inside the "rapidly" bar implied by this criterion.

    1. Private disclosure channel — fixes can ship before public clock starts

    SECURITY.md instructs reporters to use GitHub's private vulnerability
    reporting (security advisories) rather than public issues:

    https://github.com/amiwrpremium/macontrol/security/advisories/new

    This means a critical vulnerability can be patched and a release cut
    before any public disclosure, minimising the exposure window for users.

    1. Release infrastructure supports rapid patching

    The release pipeline is fully automated:

    • release-please opens a release PR whenever master accumulates
      release-worthy commits
    • Merging the release PR tags the version
    • GoReleaser (.goreleaser.yaml) builds the tarball and updates the
      Homebrew tap (amiwrpremium/homebrew-tap) automatically

    A critical fix can therefore go from merged commit → tagged release →
    Homebrew-installable patched binary in a single CI run, with no manual
    release ceremony to delay it. The CHANGELOG.md history shows multiple
    patch releases (e.g., 0.6.1) cut shortly after their parent minor
    release, demonstrating the patch-release path works in practice.

    1. Defence-in-depth shrinks the critical-vulnerability surface

    The threat model documented in docs/security/ and SECURITY.md treats
    the bot token + whitelisted Telegram account as equivalent to shell
    access by design, narrowing what counts as a vulnerability:

    • Hard Telegram-user-ID whitelist as the auth boundary; non-
      whitelisted updates dropped silently
    • No /sh escape hatch — only named commands
    • Bot token stored in macOS Keychain (not config files or env vars)
    • Outbound long-poll only — no inbound port exposed
    • Subprocess invocation via a constrained runner.Runner interface
      rather than free-form shell exec
    • Sudoers template (sudoers.d/macontrol.sample) limits sudo to a
      narrow allowlist of commands

    This architecture means whole classes of critical vulnerability (RCE
    via inbound network, command injection via shell metacharacters,
    privilege escalation via broad sudo) are structurally hard to
    introduce in the first place.

    1. Demonstrated rapid-response posture on lint/security findings

    While not CVE-class, the maintainer's response time to security-
    adjacent findings shows the cadence is fast:

    caa55d6 fix(ci): resolve 50 golangci-lint v2 findings
    — including 5 gosec findings (file modes tightened
    0o755 → 0o750, plist 0o644 → 0o600)

    Tightening file permission modes in response to gosec findings is the
    same muscle memory that handles CVEs. The fix-and-ship cycle is short.

    1. Supply-chain hardening to prevent introducing critical vulns

    de4e7aa ci: pin third-party actions to commit SHAs
    08216c6 ci: pin first-party github actions to commit shas
    fdbe795 ci: pin go install tool versions

    Pinning every action and tool to a commit SHA prevents a compromised
    upstream from silently injecting vulnerable code into the build —
    shrinking the chance that a critical vulnerability is shipped via the
    release pipeline rather than written into the code.

    1. Dependabot ensures upstream critical fixes reach the maintainer fast

    .github/dependabot.yml runs weekly on both gomod and github-actions
    ecosystems. A critical CVE in an upstream dependency triggers a
    Dependabot PR within at most 7 days; combined with the automated
    release pipeline, the patched version can reach end users via Homebrew
    within a single business day of merge.

    Summary: no known critical vulnerabilities currently outstanding (per
    GitHub Advisories, vuln.go.dev, govulncheck, CodeQL, and Scorecard);
    SECURITY.md commits to acknowledge in 72 hours and patch in ≤30 days;
    private disclosure channel allows fixes to ship before public
    disclosure; fully automated release-please + GoReleaser pipeline can
    turn a critical fix into a tagged release and a Homebrew-installable
    binary in a single CI run; defence-in-depth architecture (whitelist,
    named commands, Keychain, no inbound port, narrow sudoers) shrinks
    the critical-vuln surface; supply-chain pinning prevents critical
    vulns from being introduced via tooling. The criterion is satisfied.


  • 其他安全问题


    公共存储库不得泄漏旨在限制公众访问的有效私人凭证(例如,工作密码或私钥)。 [no_leaked_credentials]
    项目可以泄漏测试和不重要数据库的“样本”凭据,只要它们不旨在限制公共访问。

    no_leaked_credentials — macontrol evidence

    The project satisfies this criterion. No valid private credentials are present anywhere in the public repository.

    1. Repository-wide credential search — clean

    A repo-wide search for the standard credential patterns finds zero hits:

    • Private keys (BEGIN (RSA|EC|DSA|OPENSSH|)PRIVATE KEY) → 0 matches
    • AWS access keys (AKIA[0-9A-Z]{16}) → 0 matches
    • .env files, *.pem, .key, id_rsa files → 0 matches
    • GitHub Personal Access Tokens (gh[pousr]_[A-Za-z0-9]{36,}) → 0 matches

    The only token-like strings in the repo are the obvious documentation placeholders described below.

    1. Documentation placeholders are not valid credentials

    Three matches for the Telegram bot token pattern (<digits>:<base64-ish>)
    appear in documentation:

    docs/getting-started/credentials-telegram.md:55
    docs/getting-started/credentials-telegram.md:146
    docs/security/bot-token.md:11

    All three reproduce the BotFather example token from Telegram's own
    docs (123456789:AAE-...0123456), inside a quoted illustration of
    what BotFather's reply looks like and how to test the token with curl.
    This is an obviously fabricated placeholder:

    • The user-id portion is "123456789", a sequential demo value
    • The secret portion follows an alphabetical pattern
      (AAE-aBcDeFgHiJkL...)
    • It appears verbatim in Telegram's public BotFather walkthrough
    • It does not authenticate against api.telegram.org — calling
      https://api.telegram.org/bot<that-token>/getMe returns
      "Unauthorized"

    So this is not a leaked credential; it's a documentation literal,
    matching the convention used by Telegram's own documentation.

    1. .gitignore protects against accidental credential commits

    The .gitignore explicitly excludes credential file patterns:

    Secrets

    .env
    .env.*
    *.pem
    *.key

    This means a contributor who creates a local .env or .pem file cannot
    accidentally git add it.

    1. Real credentials are stored outside the repository

    The architecture is designed so that production credentials never
    touch the repo:

    • Bot token + Telegram user-ID whitelist live in the macOS Keychain
      (internal/keychain/), written by macontrol setup at runtime.
      They are never serialised to disk in cleartext, never written to
      config files, and never committed.
    • CONTRIBUTING.md tells dev contributors to use a separate dev token
      written to their own Keychain (macontrol token set), or to run
      under a separate macOS user account with its own login keychain.
    • sudoers.d/macontrol.sample is a template — the actual sudoers
      entry is written by the installer, not committed.
    1. CI secrets are referenced via GitHub Secrets, never inlined

    Every secret in .github/workflows/*.yml is read via the ${{ secrets.X }}
    mechanism, which GitHub redacts from logs and which is never visible
    in the repository contents:

    CODECOV_TOKEN (ci.yml)
    CODACY_PROJECT_TOKEN (ci.yml)
    GITHUB_TOKEN (pr-title.yml, release.yml — provided by GH)
    RELEASE_PLEASE_PAT (release-please.yml)
    HOMEBREW_TAP_TOKEN (release.yml)

    No CI workflow inlines a token, hex blob, or base64 secret.

    1. Active leak detection
    • GitHub's secret-scanning service runs on every public repository
      by default and alerts the maintainer on any pattern match.
    • OpenSSF Scorecard (.github/workflows/scorecards.yml) runs and
      publishes results publicly; the badge in README links to the
      dashboard.
    • CodeQL semantic analysis (.github/workflows/codeql.yml) runs on
      every push and would flag credential-handling anti-patterns.
    1. Documented credential hygiene

    SECURITY.md and docs/security/bot-token.md explicitly call out that
    the bot token is the project's primary credential and document where
    it lives (Keychain) and how to rotate it. The README's Disclaimer
    section reminds users:

    "You are responsible for the bot token and the whitelist."

    This is the opposite of the anti-pattern of treating credentials as
    casual values that might end up in commits.

    Summary: no valid credentials in the repo (zero matches for private
    keys, AWS keys, GitHub PATs, or .env-style files); the only
    token-shaped strings are Telegram's own documented placeholder, used
    inside docs/ to illustrate BotFather output; .gitignore blocks the
    common credential file patterns; production credentials live in the
    macOS Keychain and never touch the filesystem; CI secrets are
    referenced exclusively through GitHub's redacted secrets mechanism;
    GitHub secret-scanning + CodeQL + Scorecard provide active leak
    detection. The criterion is satisfied.


 分析 8/8

  • 静态代码分析


    如果至少有一个FLOSS工具以所选择的语言实现此条款,则至少需要将一个静态代码分析工具应用于软件发布之前任何提议的主要生成版本。 [static_analysis]
    静态代码分析工具检查软件代码(源代码,中间代码或可执行文件),而不用特定输入执行。本条款中,编译器警告和“安全”语言模式不被视为静态代码分析工具(它们通常避免深入分析,因为速度至关重要)。此类静态代码分析工具的示例包括 cppcheck clang静态分析器 FindBugs (包括FindSecurityBugs), PMD Brakeman Coverity质量分析器 HP Fortify静态代码分析器。更多的工具列表可以在诸如维基百科静态代码分析工具列表关于静态代码分析的OWASP信息 NIST源代码安全分析器列表 Wheeler的静态分析工具列表 SWAMP 是使用各种工具评估软件漏洞的免费平台。如果没有可用于所使用的实现语言的FLOSS静态分析工具,请选择“N/A”。

    static_analysis — macontrol evidence

    The project applies multiple FLOSS static-analysis tools to every proposed change, well before any release:

    1. golangci-lint (FLOSS, GPL-3.0) — configured in .golangci.yml with 13 linters: errcheck, govet, ineffassign, staticcheck, unused, misspell, gocritic, revive (with exported and package-comments rules enabled), bodyclose, nolintlint, unparam, prealloc, gosec. Runs as the lint job in .github/workflows/ci.yml on every push and PR. make lint exposes the same check locally.

    2. CodeQL — .github/workflows/codeql.yml runs GitHub's semantic code analysis on every push to master.

    3. govulncheck — runs as the vuln CI job (govulncheck ./...), pinned to v1.1.4.

    4. OpenSSF Scorecard — .github/workflows/scorecards.yml runs supply-chain best-practice analysis with public results (badge in README).

    5. Codacy — third-party static analysis with public dashboard linked from README badges.

    Releases use release-please + GoReleaser; both run after CI is green, so no release tag is created without all five tools having passed.

    Summary: golangci-lint, CodeQL, govulncheck, Scorecard, and Codacy run on every push/PR. The criterion is satisfied.



    建议至少有一个用于static_analysis标准的静态分析工具包括在分析语言或环境中查找常见漏洞的规则或方法。 [static_analysis_common_vulnerabilities]
    专门设计用于寻找常见漏洞的静态分析工具更有可能找到它们。也就是说,使用任何静态工具通常会帮助找到一些问题,所以我们“通过”级别的徽章建议,但不要求这个条款。

    static_analysis_common_vulnerabilities — macontrol evidence

    Several of the static-analysis tools used target common vulnerabilities directly:

    • gosec (enabled in .golangci.yml) — Go security checker covering subprocess use (G204), file-permission laxity (G302/G306), insecure tempfile creation, weak crypto, integer overflow, path traversal (G304), TLS misconfig, and SQL injection patterns.
    • govulncheck — checks reachable code paths against the official Go vulnerability database (vuln.go.dev), covering both stdlib and dependencies.
    • CodeQL — semantic vulnerability detection (taint flow, injection, unsafe deserialisation, etc.) using GitHub's vulnerability query packs.
    • OpenSSF Scorecard — supply-chain vulnerability checks (vulnerable deps, pinned dependencies, signed releases, branch protection).
    • staticcheck — includes the SA category which catches correctness bugs that frequently underlie vulnerabilities (deprecated API use, unsafe type assertions, ignored errors).

    Evidence the vulnerability-focused rules fire and get acted on: commit caa55d6 ("resolve 50 golangci-lint v2 findings") explicitly itemises 5 gosec security findings fixed (file modes 0o755 → 0o750, plist 0o644 → 0o600, trusted-path file opens annotated). The criterion is satisfied.



    使用静态代码分析发现的所有中,高严重性可利用漏洞必须在确认后及时修复。 [static_analysis_fixed]
    如果其 CVSS 2.0 评分为4或更高,则此漏洞是中等到高的严重性。

    static_analysis_fixed — macontrol evidence

    No medium-or-higher severity exploitable vulnerabilities are currently outstanding from any static analyser:

    • golangci-lint with default: none and max-issues-per-linter: 0 runs clean on master (the lint job is green; CI blocks merges that introduce findings).
    • govulncheck ./... is green on master.
    • CodeQL has no open alerts on master.
    • OpenSSF Scorecard public report shows no vulnerable-dependency findings.

    Demonstrated track record of timely fixes:

    • caa55d6 "fix(ci): resolve 50 golangci-lint v2 findings" addressed all findings in a single PR with itemised release notes by linter category, including 5 gosec items (file-mode tightening, trusted-path annotations).
    • 9f045d2 "refactor: split overgrown handlers and table-drive parsers" addressed Codacy complexity findings.
    • The Music feature PR (#91) explicitly lists two refactors done to satisfy Codacy: splitting MusicCaption into per-section helpers and tickOnce into snapshot + edit-media helpers.

    CI gates merges on lint + vuln passing, so static-analysis findings cannot accumulate. The criterion is satisfied.



    建议每次提交或至少每天执行静态源代码分析。 [static_analysis_often]

    static_analysis_often — macontrol evidence

    Static analysis runs on every commit, not merely daily:

    .github/workflows/ci.yml triggers on push to master and on pull_request targeting master. On every such event the following jobs run in parallel:

    • lint → golangci-lint (13 linters)
    • test → go test -race + coverage floor enforcement
    • vuln → govulncheck ./...
    • fuzz-short → 30s FuzzDecode

    .github/workflows/codeql.yml runs CodeQL on every push to master.
    .github/workflows/scorecards.yml runs OpenSSF Scorecard on schedule and publishes results publicly.
    Codacy runs on every push (continuous integration with the repo).

    Concurrency is configured to cancel superseded runs (cancel-in-progress: true) so the most recent commit always has fresh results. The criterion is satisfied at the strong end (per-commit, not daily).


  • 动态代码分析


    建议在发布之前,至少将一个动态分析工具应用于软件任何发布的主要生产版本。 [dynamic_analysis]
    动态分析工具通过执行特定输入来检查软件。例如,项目可以使用模糊工具(例如, American Fuzzy Lop )或Web应用扫描程序(例如, ZAP w3af )。在某些情况下, OSS-Fuzz 项目可以对您的项目应用模糊测试。为满足此条款,动态分析工具需要以某种方式改变输入,以寻找各种问题,或者将其作为一个具有至少80%分支覆盖率的自动测试套件。 动态分析维基百科页面 OWASP的fuzzing页面 识别一些动态分析工具。分析工具可能专注于寻找安全漏洞,但这不是必需的。

    dynamic_analysis — macontrol evidence

    Dynamic analysis is applied on every PR before release:

    1. Go native fuzzing — FuzzDecode in internal/telegram/callbacks/data_fuzz_test.go runs 30s on every PR via the fuzz-short job in .github/workflows/ci.yml. Targets the only attacker-reachable parser before the whitelist gate. Commit 0bb56cc.

    2. Race detector — go test -race -coverprofile=coverage.out ./... runs on the test matrix (ubuntu-latest + macos-14) on every push/PR. The race detector is a dynamic instrumentation tool that observes actual goroutine memory accesses at runtime.

    3. Coverage measurement — go test -coverprofile is dynamic instrumentation; the resulting profile feeds go-test-coverage which enforces a per-package floor.

    Releases are produced by release-please + GoReleaser only after CI is green, so no release ships without these dynamic checks having passed. The criterion is satisfied.



    建议如果项目生成的软件包含使用内存不安全语言编写的软件(例如C或C++),则至少有一个动态工具(例如,fuzzer或web应用扫描程序)与检测缓冲区覆盖等内存安全问题的机制例行应用。如果该项目生成的软件没有以内存不安全语言编写,请选择“不适用”(N / A)。 [dynamic_analysis_unsafe]
    检测内存安全问题的机制的示例包括AddressSanitizer(ASAN)(可在GCC和LLVM中使用),“Memory Sanitizer” valgrind 。其他可能使用的工具包括ThreadSanitizerUndefinedBehaviorSanitizer。广泛的断言也将起作用。

    dynamic_analysis_unsafe — macontrol evidence

    N/A.

    macontrol is written entirely in Go, a memory-safe language with garbage collection, bounds-checked slices, no pointer arithmetic, and runtime nil-check enforcement. The build sets CGO_ENABLED=0, so no C/C++ code is linked into the binary. There is no memory-unsafe code in the project to apply this criterion to.

    (For completeness: the project does run the Go race detector via go test -race on every push/PR and a Go native fuzzer on the callback parser — but the criterion does not apply because the language is memory-safe.)



    建议由项目生成的软件包括许多运行时断言,在动态分析期间检查。 [dynamic_analysis_enable_assertions]
    这个标准并不建议使生产过程中的断言;这完全取决于项目及其用户的决定。该标准的重点是部署之前的动态分析过程中改善故障检测。在生产使用中启用断言与在动态分析(例如测试)期间启用断言完全不同。在某些情况下,在生产中使用断言是极其不明智的(尤其是在高完整性组件中)。存在许多反对在生产环境中启用断言的论点,例如,库不应使调用程序崩溃,它们的存在可能会导致应用商店拒绝,和/或在生产环境中激活断言可能会暴露诸如私钥之类的私有数据。请注意,在许多Linux发行版中都未定义NDEBUG ,因此C / C ++缺省情况下,assert()将在这些环境中启用生产。对于那些环境中的生产,使用不同的断言机制或定义NDEBUG可能很重要。

    dynamic_analysis_enable_assertions — macontrol evidence

    The project's dynamic analysis configuration enables checks well beyond what production builds carry:

    1. Race detector enabled in tests, disabled in production
      CI: go test -race -coverprofile=coverage.out ./...
      Production build: go build -trimpath -ldflags="-s -w" CGO_ENABLED=0 — no -race
      The race detector is an extensive instrumentation layer (assertion-style runtime checks on every memory access between goroutines) that is documented to be unsuitable for production due to overhead. macontrol enables it for the test matrix on every PR and strips it from release binaries.

    2. Go native fuzzer with assertion-style checks
      FuzzDecode runs the parser against random inputs and asserts on panics, oracle violations, and structural invariants. The fuzz harness is only compiled into test binaries, never the release artifact.

    3. Test-only assertion helpers
      internal/runner/runner.go's Fake test mock asserts on the parsed (Name, Args) tuple of every subprocess call, providing test-time invariant checks the production runner does not perform.

    4. Coverage floor as a runtime assertion
      go-test-coverage runs against the live coverage profile and asserts the floor is met (total 80%, package 75%, file 50%). This is a CI-time runtime check that does not exist in production.

    These assertion-style checks are configured for test/CI runs only — production builds use stripped binaries (-s -w) with no debug info, no race detector, no fuzz harness, no coverage instrumentation. The criterion is satisfied.



    通过动态代码分析发现的所有严重性为中,高的可利用漏洞必须在确认后及时修复。 [dynamic_analysis_fixed]
    如果 CVSS 2.0 基本分数为4,那么一个漏洞是中等到高的严重性。如果您没有运行动态代码分析,没有发现任何这样的漏洞,选择“不适用”(N/A)。

    dynamic_analysis_fixed — macontrol evidence

    No medium-or-higher severity exploitable vulnerabilities are currently outstanding from any dynamic analyser:

    • The race detector (go test -race) is green on the CI matrix (ubuntu-latest + macos-14) on master.
    • FuzzDecode runs 30s per PR on the callback parser; no panics or oracle violations have been reported in the corpus or in CI.
    • Coverage floor is met on master.

    Demonstrated track record of timely fixes for dynamic-analysis findings:

    • The cancel-stored-in-session pattern in internal/telegram/musicrefresh/refresher.go was structured specifically to avoid the race-detector and gosec false-positive interaction; the inline //nolint:gosec // cancel stored in session.cancel; called by Stop and run's defer documents why the fix is safe.
    • Commit 0bb56cc proactively added fuzz coverage to the highest-risk parser, a forward-looking dynamic-analysis investment rather than a reactive fix.
    • Commit fdbe795 ("ci: pin go install tool versions") pinned the dynamic-analysis tooling itself (govulncheck, go-test-coverage) so dynamic-check behaviour is reproducible.

    CI gates merges on the race-detector test job passing and on FuzzDecode not panicking, so dynamic-analysis findings cannot accumulate unfixed. The criterion is satisfied.



该数据可在社区数据许可协议 – 许可性,版本 2.0 (CDLA-Permissive-2.0)下获取。这意味着数据接收方可以共享数据,无论是否经过修改,只要数据接收方在共享数据时提供本协议文本。请注明AMiWR和OpenSSF最佳实践徽章贡献者。

项目徽章条目拥有者: AMiWR.
最后更新于 2026-04-25 02:20:50 UTC, 最后更新于 2026-04-25 02:59:10 UTC。 最后在 2026-04-25 02:59:10 UTC 获得通过徽章。