2
0

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.

Falco GitHub Pluginのテスト

Last updated at Posted at 2022-11-08

FalcoのGitHubプラグインが最近発表されたので、テストしてみました。
「Falco GitHubプラグインでDropboxの情報漏洩に対応する」のブログ記事も、ぜひご参照ください。

テスト条件

  • Falco GitHubプラグインはバージョン0.4.0を使用
  • WebhookはHTTP接続を使用(テスト目的のため)

Falcoのインストール

GitHubプラグインのダウンロードサイト

GitHubプラグインのインストール

sudo su -
cd /tmp
wget https://download.falco.org/plugins/stable/github-0.4.0-linux-x86_64.tar.gz
tar xvzf github-0.4.0-linux-x86_64.tar.gz
mv libgithub.so /usr/share/falco/plugins/

GitHubルールファイルのダウンロード

wget https://download.falco.org/plugins/stable/github-rules-0.4.0.tar.gz
tar xvzf github-rules-0.4.0.tar.gz

github.yamlファイルが解凍される

GiHub Tokenの作成

下記URLにアクセスする
https://github.com/settings/tokens

"Generate new token"から、“Generate new token (classic)”を選択する
image.png

Scopesでは"repo"にチェックを入れてTokenを作成する
image.png

作成されたTokenをgithub.tokenファイルにコピー&ペーストする

mkdir .ghplugin
vi .ghplugin/github.token

AWS Security Group設定の変更 (EC2を使用している場合)

IPv4 AnyからのHTTP接続を許可する(テスト目的のため)

Falco設定の変更

vi /etc/falco.yaml

  - name: github
    library_path: libgithub.so
    init_config:
      websocketServerURL: "http://パブリックIPアドレス"
      UseHTTPs: false
    open_params: '*'
    
    load_plugins: [github]

*websocketServerURLはプラグインを実行しているサーバのパブリックIPアドレスを指定
*UseHTTPs: falseでHTTPSを無効化

プラグイン動作テスト

あらかじめGithub上にパブリックリポジトリを1つ作成しておく

Falcoの起動

falco -c /etc/falco/falco.yaml -r github.yaml

テストの実行

Githubのリポジトリ設定画面から、下記アクションを実行する

  1. パブリックリポジトリをプライベートリポジトリに変更する
  2. 変更したプライベートリポジトリをパブリックリポジトリに戻す
  3. パブリックリポジトリを削除する
    2022-11-08 13.54.13.png

Falcoのログ

下記イベントを検知していることを確認する

  • Warning A repository went from public to private
  • Critical A repository went from private to public
  • Warning A public repository was deleted
Tue Nov  8 03:50:07 2022: Falco version: 0.33.0 (x86_64)
Tue Nov  8 03:50:07 2022: Falco initialized with configuration file: /etc/falco/falco.yaml
Tue Nov  8 03:50:07 2022: Loading plugin 'github' from file /usr/share/falco/plugins/libgithub.so
Tue Nov  8 03:50:07 2022: Loading rules from file /etc/falco/github.yaml
Tue Nov  8 03:50:07 2022: The chosen syscall buffer dimension is: 8388608 bytes (8 MBs)
Tue Nov  8 03:50:07 2022: Starting health webserver with threadiness 4, listening on port 8765
Tue Nov  8 03:50:07 2022: Enabled event sources: github, syscall
Tue Nov  8 03:50:07 2022: Opening capture with plugin 'github'
2022/11/08 03:50:11 Installing webhook in github repo yotakeu/create-test
2022/11/08 03:50:11 [github] starting HTTP webhook server on port 80
2022/11/08 03:50:11 Installing webhook in github repo yotakeu/falcolistupdate
Tue Nov  8 03:50:12 2022: Opening capture with Kernel module
03:50:12.546839000: Debug A github webhook was linked to this Falco instance (ID=387451595 type=Repository owner=yotakeu user=yotakeu)
03:50:13.088960000: Debug A github webhook was linked to this Falco instance (ID=387451597 type=Repository owner=yotakeu user=yotakeu)
^@03:51:59.662787000: Warning A repository went from public to private (repository=https://github.com/yotakeu/create-test repo_owner=yotakeu org= user=yotakeu)
03:52:17.003885000: Critical A repository went from private to public (repository=https://github.com/yotakeu/create-test repo_owner=yotakeu org= user=yotakeu)
03:52:32.508309000: Warning A public repository was deleted (repository=https://github.com/yotakeu/create-test repo_owner=yotakeu org= user=yotakeu)
^@^CTue Nov  8 03:53:01 2022: SIGINT received, exiting...
Syscall event drop monitoring:
   - event drop detected: 0 occurrences
   - num times actions taken: 0
2022/11/08 03:53:01 deleting webhook from yotakeu/create-test
2022/11/08 03:53:01 deleting webhook from yotakeu/falcolistupdate
Events detected: 5
Rule counts by severity:
   CRITICAL: 1
   WARNING: 2
   DEBUG: 2
Triggered rules by rule name:
   Webhook Connected: 2
   Private Repository Becoming Public: 1
   Public Repository Becoming Private: 1
   Delete Public Repository: 1

以上です

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?