خط مشی JSONThreatProtection

شما در حال مشاهده اسناد Apigee Edge هستید.
به مستندات Apigee X بروید .
اطلاعات

چی

خطر ناشی از حملات سطح محتوا را با این امکان به شما می‌دهد که محدودیت‌هایی را برای ساختارهای مختلف JSON، مانند آرایه‌ها و رشته‌ها تعیین کنید.

ویدئو: برای کسب اطلاعات بیشتر در مورد اینکه چگونه خط مشی JSONThreatProtection شما را قادر می سازد API ها را در برابر حملات سطح محتوا ایمن کنید، یک ویدیوی کوتاه تماشا کنید.

ویدئو: این ویدیوی کوتاه را در پلتفرم Apigee cross-cloud API مشاهده کنید.

مرجع عنصر

مرجع عنصر عناصر و ویژگی های خط مشی JSONThreatProtection را توصیف می کند.

<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
   <DisplayName>JSONThreatProtection 1</DisplayName>
   <ArrayElementCount>20</ArrayElementCount>
   <ContainerDepth>10</ContainerDepth>
   <ObjectEntryCount>15</ObjectEntryCount>
   <ObjectEntryNameLength>50</ObjectEntryNameLength>
   <Source>request</Source>
   <StringValueLength>500</StringValueLength>
</JSONThreatProtection>

ویژگی های <JSONThreatProtection>

<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1"> 

The following table describes attributes that are common to all policy parent elements:

Attribute Description Default Presence
name

The internal name of the policy. The value of the name attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the <DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

N/A Required
continueOnError

Set to false to return an error when a policy fails. This is expected behavior for most policies.

Set to true to have flow execution continue even after a policy fails.

false Optional
enabled

Set to true to enforce the policy.

Set to false to turn off the policy. The policy will not be enforced even if it remains attached to a flow.

true Optional
async

This attribute is deprecated.

false Deprecated

<DisplayName> element

Use in addition to the name attribute to label the policy in the management UI proxy editor with a different, natural-language name.

<DisplayName>Policy Display Name</DisplayName>
Default

N/A

If you omit this element, the value of the policy's name attribute is used.

Presence Optional
Type String

عنصر <ArrayElementCount>

حداکثر تعداد عناصر مجاز در یک آرایه را مشخص می کند.

<ArrayElementCount>20</ArrayElementCount>
پیش فرض: اگر این عنصر را مشخص نکنید، یا اگر یک عدد صحیح منفی را مشخص کنید، سیستم محدودیتی را اعمال نمی کند.
حضور: اختیاری
نوع: عدد صحیح

عنصر <ContainerDepth>

حداکثر عمق محفظه مجاز را مشخص می‌کند، جایی که کانتینرها اشیا یا آرایه‌ها هستند. به عنوان مثال، آرایه ای حاوی یک شی که حاوی یک شی است، منجر به عمق محفظه 3 می شود.

<ContainerDepth>10</ContainerDepth>
پیش فرض: اگر این عنصر را مشخص نکنید، یا اگر یک عدد صحیح منفی را مشخص کنید، سیستم هیچ محدودیتی را اعمال نمی کند.
حضور: اختیاری
نوع: عدد صحیح

عنصر <ObjectEntryCount>

حداکثر تعداد ورودی های مجاز در یک شی را مشخص می کند.

<ObjectEntryCount>15</ObjectEntryCount>
پیش فرض: اگر این عنصر را مشخص نکنید، یا اگر یک عدد صحیح منفی را مشخص کنید، سیستم هیچ محدودیتی را اعمال نمی کند.
حضور: اختیاری
نوع: عدد صحیح

عنصر <ObjectEntryNameLength>

حداکثر طول رشته مجاز برای نام ویژگی در یک شی را مشخص می کند.

<ObjectEntryNameLength>50</ObjectEntryNameLength>
پیش فرض: اگر این عنصر را مشخص نکنید، یا اگر یک عدد صحیح منفی را مشخص کنید، سیستم محدودیتی را اعمال نمی کند.
حضور: اختیاری
نوع: عدد صحیح

عنصر <منبع>

پیامی که باید برای حملات JSON مورد بررسی قرار گیرد. این معمولاً روی request تنظیم می شود، زیرا معمولاً باید درخواست های ورودی از برنامه های مشتری را تأیید کنید. وقتی روی message تنظیم شود، این عنصر به طور خودکار پیام درخواست را هنگامی که به جریان درخواست متصل می شود و پیام پاسخ را هنگامی که به جریان پاسخ متصل می شود ارزیابی می کند.

<Source>request</Source>
پیش فرض: درخواست کنید
حضور: اختیاری
نوع:

رشته

مقادیر معتبر: درخواست، پاسخ یا پیام.

عنصر <StringValueLength>

حداکثر طول مجاز برای یک مقدار رشته را مشخص می کند.

<StringValueLength>500</StringValueLength>
پیش فرض: اگر این عنصر را مشخص نکنید، یا اگر یک عدد صحیح منفی را مشخص کنید، سیستم محدودیتی را اعمال نمی کند.
حضور: اختیاری
نوع: عدد صحیح

مرجع خطا

This section describes the fault codes and error messages that are returned and fault variables that are set by Edge when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

These errors can occur when the policy executes.

Fault code HTTP status Cause Fix
steps.jsonthreatprotection.ExecutionFailed 500 The JSONThreatProtection policy can throw many different types of ExecutionFailed errors. Most of these errors occur when a specific threshold set in the policy is exceeded. These types of errors include: object entry name length, object entry count, array element count, container depth, string string value length. This error also occurs when the payload contains an invalid JSON object.
steps.jsonthreatprotection.SourceUnavailable 500 This error occurs if the message variable specified in the <Source> element is either:
  • Out of scope (not available in the specific flow where the policy is being executed)
  • Is not one of the valid values request, response, or message
steps.jsonthreatprotection.NonMessageVariable 500 This error occurs if the <Source> element is set to a variable which is not of type message.

Deployment errors

None.

Fault variables

These variables are set when this policy triggers an error. For more information, see What you need to know about policy errors.

Variables Where Example
fault.name="fault_name" fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. fault.name Matches "SourceUnavailable"
jsonattack.policy_name.failed policy_name is the user-specified name of the policy that threw the fault. jsonattack.JTP-SecureRequest.failed = true

Example error response

{
  "fault": {
    "faultstring": "JSONThreatProtection[JPT-SecureRequest]: Execution failed. reason: JSONThreatProtection[JTP-SecureRequest]: Exceeded object entry name length at line 2",
    "detail": {
      "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
    }
  }
}

Example fault rule

<FaultRule name="JSONThreatProtection Policy Faults">
    <Step>
        <Name>AM-CustomErrorResponse</Name>
        <Condition>(fault.name Matches "ExecutionFailed") </Condition>
    </Step>
    <Condition>(jsonattack.JPT-SecureRequest.failed = true) </Condition>
</FaultRule>

طرحواره ها

نکات استفاده

مانند سرویس‌های مبتنی بر XML، APIهایی که از نمادگذاری شی جاوا اسکریپت (JSON) پشتیبانی می‌کنند، در برابر حملات سطح محتوا آسیب‌پذیر هستند. حملات ساده JSON سعی می کنند از ساختارهایی استفاده کنند که تجزیه کننده های JSON را تحت الشعاع قرار می دهد تا یک سرویس را خراب کند و حملات انکار سرویس در سطح برنامه را تحریک کند. همه تنظیمات اختیاری هستند و باید برای بهینه سازی خدمات مورد نیاز شما در برابر آسیب پذیری های احتمالی تنظیم شوند.

موضوعات مرتبط

خط مشی JSONtoXML

خط مشی XMLThreatProtection

خط مشی RegularExpressionProtection