Skip to content
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

Issueid #226738 fix: Score not updating for speak with me section if … #160

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Assesment/Assesment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
const handleProfileBack = () => {
try {
if (process.env.REACT_APP_IS_APP_IFRAME === "true") {
window.parent.postMessage({ type: "restore-iframe-content" });
window.parent.postMessage({ type: "restore-iframe-content" }, "*");

Check failure

Code scanning / SonarCloud

Origins should be verified during cross-origin communications High

Specify a target origin for this message. See more on SonarCloud
Copy link

Choose a reason for hiding this comment

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

Security Issue: Specify the exact target origin instead of using "*".

Using "*" as the target origin in the postMessage call allows the message to be sent to any window, which can lead to security vulnerabilities. It is recommended to specify the exact origin of the intended recipient instead.

To address this, replace "*" with the specific origin URL:

- window.parent.postMessage({ type: "restore-iframe-content" }, "*");
+ window.parent.postMessage({ type: "restore-iframe-content" }, "https://example.com");

Make sure to replace "https://example.com" with the actual origin URL of the intended recipient.

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: SonarCloud

[failure] 347-347: Origins should be verified during cross-origin communications

Specify a target origin for this message.

See more on SonarCloud

navigate("/");
} else {
navigate("/discover-start");
Expand Down
49 changes: 27 additions & 22 deletions src/components/DiscoverSentance/DiscoverSentance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@
const [disableScreen, setDisableScreen] = useState(false);
const [play] = useSound(LevelCompleteAudio);
const [openMessageDialog, setOpenMessageDialog] = useState("");
const [totalSyllableCount, setTotalSyllableCount] = useState('');
const [totalSyllableCount, setTotalSyllableCount] = useState("");
const [isNextButtonCalled, setIsNextButtonCalled] = useState(false);


const callConfettiAndPlay = () => {
play();
callConfetti();
Expand Down Expand Up @@ -100,16 +99,19 @@
}, [voiceText]);

const send = (score) => {
if (process.env.REACT_APP_IS_APP_IFRAME === 'true') {
window.parent.postMessage({
score: score,
message: "all-test-rig-score",
});
if (process.env.REACT_APP_IS_APP_IFRAME === "true") {
window.parent.postMessage(

Check failure

Code scanning / SonarCloud

Origins should be verified during cross-origin communications High

Specify a target origin for this message. See more on SonarCloud
{
score: score,
message: "all-test-rig-score",
},
"*"
);
Comment on lines +102 to +109
Copy link

Choose a reason for hiding this comment

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

Restrict the target origin to trusted domains.

The formatting changes to the postMessage call improve readability. However, using "*" as the target origin allows the message to be sent to any origin, which could be a security risk if the message contains sensitive data.

Restrict the target origin to trusted domains instead of using "*". For example:

window.parent.postMessage(
  {
    score: score,
    message: "all-test-rig-score",
  },
  "https://trusted-domain.com"
);
Tools
GitHub Check: SonarCloud

[failure] 103-103: Origins should be verified during cross-origin communications

Specify a target origin for this message.

See more on SonarCloud

}
};

const handleNext = async () => {
setIsNextButtonCalled(true)
setIsNextButtonCalled(true);
setEnableNext(false);

try {
Expand Down Expand Up @@ -165,17 +167,17 @@
const { data: getSetData } = getSetResultRes;
const data = JSON.stringify(getSetData?.data);
Log(data, "discovery", "ET");
if(process.env.REACT_APP_POST_LEARNER_PROGRESS === "true"){
await axios.post(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.CREATE_LEARNER_PROGRESS}`,
{
userId: localStorage.getItem("virtualId"),
sessionId: localStorage.getItem("sessionId"),
subSessionId: sub_session_id,
milestoneLevel: getSetData?.data?.currentLevel,
language: localStorage.getItem("lang"),
}
);
if (process.env.REACT_APP_POST_LEARNER_PROGRESS === "true") {
await axios.post(
`${process.env.REACT_APP_LEARNER_AI_ORCHESTRATION_HOST}/${config.URLS.CREATE_LEARNER_PROGRESS}`,
{
userId: localStorage.getItem("virtualId"),
sessionId: localStorage.getItem("sessionId"),
subSessionId: sub_session_id,
milestoneLevel: getSetData?.data?.currentLevel,
language: localStorage.getItem("lang"),
}
);
}
if (
getSetData.data.sessionResult === "pass" &&
Expand All @@ -193,7 +195,9 @@
`${process.env.REACT_APP_CONTENT_SERVICE_APP_HOST}/${config.URLS.GET_PAGINATION}?page=1&limit=5&collectionId=${sentences?.[newSentencePassedCounter]?.collectionId}`
);
setCurrentContentType("Sentence");
setTotalSyllableCount(resSentencesPagination?.data?.totalSyllableCount);
setTotalSyllableCount(
resSentencesPagination?.data?.totalSyllableCount
);
setCurrentCollectionId(
sentences?.[newSentencePassedCounter]?.collectionId
);
Expand Down Expand Up @@ -274,7 +278,7 @@
`${process.env.REACT_APP_CONTENT_SERVICE_APP_HOST}/${config.URLS.GET_PAGINATION}?page=1&limit=5&collectionId=${sentences?.collectionId}`
);
setCurrentContentType("Sentence");
setTotalSyllableCount(resPagination?.data?.totalSyllableCount)
setTotalSyllableCount(resPagination?.data?.totalSyllableCount);
setCurrentCollectionId(sentences?.collectionId);
setAssessmentResponse(resAssessment);
localStorage.setItem("storyTitle", sentences?.name);
Expand All @@ -289,7 +293,8 @@
})();
}, []);
const handleBack = () => {
const destination = process.env.REACT_APP_IS_APP_IFRAME === 'true' ? "/" : "/discover-start";
const destination =
process.env.REACT_APP_IS_APP_IFRAME === "true" ? "/" : "/discover-start";
navigate(destination);
// if (process.env.REACT_APP_IS_APP_IFRAME === 'true') {
// navigate("/");
Expand Down
13 changes: 8 additions & 5 deletions src/views/Practice/Practice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@

const send = (score) => {
if (process.env.REACT_APP_IS_APP_IFRAME === "true") {
window.parent.postMessage({
score: score,
message: "all-test-rig-score",
});
window.parent.postMessage(

Check failure

Code scanning / SonarCloud

Origins should be verified during cross-origin communications High

Specify a target origin for this message. See more on SonarCloud
{
score: score,
message: "all-test-rig-score",
},
"*"
);
Comment on lines +122 to +128
Copy link

Choose a reason for hiding this comment

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

Security Issue: Specify trusted domain instead of "*" for postMessage target origin.

Using "*" as the target origin in postMessage is a security risk because it allows sending messages to any origin. This can potentially leak sensitive data to untrusted sources.

Fix this by replacing "*" with the specific trusted domain that is allowed to receive the message. For example:

- window.parent.postMessage({score: score, message: "all-test-rig-score"}, "*");
+ window.parent.postMessage({score: score, message: "all-test-rig-score"}, "https://trusted-domain.com");

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: SonarCloud

[failure] 122-122: Origins should be verified during cross-origin communications

Specify a target origin for this message.

See more on SonarCloud

}
};

Expand Down Expand Up @@ -683,7 +686,7 @@
questions[currentQuestion]?.contentSourceData || [];
const stringLengths = contentSourceData.map((item) => item.text.length);
const length = stringLengths[0];
window.parent.postMessage({ type: "stringLengths", length });
window.parent.postMessage({ type: "stringLengths", length }, "*");

Check failure

Code scanning / SonarCloud

Origins should be verified during cross-origin communications High

Specify a target origin for this message. See more on SonarCloud
Copy link

Choose a reason for hiding this comment

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

Security Issue: Specify trusted domain instead of "*" for postMessage target origin.

Using "*" as the target origin in postMessage is a security risk because it allows sending messages to any origin. This can potentially leak sensitive data to untrusted sources.

Fix this by replacing "*" with the specific trusted domain that is allowed to receive the message. For example:

- window.parent.postMessage({ type: "stringLengths", length }, "*");
+ window.parent.postMessage({ type: "stringLengths", length }, "https://trusted-domain.com");

Committable suggestion was skipped due to low confidence.

Tools
GitHub Check: SonarCloud

[failure] 689-689: Origins should be verified during cross-origin communications

Specify a target origin for this message.

See more on SonarCloud

}
}
}, [questions[currentQuestion]]);
Expand Down