0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】GithubのDependbotを導入する

Last updated at Posted at 2022-07-31

Flutterを使って個人で以下のスマホ向けのおみくじアプリ(大御心アプリ)を開発・運用しています。

Screenshot_home.png Screenshot_fortune_1.png Screenshot_fortune_2.png Screenshot_emperor_list.png Screenshot_emperor_detail.png

[iOS]
https://apps.apple.com/us/app/%E5%A4%A7%E5%BE%A1%E5%BF%83%E3%82%A2%E3%83%97%E3%83%AA/id1627544916

[Android]
https://play.google.com/store/apps/details?id=jp.sikisimanomiti.oomigokoro

今回上記アプリのリポジトリにGithubのDependbotを導入する記事を書きたいと思います。

Dependbotとは

アプリを開発する際に必要に応じてライブラリを使って開発することがあると思いますが、ライブラリから致命的な脆弱性が入ってしまい個人情報が流出するなど開発するアプリのセキュリティが低下しないよう定期的に使用するライブラリのアップデートも行わなければなりません。

しかし、開発が活発なライブラリはマイナーバージョンアップであれば1、2日で行うこともあるので、使用しているライブラリを1個1個確認してアップデートを行うのはとても面倒で手動で行うのはあまり現実的ではありません。

上記のようなアップデートの確認をGithubのDependbotを使うことで自動化できます。

Dependbotはnpmpackage.jsonpythonPipfileなどそれぞれの言語のパッケージ管理機構のマニフェストファイルを見て依存関係を管理することで、古かったり脆弱性があったりしたライブラリを発見しPull Requestを作成して通知してくれます。

今回は2022年4月にDependabotがpubパッケージのベータサポートを開始したということで、

pub beta support for Dependabot version updates

早速、上記アプリのリポジトリにDependabotを導入しようと思います。
(※Dependabotのpubサポートはベータのためsecurity updatesをサポートしていないらしい)

Support for pub is in beta, and thus, we are aware of some limitations. For example, security updates are not supported in this release but will be in the future.

Dependbotを導入

まずはDependabotを動かすために、プロジェクトディレクトリ配下に.githubディレクトリと設定ファイルを作成します。

bash
$ mkdir .github
$ touch .github/dependabot.yml

ディレクトリ構成は以下のようになりました。

bash
$ tree -L 1
.
├── .github
│   └── dependabot.yml
├── backend
└── frontend

ファイルが作成できたらファイルの中身を記述します。設定できるオプションはConfiguration options for the dependabot.yml fileを参照

.github/dependabot.yml
version: 2
enable-beta-ecosystems: true
updates:
  - package-ecosystem: "pub"
    directory: "/frontend"
    schedule:
      interval: "weekly"
      time: "09:00"
      timezone: Asia/Tokyo

記述できたら、Githubへプッシュします。

プッシュできたら、Githubにあるpubspec.yamlに対してチェックを開始します。

スクリーンショット 2022-07-31 16.01.42.png

チェックが完了しました。チェックが完了すると、pubspec.yamlpubspec.lockが監視対象となりました。
スクリーンショット 2022-07-31 16.12.39.png

Githubの「Pull Request」タブを開くと、5個のライブラリのアップデートを通知するプルリクがありました。

スクリーンショット 2022-07-31 16.15.25.png

試しにflutter_svgのアップデートのプルリクの詳細を開きます。

スクリーンショット 2022-07-31 16.17.47.png

現在(2022年7月31日時点)ではまだsecurity updatesに対応していないようですが、以上でライブラリのアップデートには追随できるようになりました。

参考

GitHubにDependabotを導入して依存ライブラリを自動アップデートする
DependabotとGithub Actionsで自動バージョンアップを実現する話
Flutterプロジェクトのpubパッケージに対してGitHub Dependabotを使ってみた
[Flutter] GitHub Dependabot

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?