This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace CodexShaper\WP; |
||
4 | |||
5 | use Composer\Script\Event; |
||
6 | use Symfony\Component\Process\Process; |
||
7 | |||
8 | class ComposerScripts |
||
9 | { |
||
10 | /** |
||
11 | * Handle the post-install Composer event. |
||
12 | * |
||
13 | * @param \Composer\Script\Event $event |
||
14 | * @return void |
||
15 | */ |
||
16 | public static function postInstall(Event $event) |
||
17 | { |
||
18 | require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php'; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Handle the post-update Composer event. |
||
23 | * |
||
24 | * @param \Composer\Script\Event $event |
||
25 | * @return void |
||
26 | */ |
||
27 | public static function postUpdate(Event $event) |
||
28 | { |
||
29 | require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php'; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Handle the post-autoload-dump Composer event. |
||
34 | * |
||
35 | * @param \Composer\Script\Event $event |
||
36 | * @return void |
||
37 | */ |
||
38 | public static function postAutoloadDump(Event $event) |
||
39 | { |
||
40 | require_once $event->getComposer()->getConfig()->get('vendor-dir').'/autoload.php'; |
||
41 | |||
42 | $dir = $event->getComposer()->getConfig()->get('vendor-dir').'/../'; |
||
43 | $root = dirname($event->getComposer()->getConfig()->get('vendor-dir')); |
||
44 | |||
45 | $vendor_name = strtolower(basename($root)); |
||
46 | $partials = explode('-', $vendor_name); |
||
47 | $camel_case_partials = []; |
||
48 | foreach ($partials as $partial) { |
||
49 | $camel_case_partials[] = ucfirst(strtolower($partial)); |
||
50 | } |
||
51 | $camel_case = implode('_', $camel_case_partials); |
||
52 | $snake_case = implode('_', $partials); |
||
53 | |||
54 | $files = [ |
||
55 | '/wpb.php', |
||
56 | '/bootstrap/app.php', |
||
57 | '/includes/class-wpb-activator.php', |
||
58 | '/includes/class-wpb-deactivator.php', |
||
59 | '/includes/class-wpb-i18n.php', |
||
60 | '/includes/class-wpb-loader.php', |
||
61 | '/includes/class-wpb.php', |
||
62 | '/admin/class-wpb-admin.php', |
||
63 | '/admin/class-wpb-admin-menu.php', |
||
64 | '/admin/class-wpb-admin-submenu.php', |
||
65 | '/admin/partials/wpb-admin-display.php', |
||
66 | '/admin/css/wpb-admin.css', |
||
67 | '/admin/js/wpb-admin.js', |
||
68 | '/public/class-wpb-public.php', |
||
69 | '/public/partials/wpb-public-display.php', |
||
70 | '/public/css/wpb-public.css', |
||
71 | '/public/js/wpb-public.js', |
||
72 | '/routes/web.php', |
||
73 | '/routes/api.php', |
||
74 | '/resources/js/admin/main.js', |
||
75 | '/resources/js/frontend/main.js', |
||
76 | '/resources/js/spa/main.js', |
||
77 | '/src/Application.php', |
||
78 | '/src/helpers.php', |
||
79 | '/src/Support/Facades/Config.php', |
||
80 | '/src/Support/Facades/Route.php', |
||
81 | '/src/Http/Kernel.php', |
||
82 | '/src/Http/Events/RequestHandler.php', |
||
83 | '/src/Exceptions/Handler.php', |
||
84 | '/app/User.php', |
||
85 | '/app/Post.php', |
||
86 | '/app/Http/Controllers/ProductController.php', |
||
87 | '/app/Http/Middleware/AuthMiddleware.php', |
||
88 | '/app/Http/Middleware/VerifyCsrfToken.php', |
||
89 | '/app/Http/Kernel.php', |
||
90 | '/app/Exceptions/Handler.php', |
||
91 | ]; |
||
92 | |||
93 | foreach ($files as $file) { |
||
94 | $file = $root.$file; |
||
95 | if(file_exists($file)) { |
||
96 | $contents = file_get_contents($file); |
||
97 | $contents = str_replace('wpb_', $snake_case.'_', $contents); |
||
98 | $contents = str_replace('wpb', $vendor_name, $contents); |
||
99 | $contents = str_replace('WPB_APP_ROOT', strtoupper($camel_case).'_APP_ROOT', $contents); |
||
100 | $contents = str_replace('WPB_FILE', strtoupper($camel_case).'_FILE', $contents); |
||
101 | $contents = str_replace('WPB_PATH', strtoupper($camel_case).'_PATH', $contents); |
||
102 | $contents = str_replace('WPB_INCLUDES', strtoupper($camel_case).'_INCLUDES', $contents); |
||
103 | $contents = str_replace('WPB_URL', strtoupper($camel_case).'_URL', $contents); |
||
104 | $contents = str_replace('WPB_ASSETS', strtoupper($camel_case).'_ASSETS', $contents); |
||
105 | $contents = str_replace('WPB_VERSION', strtoupper($camel_case).'_VERSION', $contents); |
||
106 | $contents = str_replace('WPB', $camel_case, $contents); |
||
107 | file_put_contents( |
||
108 | $file, |
||
109 | $contents |
||
110 | ); |
||
111 | |||
112 | $dir = dirname($file); |
||
113 | $fileName = basename($file); |
||
114 | $newFileName = str_replace('wpb', $vendor_name, $fileName); |
||
115 | |||
116 | if($fileName != $newFileName) { |
||
117 | rename($file, $dir.'/'.$newFileName); |
||
118 | } |
||
119 | |||
120 | } |
||
121 | } |
||
122 | |||
123 | // static::configApp($root, $camel_case); |
||
124 | static::updateComposer($root, $camel_case); |
||
125 | } |
||
126 | |||
127 | View Code Duplication | protected static function configApp($root, $camel_case) |
|
0 ignored issues
–
show
|
|||
128 | { |
||
129 | $file = $root.'/bootstrap/app.php'; |
||
130 | if(file_exists($file)) { |
||
131 | $contents = file_get_contents($file); |
||
132 | $contents = str_replace('WPB_APP_ROOT', strtoupper($camel_case).'_APP_ROOT', $contents); |
||
133 | file_put_contents( |
||
134 | $file, |
||
135 | $contents |
||
136 | ); |
||
137 | |||
138 | } |
||
139 | } |
||
140 | |||
141 | View Code Duplication | protected static function updateComposer($root, $camel_case) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
142 | { |
||
143 | $file = $root.'/composer.json'; |
||
144 | if(file_exists($file)) { |
||
145 | $contents = file_get_contents($file); |
||
146 | $contents = str_replace('WPB', $camel_case, $contents); |
||
147 | file_put_contents( |
||
148 | $file, |
||
149 | $contents |
||
150 | ); |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.