Skip to content

Potential fix for code scanning alert no. 92: DOM text reinterpreted as HTML#159

Merged
juliuskrah merged 4 commits into
mainfrom
alert-autofix-92
May 15, 2026
Merged

Potential fix for code scanning alert no. 92: DOM text reinterpreted as HTML#159
juliuskrah merged 4 commits into
mainfrom
alert-autofix-92

Conversation

@juliuskrah
Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/gitstore-dev/GitStore/security/code-scanning/92

Best fix: validate and normalize image URLs before storing/rendering them, and avoid rendering invalid/untrusted schemes in img.src.

Concretely in gitstore-admin/src/components/products/ProductForm.tsx:

  • Add a small helper (inside component scope) that accepts only http: / https: URLs using new URL(...).
  • In handleAddImage, sanitize imageInput.trim() and only append to formData.images if valid.
  • In the image list render, compute sanitized URL and use it for <img src=...>, with a safe fallback (empty string) and loading hints.

This preserves current functionality (users still add normal image links) while blocking dangerous/malformed values and addressing all taint variants feeding the sink at line 420.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@juliuskrah juliuskrah marked this pull request as ready for review May 15, 2026 10:19
@juliuskrah juliuskrah enabled auto-merge May 15, 2026 10:19
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0979ccb915

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +447 to +451
type="button"
onClick={() => handleRemoveImage(index)}
style={styles.removeButton}
disabled={isLoading}
>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove duplicated button block after image map

The block starting at this line is a stray duplicate outside the formData.images.map(...) callback, leaving orphaned JSX (type="button" without an opening <button) and a second ))}/)) sequence; this breaks TSX parsing and also references index out of scope, so the admin frontend cannot compile once this commit is applied.

Useful? React with 👍 / 👎.

@juliuskrah juliuskrah disabled auto-merge May 15, 2026 10:22
@juliuskrah juliuskrah added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit f37a0ba May 15, 2026
15 checks passed
@juliuskrah juliuskrah deleted the alert-autofix-92 branch May 15, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant