1
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 5 years have passed since last update.

Cloak for Visual Studio Codeの使い方

Last updated at Posted at 2020-07-08

はじめに

Cloak for Visual Studio Codeは、Visual Studio Code(以下、VSCode)を使ってプレゼンテーションや配信、録画をする場合に.envファイルに保存されている接続情報やID/パスワードを意図せず漏洩してしまうことを防ぐための拡張機能です。使い方について拡張機能のページをもとに日本語でまとめました。

インストール方法

VSCodeを開き [拡張機能] - Cloak で検索し、インストールします。

image.png

使い方

  1. .envファイルを開く
  2. コマンドパレットを開く(F1
  3. Cloakと入力
  4. Cloak: Hide Secrets を選択

image.png

.envファイルに保存されている環境変数が隠されます。

image.png
説明を読むと、Cloakはファイルを変更したり、値を別の所に退避させているわけではなく、文字の色(Foreground color)の透明度を00とすることで透明になり隠されているように見えるようにしているとのことです。

非表示のカスタマイズ

文字の透明化はsettings.jsonに定義されているcloak.environmentKeysに定義されているTextMateRuleスコープに基づいて行われています。
例えば、

settings.json
{
    "cloak.environmentKeys": "string.quoted.double.env,string.quoted.single.env,source.env,constant.numeric.env",
    "cloak.environmentComments": "comment.line.number-sign.env"
}

を次のように変更すると、

settings.json
{
    "cloak.environmentKeys": "string.quoted.double.env,source.env,constant.numeric.env",
    "cloak.environmentComments": "comment.line.number-sign.env"
}

シングルクォートで囲まれた値が透明化の範囲から外れることになります。

image.png

設定をデフォルトに戻す場合は、Cloak: Restore default scopesを使用します。

まとめ

現時点では.envファイルのみに対応しているとのことですが、VSCodeを使ってデモや配信、録画をする方は必須と言っても良い拡張機能ではないでしょうか。

1
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
1
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?