NGLでサポートされているキーワードは以下のとおりです。
Hierarchical
with-attribute
使用法: with-attributeキーワードは、ネストされたオブジェクト (json) を使用します。
構文: property1 with-attribute { property2 = value2}
例:
GoogleWorkspace GroupSetting should-have entry with-attribute { enableCollaborativeInbox = false }
with-element
使用法: with-elementキーワードは 親プロパティがリストで子プロパティがメンバーである場合、その前後のプロパティ間の階層的(または親子)関係を指定します。
構文: property1 with-element [ property2 = value2]
例:
microsoft365 sharingpolicy should-have sharingenabled = false or domains with-element [ sharingalloweddetails = "ContactsSharing" ]
with-any-element
使用法: with-any-elementキーワードは 親リストのプロパティのいずれかのメンバーが、それに続く条件に一致する条件を指定するために使用します。
構文: property1 with-any-element [ ip = “0.0.0.0” ]
例:
AzureAD User should-not-have userRegistrationDetails with-attribute { methodsRegistered with-any-element [ "mobilePhone" ] }
exists
使用方法: existsキーワードはプロパティの存在を確認します。
構文: property1 exists
例:
Okta User should-have profile with-attribute { mobilePhone exists }
not-exists
使用法: not-existsキーワードはプロパティの不在をチェックします。
構文: property1 not-exists
例:
AzureAD AuthorizationPolicy should-have defaultUserRolePermissions with-attribute { permissionGrantPoliciesAssigned not-exists }
Utility
どれでも 。 。として
使用法: anyキーワードは 式の前に指定されたリソースタイプと関係を持つリソースタイプに使用されます。
as 条件文で後で使うとなるリソースタイプの別名を指定するためのキーワードは使うです。 ルールの前半部分で値が導出され、後半部分で参照される場合、エイリアスが必要になることがあります。このような条件下では、規則の後半部分は派生値である使う(別名)を指します。 これは、値を変数に格納することと同等です。使うと、エイリアスに割り当てられたすべての利用可能なリソースを条件に一致させるキーワード any 使う。 条件が一致する場合は、 trueが返されます。
Syntax: any resource as a with-attribute {a.attribute1 = “value“}
例:
servicenow SysProperties should-have any SystemProperty as s with-attribute {s.name = "glide.authenticate.api.user.reset_password.mandatory" and s.value = "true"}
###
使用法: ###キーワードは このようなキーワードの間に続くテキストはコメント文字列であり、システムによって無視されることを示します。
構文: ###これはコメントです###
例:
microsoft365 malwarefilterpolicy should-have len(FileTypes) > 0 ### comment here ###
よくある間違い
このセクションでは、 キーワードに誤ったプロパティ型を指定した場合に発生する可能性のあるエラーについて説明します。
| Error Scenario | 不適切なNGLの例 | エラーメッセージの例 | エラーを修正する手順 |
|---|---|---|---|
| 不動産はリストではありません | AzureAD ユーザーは jobTitle with-element[2] を持つ必要があります | エラー: with-element/with-any-element/with-no-element はデータ型 'list' のプロパティのみをサポートしていますが、型 'string' の 'jobTitle' が渡されました。 | リストデータ型を使うプロパティ。 例: AzureAD ユーザーは、要素 ["2"] を持つ proxyAddresses を持つ必要があります |
| プロパティはリストですが、リストの要素はプリミティブ型と比較できません。 | AzureAD ユーザーは、要素[2]を持つ proxyAddresses を持っている必要があります | エラー: タイプ「リスト」の「proxyAddresses」 | プロパティは、同じデータ型の値と照合する必要があります。 例: AzureAD ユーザーは、要素 ["0.0.0.0"] を持つ proxyAddresses を持つ必要があります |
| with-attribute は オブジェクトでない場合、またはリンクされていないリソースタイプの場合 | AzureAD ユーザーは、属性 {1 = 1} を持つ displayName を持つ必要があります | エラー: with-attribute は 型 'object' のプロパティまたはリンクされたリソース型のみで使用できます。型 'string' の 'displayName' が指定されました。 | オブジェクト データ型またはリンクされたリソースのプロパティを使用します。 例:AzureADユーザーは、{forceChangePasswordNextSignIn = true}属性を持つpasswordProfileを持つ必要があります。 |
| 属性付きとして、いずれか 括弧内 | Salesforce RemoteSiteSettings には (属性 { r.disableProtocolSecurity exists } を持つ RemoteSiteSetting as r が存在するか、RemoteSiteSetting が存在する必要があります | エラー: 括弧式内では、any..as with-attribute は許可されていません | 属性式「any..as」を括弧で囲まないでください。 例: Salesforce RemoteSiteSettings should-have any RemoteSiteSetting as r with-attribute { r.disableProtocolSecurity exists } or RemoteSiteSetting exists |
| any..as with-attribute は条件の開始時に存在しません | GoogleWorkspace ユーザーは、id="101098653105135134115" を持ち、RoleAssignment が r で、属性 { Role with-attribute { isSuperAdminRole = true } } である必要があります。 | エラー: any..as with-attribute は条件の開始でのみサポートされています | あの...置いて。条件の開始点でのwith-attribute表現のように。 例: GoogleWorkspace User は、属性 { Role with-attribute { isSuperAdminRole = true } } を持つ RoleAssignment を r に持ち、id="101098653105135134115" である必要があります |

