アップデート一覧に戻る
New releaseJul 21, 2026

secretlint v13.0.3

プラグイン可能なリンターツールで、認証情報のコミットを防止します。

共有

Secretlint Actions Status

Secretlint is that Pluggable linting tool to prevent committing credentials.

Secretlint は、認証情報のコミットを防ぐためのプラガブルなリンティングツールです。

機能

  • スキャナー: プロジェクト内の認証情報を検出して報告します
  • プロジェクト フレンドリー: プロジェクトへのセットアップや CI サービスとの統合が簡単です
  • Pre-Commit フック: 認証情報ファイルのコミットを防ぎます
  • プラガブル: カスタムルールの作成と柔軟な設定が可能です
  • ドキュメント: そのルールがなぜシークレットとして検出したのか理由を説明します

クイックデモ

secretlint のリンティング結果は https://secretlint.github.io/ で確認できます。

クイックスタート

コマンド1つでプロジェクトに Secretlint を試すことができます。

Docker をすでにインストールしている場合:

docker run -v `pwd`:`pwd` -w `pwd` --rm -it secretlint/secretlint secretlint "**/*"

Node.js をすでにインストールしている場合:

npx @secretlint/quick-start "**/*"

実行後、 結果が空で終了ステータスが 0 であれば、プロジェクトは安全です。 そうでなければ、エラーレポートが出力され、プロジェクトに生データとしての認証情報が含まれています。

An example of secretlint results

継続的なセキュリティを実現したい場合は、以下のインストールガイドを参照し、pre-commit フックと CI を設定してください。

インストール

Docker を使用する

前提条件: Docker が必要です

当社の Docker コンテナを使用すると、ダウンロードできる最速の速度で Node.js と secretlint が動作する環境を入手できます。

以下のコマンドで、カレントディレクトリ配下のすべてのファイルを secretlint でチェックできます:

docker run -v `pwd`:`pwd` -w `pwd` --rm -it secretlint/secretlint secretlint "**/*"

secretlint/secretlint Docker コンテナは、設計上、設定なしで動作します。

この Docker イメージには以下のパッケージが組み込まれています:

詳細については、secretlint の Dockerfile を参照してください。

Node.js を使用する

前提条件: Node.js 22+ が必要です。

Secretlint は JavaScript で書かれています。 Secretlint は npm を使用してインストールできます:

npm install secretlint @secretlint/secretlint-rule-preset-recommend --save-dev

その後、設定ファイルを作成する必要があります:

npx secretlint --init

最後に、次のように任意のファイルまたはディレクトリに対してSecretlintを実行できます:

npx secretlint "**/*"

📝 Secretlint は glob パターンをサポートしており、glob パターンは二重引用符で囲む必要があります。

npm install --global を使用して Secretlint をグローバルにインストールすることも可能です。ただし、推奨しません。一部のルールがグローバル環境で壊れる可能性があります。

単一実行可能バイナリの使用

前提条件: なし

単一実行可能バイナリを使用することで、Node.js なしで secretlint コマンドを利用できます。

  1. Releases ページから最新のバイナリをダウンロードします
  2. ファイルのパーミッションを実行可能に変更します: chmod +x ./secretlint
  3. ./secretlint --init を実行して設定ファイルを作成します
  4. ./secretlint "**/*" を実行してプロジェクトをリントします

詳細については、publish/binary-compiler の README を参照してください。

使用方法

secretlint --help で使用方法が表示されます。

Secretlint CLI that scan secret/credential data.

Usage
$ secretlint [file|glob*]

Note
supported glob syntax is based on picomatch (the engine used by micromatch)
https://github.com/micromatch/picomatch#globbing-features
https://github.com/micromatch/micromatch#matching-features

Options
--init             setup config file. Create .secretlintrc.json file from your package.json
--format           [String] formatter name. Default: "stylish". Available Formatter: checkstyle, compact, github, jslint-xml, junit, pretty-error, stylish, tap, unix, json, mask-result, table
--output           [path:String] output file path that is written of reported result.
--secretlintrc     [path:String] path to .secretlintrc config file. Default: .secretlintrc.*
--secretlintignore [path:String] path to .secretlintignore file. Default: .secretlintignore
--stdinFileName    [String] filename to process STDIN content. Some rules depend on filename to check content.
--no-color         disable ANSI-color of output.
--no-terminalLink  disable terminalLink of output.
--no-maskSecrets   disable masking of secret values; secrets are masked by default.
--no-glob          disable glob pattern interpretation; treat all inputs as literal file paths.
--no-gitignore     disable .gitignore cascade respect; .gitignore files are
                   respected by default (since v13).

Options for Developer
--profile          Enable performance profile.
--secretlintrcJSON [String] a JSON string of .secretlintrc. use JSON string instead of rc file.

Experimental Options
--locale            [String] locale tag for translating message. Default: en

Examples
# Scan a single file
$ secretlint ./README.md

# Scan all files (wrap glob in double quotes to avoid shell expansion)
$ secretlint "**/*"
$ secretlint "source/**/*.ini"

# Treat inputs as literal paths (for SvelteKit (group) / Next.js [param] etc.)
$ secretlint --no-glob "src/(auth)/login.ts"

# Lint STDIN content (filename hint affects which rules apply)
$ echo "SECRET" | secretlint --stdinFileName=secret.txt

# Use a custom config file
$ secretlint "**/*" --secretlintrc=.secretlintrc.custom.json

# Scan files ignored by .gitignore (e.g. to verify build artifacts)
$ secretlint --no-gitignore "dist/**/*"

# Mask secrets in a file in-place
$ secretlint .zsh_history --format=mask-result --output=.zsh_history

# Output JSON for programmatic parsing
$ secretlint "**/*" --format=json --output=secretlint-report.json

# Output GitHub Actions annotations in CI
$ secretlint "**/*" --format=github

Exit Status
Secretlint exits with the following values:

    - 0:
      - Linting succeeded, no errors found.
      - Found only "warning" or "info" severity messages.
      - Found lint error but --output is specified.
    - 1:
      - Linting failed, errors found.
    - 2:
      - Unexpected error occurred, fatal error.

設定

Secretlint には設定ファイル .secretlintrc.{json,yml,js} があります。

secretlint --init を実行すると、ディレクトリに .secretlintrc.json ファイルが作成されます。

そのファイル内には、次のようにいくつかのルールが設定されているのが確認できます:

{
  "rules": [
    {
      "id": "@secretlint/secretlint-rule-preset-recommend"
    }
  ]
}

id プロパティは secretlint ルールパッケージの名前です。

Secretlint には組み込みのルールがありません。 ルールを追加したい場合は、パッケージをインストールし、そのルールを .secretlintrc ファイルに追加する必要があります。

各ルールは同じ設定パターンを持ちます:

  • options: そのルールのオプション定義です。詳細は各ルールのドキュメントを参照してください
  • disabled: disabled が true の場合、そのルールを無効にします
  • allowMessageIds: allowMessageIds はエラーレポートを抑制したいメッセージ id の配列です
    • メッセージ id は各ルールで定義されています。ルールのドキュメントを参照してください

例: options

例えば、@secretlint/secretlint-rule-example は options に allows を持っています。 この allows オプションは、無視したい RegExp-like String のリストを定義します。

{
  "rules": [
    {
      "id": "@secretlint/secretlint-rule-example",
      "options": {
        "allows": [
          "/dummy_secret/i"
        ]
      }
    }
  ]
}

@secretlint/secretlint-rule-preset-recommend のようなプリセットを使用する場合、オプションは rules に記述する必要があります。

例えば、@secretlint/secretlint-rule-preset-recommend > @secretlint/secretlint-rule-aws に対するオプションは次のとおりです。

カテゴリ