You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GitHub Advanced Security ADS中忽略requirements里的特定私有依赖?

解决GitHub ADS无法访问私有git+ssh依赖的忽略方案

针对你遇到的ADS因私有git+ssh依赖无法访问导致安装失败的问题,结合私有仓库已自行启用GAS验证的前提,以下是几种直接忽略特定依赖的可行方案:

1. 利用包管理器专属配置标记私有依赖

不同包管理器支持通过配置让ADS自动跳过私有依赖的扫描:

  • npm/yarn:在package.json中添加dependenciesMeta字段,标记私有包为私有:

    {
      "dependencies": {
        "your-private-repo": "git+ssh://git@github.com/your-org/private-repo.git"
      },
      "dependenciesMeta": {
        "your-private-repo": {
          "private": true
        }
      }
    }
    

    这样ADS会识别该包为私有,跳过依赖提交与验证。

  • pip:在requirements.txt中,给需要忽略的依赖行添加# github-ads-ignore注释:

    requests==2.31.0
    git+ssh://git@github.com/your-org/private-py-lib.git#egg=private-lib # github-ads-ignore
    

    或者在pyproject.toml中配置排除规则:

    [tool.github.dependency-submission]
    exclude = ["private-lib"]
    
  • Gradle:在build.gradle中配置依赖提交任务时排除特定私有库:

    dependencySubmission {
      exclude group: 'com.your-org', name: 'private-gradle-lib'
    }
    

2. 自定义ADS工作流排除依赖

如果使用GitHub Actions驱动的ADS(比如官方的github/dependency-submission-action),可以修改工作流步骤,在生成依赖清单后手动移除私有依赖:
以npm为例,在工作流中添加步骤处理依赖文件:

- name: Generate and filter dependencies
  run: |
    npm install --production
    npm list --json --production > dependencies.json
    # 移除私有依赖条目
    jq 'del(.dependencies."your-private-repo")' dependencies.json > filtered-dependencies.json
- name: Submit filtered dependencies
  uses: github/dependency-submission-action@v3
  with:
    dependency-file: filtered-dependencies.json
    package-manager: npm

3. 使用GitHub全局依赖排除配置

在仓库根目录创建.github/dependency-submission.yml文件,统一配置需要忽略的依赖:

exclude:
  - package: your-private-repo
    type: npm
  - package: private-py-lib
    type: pypi
  - group: com.your-org
    name: private-gradle-lib
    type: gradle

这个配置会对所有ADS扫描生效,自动跳过指定的私有依赖。

注意:由于你的私有仓库已单独启用GAS,主仓库跳过这些依赖的验证不会影响整体安全覆盖,私有依赖的漏洞检测会在各自仓库完成。

内容的提问来源于stack exchange,提问作者Mase

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 06:42:39