Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Política de seguridad de contenido connect-src fuentes 'unsafe-inline' y 'unsafe-eval'

Estoy tratando de resolver en qué situación se necesitarían las fuentes 'unsafe-inline' y 'unsafe-eval' en la directiva connect-src . Se enumeran aquí como fuentes: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src

Me parece claro por qué estas fuentes serían necesarias en script-src , simplemente no puedo reconstruir por qué serían necesarias para connect-src , y asumo que debe haber una razón para que MDN las incluya como fuentes en esta directiva.

¿Alguien puede ayudarme a entender o darme el caso de uso? Tome el ejemplo a continuación. Tenga en cuenta que estoy realizando con éxito una solicitud GET a mocky.io desde un script en línea, y luego llamo a eval() con la devolución de llamada SIN la fuente 'inseguro-en línea' o 'inseguro-eval' para la directiva connect-src .

 <html lang="en"> <head> <meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline' 'unsafe-eval'; connect-src https://run.mocky.io;"> </head> <body> <h1>Testing CSP</h1> <!-- testing any JS executing from unsafe inline --> <script type="text/javascript"> console.log("Testing some unsafe inline"); </script> <!-- testing XHR calls from unsafe inline --> <script type="text/javascript"> const callMocky = () => { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { //eval from the XHR state change eval("console.log('XHR Sent and Received!')") console.log(xhttp.responseText); } }; xhttp.open("GET", "https://run.mocky.io/v3/7ef12b35-8438-424f-8a5f-b11521d03fe7", true); xhttp.send(); } callMocky() </script> <!-- testing unsafe eval from unsafe inline --> <script type="text/javascript"> eval('console.log("this is an unsafe eval!")') </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!