Skip to content

Fix/secuirty issues#1030

Merged
obiPlabon merged 35 commits intosovware:alphafrom
syedgalib:fix/secuirty-issues
Aug 2, 2022
Merged

Fix/secuirty issues#1030
obiPlabon merged 35 commits intosovware:alphafrom
syedgalib:fix/secuirty-issues

Conversation

@syedgalib
Copy link
Collaborator

No description provided.

Copy link
Contributor

@obiPlabon obiPlabon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more issues similar to the feedback I shared. Please check them

?>
<div class="atbd_rated_stars">
<?php echo ATBDP()->review->print_static_rating($average); ?>
<?php echo esc_html( ATBDP()->review->print_static_rating( $average ) ); ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method returns html and doesn't need to be escaped.

$listing_id = 0;
$current_url = $current_url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$current_listing_type = isset( $_GET['directory_type'] ) ? $_GET['directory_type'] : get_post_meta( $listing_id, '_directory_type', true );
$current_url = $current_url="//". sanitize_text_field( $_SERVER['HTTP_HOST'] ) . sanitize_text_field( $_SERVER['REQUEST_URI'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a typo $current_url = $current_url="//"

Looks like we don't need the HTTP_HOST here only the REQUEST_URI is enough. Please recheck...

'please_login' => __( 'Please login first', 'directorist' ),
'select_listing_map' => $select_listing_map,
'Miles' => !empty( $_GET['miles'] ) ? $_GET['miles'] : $miles,
'Miles' => ! empty( $_GET['miles'] ) ? sanitize_text_field( $_GET['miles'] ) : $miles,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$_GET['miles'] is an integer whereas $miles is a string. Looks like the translation string in incorrect. Supposed to be $miles_text = __( '%d Miles', 'directorist' ); $miles = ! empty( $_GET['miles'] ) ? absint( $_GET['miles'] ) : 0; and `'Miles' => sprintf( $miles_text, $miles )

$action = ! empty( $_GET['atbdp_action'] ) ? $_GET['atbdp_action'] : '';
$listing_id = ! empty( $_GET['atbdp_listing'] ) ? absint( $_GET['atbdp_listing'] ) : 0;
$action = ! empty( $_GET['atbdp_action'] ) ? sanitize_text_field( $_GET['atbdp_action'] ) : '';
$listing_id = ! empty( $_GET['atbdp_listing'] ) ? absint( sanitize_text_field( $_GET['atbdp_listing'] ) ) : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sanitize_text_field unnecessary

echo '</p></div>';

echo "<script type='text/javascript'>jQuery('." . $this->client->slug . "-insights-data-we-collect').on('click', function(e) {
echo "<script type='text/javascript'>jQuery('." . esc_attr( $this->client->slug ) . "-insights-data-we-collect').on('click', function(e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use esc_js for all inline and internal js

Comment::clear_transients( $comment->comment_post_ID );

$cpage = isset( $_POST['cpage'] ) ? absint( $_POST['cpage'] ) : 0;
$cpage = isset( $_POST['cpage'] ) ? absint( sanitize_text_field( $_POST['cpage'] ) ) : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absint( $_POST['cpage'] )

}

if ( empty( $_POST['comment'] ) || empty( trim( $_POST['comment'] ) ) ) {
if ( empty( $_POST['comment'] ) || empty( trim( sanitize_text_field( $_POST['comment'] ) ) ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a textarea field so using sanitize_text_field will remove newline characters.

$comment = isset( $_POST['comment'] ) ? trim( sanitize_textarea_field( $_POST['comment'] ) : '';

if ( empty( $comment ) ) {
....
}

// And online line 83-87
$comment_data = array(
    ...
    ...
    'comment_content' => $comment
);

$nonce = ! empty( $_REQUEST['nonce'] ) ? $_REQUEST['nonce'] : '';
$post_id = ! empty( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0;
$comment_id = ! empty( $_REQUEST['comment_id'] ) ? absint( $_REQUEST['comment_id'] ) : 0;
$nonce = ! empty( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_unslash( $_REQUEST['nonce'] )

$post_id = ! empty( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0;
$comment_id = ! empty( $_REQUEST['comment_id'] ) ? absint( $_REQUEST['comment_id'] ) : 0;
$nonce = ! empty( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
$post_id = ! empty( $_REQUEST['post_id'] ) ? absint( sanitize_text_field( $_REQUEST['post_id'] ) ) : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absint( $_REQUEST['post_id'] )

$comment_id = ! empty( $_REQUEST['comment_id'] ) ? absint( $_REQUEST['comment_id'] ) : 0;
$nonce = ! empty( $_REQUEST['nonce'] ) ? sanitize_text_field( $_REQUEST['nonce'] ) : '';
$post_id = ! empty( $_REQUEST['post_id'] ) ? absint( sanitize_text_field( $_REQUEST['post_id'] ) ) : 0;
$comment_id = ! empty( $_REQUEST['comment_id'] ) ? absint( sanitize_text_field( $_REQUEST['comment_id'] ) ) : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absint( $_REQUEST['comment_id'] )

Copy link
Contributor

@kowsar89 kowsar89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs issue found

@kowsar89 kowsar89 added this to the v7.3.1 milestone Jul 20, 2022
Copy link
Contributor

@kowsar89 kowsar89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs issue found

Copy link
Contributor

@kowsar89 kowsar89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs issue found

$radius_search_unit = get_directorist_option( 'radius_search_unit', 'miles' );
$default_radius_distance = get_directorist_option( 'search_default_radius_distance', 0 );

$miles = ! empty( $_GET['miles'] ) ? absint( $_GET['miles'] ) : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improvements should go into different PR, only security fixes here

Copy link
Contributor

@vairafiq vairafiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Contributor

@vairafiq vairafiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review broke in single listing
image

@vairafiq
Copy link
Contributor

vairafiq commented Aug 1, 2022

vairafiq
vairafiq previously approved these changes Aug 2, 2022
Copy link
Contributor

@vairafiq vairafiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works fine

Copy link
Contributor

@kowsar89 kowsar89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpcs ok

Copy link
Contributor

@kowsar89 kowsar89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP error found

[02-Aug-2022 06:46:52 UTC] PHP Parse error:  syntax error, unexpected ')' in /media/k/SSD/xampp/htdocs/wpwax/directorist/wp-content/plugins/directorist/includes/helper-functions.php on line 9009
[02-Aug-2022 06:46:52 UTC] PHP Fatal error:  Exception thrown without a stack frame in Unknown on line 0

Copy link
Contributor

@obiPlabon obiPlabon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@obiPlabon obiPlabon merged commit 677f59f into sovware:alpha Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants