-
Notifications
You must be signed in to change notification settings - Fork 34
feat: implement shady-url detection for local IPs and localhost (#449) #452
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
base: master
Are you sure you want to change the base?
feat: implement shady-url detection for local IPs and localhost (#449) #452
Conversation
🦋 Changeset detectedLatest commit: 16cdffa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi maintainers 👋 |
|
In the issue by throwing a shady-url warning I wanted |
|
Updated based on feedback |
| it("should return false for .link TLD", () => { | ||
| assert.equal(ShadyURL.isSafe("https://malicious.link", { | ||
| collectableSetRegistry | ||
| }), false); | ||
| }); |
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.
Not sure why some of the tests are been deleted (please review the diff)
workspaces/js-x-ray/src/ShadyURL.ts
Outdated
| collectableSetRegistry.add("ip", { value: hostname, file, location: sourceArrayLocation }); | ||
| if (this.#isPrivateIPAddress(hostname)) { | ||
| return true; | ||
| // التحقق المبكر من localhost |
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.
??
6ffe7a8 to
16cdffa
Compare
|
Hi @fraxken 👋 Thank you very much for the review and for taking the time to guide me through the changes — I really appreciate it. This is my first pull request to this project (and one of my first OSS contributions), so I apologize for the earlier mistakes and any confusion caused along the way. Your feedback helped me understand the project conventions much better. Thanks again for your patience and clear explanations — they were extremely helpful 🙏 |
Description
This PR implements the detection of local IP addresses (both IPv4 and IPv6) and localhost hostnames within URLs, as requested in issue #449. This is handled by a new warning type shady-url with Information severity to distinguish it from external shady-link warnings.
Changes
Verification Results
I have added and updated unit tests in ShadyURL.spec.ts and isLiteral.spec.ts. All 78 tests passed successfully on Windows using tsx.