-
Notifications
You must be signed in to change notification settings - Fork 8
Dev #901
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
Dev #901
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5333304
feat:reolved global field issue in siteocore,when mapped with existin…
AishDani a6f6b63
Merge pull request #896 from contentstack/bugfix/cmg-624
umeshmore45 b8471bb
snyk fix: Open Redirect and eslint version upgrade
sayalijoshi27 b4c9faf
feat: add initial reference handling in content mapping service and i…
AishDani a9cf0eb
Unsanitized input - Prototype Pollution snyk fix added
sayalijoshi27 ee99e36
Merge pull request #899 from contentstack/bugfix/cmg-624
sayalijoshi27 fca5b22
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 f833ca0
Removed extra space
sayalijoshi27 eac23cc
Merge pull request #900 from contentstack/hotfix/path-issue
umeshmore45 9daec00
Removed unwanted line
sayalijoshi27 75b86af
Merge branch 'dev' of https://github.com/contentstack/migration-v2-no…
sayalijoshi27 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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2012,9 +2012,9 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref: | |||||
| contentstackFieldType: row?.backupFieldType, | ||||||
| contentstackField: row?.otherCmsField, | ||||||
| contentstackFieldUid: row?.backupFieldUid, | ||||||
| advanced: { | ||||||
| ...row?.advanced?.initial, | ||||||
| }, | ||||||
| advanced: row?.advanced?.initial, | ||||||
| ...(row?.refrenceTo && { refrenceTo: row?.initialRefrenceTo }), | ||||||
|
||||||
| ...(row?.refrenceTo && { refrenceTo: row?.initialRefrenceTo }), | |
| ...(row?.referenceTo && { referenceTo: row?.initialRefrenceTo }), |
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 |
|---|---|---|
| @@ -1,22 +1,43 @@ | ||
| import { useEffect } from 'react'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import { useEffect, useRef } from 'react'; | ||
| import { useNavigate, useLocation } from 'react-router-dom'; | ||
| import { getSafeRouterPath } from '../utilities/functions'; | ||
|
|
||
| /** | ||
| * Custom hook to prevent browser back navigation. | ||
| * Uses React Router's internal location state instead of window.location | ||
| * to avoid Open Redirect vulnerabilities (CWE-601). | ||
| */ | ||
| const usePreventBackNavigation = (): void => { | ||
| const navigate = useNavigate(); | ||
| const location = useLocation(); | ||
|
|
||
| // Store the current safe path from React Router's internal state | ||
| // This avoids using window.location which is user-controlled | ||
| const safePathRef = useRef<string>('/'); | ||
|
|
||
| useEffect(() => { | ||
| // Build the full path from React Router's location object | ||
| // This is safe because React Router validates routes internally | ||
| const fullPath = getSafeRouterPath(location, true); | ||
|
|
||
| // Store the validated path | ||
| safePathRef.current = fullPath; | ||
|
|
||
| // Push a new history state to enable back navigation detection | ||
| window.history.pushState({ preventBack: true }, '', fullPath); | ||
|
|
||
| const handleBackNavigation = (event: PopStateEvent) => { | ||
| event.preventDefault(); | ||
| navigate(window.location.pathname, { replace: true }); | ||
| // Use the stored safe path from React Router, not window.location | ||
| // Navigate to the path we stored from React Router's validated state | ||
| window.history.pushState({ preventBack: true }, '', safePathRef.current); | ||
| }; | ||
|
|
||
| window.history.pushState(null, '', window.location.href); | ||
|
|
||
| window.addEventListener('popstate', handleBackNavigation); | ||
|
|
||
| return () => { | ||
| window.removeEventListener('popstate', handleBackNavigation); | ||
| }; | ||
| }, [navigate]); | ||
| }, [navigate, location]); | ||
| }; | ||
| export default usePreventBackNavigation; |
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 |
|---|---|---|
| @@ -1,36 +1,53 @@ | ||
| import { useEffect, useRef } from 'react'; | ||
| import { useLocation, useNavigate } from 'react-router-dom'; | ||
| import { useEffect, useRef, useCallback } from 'react'; | ||
| import { useLocation } from 'react-router-dom'; | ||
| import { getSafeRouterPath } from '../utilities/functions'; | ||
|
|
||
| /** | ||
| * Custom hook to block browser navigation when a modal is open. | ||
| * Uses stored pathname from React Router to avoid Open Redirect vulnerabilities (CWE-601). | ||
| */ | ||
| const useBlockNavigation = (isModalOpen: boolean) => { | ||
| const location = useLocation(); | ||
| const navigate = useNavigate(); | ||
| const initialPathnameRef = useRef(location.pathname); | ||
|
|
||
| // Store the validated pathname when modal state changes | ||
| // This breaks the data flow from user-controlled input to redirect | ||
| const storedPathnameRef = useRef<string>('/'); | ||
|
|
||
| // Memoized function to get the safe stored path | ||
| const getSafeStoredPath = useCallback(() => { | ||
| return storedPathnameRef.current; | ||
| }, []); | ||
|
|
||
| // Update stored pathname only when modal is not open | ||
| // This captures the safe path before any manipulation | ||
| useEffect(() => { | ||
| if (!isModalOpen) { | ||
| // Store the current path from React Router's validated state | ||
| storedPathnameRef.current = getSafeRouterPath(location); | ||
| } | ||
| }, [isModalOpen, location]); | ||
|
|
||
| useEffect(() => { | ||
| const handlePopState = (event: PopStateEvent) => { | ||
| // If the modal is open, prevent navigation | ||
| const handlePopState = () => { | ||
| // If the modal is open, prevent navigation by pushing state with stored safe path | ||
| if (isModalOpen) { | ||
| window.history.pushState(null, '', window.location.pathname); | ||
| navigate(location.pathname); | ||
| const safePath = getSafeStoredPath(); | ||
| window.history.pushState({ blockNav: true }, '', safePath); | ||
| } | ||
| }; | ||
|
|
||
| if (isModalOpen) { | ||
| initialPathnameRef.current = location.pathname; | ||
| window.history.pushState(null, '', window.location.pathname); | ||
| // Store the current safe path when modal opens | ||
| storedPathnameRef.current = getSafeRouterPath(location); | ||
| const safePath = getSafeStoredPath(); | ||
| window.history.pushState({ blockNav: true }, '', safePath); | ||
| window.addEventListener('popstate', handlePopState); | ||
| } | ||
|
|
||
| return () => { | ||
| window.removeEventListener('popstate', handlePopState); | ||
| }; | ||
| }, [isModalOpen, navigate, location.pathname]); | ||
|
|
||
| useEffect(() => { | ||
| if (!isModalOpen) { | ||
| initialPathnameRef.current = location.pathname; | ||
| } | ||
| }, [isModalOpen, location.pathname]); | ||
| }, [isModalOpen, getSafeStoredPath, location]); | ||
| }; | ||
|
|
||
| export default useBlockNavigation; |
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.
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.
The property name is misspelled as "refrenceTo" (should be "referenceTo"). This typo creates inconsistency with the backend code which uses the correct spelling "referenceTo" in the reset functionality, potentially causing the reference tracking to fail.