@dependfix/engine 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,3 +25,11 @@
25
25
  pnpm --filter @dependfix/engine build # 构建 dist
26
26
  pnpm --filter @dependfix/engine test # 测试
27
27
  ```
28
+
29
+ ## 相关包
30
+
31
+ - [dependfix 主项目](https://github.com/dependfix/dependfix) — 本包源码与完整文档
32
+ - [@dependfix/core](https://github.com/dependfix/dependfix/blob/master/packages/core/README.md) — 核心领域模型库(本包依赖)
33
+ - [dependfix](https://github.com/dependfix/dependfix/blob/master/packages/cli/README.md) — CLI 应用入口(依赖本包)
34
+ - [@dependfix/mcp](https://github.com/dependfix/dependfix/blob/master/packages/mcp/README.md) — MCP Server(依赖本包)
35
+ - [@dependfix/skills](https://github.com/dependfix/dependfix/blob/master/packages/skills/README.md) — 产品 Agent Skill 权威源
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Octokit } from "@octokit/rest";
2
- import { AlertClass, AlertSourceKind, AppError, FixAction, FixError, Logger, NormalizedSecurityAlert, RepositoryResult, RunResult, RunSummary, SeverityThreshold, createEmptyRunSummary } from "@dependfix/core";
2
+ import { AlertClass, AlertSeverity, AlertSourceKind, AppError, FixAction, FixError, Logger, NormalizedSecurityAlert, RepositoryResult, RunResult, RunSummary, SeverityThreshold, createEmptyRunSummary } from "@dependfix/core";
3
3
  import { z } from "zod";
4
4
  //#region src/github/client.d.ts
5
5
  interface RetryPolicyOptions {
@@ -75,6 +75,48 @@ declare function createGitHubClient(options: OctokitClientOptions): Octokit;
75
75
  */
76
76
  declare function computeRetryDelayMs(error: unknown, attempt: number, baseDelayMs?: number, maxBackoffMs?: number): number | null;
77
77
  //#endregion
78
+ //#region src/github/code-quality-fetcher.d.ts
79
+ interface FetchCodeQualityFindingsParams {
80
+ /** 仓库所属组织或用户 */
81
+ owner: string;
82
+ /** 仓库名称 */
83
+ repo: string;
84
+ /**
85
+ * 告警状态过滤。
86
+ * 默认 `open`;GitHub 合法值 `open` / `resolved` / `dismissed`。
87
+ */
88
+ state?: 'open' | 'resolved' | 'dismissed';
89
+ /** 每页数量,默认 100(GitHub API 最大值) */
90
+ perPage?: number;
91
+ }
92
+ /**
93
+ * 拉取指定仓库的 Code Quality findings 并映射为标准化模型。
94
+ *
95
+ * - 自动分页(cursor-based:before/after 走 `Link` header,与 GitHub 通用分页一致)
96
+ * - 仅处理 `state=open` 的 finding(可通过 `params.state` 覆盖)
97
+ * - severity:`rule.severity`(error/warning/note)经 `mapCodeQualitySeverity` 映射
98
+ * - Code Quality findings **不可自动修复**(`fixable: false`、`fixStrategy: null`),
99
+ * 首版统一归 C 类(`alertClass: 'report-only'`),不实现模板化修复
100
+ * - 异常通过 `mapGitHubError` 转为 `AppError`
101
+ * - 空仓库返回 `[]`,不抛异常
102
+ *
103
+ * @param client - 已认证的 Octokit 实例(来自 `createGitHubClient`)
104
+ * @param params - 仓库标识与过滤参数
105
+ * @returns 标准化告警列表
106
+ */
107
+ declare function fetchCodeQualityFindings(client: Octokit, params: FetchCodeQualityFindingsParams): Promise<NormalizedSecurityAlert[]>;
108
+ /**
109
+ * 映射 Code Quality severity:
110
+ * - `error` → `high`(语义对齐 code-scanning 映射:error 表示需立即关注)
111
+ * - `warning` → `medium`
112
+ * - `note` → `low`
113
+ * - 缺失或非法值 → `'unknown'`(不静默丢弃)
114
+ *
115
+ * 与 code-scanning 共用 `error/warning/note` 值域(GitHub CodeQL 规则同源),
116
+ * 映射口径与 `mapCodeScanningSeverity` 对齐(避免新源不一致)。
117
+ */
118
+ declare function mapCodeQualitySeverity(severity: string | null | undefined): AlertSeverity;
119
+ //#endregion
78
120
  //#region src/github/code-scanning-fetcher.d.ts
79
121
  interface FetchCodeScanningAlertsParams {
80
122
  /** 仓库所属组织或用户 */
@@ -408,9 +450,64 @@ declare function discoverRepositories(options: RepositoryDiscoveryOptions): Prom
408
450
  */
409
451
  declare function mergeRepositories(explicit: string[], discovered: string[]): string[];
410
452
  //#endregion
453
+ //#region src/github/token-scope.d.ts
454
+ /**
455
+ * 凭据权限面启动检查(安全治理:超权限 token 启动即警告)。
456
+ *
457
+ * 判定依据 GitHub API 的 `GET /user` 响应头:
458
+ * - `x-oauth-scopes`:classic PAT 的 scope 列表(`repo` 即全量仓库权限)
459
+ * - `x-accepted-github-permissions`:fine-grained PAT / 内置 GITHUB_TOKEN 的
460
+ * 已接受权限列表(`resource: access` 格式)
461
+ *
462
+ * 语义:最小权限 = fine-grained token(仅目标仓库的
463
+ * `contents`/`pull-requests` 写 + `security-events` 读 + `metadata` 读)。
464
+ * classic PAT 的 `repo` scope 是全量仓库权限,属于超权限——一旦被恶意
465
+ * 依赖脚本窃取即可接管所有可见仓库(威胁链 B 路径的最终防线是凭据权限面)。
466
+ * 检查为 best-effort:网络失败 / 无 token / 无法判定时静默跳过,不阻断运行。
467
+ */
468
+ interface TokenScopeWarning {
469
+ code: 'CLASSIC_REPO_SCOPE' | 'MISSING_SECURITY_EVENTS';
470
+ message: string;
471
+ }
472
+ interface TokenScopeAnalysis {
473
+ /** classic PAT 的 scopes(x-oauth-scopes 解析结果) */
474
+ scopes?: string[];
475
+ /** fine-grained PAT 的 accepted permissions(x-accepted-github-permissions 解析结果) */
476
+ acceptedPermissions?: string[];
477
+ /** 需要提示用户的权限问题(空 = 无问题) */
478
+ warnings: TokenScopeWarning[];
479
+ }
480
+ interface TokenScopeCheckResult extends TokenScopeAnalysis {
481
+ /** 探测是否成功(鉴权/网络失败为 false,调用方静默跳过) */
482
+ ok: boolean;
483
+ /** 认证用户登录名(探测成功时填充) */
484
+ login?: string;
485
+ }
486
+ /**
487
+ * 解析 GitHub token 权限面并输出警告(纯函数,可单测)。
488
+ *
489
+ * @param scopeHeader `GET /user` 响应的 `x-oauth-scopes` 头(classic PAT 才有值)
490
+ * @param acceptedHeader `GET /user` 响应的 `x-accepted-github-permissions` 头(fine-grained / 内置 token 才有值)
491
+ * @param options.codeScanningEnabled 是否开启 Code Scanning 源(开启时校验 security-events 权限)
492
+ */
493
+ declare function analyzeTokenScope(scopeHeader: string | undefined, acceptedHeader: string | undefined, options?: {
494
+ codeScanningEnabled?: boolean;
495
+ }): TokenScopeAnalysis;
496
+ /**
497
+ * 探测 token 权限面(网络调用,best-effort)。
498
+ * 任何失败(鉴权 401 / 网络错误 / 超时)均静默返回 `ok: false`,不抛错。
499
+ */
500
+ declare function checkTokenPermissions(client: Octokit, options?: {
501
+ codeScanningEnabled?: boolean;
502
+ }): Promise<TokenScopeCheckResult>;
503
+ //#endregion
411
504
  //#region src/code-scanning/rule-classifier.d.ts
412
505
  /**
413
- * A 类自动修复白名单:仅收录"删除/改动后不影响程序行为"且**已有修复模板**的规则。
506
+ * A 类自动修复白名单默认集合(默认值常量;测试 disjointness 不变量用)。
507
+ *
508
+ * **与 active config 的关系**:本导出为默认常量(向后兼容历史测试与外部引用),
509
+ * 运行时 classifyRule 实际从 `getActiveRulesConfig().autoFixable` 读取。
510
+ * 若配置已被 setActiveRulesConfig 替换,本常量与运行时分类可能不一致(设计意图)。
414
511
  *
415
512
  * 选择标准(实现时评审确认):
416
513
  * - 可模板化:修复动作可机械描述(删行 / 对齐 / 移除空白)
@@ -425,9 +522,9 @@ declare function mergeRepositories(explicit: string[], discovered: string[]): st
425
522
  * 纯格式规则(eol-last 等)实际出现频率低;此处先建立机制,
426
523
  * 规则命中与否不影响分层正确性。
427
524
  */
428
- declare const AUTO_FIXABLE_RULES: Set<string>;
525
+ declare const AUTO_FIXABLE_RULES: ReadonlySet<string>;
429
526
  /**
430
- * B 类建议修复列表:高风险 / 需人工判断的规则。
527
+ * B 类建议规则默认列表(默认值常量;测试 disjointness 不变量用)。
431
528
  *
432
529
  * 收录原则:
433
530
  * - 安全敏感(注入 / XSS / 路径穿越 / 密码学等),修复需结合业务语义
@@ -446,11 +543,76 @@ declare const SUGGESTED_RULES: Set<string>;
446
543
  * - A 类白名单 → `'auto-fixable'`
447
544
  * - B 类建议列表 → `'suggested'`
448
545
  * - 其余(含空字符串)→ `'report-only'`(C 类,默认,不静默丢弃)
546
+ *
547
+ * 读取自当前生效配置(`getActiveRulesConfig()`);首次调用前需通过
548
+ * `setActiveRulesConfig` 替换或保持默认。
449
549
  */
450
550
  declare function classifyRule(ruleId: string | null | undefined): AlertClass;
451
- /** 生成修复建议方向文本;未知规则返回通用建议(C 类兜底)。 */
551
+ /**
552
+ * B 类建议规则的人工修复方向(报告/PR body 建议区块展示)。
553
+ * 读取自当前生效配置(`getActiveRulesConfig().suggested`);未收录规则返回通用建议(C 类兜底,不静默)。
554
+ */
452
555
  declare function suggestionFor(ruleId: string | null | undefined): string;
453
556
  //#endregion
557
+ //#region src/code-scanning/rule-config.d.ts
558
+ type RuleClass = 'auto-fixable' | 'suggested' | 'report-only';
559
+ interface RuleConfigEntry {
560
+ /** 规则 id(如 `js/sql-injection`,trim 后用于匹配;空串非法) */
561
+ id: string;
562
+ /** 分类 */
563
+ class: RuleClass;
564
+ /** B 类建议文本(A/C 类可省略) */
565
+ suggestion?: string;
566
+ }
567
+ interface RulesConfigFile {
568
+ rules: RuleConfigEntry[];
569
+ }
570
+ /** 编译后的内部表示:高性能查找(A 类 Set / B 类 Map) */
571
+ interface CompiledRulesConfig {
572
+ autoFixable: ReadonlySet<string>;
573
+ suggested: ReadonlyMap<string, string>;
574
+ }
575
+ /** 默认规则配置(编译后;与既有常量表等价,单点声明保持向后兼容) */
576
+ declare const DEFAULT_RULES_CONFIG: CompiledRulesConfig;
577
+ /**
578
+ * 解析 JSON 配置输入为编译后配置。
579
+ *
580
+ * 校验规则(全部失败均降级返回 null,由调用方走默认):
581
+ * - 顶层必须是对象,含 `rules` 数组
582
+ * - 每个 entry 必须含非空 `id`(trim 后)、合法 `class`
583
+ * - 同 id 在多个 class 中出现 → 拒绝(disjointness 不变量)
584
+ * - suggested 必须含 `suggestion` 字段且非空
585
+ *
586
+ * @returns 解析成功 → 编译后配置;失败 → null(调用方降级)
587
+ */
588
+ declare function parseRulesConfig(input: unknown): CompiledRulesConfig | null;
589
+ /**
590
+ * 从 JSON 文件路径加载并编译。读取失败 / 解析失败 / 校验失败 → 返回 null(调用方降级)。
591
+ */
592
+ declare function loadRulesConfigFromFile(configPath: string): CompiledRulesConfig | null;
593
+ /** 环境变量名:Code Scanning 规则分类配置文件路径 */
594
+ declare const RULE_CONFIG_ENV = "CODE_SCANNING_RULES_CONFIG_PATH";
595
+ /**
596
+ * 从 env 读取 `RULE_CONFIG_ENV` 并尝试加载。
597
+ *
598
+ * - env 未设或空 → 返回 null(调用方继续走默认)
599
+ * - 路径不存在 → 返回 null
600
+ * - 加载失败 → 返回 null(错误已写入 stderr)
601
+ */
602
+ declare function loadRulesConfigFromEnv(env: NodeJS.ProcessEnv): CompiledRulesConfig | null;
603
+ /** 获取当前生效的配置(classifyRule / suggestionFor 内部使用) */
604
+ declare function getActiveRulesConfig(): CompiledRulesConfig;
605
+ /**
606
+ * 替换为自定义配置。
607
+ *
608
+ * **使用协议**:运行时模块初始化时(如 AppContext 装配)调用一次;
609
+ * 测试可临时覆盖后通过 `resetActiveRulesConfig` 恢复。频繁切换会破坏
610
+ * `code-scanning-fetcher` 的可预测行为(同一规则在不同 fetch 中分类不同)。
611
+ */
612
+ declare function setActiveRulesConfig(config: CompiledRulesConfig): void;
613
+ /** 重置为默认配置(测试 cleanup + 运行时 fallback) */
614
+ declare function resetActiveRulesConfig(): void;
615
+ //#endregion
454
616
  //#region src/code-scanning/templates.d.ts
455
617
  interface TemplateApplyResult {
456
618
  /** 修改后的文件内容 */
@@ -698,7 +860,7 @@ declare function detectPnpmMajor(workDir: string): number | null;
698
860
  declare function isCrossMajorFixRequired(lockfilePath: string, alert: NormalizedSecurityAlert): boolean;
699
861
  //#endregion
700
862
  //#region src/fixers/pnpm/index.d.ts
701
- type LockfileFailureCategory = 'LOCKFILE_NOT_FOUND' | 'MANIFEST_MISMATCH' | 'LOCKFILE_VERSION_MISMATCH' | 'CORRUPTED_LOCKFILE' | 'CREDENTIAL_ERROR' | 'RESOLVE_ERROR' | 'UNKNOWN';
863
+ type LockfileFailureCategory = 'LOCKFILE_NOT_FOUND' | 'MANIFEST_MISMATCH' | 'LOCKFILE_VERSION_MISMATCH' | 'CORRUPTED_LOCKFILE' | 'CREDENTIAL_ERROR' | 'RESOLVE_ERROR' | 'MINIMUM_RELEASE_AGE' | 'UNKNOWN';
702
864
  type RepairStrategy = 'REGENERATE' | 'FIX_ENTRIES' | 'PIN_TOOLCHAIN' | 'REINSTALL' | 'SKIP';
703
865
  interface RepairLockfileParams {
704
866
  /** 工作目录(必须包含 package.json 和 pnpm-lock.yaml) */
@@ -889,6 +1051,14 @@ interface RuntimeConfig {
889
1051
  * 需要 token 具备 `security-events: read` 权限(GITHUB_TOKEN 默认具备)。
890
1052
  */
891
1053
  codeScanningEnabled: boolean;
1054
+ /**
1055
+ * 是否同时拉取 Code Quality findings(与 Dependabot 并行源;可与 codeScanningEnabled 同开)。
1056
+ * 默认关闭(opt-in,向后兼容);开启后 GitHub 源下 Dependabot + Code Quality
1057
+ * 并行拉取、互不覆盖。Code Quality findings 不可自动修复(首版统一 C 类),
1058
+ * 仅做最小报告接入(不实现 CodeQL 完整语义解析)。
1059
+ * 需要 token 具备 fine-grained `Code quality: read`(classic PAT 需 `repo`/`public_repo`)。
1060
+ */
1061
+ codeQualityEnabled: boolean;
892
1062
  /**
893
1063
  * 跨线告警(推荐版本跨大版本)显式授权自动升级(`--allow-major-upgrade`)。
894
1064
  *
@@ -1007,6 +1177,8 @@ interface CliConfigOverrides {
1007
1177
  alertSource?: AlertSourceKind;
1008
1178
  /** 是否同时拉取 Code Scanning alerts(默认 false) */
1009
1179
  codeScanningEnabled?: boolean;
1180
+ /** 是否同时拉取 Code Quality findings(默认 false) */
1181
+ codeQualityEnabled?: boolean;
1010
1182
  /**
1011
1183
  * 跨线告警显式授权自动升级(仅 CLI `--allow-major-upgrade` 入口,
1012
1184
  * 无 env 通道;Action 不支持)。详见 RuntimeConfig.allowMajorUpgrade。
@@ -1214,6 +1386,14 @@ interface AppContext {
1214
1386
  startedAt: string;
1215
1387
  finishedAt: string;
1216
1388
  }
1389
+ /**
1390
+ * 按动作构成生成 PR 标题(收尾审查遗留修复:cs-only 修复不再误标 "N upgrades",
1391
+ * lockfile-only 不再出现 "0 upgrades")。
1392
+ * - 依赖升级 + code-scanning 修复分别计数;均为 0 时(lockfile-only)中性标题。
1393
+ * - ⚠️ 不变式:`upgrades = alertsFixed - codeFixes` 依赖 computeSummary 与
1394
+ * codeFixes 过滤条件一致(均 success && !noOp);任一侧口径变更必须同步。
1395
+ */
1396
+ declare function buildPrTitle(summary: Pick<RunSummary, 'alertsFixed'>, actions: FixAction[]): string;
1217
1397
  //#endregion
1218
1398
  //#region src/helpers/index.d.ts
1219
1399
  /**
@@ -1394,6 +1574,37 @@ declare function isMainPackagePresent(pkg: PackageJsonLike, lockfilePath: string
1394
1574
  */
1395
1575
  declare function buildUpgradeGroups(alerts: NormalizedSecurityAlert[], options: GroupingOptions): GroupingResult;
1396
1576
  //#endregion
1577
+ //#region src/runners/network-audit.d.ts
1578
+ /**
1579
+ * 执行期网络外联审计 + 出站白名单拦截(安全治理:恶意脚本外联回传/下载 payload 的事故溯源与阻断)。
1580
+ *
1581
+ * 捕获面(实证驱动,2026-08-14):
1582
+ * - **命令输出 URL 提取**(主):执行命令 stdout/stderr 中的 http(s) URL——
1583
+ * pnpm install 输出含完整 tarball URL(registry 域名 + 包名 + 版本),
1584
+ * 确定性捕获 pnpm/npm 的 registry 外联(pnpm 11 undici 直连不走代理 env,实证确认)
1585
+ * - **本地拦截代理**(辅):注入 HTTP(S)_PROXY 捕获尊重代理的工具(curl/wget/npm CLI/git http);
1586
+ * 仅当环境无既有代理时注入(覆盖用户代理会破坏其网络行为,稳定性优先);
1587
+ * **deny-by-default**:非白名单域名的 CONNECT/HTTP 请求直接 502 拒绝(不建上游连接),
1588
+ * 记录为违规外联(`violation`);白名单命中才放行(registry/GitHub 默认域 + 可配置扩展)
1589
+ * - 覆盖边界:undici 直连(node fetch/https.request 默认不读代理 env)不在连接级拦截范围——
1590
+ * 命令输出 URL 提取对这类外联提供冗余判定(攻击者绕过代理 env 也会被命中并归类违规)
1591
+ *
1592
+ * 无敏感信息:仅记录方法 + 目标(host/URL),不记录请求体与响应体。
1593
+ */
1594
+ type NetworkAuditSource = 'proxy' | 'command-output';
1595
+ interface NetworkAuditEntry {
1596
+ /** 记录时间(ISO) */
1597
+ time: string;
1598
+ /** 来源:proxy = 审计代理捕获;command-output = 命令输出 URL 提取 */
1599
+ source: NetworkAuditSource;
1600
+ /** 请求方法(CONNECT / GET / POST / ...) */
1601
+ method: string;
1602
+ /** 外联目标(proxy:host:port;command-output:完整 URL) */
1603
+ target: string;
1604
+ /** deny-by-default 拦截的违规外联标记(白名单校验失败的外联为 true) */
1605
+ violation?: boolean;
1606
+ }
1607
+ //#endregion
1397
1608
  //#region src/runners/verification-runner.d.ts
1398
1609
  /**
1399
1610
  * 单条命令的执行结果
@@ -1401,10 +1612,12 @@ declare function buildUpgradeGroups(alerts: NormalizedSecurityAlert[], options:
1401
1612
  interface CommandResult {
1402
1613
  /** 执行的命令文本 */
1403
1614
  command: string;
1404
- /** 退出码(0 = 成功) */
1615
+ /** 退出码(0 = 成功;-1 = 启动失败或超时被杀) */
1405
1616
  exitCode: number;
1406
1617
  /** 执行耗时(毫秒) */
1407
1618
  durationMs: number;
1619
+ /** 是否因超时被中止(默认 false) */
1620
+ timedOut?: boolean;
1408
1621
  /** stdout 摘要(截断到 200 行,已脱敏) */
1409
1622
  stdout: string;
1410
1623
  /** stderr 摘要(截断到 200 行,已脱敏) */
@@ -1421,6 +1634,17 @@ interface VerificationParams {
1421
1634
  * 默认: `pnpm install --frozen-lockfile` → `pnpm lint` → `pnpm build`
1422
1635
  */
1423
1636
  commands?: string[];
1637
+ /**
1638
+ * 单命令超时(毫秒),超时中止该命令并终止其进程树。
1639
+ * 默认 10 分钟(恶意死循环脚本超时中止,防长时间占用)。
1640
+ */
1641
+ commandTimeoutMs?: number;
1642
+ /**
1643
+ * 关闭执行期网络外联审计(默认开启)。
1644
+ * 审计记录命令输出中的外联 URL + 注入本地审计代理捕获尊重代理的工具外联;
1645
+ * 仅当环境无既有代理时注入(覆盖用户代理会破坏其网络行为)。
1646
+ */
1647
+ networkAuditDisabled?: boolean;
1424
1648
  }
1425
1649
  /**
1426
1650
  * 验证执行结果
@@ -1434,6 +1658,10 @@ interface VerificationResult {
1434
1658
  failedCommand?: string;
1435
1659
  /** 失败详情(仅 success=false 时填充) */
1436
1660
  failure?: string;
1661
+ /** 执行期网络外联记录(审计开启时;空数组 = 无外联或未捕获到) */
1662
+ networkAudit?: NetworkAuditEntry[];
1663
+ /** 非白名单外联违规(deny-by-default 拦截记录;空数组 = 无违规或审计关闭) */
1664
+ networkViolations?: NetworkAuditEntry[];
1437
1665
  }
1438
1666
  /**
1439
1667
  * 压缩验证命令输出为报告可读的摘要(首尾各取若干行,超长中间省略)。
@@ -1442,7 +1670,8 @@ interface VerificationResult {
1442
1670
  declare function summarizeVerificationOutput(output: string): string;
1443
1671
  /**
1444
1672
  * 构造失败验证命令的 error 描述:`exit code N — <stdout/stderr 摘要>`。
1445
- * 无输出时退化为裸 `exit code N`。stdout/stderr 已在 execCommand 中脱敏、截断 200 行。
1673
+ * 无输出时退化为裸 `exit code N`;超时命令归类为 `timed out after Xms`。
1674
+ * stdout/stderr 已在 execCommand 中脱敏、截断 200 行。
1446
1675
  */
1447
1676
  declare function formatVerificationError(cr: CommandResult): string;
1448
1677
  /**
@@ -1648,6 +1877,14 @@ interface AssessOptions {
1648
1877
  */
1649
1878
  declare function assessBreakingChange(options: AssessOptions): Promise<AssessResult>;
1650
1879
  //#endregion
1880
+ //#region src/app/repo-alerts.d.ts
1881
+ /**
1882
+ * 获取仓库的默认分支。
1883
+ * pnpm-audit 模式 client 为 null → 返回 ''(报告显示 local)。
1884
+ * 失败时返回 `'unknown'`(不阻塞主流程)。
1885
+ */
1886
+ declare function fetchDefaultBranch(client: Octokit | null, owner: string, repo: string): Promise<string>;
1887
+ //#endregion
1651
1888
  //#region src/app/index.d.ts
1652
1889
  interface DependfixAppOptions {
1653
1890
  /** 已解析的运行时配置 */
@@ -1660,6 +1897,12 @@ interface DependfixAppOptions {
1660
1897
  verbose?: boolean;
1661
1898
  /** 自定义验证命令(覆盖默认命令链) */
1662
1899
  commands?: string[];
1900
+ /**
1901
+ * 执行环境:`local`(CLI/MCP 等用户机器直接执行)| `container`(平台容器沙箱)。
1902
+ * 默认 `local`。容器内执行属于设计内隔离行为(非 root + 临时目录),
1903
+ * 不触发本地模式不可信代码风险警告。
1904
+ */
1905
+ executionEnvironment?: 'local' | 'container';
1663
1906
  }
1664
1907
  interface DependfixRunResult {
1665
1908
  /** 结构化运行结果(用于报告生成) */
@@ -1674,6 +1917,7 @@ declare class DependfixApp {
1674
1917
  private readonly logger;
1675
1918
  private readonly verbose;
1676
1919
  private readonly customCommands?;
1920
+ private readonly executionEnvironment;
1677
1921
  private readonly runId;
1678
1922
  private readonly allAlerts;
1679
1923
  private readonly allActions;
@@ -1691,6 +1935,14 @@ declare class DependfixApp {
1691
1935
  private get ctx();
1692
1936
  /** 执行完整的编排流程,返回结构化结果和退出码。 */
1693
1937
  run(): Promise<DependfixRunResult>;
1938
+ /**
1939
+ * 启动安全自检(best-effort,任何失败不阻断运行):
1940
+ * - 本地模式风险提示:fix/fix-and-pr 会在用户机器直接执行目标仓库的
1941
+ * 依赖脚本(不可信代码);容器环境(平台沙箱)属于设计内隔离,跳过。
1942
+ * - token 权限面探测:超权限 token(classic repo scope)启动即警告,
1943
+ * Code Scanning 开启但缺 security-events 权限时提示。
1944
+ */
1945
+ private runStartupSecurityChecks;
1694
1946
  private executeMode;
1695
1947
  private executeReportMode;
1696
1948
  private processRepoForReport;
@@ -1739,5 +1991,5 @@ declare class DependfixApp {
1739
1991
  private createClient;
1740
1992
  }
1741
1993
  //#endregion
1742
- export { ALERT_SOURCES, AUTO_FIXABLE_RULES, type AiAssessment, type AiChatResult, type AiConfig, type AiFileChange, AiOptions, type AiReplaceBlock, AiTriggerKind, type AiUsage, AiUsageTracker, type AlertClass, type AlertSourceKind, ApplyCodeScanningFixParams, ArchiveIndex, ArchiveRepoStats, ArchiveResult, ArchiveRunEntry, AssessOptions, AssessResult, type AssessmentContextInput, CliConfigOverrides, CodeScanningFixTemplate, CommandResult, ConcurrencySchedulerOptions, CreatePullRequestParams, DEFAULT_CONCURRENCY, DEFAULT_RUNTIME_CONFIG, DependencyFixResult, DependencyGroup, DependfixApp, DependfixAppOptions, DependfixBranchStatus, DependfixOpenPR, DependfixRunResult, DiscoveredRepository, ENV_PREFIX, FetchCodeScanningAlertsParams, FetchDependabotAlertsParams, FetchPnpmAuditAlertsParams, FixAndPrPlan, FixBranchResult, GroupSource, GroupingOptions, GroupingResult, LockfileDiff, LockfileFailureCategory, LockfileRepairResult, MAX_CONCURRENCY_LIMIT, MAX_GLOB_PATTERN_LENGTH, MemberManifestAlert, OctokitClientOptions, PackageJson, PullRequestResult, RUNTIME_MODES, RepairAttempt, RepairLockfileParams, RepairStrategy, RepoPolicy, RepositoryDiscoveryOptions, ResolveRuntimeConfigOptions, RetryPolicyOptions, RuntimeConfig, RuntimeMode, SEVERITY_THRESHOLDS, SUGGESTED_RULES, type SeverityThreshold, SourceFileSnapshot, SubmanifestPartition, TemplateApplyResult, UpgradeDependencyParams, VerificationParams, VerificationResult, applyCodeScanningFix, applyVersionedOverrides, assessBreakingChange, buildUpgradeGroups, classifyLockfileFailure, classifyRule, closePullRequest, compareSemver, computeFixAndPrPlan, computeFixFingerprint, computeLockfileDiff, computeRetryDelayMs, createFixBranch, createGitHubClient, createPullRequest, dedupeFixableAlerts, deleteRemoteBranch, detectPnpmMajor, discoverRepositories, ensurePnpmOverrides, estimateCostUsd, extractFingerprintFromBranch, extractLockfileVersion, extractMainPackage, extractPrefix, fetchCodeScanningAlerts, fetchDependabotAlerts, fetchPnpmAuditAlerts, filterExplicitRepositories, findDependencyVersion, findDependfixOpenPR, formatHistory, formatVerificationError, generatePRBody, getBranchPrStatus, getCodeScanningFixTemplate, hashAdvisoryId, inferRepoFromGitRemote, isConfirmAnswer, isCrossMajorFixRequired, isMainPackagePresent, isNonSemverDeclaration, isRootDirectDependency, isValidConcurrency, isValidPnpmVersion, listDependfixBranches, mapGitHubError, maskSecrets, matchesPattern, matchesRepoExclude, matchesRepoGlob, matchesRepoInclude, matchesTopicsExclude, mergeRepositories, overrideTransitiveDependency, parseAuditReport, parseDependabotGroups, parseMajorVersion, partitionSubmanifestAlerts, pushBranch, queryRepoHistory, quickVerifyProject, readArchiveIndex, readEnv, readEnvConfig, readExistingOverrides, readLockfileVersion, readLockfileVersions, readReposFile, repairLockfile, repoGlobToRegExp, resolvePnpmVersion, resolveRepoList, resolveRuntimeConfig, resolveWithinWorkDir, restoreSourceFile, restoreTrackedFiles, runVerification, runWithConcurrency, sanitizeOutput, snapshotSourceFile, snapshotTrackedFiles, stageAndCommit, suggestionFor, summarizeVerificationOutput, upgradeDependency, writeArchive };
1994
+ export { ALERT_SOURCES, AUTO_FIXABLE_RULES, type AiAssessment, type AiChatResult, type AiConfig, type AiFileChange, AiOptions, type AiReplaceBlock, AiTriggerKind, type AiUsage, AiUsageTracker, type AlertClass, type AlertSourceKind, ApplyCodeScanningFixParams, ArchiveIndex, ArchiveRepoStats, ArchiveResult, ArchiveRunEntry, AssessOptions, AssessResult, type AssessmentContextInput, CliConfigOverrides, CodeScanningFixTemplate, CommandResult, CompiledRulesConfig, ConcurrencySchedulerOptions, CreatePullRequestParams, DEFAULT_CONCURRENCY, DEFAULT_RULES_CONFIG, DEFAULT_RUNTIME_CONFIG, DependencyFixResult, DependencyGroup, DependfixApp, DependfixAppOptions, DependfixBranchStatus, DependfixOpenPR, DependfixRunResult, DiscoveredRepository, ENV_PREFIX, FetchCodeQualityFindingsParams, FetchCodeScanningAlertsParams, FetchDependabotAlertsParams, FetchPnpmAuditAlertsParams, FixAndPrPlan, FixBranchResult, GroupSource, GroupingOptions, GroupingResult, LockfileDiff, LockfileFailureCategory, LockfileRepairResult, MAX_CONCURRENCY_LIMIT, MAX_GLOB_PATTERN_LENGTH, MemberManifestAlert, OctokitClientOptions, PackageJson, PullRequestResult, RULE_CONFIG_ENV, RUNTIME_MODES, RepairAttempt, RepairLockfileParams, RepairStrategy, RepoPolicy, RepositoryDiscoveryOptions, ResolveRuntimeConfigOptions, RetryPolicyOptions, RuleClass, RuleConfigEntry, RulesConfigFile, RuntimeConfig, RuntimeMode, SEVERITY_THRESHOLDS, SUGGESTED_RULES, type SeverityThreshold, SourceFileSnapshot, SubmanifestPartition, TemplateApplyResult, TokenScopeAnalysis, TokenScopeCheckResult, TokenScopeWarning, UpgradeDependencyParams, VerificationParams, VerificationResult, analyzeTokenScope, applyCodeScanningFix, applyVersionedOverrides, assessBreakingChange, buildPrTitle, buildUpgradeGroups, checkTokenPermissions, classifyLockfileFailure, classifyRule, closePullRequest, compareSemver, computeFixAndPrPlan, computeFixFingerprint, computeLockfileDiff, computeRetryDelayMs, createFixBranch, createGitHubClient, createPullRequest, dedupeFixableAlerts, deleteRemoteBranch, detectPnpmMajor, discoverRepositories, ensurePnpmOverrides, estimateCostUsd, extractFingerprintFromBranch, extractLockfileVersion, extractMainPackage, extractPrefix, fetchCodeQualityFindings, fetchCodeScanningAlerts, fetchDefaultBranch, fetchDependabotAlerts, fetchPnpmAuditAlerts, filterExplicitRepositories, findDependencyVersion, findDependfixOpenPR, formatHistory, formatVerificationError, generatePRBody, getActiveRulesConfig, getBranchPrStatus, getCodeScanningFixTemplate, hashAdvisoryId, inferRepoFromGitRemote, isConfirmAnswer, isCrossMajorFixRequired, isMainPackagePresent, isNonSemverDeclaration, isRootDirectDependency, isValidConcurrency, isValidPnpmVersion, listDependfixBranches, loadRulesConfigFromEnv, loadRulesConfigFromFile, mapCodeQualitySeverity, mapGitHubError, maskSecrets, matchesPattern, matchesRepoExclude, matchesRepoGlob, matchesRepoInclude, matchesTopicsExclude, mergeRepositories, overrideTransitiveDependency, parseAuditReport, parseDependabotGroups, parseMajorVersion, parseRulesConfig, partitionSubmanifestAlerts, pushBranch, queryRepoHistory, quickVerifyProject, readArchiveIndex, readEnv, readEnvConfig, readExistingOverrides, readLockfileVersion, readLockfileVersions, readReposFile, repairLockfile, repoGlobToRegExp, resetActiveRulesConfig, resolvePnpmVersion, resolveRepoList, resolveRuntimeConfig, resolveWithinWorkDir, restoreSourceFile, restoreTrackedFiles, runVerification, runWithConcurrency, sanitizeOutput, setActiveRulesConfig, snapshotSourceFile, snapshotTrackedFiles, stageAndCommit, suggestionFor, summarizeVerificationOutput, upgradeDependency, writeArchive };
1743
1995
  //# sourceMappingURL=index.d.mts.map