{"id":36985950,"url":"https://github.com/karster/firewall","last_synced_at":"2026-01-13T23:03:52.060Z","repository":{"id":57004638,"uuid":"99616309","full_name":"karster/firewall","owner":"karster","description":"Simple firewall to protect your web application against many attacks","archived":false,"fork":false,"pushed_at":"2017-09-19T18:11:05.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-18T05:04:42.868Z","etag":null,"topics":["firewall","protection","security","waf"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-07T20:15:12.000Z","updated_at":"2017-08-28T19:59:28.000Z","dependencies_parsed_at":"2022-08-21T12:10:52.855Z","dependency_job_id":null,"html_url":"https://github.com/karster/firewall","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/karster/firewall","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karster%2Ffirewall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karster%2Ffirewall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karster%2Ffirewall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karster%2Ffirewall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karster","download_url":"https://codeload.github.com/karster/firewall/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karster%2Ffirewall/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28404124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firewall","protection","security","waf"],"created_at":"2026-01-13T23:03:51.357Z","updated_at":"2026-01-13T23:03:52.053Z","avatar_url":"https://github.com/karster.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Firewall\n\n[![Build Status](https://travis-ci.org/karster/firewall.svg?branch=master)][travis]\n[![Latest Stable Version](https://poser.pugx.org/karster/security/v/stable)][version]\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)][license]\n\n\u003e Simple firewall to protect your web application against many attacks\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```shell\ncomposer require karster/firewall:\"dev-master\"\n```\n\nor add\n\n```\n\"karster/firewall\": \"dev-master\"\n```\n\nto the require section of your composer.json.\n\n## Usage\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\n$config = [\n    'logDirectory' =\u003e __DIR__ . \"/firewall_logs\",\n    'logFilesCount' =\u003e 10,\n    'allowAttackCount' =\u003e 5,\n    'active' =\u003e true,\n    'protection' =\u003e [\n        'allowedRequestMethod' =\u003e [\n            'active' =\u003e true\n        ],\n        'allowedGlobals' =\u003e [\n            'active' =\u003e false\n        ],\n        'urlLength' =\u003e [\n            'active' =\u003e true,\n            'rules' =\u003e 200,\n        ],\n        'getProtection' =\u003e [\n            'active' =\u003e true,\n            'rules' =\u003e ['select', 'from'],\n        ],\n        'urlProtection' =\u003e [\n            'active' =\u003e true,\n            'rulesFile' =\u003e 'path/to/rulesFile.json'\n        ],\n        'whitelistIp' =\u003e [\n            'active' =\u003e true,\n            'rules' =\u003e ['127.0.0.1', '::1']\n        ],\n        'blacklistIp' =\u003e [\n            'active' =\u003e true,\n            'rules' =\u003e ['23.254.0.1', '22.23.22.8']\n        ]\n    ]\n];\n\n$firewall = new \\karster\\security\\Firewall($config);\n$firewall-\u003erun();\n\n```\n\nor\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\n$protections = [\n    'allowedRequestMethod' =\u003e [\n        'active' =\u003e true\n    ],\n    'allowedGlobals' =\u003e [\n        'active' =\u003e false\n    ],\n    'urlLength' =\u003e [\n        'active' =\u003e true,\n        'rules' =\u003e 200,\n    ],\n    'getProtection' =\u003e [\n        'active' =\u003e true,\n        'rules' =\u003e ['select', 'from'],\n    ],\n    'urlProtection' =\u003e [\n        'active' =\u003e true,\n        'rulesFile' =\u003e 'path/to/rulesFile.json'\n    ],\n    'whitelistIp' =\u003e [\n        'active' =\u003e true,\n        'rules' =\u003e ['127.0.0.1', '::1']\n    ],\n    'blacklistIp' =\u003e [\n        'active' =\u003e true,\n        'rules' =\u003e ['23.254.0.1', '22.23.22.8']\n    ]\n];\n\n$firewall = new \\karster\\security\\Firewall();\n$firewall-\u003esetAllowAttackCount(5)\n         -\u003esetActive(true)\n         -\u003esetLogDirectory(__DIR__ . \"/firewall_logs\")\n         -\u003esetLogFilesCount(10)\n         -\u003esetProtection($protections)\n         -\u003erun();\n\n```\n\n* logDirectory - `string` - path to directory where firewall can writes\n* logFilesCount - `integer` - delete older logs than specific count. Set `0` to disable\n* allowAttackCount - `integer` - attack count from same IP address before blacklisting (**logDirectory** is required). Set `0` to disable\n* active - `boolean` - default `true` \n* protection - `array` - associative array of protections where key is protection name and value is protection configuration\n\n## Protections\nWe can chose different types of protection:\n* allowedRequestMethod\n* allowedGlobals\n* blacklistIp\n* cookieProtection\n* getProtection\n* postProtection\n* sessionProtection\n* urlLength\n* urlProtection\n\nEvery protection contains configuration array with parameters:\n* active `boolen` - default `true`\n* rules `array|integer` - every protection accept array except **urlLength** protection witch accept integer\n* rulesFile `string` - path to json file with rules\n\n```php\n'cookieProtection' =\u003e [\n    'active' =\u003e true,\n    'rules' =\u003e [\n        'select', 'from', 'where'\n    ],\n    // or\n    'rulesFile' =\u003e 'path/to/rulesFile.json'\n]\n\n```\n\nIf isn't set `rules` or `rulesFile` use default rules.\n\n## Tests\n\n```\n./vendor/bin/phpunit -c phpunit.xml\n```\n\n## Contribution\nHave an idea? Found a bug? See [how to contribute][contributing].\n\n## License\nMIT see [LICENSE][] for the full license text.\n\n[version]: https://packagist.org/packages/karster/security\n[travis]: https://travis-ci.org/karster/firewall\n[license]: LICENSE.md\n[contributing]: CONTRIBUTING.md","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarster%2Ffirewall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarster%2Ffirewall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarster%2Ffirewall/lists"}