Skip to content

Commit b62017a

Browse files
authored
Ready for v2.0.1
Add new methods
2 parents ae6023e + ebf3b25 commit b62017a

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to `AntiScanScanClub` will be documented in this file.
44

5+
## Version 2.0.1
6+
7+
### Added
8+
- getPublicFiles() method for get all files in public path recursively
9+
- getAllRoutes() method for get uri of all registered routes
10+
- whitelistPublicFiles() method for whitelisting all public files recursively
11+
- whitelistAllRoutes() method for whitelisting uri of all registered routes
12+
513
## Version 2.0.0
614

715
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,4 @@ license. Please see the [LICENSE file](LICENSE) for more information.
212212
213213
## Version
214214
215-
**Current version is 2.0.0** and still development.
215+
**Current version is 2.0.1** and still development.

src/AntiScanScanClub.php

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use Illuminate\Foundation;
66
use Illuminate\Http\Request;
7-
use Storage;
7+
use Illuminate\Support\Facades\File;
8+
use Illuminate\Support\Facades\Route;
9+
use Illuminate\Support\Facades\Storage;
810

911
class AntiScanScanClub
1012
{
@@ -245,6 +247,78 @@ private function writeToBlacklistsFile($data = []) {
245247
}
246248
}
247249

250+
/**
251+
* Get all files in public path recursively
252+
*
253+
* @return array
254+
*/
255+
private function getPublicFiles() {
256+
$getFiles = File::allFiles(public_path());
257+
$files = [];
258+
259+
foreach ($getFiles as $key => $value) {
260+
$files[] = $value->getRelativePathname();
261+
}
262+
263+
return $files;
264+
}
265+
266+
/**
267+
* Get uri of all registered routes
268+
*
269+
* @return array
270+
*/
271+
private function getAllRoutes() {
272+
$getRoutes = Route::getRoutes()->getIterator();
273+
$routes = [];
274+
275+
foreach ($getRoutes as $key => $route) {
276+
$routes[] = $route->uri();
277+
}
278+
279+
foreach ($routes as $key => $value) {
280+
if (preg_match("/\{.*?\}/", $value)) {
281+
unset($routes[$key]);
282+
}
283+
}
284+
285+
return array_values($routes);
286+
}
287+
288+
/**
289+
* Whitelisting all public files recursively
290+
*
291+
* @return array
292+
*/
293+
public function whitelistPublicFiles() {
294+
$getPublicFiles = $this->getPublicFiles();
295+
$results = [];
296+
297+
foreach ($getPublicFiles as $key => $file) {
298+
$whitelistFile = $this->whitelistFile($file);
299+
$results[] = [ $file => $whitelistFile ];
300+
}
301+
302+
return $results;
303+
}
304+
305+
/**
306+
* Whitelisting uri of all registered routes
307+
*
308+
* @return array
309+
*/
310+
public function whitelistAllRoutes() {
311+
$getAllRoutes = $this->getAllRoutes();
312+
$results = [];
313+
314+
foreach ($getAllRoutes as $key => $route) {
315+
$whitelistFile = $this->whitelistFile($route);
316+
$results[] = [ $route => $whitelistFile ];
317+
}
318+
319+
return $results;
320+
}
321+
248322
/**
249323
* Whitelisting credentials and/ important files/path
250324
*

0 commit comments

Comments
 (0)