NGL で使われる表現は次のとおりです。
should-have
使用法: should-have は、リソース タイプに対して条件を照合するために使用されます。
構文: <app suite> <resource type> should-have <condition>
例:
microsoft365 remotedomain should-have autoforwardenabled = false
Explanation: the NGL rule will filter the Microsoft365 resources that have remotedomain resource type where autoforwardenable property is false.
should-not-have
使用法: should-not-haveは、リソースタイプに対して条件を一致させないために使用されます。
構文: <app suite> <resource type> should-not-have <condition>
例:
microsoft365 remotedomain should-not-have autoforwardenabled = false
Explanation: the NGL rule will filter the Microsoft365 resources that have remotedomain resource type but autoforwardenable property is not false.
条件付きスコープ
where
使用法: whereはリソースのフィルター処理、つまりリソース プロパティの使用に使用され、評価中にリソースの関連するサブセットのみが考慮されるようにします。 式whereでは複数の条件を組み合わせることができます 論理演算子 (and、or) を使用して複雑なフィルタを作成できます。 リソースフィルタリングを使用してNGLクエリを最適化する方法を参照してください。スコープ設定の時期と方法に関する詳細については、記事をご覧ください。 スコープ設定。
構文:<app suite><resource type> should-have/should-not-have<condition> where <scoped condition>
例:
Workday WorkdayAccount should-have age(nskp_LastPasswordChangeDate, "days") < 180 where textmatch(username, "-external$") = true
説明: NGL は、ユーザー名が「-external」で終わるすべての Workday ユーザーを評価し、パスワードが最後に変更されたのが過去 180 日以内かどうかを確認します。where式がない場合、すべての Workday ユーザーが評価されます。
should-have/ should-not-have式は条件の評価に影響を与え、スコープ条件はその範囲をフィルタリングします。よくある間違い
このセクションでは、 whereで発生する可能性のあるエラーについて説明します。
| Error Scenario | 不適切なNGLの例 | エラーメッセージの例 | エラーを修正する手順 |
|---|---|---|---|
| スコープ付き二次リソースに評価条件がありません | servicenow SysProperties should-have 1 = 1 where SystemProperty with-attribute { name = "my.prop.name" } | エラー: スコープ条件を持つセカンダリ リソース 'SystemProperty' には、should-have 句に少なくとも 1 つの条件が必要です | スコープ付き二次リソースの評価条件を追加します。 |

