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

[SEMGREP] - Prevent Semgrep warnings in add_query vars and in Scripts loader #1950

Merged
merged 4 commits into from
Apr 26, 2023

Conversation

puntope
Copy link
Contributor

@puntope puntope commented Apr 17, 2023

Changes proposed in this Pull Request:

This PR prevents two issues in SEMGREP to warn in the output:

  • Potential Unsafe usage (non escaped) of remove_query_arg() or add_query_arg(), which could lead to XSS
  • Argument of a function used in an include/require, could lead to File Inclusion

Detailed test instructions:

  1. ⚠️ Verify you can connect to Wordpress.com from the Extension Setup in Step 1.
  2. Verify that running SEMGREP against the extension doesn't generate this warnings anymore

Additional details:

For running semgrep:

  • Install semgrep
  • clone rules --> git clone [email protected]:Automattic/wpscan-semgrep-rules.git
  • cd wpscan-semgrep-rules
  • download last release google-listings-and-ads zip somewhere and unzip it.
  • Run --> semgrep --no-git-ignore --text -c audit {UNZIPPED_GLA_PATH}
  • (You can also run it agains your locally cloned repo, but that would include noise in regards vendor files)

Changelog entry

Dev - Fix SEMGREP warnings

@puntope puntope requested a review from a team April 17, 2023 12:51
@puntope puntope self-assigned this Apr 17, 2023
@github-actions github-actions bot added the changelog: dev Developer-facing only change. label Apr 17, 2023
@codecov
Copy link

codecov bot commented Apr 17, 2023

Codecov Report

Merging #1950 (97922a0) into develop (ef52b83) will not change coverage.
The diff coverage is 100.0%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             develop   #1950   +/-   ##
=========================================
  Coverage       56.8%   56.8%           
  Complexity      4101    4101           
=========================================
  Files            456     456           
  Lines          17620   17620           
=========================================
  Hits           10010   10010           
  Misses          7610    7610           
Flag Coverage Δ
php-unit-tests 56.8% <100.0%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Assets/ScriptWithBuiltDependenciesAsset.php 0.0% <ø> (ø)
...API/Site/Controllers/Jetpack/AccountController.php 100.0% <100.0%> (ø)

Copy link
Contributor

@mikkamp mikkamp left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. I can confirm the Jetpack Connect URL remains the same regardless of adding esc_url. All parts of the URL are already properly escaped so it doesn't really do anything but esc_url is safe to call multiple times, so that's ok.

Just left one comment adding a colon to the ignore comment, it's important to add (in other PR's as well) since without it it disables all rules.

I'll go ahead and approve the PR already because once we add the colon it should all be good.

@puntope puntope merged commit 5ca1e51 into develop Apr 26, 2023
@puntope puntope deleted the dev/semgrep branch April 26, 2023 12:22
@eason9487 eason9487 mentioned this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: dev Developer-facing only change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants