API Specification Enforcement Kurulumu
¶
Bu makale, yüklediğiniz API spesifikasyonuna dayalı API korumanızı nasıl etkinleştireceğinizi ve yapılandıracağınızı açıklar.
Adım 1: Spesifikasyonu yükleyin¶
-
US Cloud veya EU Cloud içindeki API Specifications bölümünde Upload specification öğesine tıklayın.
-
Spesifikasyon yükleme parametrelerini belirleyin ve yüklemeyi başlatın.
Spesifikasyon dosyası, API spesifikasyonu sözdizimine uygunluk açısından kontrol edilir; geçerli değilse yüklenmez. Spesifikasyon dosyası başarıyla yüklenene kadar API specification enforcement yapılandırmasını başlatamayacağınızı unutmayın.
Spesifikasyonu bir URI’den yüklemeyi ve Regularly update the specification (saatte bir) seçeneğini seçerseniz, düzenli güncelleme sırasında hatalar olabilir: URI kullanılamaz olabilir veya güncellenen spesifikasyon dosyası API spesifikasyonu sözdizimine uymayabilir. Bu tür hatalara ilişkin bildirimler almak için, yapılandırdığınız Integrations içinde System related olaylarını seçin—spesifikasyon yükleme hatalarıyla ilgili bildirimler bu kategoriye dahildir.
Adım 2: İlkeler ihlalleri için eylemleri belirleyin¶
-
API specification enforcement sekmesine tıklayın.
Rogue API tespiti
- Güvenlik politikalarını uygulamanın yanı sıra, spesifikasyonlar API Discovery modülü tarafından rogue API tespiti için de kullanılabilir. API Discovery etkinse sekme görüntülenir.
- Spesifikasyonu güvenlik politikalarını uygulamak için kullanmadan önce, API Discovery kullanarak rogue (gölge, zombi ve yetim) API’leri aramak için kullanmanız önerilir. Bu şekilde, spesifikasyonunuzun istemcilerinizin gerçek isteklerinden ne kadar farklı olduğunu anlayabilirsiniz—bu farklar, güvenlik politikaları uygulandıktan sonra ilgili isteklerin engellenmesine büyük olasılıkla neden olacaktır.
-
Use for API specification enforcement seçeneğini belirleyin.
-
İlke ihlali eylemlerini etkinleştirmek istediğiniz host veya endpoint’i belirtin.
- Yüklenen spesifikasyonun hangi endpoint’lere uygulanacağını yanlış belirtirseniz, çok sayıda yanlış pozitif olay oluşacaktır.
- Aynı host’a uygulanan ancak farklı endpoint’lere ait birden fazla spesifikasyonunuz varsa (örneğin
domain.com/v1/api/users/
vedomain.com/v1/api/orders/
), spesifikasyonun hangi endpoint’lere uygulanması gerektiğini belirtmeniz zorunludur. - Bir host’a bir spesifikasyon ekleyip ardından bu host’un belirli endpoint’lerine başka bir spesifikasyon eklerseniz, her iki spesifikasyon da bu endpoint’lere uygulanacaktır.
- Değer, URI constructor veya advanced edit form üzerinden yapılandırılabilir.
-
İstekler spesifikasyonunuzu ihlal ederse sistemin nasıl tepki vereceğini ayarlayın.
Olası ihlallerle ilgili ayrıntılar:
- Requesting an undefined endpoint - a request targets the endpoint not presented in your specification
- Requesting endpoint with undefined parameter - a request contains the parameter not presented for this endpoint in your specification
- Requesting endpoint without required parameter - a request does not contain the parameter or its value that are marked as required in your specification
- Requesting endpoint with invalid parameter value - a request parameter's value in not in correspondence with its type/format defined by your specification
- Requesting endpoint without authentication method - a request does not contain the information about the authentication method
- Requesting endpoint with invalid JSON - a request contains an invalid JSON
The system can perform the following actions in case of found inconsistency:
-
Block - block a request and put in the Attacks section as blocked
Filtration mode
The Wallarm node will block requests only when the blocking filtration mode is enabled for target endpoint - otherwise, Monitor action will be performed.
-
Monitor - mark a request as incorrect, but do not block, put it in the Attacks section as monitored
- Not tracked - do nothing
Note that several specifications can be used for setting policies. In case when one request falls on two different specifications (the same policy and different actions in different specifications), the following will happen:
- Block and Block - the request will be blocked and two events will be added to the Attacks section with status
Blocked
pointing at the reason of blocking and at the fact that the request violated two different specifications. - Monitor and Block - the request will be blocked and one event will be added to the Attacks section with status
Blocked
explaining the reason of blocking. - Monitor and Monitor - the request will not be blocked and two events will be added to the Attacks section with status
Monitoring
pointing at the fact that specific policy was violated.
Spesifikasyonu güvenlik politikalarını ayarlamak için ilk kez kullanırken, spesifikasyonun gerekli endpoint’lere uygulandığından ve gerçek hataları tespit ettiğinden emin olmak için tepki olarak
Monitor
ayarlanması önerilir.
Devre dışı bırakma¶
API Specification Enforcement’ın çalışması, yüklenmiş ve her biri için Use for API specification enforcement seçeneği işaretli bir veya birden fazla spesifikasyona dayanır. Bu seçeneğin bazı spesifikasyonlar için işaretinin kaldırılmasının veya bu spesifikasyonun silinmesinin, o spesifikasyona dayalı korumayı durduracağını dikkate alın.
Ayrıca, bazı durumlarda API Specification Enforcement işlevselliğini API’nizin yalnızca bazı bölümleri için devre dışı bırakmanız gerekebilir. Bu şu şekilde yapılabilir:
-
all-in-one installer kurulumları için, API Specification Enforcement kullanılan herhangi bir
server
bölümündewallarm_enable_apifw
NGINX yönergesinioff
olarak ayarlayarak. -
NGINX tabanlı Docker imajı için,
WALLARM_APIFW_ENABLE
ortam değişkeninifalse
olarak ayarlayarak. -
NGINX Ingress Controller için,
controller.wallarm.apifirewall
değer grubundaenable
değerinifalse
olarak ayarlayarak.