Properties like innerHTML and outerHTML should not be modified directly unless such modifications are clearly reviewed. Modifying innerHTML or outerHTML using user inputs that has not been validated can lead to XSS injection.
if(typeof(SERVER_DOMAIN)==='undefined'){window.location.replace("/unconfigured.html");}constRECEIVE_URL=SERVER_DOMAIN+"/challenge_scoreboard.html"+"?origin="+get_domain();varwindow_ref=null;document.getElementById("username").focus();functionstore_username() {varusername;varusername_obj;username_obj=document.getElementById("username");username=username_obj.valuevarwelcome;welcome=document.getElementById("welcome");welcome.innerHTML="Welcome "+html_encode(username);varset_username;set_username=document.getElementById("set_username");set_username.style.display="none";vargame;game=document.getElementById("game");game.style.display="inline";start_game();// have to do time out so the window can open
setTimeout(function(){send_username(username);},1000);returnfalse;}
functionsafeUpdate(content: string){constelement=document.getElementById("content");// Safe: using DOMPurify to sanitize content
element.innerHTML=DOMPurify.sanitize(content);}functionsafeTextUpdate(text: string){constelement=document.getElementById("content");// Safe: using textContent instead of innerHTML
element.textContent=text;}
シームレスな連携。 Datadog Code Security をお試しください
Datadog Code Security
このルールを試して、Datadog Code Security でコードを分析してみましょう
このルールの使用方法
1
2
rulesets:- typescript-browser-security # Rules to enforce TypeScript browser security.