-
Notifications
You must be signed in to change notification settings - Fork 1
Security hardening (audit): HTTPS warning, capability disclosure, permissions (v3.8.0) #9
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import os, sys, unittest | ||
|
|
||
| SCRIPTS = os.path.join(os.path.dirname(__file__), "..", "wordpress-api-pro", "scripts") | ||
| sys.path.insert(0, os.path.abspath(SCRIPTS)) | ||
|
|
||
| from security import SafetyError, warn_insecure_wp_url # noqa: E402 | ||
|
|
||
|
|
||
| class WarnInsecureWpUrlTest(unittest.TestCase): | ||
| def test_warns_on_http_nonlocal(self): | ||
| """http:// on a public host prints a SECURITY WARNING to stderr.""" | ||
| import io, contextlib | ||
| buf = io.StringIO() | ||
| with contextlib.redirect_stderr(buf): | ||
| result = warn_insecure_wp_url("http://example.com", env={}) | ||
| self.assertIn("SECURITY WARNING", buf.getvalue()) | ||
| self.assertEqual(result, "http://example.com") # url returned unchanged | ||
|
|
||
| def test_silent_on_https(self): | ||
| """https:// never triggers a warning.""" | ||
| import io, contextlib | ||
| buf = io.StringIO() | ||
| with contextlib.redirect_stderr(buf): | ||
| warn_insecure_wp_url("https://example.com", env={}) | ||
| self.assertEqual(buf.getvalue(), "") | ||
|
|
||
| def test_silent_on_localhost_http(self): | ||
| """http:// on localhost/dev hosts is exempt — no warning.""" | ||
| import io, contextlib | ||
| buf = io.StringIO() | ||
| with contextlib.redirect_stderr(buf): | ||
| warn_insecure_wp_url("http://localhost:8080", env={}) | ||
| warn_insecure_wp_url("http://site.local", env={}) | ||
| self.assertEqual(buf.getvalue(), "") | ||
|
|
||
| def test_raises_when_wp_require_https_set(self): | ||
| """WP_REQUIRE_HTTPS=1 upgrades the warning to a SafetyError.""" | ||
| with self.assertRaises(SafetyError): | ||
| warn_insecure_wp_url("http://example.com", env={"WP_REQUIRE_HTTPS": "1"}) | ||
|
|
||
| def test_silent_on_dot_test_host(self): | ||
| """http://*.test hosts are treated as local dev — no warning.""" | ||
| import io, contextlib | ||
| buf = io.StringIO() | ||
| with contextlib.redirect_stderr(buf): | ||
| warn_insecure_wp_url("http://mysite.test", env={}) | ||
| self.assertEqual(buf.getvalue(), "") | ||
|
|
||
| def test_silent_on_dot_localhost_host(self): | ||
| """http://*.localhost hosts are treated as local dev — no warning.""" | ||
| import io, contextlib | ||
| buf = io.StringIO() | ||
| with contextlib.redirect_stderr(buf): | ||
| warn_insecure_wp_url("http://app.localhost", env={}) | ||
| self.assertEqual(buf.getvalue(), "") | ||
|
|
||
| def test_wp_require_https_not_triggered_for_local(self): | ||
| """WP_REQUIRE_HTTPS=1 does NOT raise for localhost — local is always exempt.""" | ||
| import io, contextlib | ||
| buf = io.StringIO() | ||
| with contextlib.redirect_stderr(buf): | ||
| warn_insecure_wp_url("http://localhost", env={"WP_REQUIRE_HTTPS": "1"}) | ||
| self.assertEqual(buf.getvalue(), "") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a user supplies an
http://WordPress URL, the newwarn_insecure_wp_url()path only warns by default and the scripts still send the request unlessWP_REQUIRE_HTTPS=1is set, so this permission entry underreports the skill's actual network access. This matters for the newly added least-privilege disclosure because local-dev HTTP is explicitly supported and public HTTP is still allowed with a warning; the permission should include HTTP egress or say HTTPS is recommended/enforceable rather than exclusive.Useful? React with 👍 / 👎.