Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PO-242 : added esc_url for security fix #22

Merged
merged 2 commits into from
Nov 12, 2024
Merged

Conversation

abdulwahidsharief
Copy link
Contributor

No description provided.

</div>
<div class="row">
<div class="col-sm-4 panel-label">Created on</div>
<div class="col-sm-8 panel-value">'.$button_detail['created_at'].'</div>
<div class="col-sm-8 panel-value">' . esc_html($button_detail['created_at']) . '</div>
</div>
</div>
<div class="col-md-7">'.$button_detail['html_content_item'].'</div>

Choose a reason for hiding this comment

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

Echoing user input risks cross-site scripting vulnerability. You should use htmlentities() when showing data to users.

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>templates/razorpay-button-view-templates.php</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0["<a href=https://github.com/razorpay/payment-button-elementor-plugin/blob/d53d01809c8fef793483f449b55ea821b34613a5/templates/razorpay-button-view-templates.php#L28 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 28] $_REQUEST</a>"]
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2["<a href=https://github.com/razorpay/payment-button-elementor-plugin/blob/d53d01809c8fef793483f449b55ea821b34613a5/templates/razorpay-button-view-templates.php#L28 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 28] $pagenum</a>"]

            v3["<a href=https://github.com/razorpay/payment-button-elementor-plugin/blob/d53d01809c8fef793483f449b55ea821b34613a5/templates/razorpay-button-view-templates.php#L29 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 29] $previous_page_url</a>"]
        end
            v2 --> v3
        %% Sink

        subgraph Sink
            direction LR

            v1["<a href=https://github.com/razorpay/payment-button-elementor-plugin/blob/d53d01809c8fef793483f449b55ea821b34613a5/templates/razorpay-button-view-templates.php#L34 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 34] echo &apos;&lt;div class=&quot;wrap&quot;&gt;<br>            &lt;div class=&quot;content-header&quot;&gt;<br>                &lt;a href=&quot;&apos;.$previous_page_url.&apos;&quot;&gt;<br>                    &lt;span class=&quot;dashicons rzp-dashicons dashicons-arrow-left-alt&quot;&gt;&lt;/span&gt; Button List<br>                &lt;/a&gt;<br>                &lt;span class=&quot;dashicons rzp-dashicons dashicons-arrow-right-alt2&quot;&gt;&lt;/span&gt;&apos;. esc_html($button_detail[&apos;title&apos;]) . &apos;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;container rzp-container&quot;&gt;<br>                &lt;div class=&quot;row panel-heading&quot;&gt;<br>                    &lt;div class=&quot;text&quot;&gt;&apos; . esc_html($button_detail[&apos;title&apos;]) . &apos;&lt;/div&gt;<br>                &lt;/div&gt;<br>                &lt;div class=&quot;row panel-body&quot;&gt;<br>                    &lt;div class=&quot;col-md-5 panel-body-left&quot;&gt;<br>                        &lt;div class=&quot;row&quot;&gt;<br>                            &lt;div class=&quot;col-sm-4 panel-label&quot;&gt;Button ID&lt;/div&gt;<br>                            &lt;div class=&quot;col-sm-8 panel-value&quot;&gt;&apos; . esc_html($button_detail[&quot;id&quot;]) . &apos;&lt;/div&gt;<br>                        &lt;/div&gt;<br>                        &lt;div class=&quot;row&quot;&gt;<br>                            &lt;div class=&quot;col-sm-4 panel-label&quot;&gt;Button Status&lt;/div&gt;<br>                            &lt;div class=&quot;col-sm-8 panel-value&quot;&gt;<br>                                &lt;span class=&quot;status-label&quot;&gt;&apos; . esc_html$button_detail[&apos;status&apos;]) . &apos;&lt;/span&gt;<br>                                &lt;button onclick=&quot;&apos;.$show.&apos;&quot; class=&quot;status-button&quot;&gt;&apos; . esc_html($button_detail[&apos;btn_pointer_status&apos;]) . &apos;&lt;/button&gt;<br>                            &lt;/div&gt;<br>                        &lt;/div&gt;<br>                        &lt;div class=&quot;row&quot;&gt;<br>                            &lt;div class=&quot;col-sm-4 panel-label&quot;&gt;Total Quantity Sold&lt;/div&gt;<br>                            &lt;div class=&quot;col-sm-8 panel-value&quot;&gt;&apos; . htmlentities($button_detail[&apos;total_item_sold&apos;]) . &apos;&lt;/div&gt;<br>                        &lt;/div&gt;<br>                        &lt;div class=&quot;row&quot;&gt;<br>                            &lt;div class=&quot;col-sm-4 panel-label&quot;&gt;Total revenue&lt;/div&gt;<br>                            &lt;div class=&quot;col-sm-8 panel-value&quot;&gt;&lt;span class=&quot;rzp-currency&quot;&gt;₹ &lt;/span&gt;&apos; . esc_html($button_detail[&apos;total_revenue&apos;]) . &apos;&lt;/div&gt;<br>                        &lt;/div&gt;<br>                        &lt;div class=&quot;row&quot;&gt;<br>                            &lt;div class=&quot;col-sm-4 panel-label&quot;&gt;Created on&lt;/div&gt;<br>                            &lt;div class=&quot;col-sm-8 panel-value&quot;&gt;&apos; . esc_html($button_detail[&apos;created_at&apos;]) . &apos;&lt;/div&gt;<br>                        &lt;/div&gt;<br>                    &lt;/div&gt;<br>                    &lt;div class=&quot;col-md-7&quot;&gt;&apos;.$button_detail[&apos;html_content_item&apos;].&apos;&lt;/div&gt;<br>                &lt;/div&gt;          <br>            &lt;/div&gt;<br>                  <br>        &lt;/div&gt;&apos;;</a>"]
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

Loading
# ```suggestion echo htmlentities('
Button List '. esc_html($button_detail['title']) . '
' . esc_html($button_detail['title']) . '
Button ID
' . esc_html($button_detail["id"]) . '
Button Status
' . esc_html$button_detail['status']) . ' ' . esc_html($button_detail['btn_pointer_status']) . '
Total Quantity Sold
' . htmlentities($button_detail['total_item_sold']) . '
Total revenue
' . esc_html($button_detail['total_revenue']) . '
Created on
' . esc_html($button_detail['created_at']) . '
'.$button_detail['html_content_item'].'
            </div>');
<sub>⚪️ This finding does not block your pull request.
</sub><br/><sub>
<a href="https://semgrep.dev/docs/ignoring-files-folders-code">Ignore this finding</a> from <a href="https://semgrep.dev/playground/r/RGTKGXN/php.lang.security.injection.echoed-request.echoed-request?utm_campaign=finding_notification&utm_medium=review_comment&utm_source=github&utm_content=rule">echoed-request</a>.
</sub>


<!--

🤫 WELCOME TO SECRET SEMGREP! 🤫
This information is for debugging purposes and does not appear in rendered PR comments.

Finding id: 105423697
Syntactic id: 830568d0e859b0a7a0e329f71809bbfc
Start line: 34,9
End line: 75,17
Index: 0
-->

Choose a reason for hiding this comment

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

Semgrep Assistant thinks this might be safe to ignore. The user input from $_request['paged'] is sanitized using sanitize_text_field before being used, which mitigates the risk of cross-site scripting. the finding is not exploitable in this context.

AI-generated comment; review carefully.
Leave a 👍 reaction to ignore the finding. Reacting with 👍 or 👎 also provides feedback to improve Assistant's future comments.

@abdulwahidsharief abdulwahidsharief marked this pull request as ready for review November 12, 2024 12:42
Copy link
Contributor

@yashgit891 yashgit891 left a comment

Choose a reason for hiding this comment

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

LGTM

@abdulwahidsharief abdulwahidsharief merged commit 02da5b6 into master Nov 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants