Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq1988 committed Jul 18, 2024
1 parent 33ad415 commit 902ac0b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function render_admin_page() {
'optimizations' => __( 'Optimizations', 'flywp' ),
];

// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ? $_GET['tab'] : 'cache';
$site_info = $this->fetch_site_info();
$app_site_url = $this->get_site_url( $site_info );
Expand Down
3 changes: 3 additions & 0 deletions includes/Admin/Litespeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function handle_enable_disable() {
return;
}

// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['_wpnonce'] ) && ! wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), 'flywp-litespeed-nonce' ) ) {

Check failure on line 51 in includes/Admin/Litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of a non-sanitized input variable: $_GET['_wpnonce']
return;
}
Expand All @@ -56,6 +57,8 @@ public function handle_enable_disable() {
}

$valid_types = [ 'enable', 'disable' ];

// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$type = isset( $_GET['type'] ) && in_array( wp_unslash( $_GET['type'] ), $valid_types, true ) ? wp_unslash( $_GET['type'] ) : 'enable';

Check failure on line 62 in includes/Admin/Litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of a non-sanitized input variable: $_GET['type']
$status = $type === 'enable' ? '1' : '0';
$notice = $type === 'enable' ? 'lscache-enabled' : 'lscache-disabled';
Expand Down
2 changes: 1 addition & 1 deletion includes/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function get_bearer_token() {
return false;
}

$auth_header = $_SERVER['HTTP_AUTHORIZATION'];
$auth_header = wp_unslash( $_SERVER['HTTP_AUTHORIZATION'] );

if ( ! preg_match( '/Bearer\s(\S+)/', $auth_header, $matches ) ) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion views/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<div class="fw-flex -fw-mb-px fw-gap-2">
<?php foreach ( $tabs as $key => $label ) { ?>
<a href="<?php echo esc_url( add_query_arg( ['tab' => $key ], $this->page_url() ) ); ?>" class="fw-block fw-px-4 fw-py-3 fw-text-sm -m fw-text-gray-800 fw-no-underline fw-outline-none focus:fw-outline-none <?php echo $key === $active_tab ? 'fw-border-b-2 fw-border-indigo-500 fw-font-semibold' : ''; ?>"><?php echo $label; ?></a>
<a href="<?php echo esc_url( add_query_arg( [ 'tab' => $key ], $this->page_url() ) ); ?>" class="fw-block fw-px-4 fw-py-3 fw-text-sm -m fw-text-gray-800 fw-no-underline fw-outline-none focus:fw-outline-none <?php echo $key === $active_tab ? 'fw-border-b-2 fw-border-indigo-500 fw-font-semibold' : ''; ?>"><?php echo $label; ?></a>
<?php } ?>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions views/litespeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
'lscache-disabled' => __( 'Page Caching has been disabled.', 'flywp' ),
];

if ( isset( $_GET['fly-notice'] ) && isset( $cache_messages[$_GET['fly-notice']] ) ) {
$notice = $cache_messages[$_GET['fly-notice']];
if ( isset( $_GET['fly-notice'] ) && isset( $cache_messages[ $_GET['fly-notice'] ] ) ) {

Check warning on line 10 in views/litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check warning on line 10 in views/litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
$notice = $cache_messages[ $_GET['fly-notice'] ];

Check warning on line 11 in views/litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check failure on line 11 in views/litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

$_GET data not unslashed before sanitization. Use wp_unslash() or similar

Check failure on line 11 in views/litespeed.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of a non-sanitized input variable: $_GET['fly-notice']
}
?>

Expand Down
4 changes: 2 additions & 2 deletions views/op-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
'opcache-purged' => __( 'PHP OPcache has been cleared.', 'flywp' ),
];

if ( isset( $_GET['fly-notice'] ) && isset( $cache_messages[$_GET['fly-notice']] ) ) {
$notice = $cache_messages[$_GET['fly-notice']];
if ( isset( $_GET['fly-notice'] ) && isset( $cache_messages[ $_GET['fly-notice'] ] ) ) {

Check warning on line 11 in views/op-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check warning on line 11 in views/op-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
$notice = $cache_messages[ $_GET['fly-notice'] ];

Check warning on line 12 in views/op-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check failure on line 12 in views/op-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

$_GET data not unslashed before sanitization. Use wp_unslash() or similar

Check failure on line 12 in views/op-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of a non-sanitized input variable: $_GET['fly-notice']
}
?>

Expand Down
4 changes: 2 additions & 2 deletions views/page-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
'fastcgi-disabled' => __( 'Page Caching has been disabled.', 'flywp' ),
];

if ( isset( $_GET['fly-notice'] ) && isset( $cache_messages[$_GET['fly-notice']] ) ) {
$notice = $cache_messages[$_GET['fly-notice']];
if ( isset( $_GET['fly-notice'] ) && isset( $cache_messages[ $_GET['fly-notice'] ] ) ) {

Check warning on line 12 in views/page-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check warning on line 12 in views/page-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.
$notice = $cache_messages[ $_GET['fly-notice'] ];

Check warning on line 13 in views/page-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Processing form data without nonce verification.

Check failure on line 13 in views/page-cache.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

$_GET data not unslashed before sanitization. Use wp_unslash() or similar
}
?>

Expand Down

0 comments on commit 902ac0b

Please sign in to comment.