mirror of
https://codeberg.org/dabao1955/apk-reverse.git
synced 2026-12-04 04:30:23 +08:00
Package the apk-reverse skill as Claude Code and Codex plugins
Add a manifest and marketplace for each host. Both wrap the existing skills/apk-reverse/ tree without duplicating it. Document both install routes in both READMEs, switch all repository links to the Codeberg remote, and add offline manifest tests. A real install round-trip stays unverified: neither CLI is installed here.
This commit is contained in:
1 parent
93ec493d02
commit
dd3d4e21b4
8 files changed
+324
-20
No files matched your search
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "apk-reverse",
|
||||
"interface": {
|
||||
"displayName": "APK Reverse plugins"
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "apk-reverse",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "AVAILABLE",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Security"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "apk-reverse",
|
||||
"description": "Agent Skill for Android APK reverse engineering and patching.",
|
||||
"owner": {
|
||||
"name": "newliver666",
|
||||
"url": "https://codeberg.org/reverse-skill-lab"
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "apk-reverse",
|
||||
"source": ".",
|
||||
"description": "Classify, patch, repack and verify Android APKs. The skill is invoked as /apk-reverse:apk-reverse.",
|
||||
"category": "security"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "apk-reverse",
|
||||
"version": "1.0.0",
|
||||
"description": "Reverse engineer, debloat, de-ad, patch, repack and verify Android APKs. Bundles the apk-reverse Agent Skill with its references and scripts.",
|
||||
"author": {
|
||||
"name": "newliver666",
|
||||
"url": "https://codeberg.org/reverse-skill-lab"
|
||||
},
|
||||
"homepage": "https://codeberg.org/reverse-skill-lab/apk-reverse",
|
||||
"repository": "https://codeberg.org/reverse-skill-lab/apk-reverse",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"android",
|
||||
"apk",
|
||||
"reverse-engineering",
|
||||
"dex",
|
||||
"frida",
|
||||
"security"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "apk-reverse",
|
||||
"version": "1.0.0",
|
||||
"description": "Reverse engineer, debloat, de-ad, patch, repack and verify Android APKs. Bundles the apk-reverse Agent Skill with its references and scripts.",
|
||||
"author": {
|
||||
"name": "newliver666",
|
||||
"url": "https://codeberg.org/reverse-skill-lab"
|
||||
},
|
||||
"homepage": "https://codeberg.org/reverse-skill-lab/apk-reverse",
|
||||
"repository": "https://codeberg.org/reverse-skill-lab/apk-reverse",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"android",
|
||||
"apk",
|
||||
"reverse-engineering",
|
||||
"dex",
|
||||
"frida",
|
||||
"security"
|
||||
],
|
||||
"skills": "./skills/",
|
||||
"interface": {
|
||||
"displayName": "APK Reverse",
|
||||
"shortDescription": "Reverse engineer, debloat, patch and repack Android APKs.",
|
||||
"longDescription": "A procedure-driven Agent Skill for Android APK work: classification gates, surgical dex patching, repacking, runtime analysis and a definition of done that requires verification.",
|
||||
"developerName": "newliver666",
|
||||
"category": "Security",
|
||||
"defaultPrompt": [
|
||||
"Reverse engineer this APK and tell me what is feasible."
|
||||
],
|
||||
"brandColor": "#49454F"
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -44,7 +44,12 @@ game-reserve/
|
||||
|
||||
# sandbox installs made while testing `npx skills add .` against this repo
|
||||
.claude/
|
||||
.agents/
|
||||
# Keep ignoring installed skills, but let the tracked Codex marketplace through.
|
||||
# A bare `.agents/` here would hide it and git would refuse to descend to un-ignore it.
|
||||
.agents/*
|
||||
!.agents/plugins/
|
||||
.agents/plugins/*
|
||||
!.agents/plugins/marketplace.json
|
||||
*.log
|
||||
*.jsonl
|
||||
*.pcap
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/newliver666/apk-reverse/stargazers"><img src="https://img.shields.io/github/stars/newliver666/apk-reverse?style=flat-square&label=stars&color=49454F" alt="stars"></a>
|
||||
<a href="https://github.com/newliver666/apk-reverse/network/members"><img src="https://img.shields.io/github/forks/newliver666/apk-reverse?style=flat-square&label=forks&color=49454F" alt="forks"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/github/license/newliver666/apk-reverse?style=flat-square&color=49454F" alt="license"></a>
|
||||
<a href="https://codeberg.org/reverse-skill-lab/apk-reverse/stars"><img src="https://img.shields.io/badge/stars-codeberg-49454F?style=flat-square&logo=codeberg&logoColor=white" alt="stars"></a>
|
||||
<a href="https://codeberg.org/reverse-skill-lab/apk-reverse/forks"><img src="https://img.shields.io/badge/forks-codeberg-49454F?style=flat-square&logo=codeberg&logoColor=white" alt="forks"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-49454F?style=flat-square" alt="license"></a>
|
||||
<img src="https://img.shields.io/badge/python-3.9%2B-49454F?style=flat-square&logo=python&logoColor=white" alt="python">
|
||||
<img src="https://img.shields.io/badge/platform-android-49454F?style=flat-square&logo=android&logoColor=white" alt="android">
|
||||
<a href="https://github.com/newliver666/apk-reverse/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/newliver666/apk-reverse/ci.yml?style=flat-square&label=ci&color=49454F" alt="ci"></a>
|
||||
<a href="https://codeberg.org/reverse-skill-lab/apk-reverse/src/branch/main/.github/workflows/ci.yml"><img src="https://img.shields.io/badge/CI-workflow-49454F?style=flat-square" alt="ci"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -150,8 +150,9 @@ measurements.
|
||||
## Structure
|
||||
|
||||
`SKILL.md`, `references/` and `scripts/` are all inside the skill directory, `skills/apk-reverse/`.
|
||||
Everything at the repository root is maintenance tooling shared across skills, not part of an
|
||||
installed skill.
|
||||
Everything else at the repository root is maintenance tooling shared across skills, not part of an
|
||||
installed skill — except the plugin manifests (`.claude-plugin/`, `.codex-plugin/` and
|
||||
`.agents/plugins/`), which package that one skill and ship no content of their own.
|
||||
|
||||
```
|
||||
SKILL.md a procedure with gates, not background reading:
|
||||
@@ -522,10 +523,10 @@ This repository is a **skills repository**: the skill lives at `skills/apk-rever
|
||||
layout the `skills` CLI resolves, and it is installed by name rather than by copying a directory:
|
||||
|
||||
```
|
||||
npx skills add newliver666/apk-reverse # install every skill in the repo
|
||||
npx skills add newliver666/apk-reverse --list # list what is here, install nothing
|
||||
npx skills add newliver666/apk-reverse --skill apk-reverse -y
|
||||
npx skills use newliver666/apk-reverse@apk-reverse # use it once, without installing
|
||||
npx skills add https://codeberg.org/reverse-skill-lab/apk-reverse # install every skill in the repo
|
||||
npx skills add https://codeberg.org/reverse-skill-lab/apk-reverse --list # list what is here, install nothing
|
||||
npx skills add https://codeberg.org/reverse-skill-lab/apk-reverse --skill apk-reverse -y
|
||||
npx skills use https://codeberg.org/reverse-skill-lab/apk-reverse --skill apk-reverse # use it once, without installing
|
||||
```
|
||||
|
||||
The CLI symlinks the skill into your agent's skills directory by default (`--copy` makes independent
|
||||
@@ -536,6 +537,43 @@ selects a single skill once a second one exists.
|
||||
Once installed, the agent loads `SKILL.md` when a task matches its description, and pulls in
|
||||
`references/*` only as needed. No global state, no machine-specific paths, and no build step.
|
||||
|
||||
### Also installable as a plugin (Claude Code / Codex)
|
||||
|
||||
The same skill is packaged as a plugin for both agent CLIs. A plugin installs and updates the skill
|
||||
as one unit; the `npx skills add` route above installs just the skill folder and does not need either
|
||||
plugin.
|
||||
|
||||
**Claude Code** — add this repository as a marketplace, then install from it:
|
||||
|
||||
```
|
||||
/plugin marketplace add https://codeberg.org/reverse-skill-lab/apk-reverse
|
||||
/plugin install apk-reverse@apk-reverse
|
||||
```
|
||||
|
||||
The shell equivalents are `claude plugin marketplace add https://codeberg.org/reverse-skill-lab/apk-reverse` and
|
||||
`claude plugin install apk-reverse@apk-reverse`. The skill appears as `/apk-reverse:apk-reverse`.
|
||||
To load a local checkout without installing, use `claude --plugin-dir .`.
|
||||
|
||||
**Codex** — add the same repository as a marketplace, then add the plugin:
|
||||
|
||||
```
|
||||
codex plugin marketplace add https://codeberg.org/reverse-skill-lab/apk-reverse
|
||||
codex plugin add apk-reverse@apk-reverse
|
||||
```
|
||||
|
||||
Restart Codex so the new skill is picked up; invoke it with `$apk-reverse` or let the description
|
||||
trigger it implicitly. `codex plugin list --json` shows what was installed.
|
||||
|
||||
The plugin files are manifests only — `.claude-plugin/plugin.json` and
|
||||
`.claude-plugin/marketplace.json` for Claude Code, `.codex-plugin/plugin.json` and
|
||||
`.agents/plugins/marketplace.json` for Codex. All four point at the one skill in
|
||||
`skills/apk-reverse/`; no skill content is duplicated.
|
||||
|
||||
Verification status: the files were checked against each vendor's published plugin format and by
|
||||
`tests/unit/test_plugin_manifests.py` (required fields, path resolution and cross-manifest
|
||||
agreement). Neither `claude` nor `codex` was installed on the machine where this was written, so a
|
||||
real install round-trip is `unverified`; run the commands above before treating it as `observed`.
|
||||
|
||||
## Requirements
|
||||
|
||||
Nothing is mandatory; each script checks what it needs. `skills/apk-reverse/scripts/doctor.py` reports
|
||||
|
||||
+43
-9
@@ -10,12 +10,12 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/newliver666/apk-reverse/stargazers"><img src="https://img.shields.io/github/stars/newliver666/apk-reverse?style=flat-square&label=stars&color=49454F" alt="stars"></a>
|
||||
<a href="https://github.com/newliver666/apk-reverse/network/members"><img src="https://img.shields.io/github/forks/newliver666/apk-reverse?style=flat-square&label=forks&color=49454F" alt="forks"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/github/license/newliver666/apk-reverse?style=flat-square&color=49454F" alt="license"></a>
|
||||
<a href="https://codeberg.org/reverse-skill-lab/apk-reverse/stars"><img src="https://img.shields.io/badge/stars-codeberg-49454F?style=flat-square&logo=codeberg&logoColor=white" alt="stars"></a>
|
||||
<a href="https://codeberg.org/reverse-skill-lab/apk-reverse/forks"><img src="https://img.shields.io/badge/forks-codeberg-49454F?style=flat-square&logo=codeberg&logoColor=white" alt="forks"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-49454F?style=flat-square" alt="license"></a>
|
||||
<img src="https://img.shields.io/badge/python-3.9%2B-49454F?style=flat-square&logo=python&logoColor=white" alt="python">
|
||||
<img src="https://img.shields.io/badge/platform-android-49454F?style=flat-square&logo=android&logoColor=white" alt="android">
|
||||
<a href="https://github.com/newliver666/apk-reverse/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/newliver666/apk-reverse/ci.yml?style=flat-square&label=ci&color=49454F" alt="ci"></a>
|
||||
<a href="https://codeberg.org/reverse-skill-lab/apk-reverse/src/branch/main/.github/workflows/ci.yml"><img src="https://img.shields.io/badge/CI-workflow-49454F?style=flat-square" alt="ci"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
## 结构
|
||||
|
||||
`SKILL.md`、`references/` 与 `scripts/` 都在 skill 目录 `skills/apk-reverse/` 内。仓库根目录下的一切是跨 skill 共享的维护工具,不属于已安装的 skill。
|
||||
`SKILL.md`、`references/` 与 `scripts/` 都在 skill 目录 `skills/apk-reverse/` 内。仓库根目录下的其他内容是跨 skill 共享的维护工具,不属于已安装的 skill —— 例外是插件清单(`.claude-plugin/`、`.codex-plugin/` 和 `.agents/plugins/`),它们只打包那一个 skill,自身不含任何 skill 内容。
|
||||
|
||||
```
|
||||
SKILL.md 带 gate 的流程,不是背景阅读材料:
|
||||
@@ -425,16 +425,50 @@ scripts/ 参数化、与路径无关
|
||||
这个仓库是一个 **skills 仓库**:skill 位于 `skills/apk-reverse/`,这正是 `skills` CLI 解析的布局;安装是按名字进行的,而不是复制一个目录:
|
||||
|
||||
```
|
||||
npx skills add newliver666/apk-reverse # install every skill in the repo
|
||||
npx skills add newliver666/apk-reverse --list # list what is here, install nothing
|
||||
npx skills add newliver666/apk-reverse --skill apk-reverse -y
|
||||
npx skills use newliver666/apk-reverse@apk-reverse # use it once, without installing
|
||||
npx skills add https://codeberg.org/reverse-skill-lab/apk-reverse # install every skill in the repo
|
||||
npx skills add https://codeberg.org/reverse-skill-lab/apk-reverse --list # list what is here, install nothing
|
||||
npx skills add https://codeberg.org/reverse-skill-lab/apk-reverse --skill apk-reverse -y
|
||||
npx skills use https://codeberg.org/reverse-skill-lab/apk-reverse --skill apk-reverse # use it once, without installing
|
||||
```
|
||||
|
||||
CLI 默认把 skill 软链进你的 agent 的 skills 目录(`--copy` 则生成独立副本),`-g` 为所有项目安装而不是仅当前项目。仓库里只有一个 skill 时,`--skill apk-reverse` 今天是多余的;这里把它写出来,是因为等第二个 skill 存在时,正是它用来选中单个 skill。
|
||||
|
||||
安装后,agent 在任务匹配其描述时加载 `SKILL.md`,并且只在需要时拉入 `references/*`。没有全局状态,没有与机器绑定的路径,也没有构建步骤。
|
||||
|
||||
### 也可作为插件安装(Claude Code / Codex)
|
||||
|
||||
同一个 skill 也被打包成这两款 agent CLI 的插件。插件把 skill 作为一个整体安装和升级;上面的 `npx skills add` 路线只安装 skill 目录,不需要任何一个插件。
|
||||
|
||||
**Claude Code** —— 把本仓库添加为 marketplace,再从中安装:
|
||||
|
||||
```
|
||||
/plugin marketplace add https://codeberg.org/reverse-skill-lab/apk-reverse
|
||||
/plugin install apk-reverse@apk-reverse
|
||||
```
|
||||
|
||||
对应的 shell 命令是 `claude plugin marketplace add https://codeberg.org/reverse-skill-lab/apk-reverse` 和
|
||||
`claude plugin install apk-reverse@apk-reverse`。安装后 skill 以 `/apk-reverse:apk-reverse` 调用。
|
||||
要从本地检出直接加载而不安装,用 `claude --plugin-dir .`。
|
||||
|
||||
**Codex** —— 把同一个仓库添加为 marketplace,再加插件:
|
||||
|
||||
```
|
||||
codex plugin marketplace add https://codeberg.org/reverse-skill-lab/apk-reverse
|
||||
codex plugin add apk-reverse@apk-reverse
|
||||
```
|
||||
|
||||
重启 Codex 让新 skill 生效;用 `$apk-reverse` 显式调用,或让描述匹配隐式触发。
|
||||
`codex plugin list --json` 可以看装了什么。
|
||||
|
||||
插件文件只有清单 —— Claude Code 用 `.claude-plugin/plugin.json` 和
|
||||
`.claude-plugin/marketplace.json`,Codex 用 `.codex-plugin/plugin.json` 和
|
||||
`.agents/plugins/marketplace.json`。四份清单都指向 `skills/apk-reverse/` 下那唯一一份 skill,
|
||||
skill 内容没有复制。
|
||||
|
||||
验证状态:文件已按两家公开的插件格式核对,并由 `tests/unit/test_plugin_manifests.py` 检查
|
||||
(必填字段、路径解析和跨清单一致性)。写这份文档时机器上既没有 `claude` 也没有 `codex`,
|
||||
所以真正的安装往返是 `unverified`;先跑一遍上面的命令,才能把它记作 `observed`。
|
||||
|
||||
## 环境要求
|
||||
|
||||
没有什么是强制的;每个脚本都自己检查所需。`skills/apk-reverse/scripts/doctor.py` 报告这里哪些工具存在、因此哪些脚本能跑,以及——这很有用——哪些工具存在于 PATH 之外。
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
"""The two plugin wrappers must point at the one skill that actually ships.
|
||||
|
||||
Neither `claude` nor `codex` is installed in CI, so this cannot prove a real install
|
||||
works -- that stays `unverified`. What it can prove without either binary is the
|
||||
part that silently breaks first: a manifest with a missing field, a path that does
|
||||
not resolve, or two plugins that disagree about what they wrap. The checks mirror
|
||||
the published manifest rules (required keys, `./`-relative component paths, no
|
||||
`..`, marketplace entry source resolving to the plugin root).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import REPO_ROOT
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
CLAUDE_PLUGIN = REPO_ROOT / ".claude-plugin" / "plugin.json"
|
||||
CLAUDE_MARKETPLACE = REPO_ROOT / ".claude-plugin" / "marketplace.json"
|
||||
CODEX_PLUGIN = REPO_ROOT / ".codex-plugin" / "plugin.json"
|
||||
CODEX_MARKETPLACE = REPO_ROOT / ".agents" / "plugins" / "marketplace.json"
|
||||
ALL = (CLAUDE_PLUGIN, CLAUDE_MARKETPLACE, CODEX_PLUGIN, CODEX_MARKETPLACE)
|
||||
SKILL = REPO_ROOT / "skills" / "apk-reverse" / "SKILL.md"
|
||||
|
||||
NAME = "apk-reverse"
|
||||
NAME_RE = re.compile(r"^[a-z0-9]+(?:-[a-z0-9]+)*$")
|
||||
|
||||
|
||||
def load(path):
|
||||
with path.open(encoding="utf-8") as fh:
|
||||
data = json.load(fh)
|
||||
assert isinstance(data, dict), "%s is not a JSON object" % path
|
||||
return data
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", ALL, ids=lambda p: str(p.relative_to(REPO_ROOT)))
|
||||
def test_manifest_exists_parses_and_names_the_plugin(path):
|
||||
data = load(path)
|
||||
assert data["name"] == NAME
|
||||
assert NAME_RE.match(data["name"])
|
||||
|
||||
|
||||
def test_both_plugin_manifests_agree_on_identity():
|
||||
claude = load(CLAUDE_PLUGIN)
|
||||
codex = load(CODEX_PLUGIN)
|
||||
for field in ("name", "version", "description", "license"):
|
||||
assert claude[field] == codex[field], field
|
||||
for field in ("homepage", "repository"):
|
||||
assert urlparse(claude[field]).scheme == "https", field
|
||||
assert claude[field] == codex[field], field
|
||||
# Codex requires semver; Claude pins whatever string it is given. One version
|
||||
# for both keeps an upgrade from silently changing one side only.
|
||||
assert re.match(r"^\d+\.\d+\.\d+$", claude["version"])
|
||||
assert claude["license"] == "MIT"
|
||||
|
||||
|
||||
def test_claude_marketplace_entry_resolves_to_the_plugin_root():
|
||||
data = load(CLAUDE_MARKETPLACE)
|
||||
assert NAME_RE.match(data["name"])
|
||||
assert data["owner"]["name"]
|
||||
assert isinstance(data["plugins"], list) and len(data["plugins"]) == 1
|
||||
entry = data["plugins"][0]
|
||||
assert entry["name"] == NAME == load(CLAUDE_PLUGIN)["name"]
|
||||
assert entry["description"]
|
||||
# "." is the documented relative source for a plugin at the marketplace root.
|
||||
assert entry["source"] == "."
|
||||
assert (REPO_ROOT / entry["source"]).resolve() == REPO_ROOT.resolve()
|
||||
|
||||
|
||||
def test_codex_marketplace_entry_resolves_to_the_plugin_root():
|
||||
data = load(CODEX_MARKETPLACE)
|
||||
assert NAME_RE.match(data["name"])
|
||||
assert data["interface"]["displayName"]
|
||||
assert len(data["plugins"]) == 1
|
||||
entry = data["plugins"][0]
|
||||
assert entry["name"] == NAME == load(CODEX_PLUGIN)["name"]
|
||||
source = entry["source"]
|
||||
assert source["source"] == "local"
|
||||
assert source["path"].startswith("./")
|
||||
assert (REPO_ROOT / source["path"]).resolve() == REPO_ROOT.resolve()
|
||||
assert entry["policy"]["installation"] == "AVAILABLE"
|
||||
assert entry["policy"]["authentication"] == "ON_INSTALL"
|
||||
assert entry["category"]
|
||||
|
||||
|
||||
def test_codex_skills_component_points_at_the_shipped_skill():
|
||||
data = load(CODEX_PLUGIN)
|
||||
value = data["skills"]
|
||||
assert isinstance(value, str) and value.startswith("./")
|
||||
assert ".." not in Path(value).parts
|
||||
target = (REPO_ROOT / value).resolve()
|
||||
assert target == (REPO_ROOT / "skills").resolve()
|
||||
assert (target / NAME / "SKILL.md").is_file()
|
||||
|
||||
# Install-surface copy is validated by Codex: <=125 chars, at most 3 prompts
|
||||
# of <=128 chars each. Re-implementing that here catches a bad edit offline.
|
||||
interface = data["interface"]
|
||||
assert 0 < len(interface["shortDescription"]) <= 125
|
||||
prompts = interface["defaultPrompt"]
|
||||
assert 1 <= len(prompts) <= 3
|
||||
assert all(0 < len(p) <= 128 for p in prompts)
|
||||
|
||||
|
||||
def test_the_wrapped_skill_has_valid_frontmatter():
|
||||
assert SKILL.is_file()
|
||||
text = SKILL.read_text(encoding="utf-8")
|
||||
match = re.match(r"^---\r?\n(.*?)\r?\n---\r?\n", text, re.S)
|
||||
assert match, "SKILL.md has no frontmatter"
|
||||
front = match.group(1)
|
||||
name = re.search(r"^name:\s*(.+)$", front, re.M)
|
||||
description = re.search(r"^description:\s*(.+)$", front, re.M)
|
||||
assert name and name.group(1).strip() == NAME
|
||||
assert description and 40 <= len(description.group(1).strip()) <= 1024
|
||||
|
||||
|
||||
def test_no_manifest_path_is_absolute_or_escapes_the_repo():
|
||||
"""Every path-looking value in all four files stays inside the repo."""
|
||||
def walk(value, origin):
|
||||
if isinstance(value, dict):
|
||||
for key, item in value.items():
|
||||
walk(item, "%s.%s" % (origin, key))
|
||||
elif isinstance(value, list):
|
||||
for index, item in enumerate(value):
|
||||
walk(item, "%s[%d]" % (origin, index))
|
||||
elif isinstance(value, str) and (value.startswith(("./", "/")) or "/.." in value):
|
||||
assert not value.startswith("/"), "%s: absolute path %r" % (origin, value)
|
||||
assert ".." not in Path(value).parts, "%s: traversal in %r" % (origin, value)
|
||||
target = (REPO_ROOT / value).resolve()
|
||||
assert target == REPO_ROOT or REPO_ROOT.resolve() in target.parents, \
|
||||
"%s: %r resolves outside the repository" % (origin, value)
|
||||
assert target.exists(), "%s: %r does not resolve" % (origin, value)
|
||||
|
||||
for path in ALL:
|
||||
walk(load(path), path.relative_to(REPO_ROOT).as_posix())
|
||||
Reference in new issue
Block a user