GitHub Dependabot security updatesがPubパッケージをサポートしていました

GitHub Dependabot security updatesがPubパッケージをサポートしていました

Clock Icon2022.12.19 12:54

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちは、CX事業本部 IoT事業部の若槻です。

先日(2022/11/30)のGitHub Dependabotのアップデートで、Pubパッケージのsecurity updatesがサポートされるようになりました。

Dependabot security updates now supports the Pub ecosystem, making it easier for you to fix vulnerable dependencies in your Dart or Flutter apps. With security updates enabled, Dependabot will automatically raise a pull request to update vulnerable Pub dependencies to the latest patched version.

このアップデートにより、以前まではversion updateのBetaサポートのみでしたが、今後はpubパッケージにセキュリティの脆弱性が発見された場合にalertsを発生させられるようになります。

やってみた

実際に試してみます。

security updatesを設定する

Flutterプロジェクト内にDependabot config fileを作成します。

mkdir .github
touch .github/dependabot.yml

Dependabot config fileを次のように記載します。package-ecosystem: "pub"を指定します。

version: 2
updates:
  - package-ecosystem: "pub"
    directory: "/"
    schedule:
      interval: "daily"
    open-pull-requests-limit: 0 # version updates を無効化

version updatesを無効化することにより、Dependencyに脆弱性がある場合にalertsの作成のみ行われるようになります。詳しくは下記も合わせてご覧ください。

変更をGitHub上のRemote RepositoryにPushします。

Repositoryの[Insights]タブで、[Dependency graph]の[Dependencies]タブを開きます。するとDependabotからRepositoryへのアクセス権の付与が必要なようなので[Allow access]をクリックします。

少し待つとスキャン対象としてpubspec.lockおよびpubspec.yamlのDependency graphが表示されました。

[Settings]タブで[Security > Code security and analysis]を開き、[Dependabot security updates]の[Enable]をクリックして有効化します。

有効化されました。

これでFlutterプロジェクトに対してsecurity updatesを設定できました。

動作確認

さてここで実際に脆弱性のalertsを発生させたいところでしたが、古いバージョンに脆弱性を持っているpubパッケージを見つけられなかったので、その部分の動作確認の実施は叶いませんでした。

代わりに、下記エントリでnpmパッケージで脆弱性が検出された際のalerts発生の動作を確認しているので、合わせてご覧ください。

alertsが発生した際に下記のような通知メールが届きます。(npmパッケージで検証した際のもの)

参考

以上

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.