Repository navigation
Ensure that importer names are sanitized before making REST requests. - #632
Conversation
TallblokeUK
left a comment
There was a problem hiding this comment.
Tested locally on a site with Header Footer Code Manager installed:
- Opening the import page with ?from= set to a value containing path segments or other characters keeps both requests (loading the importer's snippets, and the import itself) under /code-snippets/v1/import/plugins/.
- The three built-in importer names are unchanged by sanitizeImporterName(), so their request URLs are identical to before. An uppercase ?from= value still selects the right importer.
- Choosing an importer from the dropdown, and arriving with a valid ?from=, both load the snippet list. Importing a selected snippet succeeds.
- ESLint and the build pass. tsc reports no new errors.
Non-blocking suggestions:
- A small Playwright check that a ?from= containing path segments keeps requests under the importer route would guard against this coming back.
- The GET in WithMigrationData.tsx (line 133) builds its URL from selectedImporter without encodeURIComponent(). That's safe as it stands, because the value is already sanitised; encoding it would match the import request.
Separate from this PR: opening the import page with ?from= set to an importer whose plugin isn't active returns a 500 from /import/plugins/{name}, because the importer expects the plugin's classes to be loaded.
|
Code looks good and is okay to merge. It closes the path traversal via Agree with Tallbloke's review and suggestions (encoding the GET, adding a Playwright check, and handling the inactive-plugin 500 in a separate PR). One small suggestion to consider - not urgent but we may want to sanitise |
lightbulbman
left a comment
There was a problem hiding this comment.
see previous comments
|
Appreciate the feedback! |
No description provided.