-
Notifications
You must be signed in to change notification settings - Fork 359
feat: Implement a PDF conversion script #2466 #2467
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: main
Are you sure you want to change the base?
Conversation
|
|
||
| while (nextPageUrl) { | ||
| if (urls.length >= maxPages) break; | ||
| if (urls.includes(nextPageUrl)) break; |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
https://docs.h2o.ai/h2o-document-ai/get-started/what-is-h2o-document-ai
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To address the issue, we need to validate that nextPageUrl belongs to the trusted domain (docs.h2o.ai) before adding it to the urls array. This can be achieved by parsing the URL using the URL constructor and checking its hostname property against the trusted domain. This approach ensures that only URLs with the correct host are processed, mitigating the risk of malicious URLs bypassing the check.
The changes will involve:
- Parsing
nextPageUrlusing theURLconstructor. - Validating that the
hostnameofnextPageUrlmatches the trusted domain (docs.h2o.ai). - Updating the condition on line 16 to include this validation.
-
Copy modified lines R16-R22
| @@ -15,3 +15,9 @@ | ||
| if (urls.length >= maxPages) break; | ||
| if (urls.includes(nextPageUrl)) break; | ||
| try { | ||
| const parsedUrl = new URL(nextPageUrl); | ||
| if (parsedUrl.hostname !== 'docs.h2o.ai' || urls.includes(nextPageUrl)) break; | ||
| } catch (e) { | ||
| console.error(`Invalid URL encountered: ${nextPageUrl}`); | ||
| break; | ||
| } | ||
|
|
Fixes #2466
This PR is still a WIP and not yet ready for review
The PR fulfills these requirements: (check all the apply)
mainbranch.feat: Add a button #xxx, where "xxx" is the issue number).Closes #xxx, where "xxx" is the issue number.uifolder, unit tests (make test) still pass.