機密データの非表示

デバッガを使用すると、メールアドレス、アカウント番号など、アプリケーション内のセンシティブ データが露出する可能性があります。ブロックリストとブロックリストの例外を設定して、デバッガ エージェントがこのセンシティブ データにアクセスするのを阻止できます。

次のスクリーンショットのように、非表示になったデータは「blocked by admin」と表示されます。

非表示のテキストに「blocked by admin」と表示される

推奨事項

ブロックリスト ファイルの設定や更新を行う場合は、次の推奨事項にご注意ください。

  • バージョン 2.27 以降の Java エージェントを使用します。インストール手順については、Java 用 Cloud デバッガの設定をご覧ください。

  • 構成ファイルの名前とキーワードが blocklist に更新されていることにご注意ください。これに合わせてファイルを更新します。

ファイルの設定

次に設定ファイルの例を示します。インライン ドキュメントを参考に設定を行ってください。

# Cloud Debugger Blocklist Configuration File
#
# == Format ==
#
#   This configuration file accepts the following keywords:
#
#    - blocklist
#    - blocklist_exception
#
#   The debugger uses the following rules to determine if a variable's data
#   should be hidden, using the variable's type as the match criteria.
#
#   | Matches `blocklist` | Matches `blocklist_exception` | Data is |
#   |---------------------|-------------------------------|---------|
#   | no                  | no                            | shown   |
#   | no                  | yes                           | shown   |
#   | yes                 | no                            | hidden  |
#   | yes                 | yes                           | shown   |
#
#   Patterns listed under "blocklist" and "blocklist_exception" have the
#   following format:
#
#   [!]<type>
#
#   - `type` is a type prefix (such as a class or package name). Any
#      nested types will also match the pattern. For example, if you
#      specify a package name, the package and all of it's subtypes will
#      match. Note that glob patterns such as `*` can be used anywhere in
#      the type name.
#   -  By prefixing a pattern with an exclamation point, `!`, the pattern
#      is considered an "inverse match" which evaluates to true for any
#      type that does not match the provided pattern.
#   -  The debugger makes no attempt to verify that specified patterns
#      will actually match anything. If you have a misspelling in your
#      pattern, then there will be no reported errors but the pattern will
#      not work as intended.
#
# == Verification ==
#
#   A verification tool is available and can be downloaded with the
#   following command:
#
#   wget https://storage.googleapis.com/cloud-debugger/compute-java/debian-wheezy/debugger_blocklist_checker.py
#
#   This tool can be used to check the configuration file for syntax errors.
#   It can also be used to experiment with configuration files locally
#   without having to deploy a real application.
#
#   A basic usage example:
#
#       debugger_blocklist_checker.py debugger-blocklist.yaml
#
#   You can also use the tool to check if symbols will be blocklisted
#
#     echo com.java.Integer | \
#       debugger_blocklist_checker.py debugger-blocklist.yaml --check

# Uncomment The line below to add blocklists
#blocklist:
#  - "java.security"  # Example package

# Uncomment The line below to add blocklist exceptions
#blocklist_exception:
#  - "java.security.Timestamp"  # Example class

次の設定例を使用すると、デバッガから単一クラス内のデータを非表示にできます。

blocklist:
- "com.sales.Ticket"

パッケージ名を指定して、パッケージを非表示にすることもできます。

blocklist:
- "com.sales"

blocklist ルールの例外を作成すると便利な場合があります。この操作は blocklist_exception で行うことができます。

blocklist:
- "com.sales"
blocklist_exception:
- "com.sales.testing"

最後に、逆パターンを指定することもできます。この場合、パターンに一致しないクラスをブラックリストに登録します。

blocklist:
- "!com.sales"

構成ファイルの場所

構成ファイルの名前は debugger-blocklist.yaml で、クラスパスの任意の場所に配置できます。最適な場所は .jar ファイルのルートです。以降のセクションでは、この配置方法について説明します。

jar コマンドの使用

.jar ファイルに構成ファイルを挿入、あるいは更新するには、jar コマンドを使用します。構成ファイル debugger-blocklist.yaml をアーカイブ TicketTracker.jar に追加するには、次のコマンドを使用します。

jar uvf TicketTracker.jar debugger-blocklist.yaml

Ant の使用

Ant ビルドシステムを使用して JAR に構成ファイルを挿入するには、Ant の組み込み jar タスクを使用します。たとえば、次の distribute ターゲットは jar タスクを使用して、構成ファイル debugger-blocklist.yaml をアーカイブ TicketTracker.jar に追加します。

<target name="distribute" depends="compile">
  <jar destfile="${distributionDir}/TicketTracker.jar" >
    <fileset dir="${outputDir}"/>
    <fileset dir="${sourceDir}"/>
    <fileset file="debugger-blocklist.yaml" />
  </jar>
</target>

Maven の使用

Maven ビルドシステムで管理されているパッケージに構成ファイルを挿入するには、src/main/resources ディレクトリに debugger-blocklist.yaml ファイルを作成します(ディレクトリの作成が必要になる場合があります)。プロジェクトをビルドし、debugger-blocklist.yamltarget/classes にコピーされたことを確認します。