Skip to content

Commit

Permalink
Tests, copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
azurit committed Feb 14, 2024
1 parent f803bec commit 35fd9ef
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
on: [push, pull_request] # yamllint disable-line rule:truthy
name: Integration tests

jobs:
integration-tests:
uses: coreruleset/crs-plugin-test-action/.github/workflows/integration.yaml@main
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
on: [push, pull_request] # yamllint disable-line rule:truthy

jobs:
plugin-lint:
uses: coreruleset/crs-plugin-test-action/.github/workflows/lint.yaml@main
2 changes: 1 addition & 1 deletion plugins/fake-bot-after.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------------------------------------------------------------
# OWASP CRS Plugin
# Copyright (c) 2021-2022 Core Rule Set project. All rights reserved.
# Copyright (c) 2021-2024 Core Rule Set project. All rights reserved.
#
# The OWASP CRS plugins are distributed under
# Apache Software License (ASL) version 2
Expand Down
2 changes: 1 addition & 1 deletion plugins/fake-bot-before.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ------------------------------------------------------------------------
# OWASP CRS Plugin
# Copyright (c) 2021-2022 Core Rule Set project. All rights reserved.
# Copyright (c) 2021-2024 Core Rule Set project. All rights reserved.
#
# The OWASP CRS plugins are distributed under
# Apache Software License (ASL) version 2
Expand Down
3 changes: 1 addition & 2 deletions plugins/fake-bot-config.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

# ------------------------------------------------------------------------
# OWASP CRS Plugin
# Copyright (c) 2021-2022 Core Rule Set project. All rights reserved.
# Copyright (c) 2021-2024 Core Rule Set project. All rights reserved.
#
# The OWASP CRS plugins are distributed under
# Apache Software License (ASL) version 2
Expand Down
9 changes: 9 additions & 0 deletions plugins/fake-bot.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- -----------------------------------------------------------------------
-- OWASP CRS Plugin
-- Copyright (c) 2021-2024 Core Rule Set project. All rights reserved.
--
-- The OWASP CRS plugins are distributed under
-- Apache Software License (ASL) version 2
-- Please see the enclosed LICENSE file for full details.
-- -----------------------------------------------------------------------

-- Code inspired by http://lua-users.org/wiki/StringRecipes .
function ends_with(str, ending)
str = str:lower()
Expand Down
127 changes: 127 additions & 0 deletions tests/regression/fake-bot-plugin/9504110.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
meta:
author: "azurit"
description: "Fake Bot Plugin"
enabled: true
name: 9504110.yaml
tests:
- test_title: 9504110-1
desc: Check that plugin is not blocking standard User-Agents
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: OWASP CRS
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
no_log_contains: id "9504110"
- test_title: 9504110-2
desc: Check for blocking of fake Googlebot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/W.X.Y.Z Safari/537.36
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"
- test_title: 9504110-3
desc: Check for blocking of fake Facebookbot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"
- test_title: 9504110-4
desc: Check for blocking of fake Bingbot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) W.X.Y.Z Safari/537.36
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"
- test_title: 9504110-5
desc: Check for blocking of fake Twitterbot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36 Twitterbot/1.0
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"
- test_title: 9504110-6
desc: Check for blocking of fake Applebot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: Mozilla/5.0 (Device; OS_version) AppleWebKit/WebKit_version (KHTML, like Gecko) Version/Safari_version Safari/WebKit_version (Applebot/Applebot_version)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"
- test_title: 9504110-7
desc: Check for blocking of fake LinkedInBot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: LinkedInBot/1.0 (compatible; Mozilla/5.0; +http://www.linkedin.com)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"
- test_title: 9504110-8
desc: Check for blocking of fake Amazonbot
stages:
- stage:
input:
dest_addr: 127.0.0.1
headers:
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML\, like Gecko) Version/8.0.2 Safari/600.2.5 (Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot)

Check warning on line 121 in tests/regression/fake-bot-plugin/9504110.yaml

View workflow job for this annotation

GitHub Actions / plugin-lint / check-syntax

121:209 [trailing-spaces] trailing spaces
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
port: 80
method: GET
uri: /
output:
log_contains: id "9504110"

0 comments on commit 35fd9ef

Please sign in to comment.