Skip to content

Commit 7a2e989

Browse files
committed
First commit with base concept.
1 parent 76badf9 commit 7a2e989

9 files changed

Lines changed: 1086 additions & 22 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Learn more about .gitignore:
44
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
55

6+
# PHP artifact files
7+
vendor/
8+
69
# Node artifact files
710
node_modules/
811
dist/

README.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
# README #
1+
# Patchstack Firewall Engine #
22

3-
This README would normally document whatever steps are necessary to get your application up and running.
3+
This repository contains the firewall engine of Patchstack.
4+
It can be implemented inside of other content management systems to provide firewall functionality.
45

5-
### What is this repository for? ###
6+
## How do I get set up? ##
67

7-
* Quick summary
8-
* Version
9-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
8+
Due to library limitations and the way the firewall engine works, a few manual interactions are required. Since the firewall engine depends on the opis/closure and laravel/serializable-closure packages which both require different PHP versions, sticking to one PHP version is tricky.
109

11-
### How do I get set up? ###
10+
Therefore, in order to use this package, these libraries must exist in the following locations:
11+
* opis/closure at /vendor/closure/
12+
* laravel/serializable-closure at /vendor/serializable-closure/
1213

13-
* Summary of set up
14-
* Configuration
15-
* Dependencies
16-
* Database configuration
17-
* How to run tests
18-
* Deployment instructions
14+
## To-Do List ##
15+
- ⬜️ Unit tests
16+
- ⬜️ Test on many different environments and combinations with other plugins
17+
- ⬜️ Attach PHP CS Fixer
18+
- ✅ First initial concept and implementation
1919

20-
### Contribution guidelines ###
20+
## Who do I talk to? ##
2121

22-
* Writing tests
23-
* Code review
24-
* Other guidelines
25-
26-
### Who do I talk to? ###
27-
28-
* Repo owner or admin
29-
* Other community or team contact
22+
* dave.jong@patchstack.com

composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "patchstack/firewall",
3+
"description": "The firewall engine of Patchstack.",
4+
"type": "library",
5+
"require": {
6+
"php": ">=5.4"
7+
},
8+
"license": "GNU AGPLv3",
9+
"autoload": {
10+
"psr-4": {
11+
"Patchstack\\": "src/"
12+
}
13+
},
14+
"authors": [
15+
{
16+
"name": "Patchstack",
17+
"email": "support@patchstack.com"
18+
}
19+
]
20+
}

composer.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Patchstack\Extensions;
4+
5+
/**
6+
* Any extension must implement the methods of the interface.
7+
* Some CMS systems might implement some of the logic completely different than others.
8+
*/
9+
interface ExtensionInterface
10+
{
11+
/**
12+
* Log the request, this can be of type BLOCK, LOG or REDIRECT.
13+
*
14+
* @param int $ruleId
15+
* @param string $bodyData
16+
* @param string $blockType
17+
* @return void
18+
*/
19+
public function logRequest($ruleId, $bodyData, $blockType);
20+
21+
/**
22+
* Determine if the current visitor can bypass the firewall.
23+
*
24+
* @return bool
25+
*/
26+
public function canBypass();
27+
28+
/**
29+
* Determine if the visitor is blocked from the website.
30+
*
31+
* @param int $minutes
32+
* @param int $blockTime
33+
* @param int $attempts
34+
* @return bool
35+
*/
36+
public function isBlocked($minutes, $blockTime, $attempts);
37+
38+
/**
39+
* Force exit the page when a request has been blocked.
40+
*
41+
* @param int $ruleId
42+
* @return void
43+
*/
44+
public function forceExit($ruleId);
45+
46+
/**
47+
* Get the IP address of the request.
48+
*
49+
* @return string
50+
*/
51+
public function getIpAddress();
52+
53+
/**
54+
* Determine if the request should be passed without going through the firewall.
55+
*
56+
* @param array $whitelistRules
57+
* @param array $request
58+
*/
59+
public function isWhitelisted($whitelistRules, $request);
60+
61+
/**
62+
* Determine if the current request is a file upload request.
63+
*
64+
* @return boolean
65+
*/
66+
public function isFileUploadRequest();
67+
}

0 commit comments

Comments
 (0)