security-ownership-map by openai/skills
npx skills add https://github.com/openai/skills --skill security-ownership-map从 git 历史记录中构建人员与文件的双部图,然后计算所有权风险并导出用于 Neo4j/Gephi 的图谱产物。同时构建文件协同变更图(基于共享提交的 Jaccard 相似度),以根据文件如何一起变动来聚类文件,同时忽略大型、嘈杂的提交。
networkx(必需;社区检测默认启用)安装方法:
pip install networkx
--since/--until)。scripts/run_ownership_map.py 构建所有权图谱(协同变更图默认启用;使用 --cochange-max-files 忽略超节点提交)。--graphml)。scripts/query_ownership.py 查询输出以获取有界的 JSON 数据切片。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/neo4j-import.md)。默认情况下,协同变更图忽略常见的“胶水”文件(lockfiles、.github/*、编辑器配置),因此聚类反映的是实际的代码变动,而不是共享的基础设施编辑。使用 --cochange-exclude 或 --no-default-cochange-excludes 来覆盖此行为。Dependabot 提交默认被排除;使用 --no-default-author-excludes 覆盖或通过 --author-exclude-regex 添加模式。
如果要从协同变更聚类中排除 Linux 构建胶水文件如 Kbuild,请传递:
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo /path/to/linux \
--out ownership-map-out \
--cochange-exclude "**/Kbuild"
从仓库根目录运行:
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo . \
--out ownership-map-out \
--since "12 months ago" \
--emit-commits
默认设置:排除作者身份、作者日期和合并提交。如果需要,请使用 --identity committer、--date-field committer 或 --include-merges。
示例(覆盖协同变更排除项):
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo . \
--out ownership-map-out \
--cochange-exclude "**/Cargo.lock" \
--cochange-exclude "**/.github/**" \
--no-default-cochange-excludes
默认计算社区。要禁用:
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo . \
--out ownership-map-out \
--no-communities
默认情况下,脚本会标记常见的身份验证/加密/密钥路径。通过提供 CSV 文件来覆盖:
# pattern,tag,weight
**/auth/**,auth,1.0
**/crypto/**,crypto,1.0
**/*.pem,secrets,1.0
使用 --sensitive-config path/to/sensitive.csv 来应用它。
ownership-map-out/ 包含:
people.csv(节点:人员)files.csv(节点:文件)edges.csv(边:接触)cochange_edges.csv(文件到文件的协同变更边,带有 Jaccard 权重;使用 --no-cochange 时省略)summary.json(安全所有权发现)commits.jsonl(可选,如果使用 --emit-commits)communities.json(默认从协同变更边计算,如果可用;包含每个社区的 maintainers;使用 --no-communities 禁用)cochange.graph.json(NetworkX 节点-链接 JSON,包含 community_id + community_maintainers;如果没有协同变更边,则回退到 ownership.graph.json)ownership.graphml / cochange.graphml(可选,如果使用 --graphml)people.csv 包含基于作者提交偏移的时区检测:primary_tz_offset、primary_tz_minutes 和 timezone_offsets。
使用 scripts/query_ownership.py 返回小的、有 JSON 边界的切片,而无需将完整图谱加载到上下文中。
示例:
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out people --limit 10
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out files --tag auth --bus-factor-max 1
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out person --person alice@corp --limit 10
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out file --file crypto/tls
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out cochange --file crypto/tls --limit 10
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section orphaned_sensitive_code
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out community --id 3
使用 --community-top-owners 5(默认)来控制每个社区存储多少维护者。
运行这些命令来回答常见的安全所有权问题,并输出有界的结果:
# 孤立的敏感代码(陈旧 + 低巴士因子)
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section orphaned_sensitive_code
# 敏感标签的隐藏所有者
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section hidden_owners
# 巴士因子低的敏感热点
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section bus_factor_hotspots
# 巴士因子 <= 1 的身份验证/加密文件
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out files --tag auth --bus-factor-max 1
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out files --tag crypto --bus-factor-max 1
# 谁最频繁接触敏感代码
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out people --sort sensitive_touches --limit 10
# 协同变更邻居(所有权漂移的聚类提示)
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out cochange --file path/to/file --min-jaccard 0.05 --limit 20
# 社区维护者(针对一个聚类)
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out community --id 3
# 包含某个文件的社区的月度维护者
python skills/skills/security-ownership-map/scripts/community_maintainers.py \
--data-dir ownership-map-out \
--file network/card.c \
--since 2025-01-01 \
--top 5
# 按季度分组而非月度
python skills/skills/security-ownership-map/scripts/community_maintainers.py \
--data-dir ownership-map-out \
--file network/card.c \
--since 2025-01-01 \
--bucket quarter \
--top 5
注意:
--touch-mode file 来按文件计算接触次数。--window-days 90 或 --weight recency --half-life-days 180 来平滑变动。--ignore-author-regex '(bot|dependabot)' 过滤机器人。--min-share 0.1 仅显示稳定的维护者。--bucket quarter 进行日历季度分组。--identity committer 或 --date-field committer 来切换作者归属。--include-merges 来包含合并提交(默认排除)。使用此结构,如果需要可以添加字段:
{
"orphaned_sensitive_code": [
{
"path": "crypto/tls/handshake.rs",
"last_security_touch": "2023-03-12T18:10:04+00:00",
"bus_factor": 1
}
],
"hidden_owners": [
{
"person": "alice@corp",
"controls": "63% of auth code"
}
]
}
当需要将 CSV 加载到 Neo4j 时,请使用 references/neo4j-import.md。它包含约束、导入 Cypher 语句和可视化技巧。
summary.json 中的 bus_factor_hotspots 列出了巴士因子低的敏感文件;orphaned_sensitive_code 是其中的陈旧子集。git log 太大,请使用 --since 或 --until 缩小范围。summary.json 与 CODEOWNERS 进行比较,以突出显示所有权漂移。每周安装量
388
仓库
GitHub 星标数
15.3K
首次出现
2026年2月2日
安全审计
安装于
codex346
opencode326
gemini-cli318
github-copilot311
cursor305
amp301
Build a bipartite graph of people and files from git history, then compute ownership risk and export graph artifacts for Neo4j/Gephi. Also build a file co-change graph (Jaccard similarity on shared commits) to cluster files by how they move together while ignoring large, noisy commits.
networkx (required; community detection is enabled by default)Install with:
pip install networkx
--since/--until).scripts/run_ownership_map.py (co-change graph is on by default; use --cochange-max-files to ignore supernode commits).--graphml).scripts/query_ownership.py for bounded JSON slices.references/neo4j-import.md).By default, the co-change graph ignores common “glue” files (lockfiles, .github/*, editor config) so clusters reflect actual code movement instead of shared infra edits. Override with --cochange-exclude or --no-default-cochange-excludes. Dependabot commits are excluded by default; override with --no-default-author-excludes or add patterns via --author-exclude-regex.
If you want to exclude Linux build glue like Kbuild from co-change clustering, pass:
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo /path/to/linux \
--out ownership-map-out \
--cochange-exclude "**/Kbuild"
Run from the repo root:
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo . \
--out ownership-map-out \
--since "12 months ago" \
--emit-commits
Defaults: author identity, author date, and merge commits excluded. Use --identity committer, --date-field committer, or --include-merges if needed.
Example (override co-change excludes):
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo . \
--out ownership-map-out \
--cochange-exclude "**/Cargo.lock" \
--cochange-exclude "**/.github/**" \
--no-default-cochange-excludes
Communities are computed by default. To disable:
python skills/skills/security-ownership-map/scripts/run_ownership_map.py \
--repo . \
--out ownership-map-out \
--no-communities
By default, the script flags common auth/crypto/secret paths. Override by providing a CSV file:
# pattern,tag,weight
**/auth/**,auth,1.0
**/crypto/**,crypto,1.0
**/*.pem,secrets,1.0
Use it with --sensitive-config path/to/sensitive.csv.
ownership-map-out/ contains:
people.csv (nodes: people)files.csv (nodes: files)edges.csv (edges: touches)cochange_edges.csv (file-to-file co-change edges with Jaccard weight; omitted with --no-cochange)summary.json (security ownership findings)commits.jsonl (optional, if --emit-commits)communities.json (computed by default from co-change edges when available; includes maintainers per community; disable with )people.csv includes timezone detection based on author commit offsets: primary_tz_offset, primary_tz_minutes, and timezone_offsets.
Use scripts/query_ownership.py to return small, JSON-bounded slices without loading the full graph into context.
Examples:
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out people --limit 10
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out files --tag auth --bus-factor-max 1
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out person --person alice@corp --limit 10
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out file --file crypto/tls
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out cochange --file crypto/tls --limit 10
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section orphaned_sensitive_code
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out community --id 3
Use --community-top-owners 5 (default) to control how many maintainers are stored per community.
Run these to answer common security ownership questions with bounded output:
# Orphaned sensitive code (stale + low bus factor)
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section orphaned_sensitive_code
# Hidden owners for sensitive tags
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section hidden_owners
# Sensitive hotspots with low bus factor
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out summary --section bus_factor_hotspots
# Auth/crypto files with bus factor <= 1
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out files --tag auth --bus-factor-max 1
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out files --tag crypto --bus-factor-max 1
# Who is touching sensitive code the most
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out people --sort sensitive_touches --limit 10
# Co-change neighbors (cluster hints for ownership drift)
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out cochange --file path/to/file --min-jaccard 0.05 --limit 20
# Community maintainers (for a cluster)
python skills/skills/security-ownership-map/scripts/query_ownership.py --data-dir ownership-map-out community --id 3
# Monthly maintainers for the community containing a file
python skills/skills/security-ownership-map/scripts/community_maintainers.py \
--data-dir ownership-map-out \
--file network/card.c \
--since 2025-01-01 \
--top 5
# Quarterly buckets instead of monthly
python skills/skills/security-ownership-map/scripts/community_maintainers.py \
--data-dir ownership-map-out \
--file network/card.c \
--since 2025-01-01 \
--bucket quarter \
--top 5
Notes:
--touch-mode file to count per-file touches.--window-days 90 or --weight recency --half-life-days 180 to smooth churn.--ignore-author-regex '(bot|dependabot)'.--min-share 0.1 to show stable maintainers only.--bucket quarter for calendar quarter groupings.--identity committer or --date-field committer to switch from author attribution.--include-merges to include merge commits (excluded by default).Use this structure, add fields if needed:
{
"orphaned_sensitive_code": [
{
"path": "crypto/tls/handshake.rs",
"last_security_touch": "2023-03-12T18:10:04+00:00",
"bus_factor": 1
}
],
"hidden_owners": [
{
"person": "alice@corp",
"controls": "63% of auth code"
}
]
}
Use references/neo4j-import.md when you need to load the CSVs into Neo4j. It includes constraints, import Cypher, and visualization tips.
bus_factor_hotspots in summary.json lists sensitive files with low bus factor; orphaned_sensitive_code is the stale subset.git log is too large, narrow with --since or --until.summary.json against CODEOWNERS to highlight ownership drift.Weekly Installs
388
Repository
GitHub Stars
15.3K
First Seen
Feb 2, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex346
opencode326
gemini-cli318
github-copilot311
cursor305
amp301
Vite Flare Starter:开箱即用的全栈Cloudflare应用模板,集成React 19、Hono、D1
375 周安装
VectorBT + OpenAlgo Python回测环境一键配置指南 | 量化交易开发
375 周安装
Turso数据库测试指南:SQL兼容性、Rust集成与模糊测试方法详解
375 周安装
LLM硬件模型匹配器:自动检测系统配置,推荐最佳LLM模型,支持GPU/CPU/量化
375 周安装
MySQL数据库管理、优化与开发实战指南 - 生产环境技能全解析
375 周安装
Cosmos dbt Core 集成指南:Airflow 中运行 dbt 任务的完整配置清单
376 周安装
--no-communitiescochange.graph.json (NetworkX node-link JSON with community_id + community_maintainers; falls back to ownership.graph.json if no co-change edges)ownership.graphml / cochange.graphml (optional, if --graphml)