> For the complete documentation index, see [llms.txt](https://help.aikido.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.aikido.dev/docs/docs-ja/kdosukyan/scanning-practices/add-custom-sast-iac-rules.md).

# カスタムSAST & IaCルールを追加する

## はじめに <a href="#introduction" id="introduction"></a>

これらのカスタムルールを使うと、Aikido にコードベース内の特定のリスク、特にあなたの環境にとって特に関連性の高いリスクをスキャンさせることができます。これにより、より広範な SAST や IaC ルールでは見落とされる可能性のある脆弱性を検出できます。

## ステップごとのガイド <a href="#step-by-step-guide" id="step-by-step-guide"></a>

{% hint style="info" %}
この機能は、デフォルトではあなたのワークスペースで有効になっていません。有効化するには Aikido にお問い合わせください。
{% endhint %}

**ステップ 1:** 次へ移動 [リポジトリチェック](https://app.aikido.dev/repositories/checks) ページ。

**ステップ 2:** 「[カスタムルールを作成](https://app.aikido.dev/repositories/sast/custom/add)」を SAST セクションで\


![カスタムのセキュリティおよびコンプライアンスルールを作成するためのオプションを備えたリポジトリチェックのダッシュボード。](/files/ff5ea2dc52ee6bdda5248157e3e3b6fc534f708c)

**ステップ 3:** ルールに次の詳細を入力してください:

* **Opengrep ルール:** Aikido が検索するルールを定義します。 **ヒント:** 次を使用してください [Opengrep playground](https://github.com/opengrep/opengrep-playground?tab=readme-ov-file#installation)[ ](https://semgrep.dev/playground)保存する前に、ルールの有効性をテストします。
* **タイトル:** 簡単に識別できるようにルールに名前を付けます。
* **要約:** 問題の簡潔な説明を入力してください。これはサイドバーに表示されます。
* **修正方法:** この問題を修正する最善の方法をチームに知らせてください。
* **言語:** プログラミング言語を指定してください。
* **Aikido スコア:** メインフィードでの問題レポートの優先度を設定します。

<figure><img src="/files/dfd71190e9c033a3a785cf2bb6d23c1f87f5b48a" alt=""><figcaption></figcaption></figure>

**ステップ 4:** ルールの設定に満足したら、「保存」をクリックして Aikido の SAST チェックに追加します。これでカスタムルールは有効になり、今後のスキャンで自動的に適用されます。

### 追加情報 <a href="#extra-info" id="extra-info"></a>

* 全体として、Opengrep ルールの language 属性が常に優先されます。これは、すべての言語とファイルに一度に適用する必要があるカスタムルールを実装したい場合に役立ちます。
* IaC ルールを作成したい場合は、language を yaml/terraform/... に設定することで実行できます。

## 例 <a href="#examples" id="examples"></a>

* **SAST ルール:** JavaScript で弱い MD5 ハッシュアルゴリズムの使用を探しています。

  ```
  rules:
    - id: CUSTOM-RULE-XXXX
      message: MD5 が使用されているようです 
      languages:
        - javascript
      paths: 
        include
          - "*.js"
      severity: WARNING
      pattern-either:
        - pattern: $CRYPTO.createHash("md5")
        - pattern: CryptoJS.MD5(...)
  ```
* **IaC ルール:** 危険な可能性のある Lambda 関数を検出するためのカスタムルール。

  ```
  rules:
     - id: CUSTOM-RULE-530
       languages:
         - hcl
       severity: WARNING
       message: >
         「type:monitored」タグは見つかりましたが、「service」タグはありませんでした。
       patterns:
         - pattern: |-
             resource "aws_lambda_function" $ANYTHING {
               ...
               tags = {..., type = "monitored", ...}
             }
         - pattern-not: |-
             resource "aws_lambda_function" $ANYTHING {
               ...
               tags = {..., service= "...", ...}
             }
  ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.aikido.dev/docs/docs-ja/kdosukyan/scanning-practices/add-custom-sast-iac-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
