Skip to content
This repository was archived by the owner on Sep 17, 2018. It is now read-only.

Commit ebdd1ea

Browse files
committed
first commit
1 parent f44b8cf commit ebdd1ea

File tree

5 files changed

+173
-1
lines changed

5 files changed

+173
-1
lines changed

LICENCE.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Shieldfy Custom License (SCL)
2+
3+
Copyright (c) 2017 Shieldfy inc. <team@shieldfy.com>
4+
5+
> - This software is free for personal and private use only; You may use and/or modify the code for personal and/or educational purposes.
6+
> - Commercial use of this software is strictly prohibited, as it is part of the shieldfy platform.
7+
> - You may not distribute, sub-license, or sell copies of the software.
8+
>
9+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.
10+
>
11+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
# shieldfy-codeigniter-client
1+
# Shieldfy Codeigniter Client
2+
3+
This is a Codeigniter package for Shieldfy SDK
4+
5+
6+
7+
## Contributing
8+
9+
Thank you for considering contributing to this project!
10+
Bug reports, feature requests, and pull requests are very welcome.
11+
12+
13+
## Security Vulnerabilities
14+
15+
If you discover a security vulnerability within this project, please send an e-mail to security@shieldfy.com.

composer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "shieldfy/shieldfy-codeigniter-client",
3+
"description": "shieldfy firewall component for codeigniter framework",
4+
"license": "MIT",
5+
"keywords": [
6+
"shieldfy",
7+
"security",
8+
"firewall",
9+
"detection",
10+
"application",
11+
"attack",
12+
"bypass",
13+
"ips",
14+
"ids"
15+
],
16+
"authors": [
17+
{
18+
"name": "Shieldfy Inc.",
19+
"homepage":"https://shieldfy.io",
20+
"email": "team@shieldfy.io"
21+
},
22+
{
23+
"name": "Eslam Salem",
24+
"email": "eslam@shieldfy.io"
25+
}
26+
],
27+
"require": {
28+
"php": ">=5.6",
29+
"shieldfy/shieldfy-php-client":"2.*"
30+
},
31+
"minimum-stability": "dev",
32+
"prefer-stable": true
33+
}

config.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
defined('BASEPATH') OR exit('No direct script access allowed');
3+
4+
return [
5+
6+
/*
7+
|--------------------------------------------------------------------------
8+
| Shieldfy Configurations
9+
|--------------------------------------------------------------------------
10+
|
11+
| This file is for storing the credentials and configurations for Shieldfy.
12+
| You can get your credentials from https://shieldfy.io.
13+
| Please refere to the documentations on https://shieldfy.io for further info.
14+
|
15+
*/
16+
17+
/*
18+
|--------------------------------------------------------------------------
19+
| Main App Credentials
20+
|--------------------------------------------------------------------------
21+
*/
22+
'app_key' => '',
23+
'app_secret' => '',
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Shieldfy debug whether or not expose debug and errors ( True , False )
27+
|--------------------------------------------------------------------------
28+
*/
29+
'debug' => false,
30+
31+
/*
32+
|--------------------------------------------------------------------------
33+
| Shieldfy default action for detecting threat ( block , listen )
34+
|--------------------------------------------------------------------------
35+
*/
36+
'action' => 'block',
37+
38+
/*
39+
|--------------------------------------------------------------------------
40+
| List of headers exposed to shieldfy to overwrite
41+
| format
42+
| key => value
43+
| example
44+
| ['X-Frame-Options'=>'DENY']
45+
| you can specify false to disable the header
46+
| example
47+
| ['X-Frame-Options'=>false]
48+
|--------------------------------------------------------------------------
49+
*/
50+
'headers' => [],
51+
52+
/*
53+
|--------------------------------------------------------------------------
54+
| list of monitors you want to disable
55+
|--------------------------------------------------------------------------
56+
*/
57+
'disable' => []
58+
59+
];

shieldfy.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
defined('BASEPATH') OR exit('No direct script access allowed');
3+
4+
class ShieldfyDBProxy
5+
{
6+
protected $db = null;
7+
protected $guard = null;
8+
9+
public function __construct($db,$guard)
10+
{
11+
$this->db = $db;
12+
$this->guard = $guard;
13+
}
14+
public function __call($name, $parameters)
15+
{
16+
17+
if(count($parameters) > 0){
18+
$query = new stdClass;
19+
$query->sql = $parameters[0];
20+
$query->bindings = (isset($parameters[1]))? $parameters[1] : [];
21+
$this->guard->attachQuery($query);
22+
}
23+
24+
25+
return $this->db->{$name}(...$parameters);
26+
}
27+
}
28+
29+
function ShieldfyCodeIgniterBridge()
30+
{
31+
//autoload if not exists
32+
if(!class_exists(Shieldfy\Guard::class)){
33+
require_once(__DIR__.'/vendor/autoload.php');
34+
}
35+
36+
//load configurations
37+
$config = require_once(__DIR__.'/config.php');
38+
39+
//init guard
40+
$guard = \Shieldfy\Guard::init([
41+
'app_key' => $config['app_key'],
42+
'app_secret' => $config['app_secret'],
43+
'debug' => $config['debug'],
44+
'action' => $config['action'],
45+
'headers' => $config['headers'],
46+
'disable' => $config['disable'],
47+
]);
48+
49+
//attach database
50+
$CI =& get_instance();
51+
if(property_exists($CI,'db')){
52+
$db = $CI->db;
53+
$CI->db = new ShieldfyDBProxy($db,$guard);
54+
}
55+
}

0 commit comments

Comments
 (0)